aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Anderson <sean.anderson@seco.com>2022-05-05 13:11:32 -0400
committerTom Rini <trini@konsulko.com>2022-06-08 13:59:52 -0400
commitdf33fd28897b044166b7aae7e5dd5860c6f79af4 (patch)
treeff199f57dc5bf28f8f32f00412a4274bbaefe9e2
parent469a968ac78dae8b3b324c9eafdfbf405cc1a076 (diff)
downloadu-boot-df33fd28897b044166b7aae7e5dd5860c6f79af4.zip
u-boot-df33fd28897b044166b7aae7e5dd5860c6f79af4.tar.gz
u-boot-df33fd28897b044166b7aae7e5dd5860c6f79af4.tar.bz2
test: eth: Add test for ethernet addresses
This adds a test to make sure that all the ethernet interfaces have their addresses read properly. At the moment everything is read from the environment, but the next few commits will add additional sources. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--test/dm/eth.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/dm/eth.c b/test/dm/eth.c
index e4ee695..5437f9e 100644
--- a/test/dm/eth.c
+++ b/test/dm/eth.c
@@ -147,6 +147,35 @@ static int dm_test_eth_act(struct unit_test_state *uts)
}
DM_TEST(dm_test_eth_act, UT_TESTF_SCAN_FDT);
+/* Ensure that all addresses are loaded properly */
+static int dm_test_ethaddr(struct unit_test_state *uts)
+{
+ static const char *const addr[] = {
+ "02:00:11:22:33:44",
+ "02:00:11:22:33:48", /* dsa slave */
+ "02:00:11:22:33:45",
+ "02:00:11:22:33:48", /* dsa master */
+ "02:00:11:22:33:46",
+ "02:00:11:22:33:47",
+ "02:00:11:22:33:48", /* dsa slave */
+ "02:00:11:22:33:49",
+ };
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(addr); i++) {
+ char addrname[10];
+
+ if (i)
+ snprintf(addrname, sizeof(addrname), "eth%daddr", i + 1);
+ else
+ strcpy(addrname, "ethaddr");
+ ut_asserteq_str(addr[i], env_get(addrname));
+ }
+
+ return 0;
+}
+DM_TEST(dm_test_ethaddr, UT_TESTF_SCAN_FDT);
+
/* The asserts include a return on fail; cleanup in the caller */
static int _dm_test_eth_rotate1(struct unit_test_state *uts)
{