mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-12-19 08:21:27 +01:00
Now that env_get_ip() has been removed, the include file <net.h> does not need anything from <env.h>. Furthermore, include/env.h itself includes other headers which can lead to longer indirect inclusion paths. To prepare to remove <env.h> from <net.h> fix all of the remaining places which had relied on this indirect inclusion to instead include <env.h> directly. Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> # net/lwip Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> Reviewed-by: Martyn Welch <martyn.welch@collabora.com> Signed-off-by: Tom Rini <trini@konsulko.com>
82 lines
2.2 KiB
C
82 lines
2.2 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright 2020-2021 NXP
|
|
*/
|
|
|
|
#include <env.h>
|
|
#include <net/dsa.h>
|
|
#include <dm/test.h>
|
|
#include <test/ut.h>
|
|
#include <net.h>
|
|
#include <dm/uclass-internal.h>
|
|
#include <dm/device-internal.h>
|
|
|
|
/* This test exercises the major dsa.h API functions, after making sure
|
|
* that the DSA ports and the master Eth are correctly probed.
|
|
*/
|
|
static int dm_test_dsa_probe(struct unit_test_state *uts)
|
|
{
|
|
struct udevice *dev_dsa, *dev_port, *dev_master;
|
|
struct dsa_pdata *dsa_pdata;
|
|
enum uclass_id id;
|
|
|
|
id = uclass_get_by_name("dsa");
|
|
ut_assert(id == UCLASS_DSA);
|
|
|
|
ut_assertok(uclass_find_device_by_name(UCLASS_DSA, "dsa-test",
|
|
&dev_dsa));
|
|
ut_assertok(uclass_find_device_by_name(UCLASS_ETH, "dsa-test-eth",
|
|
&dev_master));
|
|
ut_assertok(device_probe(dev_master));
|
|
|
|
ut_assertok(uclass_find_device_by_name(UCLASS_ETH, "dsa-test@0",
|
|
&dev_port));
|
|
ut_assertok(device_probe(dev_port));
|
|
|
|
ut_assertok(uclass_find_device_by_name(UCLASS_ETH, "dsa-test@1",
|
|
&dev_port));
|
|
ut_assertok(device_probe(dev_port));
|
|
|
|
/* exercise DSA API */
|
|
dsa_pdata = dev_get_uclass_plat(dev_dsa);
|
|
ut_assertnonnull(dsa_pdata);
|
|
/* includes CPU port */
|
|
ut_assert(dsa_pdata->num_ports == 3);
|
|
|
|
ut_assertok(uclass_find_device_by_name(UCLASS_ETH, "lan0",
|
|
&dev_port));
|
|
ut_assertok(device_probe(dev_port));
|
|
|
|
ut_assertok(uclass_find_device_by_name(UCLASS_ETH, "lan1",
|
|
&dev_port));
|
|
ut_assertok(device_probe(dev_port));
|
|
|
|
dev_master = dsa_get_master(dev_dsa);
|
|
ut_assertnonnull(dev_master);
|
|
ut_asserteq_str("dsa-test-eth", dev_master->name);
|
|
|
|
return 0;
|
|
}
|
|
DM_TEST(dm_test_dsa_probe, UTF_SCAN_FDT);
|
|
|
|
/* This test sends ping requests with the local address through each DSA port
|
|
* via the sandbox DSA master Eth.
|
|
*/
|
|
static int dm_test_dsa(struct unit_test_state *uts)
|
|
{
|
|
char *argv[] = { "ping", "1.1.2.2" };
|
|
|
|
env_set("ethact", "eth2");
|
|
ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
|
|
|
|
env_set("ethact", "lan0");
|
|
ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
|
|
env_set("ethact", "lan1");
|
|
ut_assertok(do_ping(NULL, 0, ARRAY_SIZE(argv), argv));
|
|
|
|
env_set("ethact", "");
|
|
|
|
return 0;
|
|
}
|
|
DM_TEST(dm_test_dsa, UTF_SCAN_FDT);
|