Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Joe Hershberger | 4c19724 | 2015-03-22 17:09:15 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015 National Instruments |
| 4 | * |
| 5 | * (C) Copyright 2015 |
| 6 | * Joe Hershberger <joe.hershberger@ni.com> |
Joe Hershberger | 4c19724 | 2015-03-22 17:09:15 -0500 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <dm.h> |
Joe Hershberger | 4c19724 | 2015-03-22 17:09:15 -0500 | [diff] [blame] | 11 | #include <fdtdec.h> |
| 12 | #include <malloc.h> |
| 13 | #include <net.h> |
Joe Hershberger | 3a77be5 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 14 | #include <dm/test.h> |
Bin Meng | 111473a | 2015-10-07 21:45:43 -0700 | [diff] [blame] | 15 | #include <dm/device-internal.h> |
| 16 | #include <dm/uclass-internal.h> |
Joe Hershberger | f933a93 | 2015-03-22 17:09:20 -0500 | [diff] [blame] | 17 | #include <asm/eth.h> |
Joe Hershberger | 3a77be5 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 18 | #include <test/ut.h> |
Joe Hershberger | 4c19724 | 2015-03-22 17:09:15 -0500 | [diff] [blame] | 19 | |
Bin Meng | 111473a | 2015-10-07 21:45:43 -0700 | [diff] [blame] | 20 | #define DM_TEST_ETH_NUM 4 |
| 21 | |
Joe Hershberger | 3a77be5 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 22 | static int dm_test_eth(struct unit_test_state *uts) |
Joe Hershberger | 4c19724 | 2015-03-22 17:09:15 -0500 | [diff] [blame] | 23 | { |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 24 | net_ping_ip = string_to_ip("1.1.2.2"); |
Joe Hershberger | 4c19724 | 2015-03-22 17:09:15 -0500 | [diff] [blame] | 25 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 26 | env_set("ethact", "eth@10002000"); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 27 | ut_assertok(net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 28 | ut_asserteq_str("eth@10002000", env_get("ethact")); |
Joe Hershberger | 4c19724 | 2015-03-22 17:09:15 -0500 | [diff] [blame] | 29 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 30 | env_set("ethact", "eth@10003000"); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 31 | ut_assertok(net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 32 | ut_asserteq_str("eth@10003000", env_get("ethact")); |
Joe Hershberger | 4c19724 | 2015-03-22 17:09:15 -0500 | [diff] [blame] | 33 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 34 | env_set("ethact", "eth@10004000"); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 35 | ut_assertok(net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 36 | ut_asserteq_str("eth@10004000", env_get("ethact")); |
Joe Hershberger | 4c19724 | 2015-03-22 17:09:15 -0500 | [diff] [blame] | 37 | |
| 38 | return 0; |
| 39 | } |
| 40 | DM_TEST(dm_test_eth, DM_TESTF_SCAN_FDT); |
Joe Hershberger | 279d2f6 | 2015-03-22 17:09:16 -0500 | [diff] [blame] | 41 | |
Joe Hershberger | 3a77be5 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 42 | static int dm_test_eth_alias(struct unit_test_state *uts) |
Joe Hershberger | 279d2f6 | 2015-03-22 17:09:16 -0500 | [diff] [blame] | 43 | { |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 44 | net_ping_ip = string_to_ip("1.1.2.2"); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 45 | env_set("ethact", "eth0"); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 46 | ut_assertok(net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 47 | ut_asserteq_str("eth@10002000", env_get("ethact")); |
Joe Hershberger | 279d2f6 | 2015-03-22 17:09:16 -0500 | [diff] [blame] | 48 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 49 | env_set("ethact", "eth1"); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 50 | ut_assertok(net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 51 | ut_asserteq_str("eth@10004000", env_get("ethact")); |
Joe Hershberger | 279d2f6 | 2015-03-22 17:09:16 -0500 | [diff] [blame] | 52 | |
| 53 | /* Expected to fail since eth2 is not defined in the device tree */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 54 | env_set("ethact", "eth2"); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 55 | ut_assertok(net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 56 | ut_asserteq_str("eth@10002000", env_get("ethact")); |
Joe Hershberger | 279d2f6 | 2015-03-22 17:09:16 -0500 | [diff] [blame] | 57 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 58 | env_set("ethact", "eth5"); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 59 | ut_assertok(net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 60 | ut_asserteq_str("eth@10003000", env_get("ethact")); |
Joe Hershberger | 279d2f6 | 2015-03-22 17:09:16 -0500 | [diff] [blame] | 61 | |
| 62 | return 0; |
| 63 | } |
| 64 | DM_TEST(dm_test_eth_alias, DM_TESTF_SCAN_FDT); |
Joe Hershberger | aa52edd | 2015-03-22 17:09:17 -0500 | [diff] [blame] | 65 | |
Joe Hershberger | 3a77be5 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 66 | static int dm_test_eth_prime(struct unit_test_state *uts) |
Joe Hershberger | aa52edd | 2015-03-22 17:09:17 -0500 | [diff] [blame] | 67 | { |
Joe Hershberger | 5874dec | 2015-04-08 01:41:01 -0500 | [diff] [blame] | 68 | net_ping_ip = string_to_ip("1.1.2.2"); |
Joe Hershberger | aa52edd | 2015-03-22 17:09:17 -0500 | [diff] [blame] | 69 | |
| 70 | /* Expected to be "eth@10003000" because of ethprime variable */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 71 | env_set("ethact", NULL); |
| 72 | env_set("ethprime", "eth5"); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 73 | ut_assertok(net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 74 | ut_asserteq_str("eth@10003000", env_get("ethact")); |
Joe Hershberger | aa52edd | 2015-03-22 17:09:17 -0500 | [diff] [blame] | 75 | |
| 76 | /* Expected to be "eth@10002000" because it is first */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 77 | env_set("ethact", NULL); |
| 78 | env_set("ethprime", NULL); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 79 | ut_assertok(net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 80 | ut_asserteq_str("eth@10002000", env_get("ethact")); |
Joe Hershberger | aa52edd | 2015-03-22 17:09:17 -0500 | [diff] [blame] | 81 | |
| 82 | return 0; |
| 83 | } |
| 84 | DM_TEST(dm_test_eth_prime, DM_TESTF_SCAN_FDT); |
Joe Hershberger | f340e54 | 2015-03-22 17:09:18 -0500 | [diff] [blame] | 85 | |
Bin Meng | 111473a | 2015-10-07 21:45:43 -0700 | [diff] [blame] | 86 | /** |
| 87 | * This test case is trying to test the following scenario: |
| 88 | * - All ethernet devices are not probed |
| 89 | * - "ethaddr" for all ethernet devices are not set |
| 90 | * - "ethact" is set to a valid ethernet device name |
| 91 | * |
| 92 | * With Sandbox default test configuration, all ethernet devices are |
| 93 | * probed after power-up, so we have to manually create such scenario: |
| 94 | * - Remove all ethernet devices |
| 95 | * - Remove all "ethaddr" environment variables |
| 96 | * - Set "ethact" to the first ethernet device |
| 97 | * |
| 98 | * Do a ping test to see if anything goes wrong. |
| 99 | */ |
| 100 | static int dm_test_eth_act(struct unit_test_state *uts) |
| 101 | { |
| 102 | struct udevice *dev[DM_TEST_ETH_NUM]; |
| 103 | const char *ethname[DM_TEST_ETH_NUM] = {"eth@10002000", "eth@10003000", |
| 104 | "sbe5", "eth@10004000"}; |
| 105 | const char *addrname[DM_TEST_ETH_NUM] = {"ethaddr", "eth5addr", |
| 106 | "eth3addr", "eth1addr"}; |
| 107 | char ethaddr[DM_TEST_ETH_NUM][18]; |
| 108 | int i; |
| 109 | |
Tom Rini | 0ac17d8 | 2017-09-26 14:08:30 -0400 | [diff] [blame] | 110 | memset(ethaddr, '\0', sizeof(ethaddr)); |
Bin Meng | 111473a | 2015-10-07 21:45:43 -0700 | [diff] [blame] | 111 | net_ping_ip = string_to_ip("1.1.2.2"); |
| 112 | |
| 113 | /* Prepare the test scenario */ |
| 114 | for (i = 0; i < DM_TEST_ETH_NUM; i++) { |
| 115 | ut_assertok(uclass_find_device_by_name(UCLASS_ETH, |
| 116 | ethname[i], &dev[i])); |
Stefan Roese | 80b5bc9 | 2017-03-20 12:51:48 +0100 | [diff] [blame] | 117 | ut_assertok(device_remove(dev[i], DM_REMOVE_NORMAL)); |
Bin Meng | 111473a | 2015-10-07 21:45:43 -0700 | [diff] [blame] | 118 | |
| 119 | /* Invalidate MAC address */ |
Tom Rini | 0ac17d8 | 2017-09-26 14:08:30 -0400 | [diff] [blame] | 120 | strncpy(ethaddr[i], env_get(addrname[i]), 17); |
Bin Meng | 111473a | 2015-10-07 21:45:43 -0700 | [diff] [blame] | 121 | /* Must disable access protection for ethaddr before clearing */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 122 | env_set(".flags", addrname[i]); |
| 123 | env_set(addrname[i], NULL); |
Bin Meng | 111473a | 2015-10-07 21:45:43 -0700 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | /* Set ethact to "eth@10002000" */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 127 | env_set("ethact", ethname[0]); |
Bin Meng | 111473a | 2015-10-07 21:45:43 -0700 | [diff] [blame] | 128 | |
| 129 | /* Segment fault might happen if something is wrong */ |
| 130 | ut_asserteq(-ENODEV, net_loop(PING)); |
| 131 | |
| 132 | for (i = 0; i < DM_TEST_ETH_NUM; i++) { |
| 133 | /* Restore the env */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 134 | env_set(".flags", addrname[i]); |
| 135 | env_set(addrname[i], ethaddr[i]); |
Bin Meng | 111473a | 2015-10-07 21:45:43 -0700 | [diff] [blame] | 136 | |
| 137 | /* Probe the device again */ |
| 138 | ut_assertok(device_probe(dev[i])); |
| 139 | } |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 140 | env_set(".flags", NULL); |
| 141 | env_set("ethact", NULL); |
Bin Meng | 111473a | 2015-10-07 21:45:43 -0700 | [diff] [blame] | 142 | |
| 143 | return 0; |
| 144 | } |
| 145 | DM_TEST(dm_test_eth_act, DM_TESTF_SCAN_FDT); |
| 146 | |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 147 | /* The asserts include a return on fail; cleanup in the caller */ |
| 148 | static int _dm_test_eth_rotate1(struct unit_test_state *uts) |
Joe Hershberger | f340e54 | 2015-03-22 17:09:18 -0500 | [diff] [blame] | 149 | { |
Joe Hershberger | f340e54 | 2015-03-22 17:09:18 -0500 | [diff] [blame] | 150 | /* Make sure that the default is to rotate to the next interface */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 151 | env_set("ethact", "eth@10004000"); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 152 | ut_assertok(net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 153 | ut_asserteq_str("eth@10002000", env_get("ethact")); |
Joe Hershberger | f340e54 | 2015-03-22 17:09:18 -0500 | [diff] [blame] | 154 | |
| 155 | /* If ethrotate is no, then we should fail on a bad MAC */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 156 | env_set("ethact", "eth@10004000"); |
| 157 | env_set("ethrotate", "no"); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 158 | ut_asserteq(-EINVAL, net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 159 | ut_asserteq_str("eth@10004000", env_get("ethact")); |
Joe Hershberger | f340e54 | 2015-03-22 17:09:18 -0500 | [diff] [blame] | 160 | |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 161 | return 0; |
| 162 | } |
Joe Hershberger | f340e54 | 2015-03-22 17:09:18 -0500 | [diff] [blame] | 163 | |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 164 | static int _dm_test_eth_rotate2(struct unit_test_state *uts) |
| 165 | { |
Joe Hershberger | f340e54 | 2015-03-22 17:09:18 -0500 | [diff] [blame] | 166 | /* Make sure we can skip invalid devices */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 167 | env_set("ethact", "eth@10004000"); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 168 | ut_assertok(net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 169 | ut_asserteq_str("eth@10004000", env_get("ethact")); |
Joe Hershberger | f340e54 | 2015-03-22 17:09:18 -0500 | [diff] [blame] | 170 | |
Bin Meng | 04a11cb | 2015-08-27 22:25:53 -0700 | [diff] [blame] | 171 | /* Make sure we can handle device name which is not eth# */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 172 | env_set("ethact", "sbe5"); |
Bin Meng | 04a11cb | 2015-08-27 22:25:53 -0700 | [diff] [blame] | 173 | ut_assertok(net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 174 | ut_asserteq_str("sbe5", env_get("ethact")); |
Bin Meng | 04a11cb | 2015-08-27 22:25:53 -0700 | [diff] [blame] | 175 | |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 176 | return 0; |
| 177 | } |
| 178 | |
| 179 | static int dm_test_eth_rotate(struct unit_test_state *uts) |
| 180 | { |
| 181 | char ethaddr[18]; |
| 182 | int retval; |
| 183 | |
| 184 | /* Set target IP to mock ping */ |
| 185 | net_ping_ip = string_to_ip("1.1.2.2"); |
| 186 | |
| 187 | /* Invalidate eth1's MAC address */ |
Tom Rini | 0ac17d8 | 2017-09-26 14:08:30 -0400 | [diff] [blame] | 188 | memset(ethaddr, '\0', sizeof(ethaddr)); |
| 189 | strncpy(ethaddr, env_get("eth1addr"), 17); |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 190 | /* Must disable access protection for eth1addr before clearing */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 191 | env_set(".flags", "eth1addr"); |
| 192 | env_set("eth1addr", NULL); |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 193 | |
| 194 | retval = _dm_test_eth_rotate1(uts); |
| 195 | |
Joe Hershberger | f340e54 | 2015-03-22 17:09:18 -0500 | [diff] [blame] | 196 | /* Restore the env */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 197 | env_set("eth1addr", ethaddr); |
| 198 | env_set("ethrotate", NULL); |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 199 | |
| 200 | if (!retval) { |
| 201 | /* Invalidate eth0's MAC address */ |
Tom Rini | 0ac17d8 | 2017-09-26 14:08:30 -0400 | [diff] [blame] | 202 | strncpy(ethaddr, env_get("ethaddr"), 17); |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 203 | /* Must disable access protection for ethaddr before clearing */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 204 | env_set(".flags", "ethaddr"); |
| 205 | env_set("ethaddr", NULL); |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 206 | |
| 207 | retval = _dm_test_eth_rotate2(uts); |
| 208 | |
| 209 | /* Restore the env */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 210 | env_set("ethaddr", ethaddr); |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 211 | } |
| 212 | /* Restore the env */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 213 | env_set(".flags", NULL); |
Joe Hershberger | f340e54 | 2015-03-22 17:09:18 -0500 | [diff] [blame] | 214 | |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 215 | return retval; |
Joe Hershberger | f340e54 | 2015-03-22 17:09:18 -0500 | [diff] [blame] | 216 | } |
| 217 | DM_TEST(dm_test_eth_rotate, DM_TESTF_SCAN_FDT); |
Joe Hershberger | f933a93 | 2015-03-22 17:09:20 -0500 | [diff] [blame] | 218 | |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 219 | /* The asserts include a return on fail; cleanup in the caller */ |
| 220 | static int _dm_test_net_retry(struct unit_test_state *uts) |
Joe Hershberger | f933a93 | 2015-03-22 17:09:20 -0500 | [diff] [blame] | 221 | { |
Joe Hershberger | f933a93 | 2015-03-22 17:09:20 -0500 | [diff] [blame] | 222 | /* |
| 223 | * eth1 is disabled and netretry is yes, so the ping should succeed and |
| 224 | * the active device should be eth0 |
| 225 | */ |
| 226 | sandbox_eth_disable_response(1, true); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 227 | env_set("ethact", "eth@10004000"); |
| 228 | env_set("netretry", "yes"); |
Joe Hershberger | 6901f43 | 2015-04-21 13:57:20 -0500 | [diff] [blame] | 229 | sandbox_eth_skip_timeout(); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 230 | ut_assertok(net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 231 | ut_asserteq_str("eth@10002000", env_get("ethact")); |
Joe Hershberger | f933a93 | 2015-03-22 17:09:20 -0500 | [diff] [blame] | 232 | |
| 233 | /* |
| 234 | * eth1 is disabled and netretry is no, so the ping should fail and the |
| 235 | * active device should be eth1 |
| 236 | */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 237 | env_set("ethact", "eth@10004000"); |
| 238 | env_set("netretry", "no"); |
Joe Hershberger | 6901f43 | 2015-04-21 13:57:20 -0500 | [diff] [blame] | 239 | sandbox_eth_skip_timeout(); |
Joe Hershberger | c80b41b0 | 2015-04-08 01:41:21 -0500 | [diff] [blame] | 240 | ut_asserteq(-ETIMEDOUT, net_loop(PING)); |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 241 | ut_asserteq_str("eth@10004000", env_get("ethact")); |
Joe Hershberger | f933a93 | 2015-03-22 17:09:20 -0500 | [diff] [blame] | 242 | |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 243 | return 0; |
| 244 | } |
| 245 | |
| 246 | static int dm_test_net_retry(struct unit_test_state *uts) |
| 247 | { |
| 248 | int retval; |
| 249 | |
| 250 | net_ping_ip = string_to_ip("1.1.2.2"); |
| 251 | |
| 252 | retval = _dm_test_net_retry(uts); |
| 253 | |
Joe Hershberger | f933a93 | 2015-03-22 17:09:20 -0500 | [diff] [blame] | 254 | /* Restore the env */ |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 255 | env_set("netretry", NULL); |
Joe Hershberger | f933a93 | 2015-03-22 17:09:20 -0500 | [diff] [blame] | 256 | sandbox_eth_disable_response(1, false); |
| 257 | |
Joe Hershberger | fc755f9 | 2015-05-20 14:27:33 -0500 | [diff] [blame] | 258 | return retval; |
Joe Hershberger | f933a93 | 2015-03-22 17:09:20 -0500 | [diff] [blame] | 259 | } |
| 260 | DM_TEST(dm_test_net_retry, DM_TESTF_SCAN_FDT); |