diff mbox series

[03/14] test: eth: Add test for ethernet addresses

Message ID 20220207234212.685316-4-sean.anderson@seco.com
State Changes Requested
Delegated to: Simon Glass
Headers show
Series Add support for NVMEM API | expand

Commit Message

Sean Anderson Feb. 7, 2022, 11:42 p.m. UTC
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>
---

 test/dm/eth.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Comments

Simon Glass Feb. 26, 2022, 6:36 p.m. UTC | #1
On Mon, 7 Feb 2022 at 16:42, Sean Anderson <sean.anderson@seco.com> wrote:
>
> 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>
> ---
>
>  test/dm/eth.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/test/dm/eth.c b/test/dm/eth.c
index e4ee695610..0c786c0f9d 100644
--- a/test/dm/eth.c
+++ b/test/dm/eth.c
@@ -147,6 +147,34 @@  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)
+{
+	const char *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 */
+	};
+	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)
 {