]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - test/dm/eth.c
5688b71de07162ed6c48513750d0e93d3bf53ab2
[karo-tx-uboot.git] / test / dm / eth.c
1 /*
2  * Copyright (c) 2015 National Instruments
3  *
4  * (C) Copyright 2015
5  * Joe Hershberger <joe.hershberger@ni.com>
6  *
7  * SPDX-License-Identifier:     GPL-2.0
8  */
9
10 #include <common.h>
11 #include <dm.h>
12 #include <dm/test.h>
13 #include <dm/ut.h>
14 #include <fdtdec.h>
15 #include <malloc.h>
16 #include <net.h>
17
18 DECLARE_GLOBAL_DATA_PTR;
19
20 static int dm_test_eth(struct dm_test_state *dms)
21 {
22         NetPingIP = string_to_ip("1.1.2.2");
23
24         setenv("ethact", "eth@10002000");
25         ut_assertok(NetLoop(PING));
26         ut_asserteq_str("eth@10002000", getenv("ethact"));
27
28         setenv("ethact", "eth@10003000");
29         ut_assertok(NetLoop(PING));
30         ut_asserteq_str("eth@10003000", getenv("ethact"));
31
32         setenv("ethact", "eth@10004000");
33         ut_assertok(NetLoop(PING));
34         ut_asserteq_str("eth@10004000", getenv("ethact"));
35
36         return 0;
37 }
38 DM_TEST(dm_test_eth, DM_TESTF_SCAN_FDT);
39
40 static int dm_test_eth_alias(struct dm_test_state *dms)
41 {
42         NetPingIP = string_to_ip("1.1.2.2");
43         setenv("ethact", "eth0");
44         ut_assertok(NetLoop(PING));
45         ut_asserteq_str("eth@10002000", getenv("ethact"));
46
47         setenv("ethact", "eth1");
48         ut_assertok(NetLoop(PING));
49         ut_asserteq_str("eth@10004000", getenv("ethact"));
50
51         /* Expected to fail since eth2 is not defined in the device tree */
52         setenv("ethact", "eth2");
53         ut_assertok(NetLoop(PING));
54         ut_asserteq_str("eth@10002000", getenv("ethact"));
55
56         setenv("ethact", "eth5");
57         ut_assertok(NetLoop(PING));
58         ut_asserteq_str("eth@10003000", getenv("ethact"));
59
60         return 0;
61 }
62 DM_TEST(dm_test_eth_alias, DM_TESTF_SCAN_FDT);