[PATCH 09/21] test: Update NAND test to avoid extra macros
Simon Glass
sjg at chromium.org
Sat Aug 10 22:51:53 CEST 2024
Use a single test function with a for() loop instead of using macros to
create multiple test functions. Add a message so it is clear what piece
the test is up to, if it fails.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
test/dm/nand.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/test/dm/nand.c b/test/dm/nand.c
index 397cc88567c..2d9866030f2 100644
--- a/test/dm/nand.c
+++ b/test/dm/nand.c
@@ -12,7 +12,7 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h>
-static int dm_test_nand(struct unit_test_state *uts, int dev, bool end)
+static int run_test_nand(struct unit_test_state *uts, int dev, bool end)
{
nand_erase_options_t opts = { };
struct mtd_info *mtd;
@@ -25,6 +25,8 @@ static int dm_test_nand(struct unit_test_state *uts, int dev, bool end)
loff_t off = 0;
mtd_oob_ops_t ops = { };
+ printf("running: dev %d end %d\n", dev, end);
+
/* Seed RNG for bit errors */
srand((off >> 32) ^ off ^ ~dev);
@@ -88,17 +90,15 @@ static int dm_test_nand(struct unit_test_state *uts, int dev, bool end)
return 0;
}
-#define DM_NAND_TEST(dev) \
-static int dm_test_nand##dev##_start(struct unit_test_state *uts) \
-{ \
- return dm_test_nand(uts, dev, false); \
-} \
-DM_TEST(dm_test_nand##dev##_start, UTF_SCAN_FDT); \
-static int dm_test_nand##dev##_end(struct unit_test_state *uts) \
-{ \
- return dm_test_nand(uts, dev, true); \
-} \
-DM_TEST(dm_test_nand##dev##_end, UTF_SCAN_FDT)
-
-DM_NAND_TEST(0);
-DM_NAND_TEST(1);
+static int dm_test_nand(struct unit_test_state *uts)
+{
+ int devnum;
+
+ for (devnum = 0; devnum < 2; devnum++) {
+ ut_assertok(run_test_nand(uts, devnum, false));
+ ut_assertok(run_test_nand(uts, devnum, true));
+ }
+
+ return 0;
+}
+DM_TEST(dm_test_nand, UTF_SCAN_FDT);
--
2.34.1
More information about the U-Boot
mailing list