From 5c27fd7ef92e3fc5d3f8d248af06ba5b45d91b64 Mon Sep 17 00:00:00 2001
From: Simon Glass <sjg@chromium.org>
Date: Thu, 22 Aug 2024 07:57:52 -0600
Subject: [PATCH] test: Update NAND test to avoid extra macros

Write out the tests in full to allow the test to be found more easily
when there is a failure. We could use a single test function with a
for() loop but this would stop at the first failure, and some variations
might while other pass.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 test/dm/nand.c | 47 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 15 deletions(-)

diff --git a/test/dm/nand.c b/test/dm/nand.c
index 397cc88567..c7e0985050 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;
@@ -88,17 +88,34 @@ 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_nand0_start(struct unit_test_state *uts)
+{
+	ut_assertok(run_test_nand(uts, 0, false));
+
+	return 0;
+}
+DM_TEST(dm_test_nand0_start, UTF_SCAN_FDT);
+
+static int dm_test_nand1_start(struct unit_test_state *uts)
+{
+	ut_assertok(run_test_nand(uts, 1, false));
+
+	return 0;
+}
+DM_TEST(dm_test_nand1_start, UTF_SCAN_FDT);
+
+static int dm_test_nand0_end(struct unit_test_state *uts)
+{
+	ut_assertok(run_test_nand(uts, 0, true));
+
+	return 0;
+}
+DM_TEST(dm_test_nand0_end, UTF_SCAN_FDT);
+
+static int dm_test_nand1_end(struct unit_test_state *uts)
+{
+	ut_assertok(run_test_nand(uts, 1, true));
+
+	return 0;
+}
+DM_TEST(dm_test_nand1_end, UTF_SCAN_FDT);
-- 
2.39.5