From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Hershberger Date: Wed, 11 Mar 2015 18:44:21 -0500 Subject: [U-Boot] [PATCH v6 23/27] test: dm: net: Add a test of the netretry behavior In-Reply-To: <1426117465-16072-1-git-send-email-joe.hershberger@ni.com> References: <1425436881-10323-1-git-send-email-joe.hershberger@ni.com> <1426117465-16072-1-git-send-email-joe.hershberger@ni.com> Message-ID: <1426117465-16072-24-git-send-email-joe.hershberger@ni.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de The effect of the "netretry" env var was recently changed. This test checks that behavior. Signed-off-by: Joe Hershberger Reviewed-by: Simon Glass --- Changes in v6: None Changes in v5: -Added comments about test cases -Switched to function to control state of mock driver Changes in v4: -Updated expected behavior based on changes to the NetLoop Changes in v3: -Added testing for netretry Changes in v2: None test/dm/eth.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/dm/eth.c b/test/dm/eth.c index 9b55013..a0e9359 100644 --- a/test/dm/eth.c +++ b/test/dm/eth.c @@ -14,6 +14,7 @@ #include #include #include +#include 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 at 10004000"); + setenv("netretry", "yes"); + ut_assertok(NetLoop(PING)); + ut_asserteq_str("eth at 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 at 10004000"); + setenv("netretry", "no"); + ut_asserteq(-1, NetLoop(PING)); + ut_asserteq_str("eth at 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); -- 1.7.11.5