[U-Boot] [RFC PATCH v4 20/23] test: dm: net: Add a test of the netretry behavior

Simon Glass sjg at chromium.org
Sun Mar 1 19:07:47 CET 2015


Hi Joe,

On 24 February 2015 at 17:02, Joe Hershberger <joe.hershberger at ni.com> wrote:
> The effect of the "netretry" env var was recently changed. This test
> checks that behavior.
>
> Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
>
> ---
>
> 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 | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
>
> diff --git a/test/dm/eth.c b/test/dm/eth.c
> index a3cbd3f..4581c8e 100644
> --- a/test/dm/eth.c
> +++ b/test/dm/eth.c
> @@ -104,3 +104,26 @@ 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");
> +
> +       setenv("eth_sandbox_disable_1", "yes");

As mentioned in the other patch, something like:

sandbox_eth_set_disable(1, true);

> +       setenv("ethact", "eth at 10004000");
> +       setenv("netretry", "yes");
> +       ut_assertok(NetLoop(PING));
> +       ut_asserteq_str("eth at 10002000", getenv("ethact"));
> +

A comment against each test case as to why it works or doesn't would help.

> +       setenv("ethact", "eth at 10004000");
> +       setenv("netretry", "no");
> +       ut_asserteq(-1, NetLoop(PING));

One day it would be nice if this could return an error code from errno.h.

> +       ut_asserteq_str("eth at 10004000", getenv("ethact"));
> +
> +       /* Restore the env */
> +       setenv("netretry", NULL);
> +       setenv("eth_sandbox_disable_1", NULL);

sandbox_eth_set_disable(1, false);

> +
> +       return 0;
> +}
> +DM_TEST(dm_test_net_retry, DM_TESTF_SCAN_FDT);
> --
> 1.7.11.5
>

Regards,
Simon


More information about the U-Boot mailing list