From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 619D0C32772 for ; Tue, 23 Aug 2022 21:54:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7A10284856; Tue, 23 Aug 2022 23:54:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.b="f15E0Pzk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C1A8A8483E; Tue, 23 Aug 2022 23:53:49 +0200 (CEST) Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AC61A847FC for ; Tue, 23 Aug 2022 23:53:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=quic_jaehyoo@quicinc.com Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27NKTZAu022208; Tue, 23 Aug 2022 21:53:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=ZjqK8iCnuFEYpYzY2ka79XKxjYH+1Nl/UjsPmkAucCA=; b=f15E0PzkDBPzwl+6/Jga6LhMv4JxmCWlqfXVbnTNP+rqmRJzI+0cmF7k+b5r9FspKImr c8YjJSBmwCWljhkhUOH7E7vA92PsCyDtlzxr7u+9MbYJB1XcFlteloObUWx7zlOMLBC7 PBqwPM6wNPf2ZCZroZr4r60WecdcGl0m/hH2rrGrFkY1sFo1FtZoytN7/kVtqdt7vno0 y8LLuyNxteMtSMImrk3ICcj1W3r/C4ARPjLeIc4sR0FNrXUHcmDDGWtbxx2dIkOMqIZU 1rDTtinT0oGbl1Am358p5m+a9P4ttduPXYDFWVjBr2+1IVMhfTWDoOaY65apPK5G3Xu3 Cg== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3j52pkrupn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Aug 2022 21:53:25 +0000 Received: from pps.filterd (NALASPPMTA04.qualcomm.com [127.0.0.1]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 27NLrOi9001763; Tue, 23 Aug 2022 21:53:24 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA04.qualcomm.com (PPS) with ESMTPS id 3j2rpkvc5u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Aug 2022 21:53:24 +0000 Received: from NALASPPMTA04.qualcomm.com (NALASPPMTA04.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27NLrONu001758; Tue, 23 Aug 2022 21:53:24 GMT Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (PPS) with ESMTPS id 27NLrNa1001755 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Aug 2022 21:53:24 +0000 Received: from maru.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 23 Aug 2022 14:53:22 -0700 From: Jae Hyun Yoo To: Michal Simek , Ovidiu Panait , Simon Glass , Mario Six , Masahisa Kojima , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Heinrich Schuchardt , Ashok Reddy Soma , "Thomas Huth" , Huang Jianan , Chris Morgan , Roland Gaudig , Patrick Delaunay , Alexandru Gagniuc CC: Jamie Iles , Graeme Gregory , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Jae Hyun Yoo , Subject: [PATCH v3 7/7] test: cmd: fru: add unit test for the fru command Date: Tue, 23 Aug 2022 14:53:00 -0700 Message-ID: <20220823215300.1485789-8-quic_jaehyoo@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220823215300.1485789-1-quic_jaehyoo@quicinc.com> References: <20220823215300.1485789-1-quic_jaehyoo@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: HnA2_AH0qc0UwwqHffjGA8DVS7qkqQkB X-Proofpoint-GUID: HnA2_AH0qc0UwwqHffjGA8DVS7qkqQkB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-23_09,2022-08-22_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208230082 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add test cases for the fru command. Signed-off-by: Jae Hyun Yoo --- Changes from v2: * Newly added in v3. (Simon) include/test/suites.h | 1 + test/cmd/Makefile | 1 + test/cmd/fru.c | 84 +++++++++++++++++++++++++++++++++++++++++++ test/cmd_ut.c | 6 ++++ 4 files changed, 92 insertions(+) create mode 100644 test/cmd/fru.c diff --git a/include/test/suites.h b/include/test/suites.h index 44025ccecd6f..1d4a8c3e4a66 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -39,6 +39,7 @@ int do_ut_compression(struct cmd_tbl *cmdtp, int flag, int argc, int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); +int do_ut_fru(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); diff --git a/test/cmd/Makefile b/test/cmd/Makefile index c331757425ea..5995384dad91 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -8,6 +8,7 @@ endif obj-y += mem.o obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o obj-$(CONFIG_CMD_FDT) += fdt.o +obj-$(CONFIG_CMD_FRU) += fru.o obj-$(CONFIG_CMD_LOADM) += loadm.o obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o obj-$(CONFIG_CMD_PINMUX) += pinmux.o diff --git a/test/cmd/fru.c b/test/cmd/fru.c new file mode 100644 index 000000000000..fa560622cf0b --- /dev/null +++ b/test/cmd/fru.c @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Executes tests for fru command + * + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#include +#include +#include +#include +#include + +#define FRU_TEST(_name, _flags) UNIT_TEST(_name, _flags, fru_test) + +#define CMD_FRU_TEST_SRC_BUF_SIZE 1024 + +static const char cmd_gen_b[] = + "fru generate -b %08lx abcd efgh ijkl mnop qrst uvwx"; +static const char cmd_gen_p[] = + "fru generate -p %08lx abcd efgh ijkl mnop qrst uvwx yz01 2345"; + +static const char cmd_capture[] = "fru capture %08lx"; + +static int fru_test_board(struct unit_test_state *uts) +{ + u8 fru_src[CMD_FRU_TEST_SRC_BUF_SIZE]; + int i; + + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf(cmd_gen_b, (ulong)map_to_sysmem(fru_src))); + ut_assertok(run_commandf(cmd_capture, (ulong)map_to_sysmem(fru_src))); + ut_assertok(run_command("fru display", 0)); + for (i = 0; i < 11; i++) + ut_assert_skipline(); + ut_assert_nextline(" Manufacturer Name: abcd"); + ut_assert_nextline(" Product Name: efgh"); + ut_assert_nextline(" Serial Number: ijkl"); + ut_assert_nextline(" Part Number: mnop"); + ut_assert_nextline(" File ID: qrst"); + ut_assert_nextline(" Custom Type/Length: 0xc4"); + ut_assert_nextline(" 00000000: 75 76 77 78 uvwx"); + for (i = 0; i < 4; i++) + ut_assert_skipline(); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} +FRU_TEST(fru_test_board, UT_TESTF_CONSOLE_REC); + +static int fru_test_product(struct unit_test_state *uts) +{ + u8 fru_src[CMD_FRU_TEST_SRC_BUF_SIZE]; + int i; + + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf(cmd_gen_p, (ulong)map_to_sysmem(fru_src))); + ut_assertok(run_commandf(cmd_capture, (ulong)map_to_sysmem(fru_src))); + ut_assertok(run_command("fru display", 0)); + for (i = 0; i < 14; i++) + ut_assert_skipline(); + ut_assert_nextline(" Manufacturer Name: abcd"); + ut_assert_nextline(" Product Name: efgh"); + ut_assert_nextline(" Part Number: ijkl"); + ut_assert_nextline(" Version Number: mnop"); + ut_assert_nextline(" Serial Number: qrst"); + ut_assert_nextline(" Asset Number: uvwx"); + ut_assert_nextline(" File ID: yz01"); + ut_assert_nextline(" Custom Type/Length: 0xc4"); + ut_assert_nextline(" 00000000: 32 33 34 35 2345"); + ut_assert_skipline(); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} +FRU_TEST(fru_test_product, UT_TESTF_CONSOLE_REC); + +int do_ut_fru(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + struct unit_test *tests = UNIT_TEST_SUITE_START(fru_test); + const int n_ents = UNIT_TEST_SUITE_COUNT(fru_test); + + return cmd_ut_category("fru", "fru_test_", tests, n_ents, argc, argv); +} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 3789c6b784c0..4c163da8176c 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -80,6 +80,9 @@ static struct cmd_tbl cmd_ut_sub[] = { #ifdef CONFIG_CMD_LOADM U_BOOT_CMD_MKENT(loadm, CONFIG_SYS_MAXARGS, 1, do_ut_loadm, "", ""), #endif +#ifdef CONFIG_CMD_FRU + U_BOOT_CMD_MKENT(fru, CONFIG_SYS_MAXARGS, 1, do_ut_fru, "", ""), +#endif }; static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc, @@ -167,6 +170,9 @@ static char ut_help_text[] = #endif #ifdef CONFIG_CMD_LOADM "ut loadm [test-name]- test of parameters and load memory blob\n" +#endif +#ifdef CONFIG_CMD_FRU + "ut fru [test-name] - test of the fru command\n" #endif ; #endif /* CONFIG_SYS_LONGHELP */ -- 2.25.1