u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Jae Hyun Yoo <quic_jaehyoo@quicinc.com>
To: "Michal Simek" <michal.simek@amd.com>,
	"Ovidiu Panait" <ovidiu.panait@windriver.com>,
	"Simon Glass" <sjg@chromium.org>,
	"Mario Six" <mario.six@gdsys.cc>,
	"Masahisa Kojima" <masahisa.kojima@linaro.org>,
	"Pali Rohár" <pali@kernel.org>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Ashok Reddy Soma" <ashok.reddy.soma@xilinx.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Huang Jianan" <jnhuang95@gmail.com>,
	"Chris Morgan" <macromorgan@hotmail.com>,
	"Roland Gaudig" <roland.gaudig@weidmueller.com>,
	"Patrick Delaunay" <patrick.delaunay@foss.st.com>,
	"Alexandru Gagniuc" <mr.nuke.me@gmail.com>
Cc: "Jamie Iles" <quic_jiles@quicinc.com>,
	"Graeme Gregory" <quic_ggregory@quicinc.com>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Jae Hyun Yoo" <quic_jaehyoo@quicinc.com>,
	u-boot@lists.denx.de
Subject: [PATCH v3 7/7] test: cmd: fru: add unit test for the fru command
Date: Tue, 23 Aug 2022 14:53:00 -0700	[thread overview]
Message-ID: <20220823215300.1485789-8-quic_jaehyoo@quicinc.com> (raw)
In-Reply-To: <20220823215300.1485789-1-quic_jaehyoo@quicinc.com>

Add test cases for the fru command.

Signed-off-by: Jae Hyun Yoo <quic_jaehyoo@quicinc.com>
---
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 <common.h>
+#include <console.h>
+#include <mapmem.h>
+#include <test/suites.h>
+#include <test/ut.h>
+
+#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


  parent reply	other threads:[~2022-08-23 21:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 21:52 [PATCH v3 0/7] cmd/fru: move FRU handling support to common region Jae Hyun Yoo
2022-08-23 21:52 ` [PATCH v3 1/7] xilinx: common: refactor FRU handling support Jae Hyun Yoo
2022-08-23 21:52 ` [PATCH v3 2/7] cmd: fru: move FRU handling support to common region Jae Hyun Yoo
2022-08-23 21:52 ` [PATCH v3 3/7] cmd: fru: fix a sandbox segfault issue Jae Hyun Yoo
2022-08-23 21:52 ` [PATCH v3 4/7] cmd: fru: add product info area parsing support Jae Hyun Yoo
2022-08-25  1:25   ` Simon Glass
2022-08-25 14:33     ` Jae Hyun Yoo
2022-08-25 15:08       ` Simon Glass
2022-08-23 21:52 ` [PATCH v3 5/7] doc: fru: add documentation for the fru command and APIs Jae Hyun Yoo
2022-08-23 21:52 ` [PATCH v3 6/7] test: py: fru: add a test for the fru command Jae Hyun Yoo
2022-08-25  1:25   ` Simon Glass
2022-08-25 14:35     ` Jae Hyun Yoo
2022-08-23 21:53 ` Jae Hyun Yoo [this message]
2022-08-25  1:25   ` [PATCH v3 7/7] test: cmd: fru: add unit " Simon Glass
2022-08-25 14:34     ` Jae Hyun Yoo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220823215300.1485789-8-quic_jaehyoo@quicinc.com \
    --to=quic_jaehyoo@quicinc.com \
    --cc=ashok.reddy.soma@xilinx.com \
    --cc=clg@kaod.org \
    --cc=jnhuang95@gmail.com \
    --cc=macromorgan@hotmail.com \
    --cc=mario.six@gdsys.cc \
    --cc=masahisa.kojima@linaro.org \
    --cc=michal.simek@amd.com \
    --cc=mr.nuke.me@gmail.com \
    --cc=ovidiu.panait@windriver.com \
    --cc=pali@kernel.org \
    --cc=patrick.delaunay@foss.st.com \
    --cc=quic_ggregory@quicinc.com \
    --cc=quic_jiles@quicinc.com \
    --cc=roland.gaudig@weidmueller.com \
    --cc=sjg@chromium.org \
    --cc=thuth@redhat.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).