summaryrefslogtreecommitdiff
path: root/test/dm/eth.c
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2015-03-22 17:09:20 -0500
committerSimon Glass <sjg@chromium.org>2015-04-18 11:11:13 -0600
commit7ece1c61ade7f3b9ec25118d8adab5a8d47c3276 (patch)
tree273a2151ebb13ccc2f1433bbb58b7b6c4f5904d6 /test/dm/eth.c
parent2eede1f363b485a9b2b49ac097b9a24256716c8b (diff)
downloadu-boot-7ece1c61ade7f3b9ec25118d8adab5a8d47c3276.tar.gz
u-boot-7ece1c61ade7f3b9ec25118d8adab5a8d47c3276.tar.bz2
u-boot-7ece1c61ade7f3b9ec25118d8adab5a8d47c3276.zip
test: dm: net: Add a test of the netretry behavior
The effect of the "netretry" env var was recently changed. This test checks that behavior. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm/eth.c')
-rw-r--r--test/dm/eth.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/dm/eth.c b/test/dm/eth.c
index 9b550139b5..a0e935939f 100644
--- a/test/dm/eth.c
+++ b/test/dm/eth.c
@@ -14,6 +14,7 @@
#include <fdtdec.h>
#include <malloc.h>
#include <net.h>
+#include <asm/eth.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -122,3 +123,34 @@ static int dm_test_eth_rotate(struct dm_test_state *dms)
return 0;
}
DM_TEST(dm_test_eth_rotate, DM_TESTF_SCAN_FDT);
+
+static int dm_test_net_retry(struct dm_test_state *dms)
+{
+ NetPingIP = string_to_ip("1.1.2.2");
+
+ /*
+ * eth1 is disabled and netretry is yes, so the ping should succeed and
+ * the active device should be eth0
+ */
+ sandbox_eth_disable_response(1, true);
+ setenv("ethact", "eth@10004000");
+ setenv("netretry", "yes");
+ ut_assertok(NetLoop(PING));
+ ut_asserteq_str("eth@10002000", getenv("ethact"));
+
+ /*
+ * eth1 is disabled and netretry is no, so the ping should fail and the
+ * active device should be eth1
+ */
+ setenv("ethact", "eth@10004000");
+ setenv("netretry", "no");
+ ut_asserteq(-1, NetLoop(PING));
+ ut_asserteq_str("eth@10004000", getenv("ethact"));
+
+ /* Restore the env */
+ setenv("netretry", NULL);
+ sandbox_eth_disable_response(1, false);
+
+ return 0;
+}
+DM_TEST(dm_test_net_retry, DM_TESTF_SCAN_FDT);