summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2015-03-22 17:09:18 -0500
committerSimon Glass <sjg@chromium.org>2015-04-18 11:11:13 -0600
commit7d104eab7dfb632dd96d027b7bfb233f1ae41ba7 (patch)
treeec1f58f506ac633b61f1e592b9dd5ca9fe16004b /test
parent6536b9bb769fe764f4793a1b37a2619391bb2482 (diff)
downloadu-boot-7d104eab7dfb632dd96d027b7bfb233f1ae41ba7.tar.gz
u-boot-7d104eab7dfb632dd96d027b7bfb233f1ae41ba7.tar.bz2
u-boot-7d104eab7dfb632dd96d027b7bfb233f1ae41ba7.zip
test: dm: eth: Add testing for ethrotate env var
Make sure that the ethrotate behavior occurs as expected. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/eth.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/dm/eth.c b/test/dm/eth.c
index 96e3c46ea6..9b550139b5 100644
--- a/test/dm/eth.c
+++ b/test/dm/eth.c
@@ -80,3 +80,45 @@ static int dm_test_eth_prime(struct dm_test_state *dms)
return 0;
}
DM_TEST(dm_test_eth_prime, DM_TESTF_SCAN_FDT);
+
+static int dm_test_eth_rotate(struct dm_test_state *dms)
+{
+ char ethaddr[18];
+
+ /* Invalidate eth1's MAC address */
+ NetPingIP = string_to_ip("1.1.2.2");
+ strcpy(ethaddr, getenv("eth1addr"));
+ setenv("eth1addr", NULL);
+
+ /* Make sure that the default is to rotate to the next interface */
+ setenv("ethact", "eth@10004000");
+ ut_assertok(NetLoop(PING));
+ ut_asserteq_str("eth@10002000", getenv("ethact"));
+
+ /* If ethrotate is no, then we should fail on a bad MAC */
+ setenv("ethact", "eth@10004000");
+ setenv("ethrotate", "no");
+ ut_asserteq(-1, NetLoop(PING));
+ ut_asserteq_str("eth@10004000", getenv("ethact"));
+
+ /* Restore the env */
+ setenv("eth1addr", ethaddr);
+ setenv("ethrotate", NULL);
+
+ /* Invalidate eth0's MAC address */
+ strcpy(ethaddr, getenv("ethaddr"));
+ setenv(".flags", "ethaddr");
+ setenv("ethaddr", NULL);
+
+ /* Make sure we can skip invalid devices */
+ setenv("ethact", "eth@10004000");
+ ut_assertok(NetLoop(PING));
+ ut_asserteq_str("eth@10004000", getenv("ethact"));
+
+ /* Restore the env */
+ setenv("ethaddr", ethaddr);
+ setenv(".flags", NULL);
+
+ return 0;
+}
+DM_TEST(dm_test_eth_rotate, DM_TESTF_SCAN_FDT);