From f43b2df3e068cc7be1aa5656c0c3223e270bba63 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 17 Jan 2023 10:47:27 -0700 Subject: sandbox: Allow ethernet to be disabled at runtime For bootstd tests it is seldom useful to have ethernet enabled. Add a way to disable it, so that ethernet operations like tftpboot do nothing. Signed-off-by: Simon Glass --- include/test/test.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include/test') diff --git a/include/test/test.h b/include/test/test.h index 4ad74614afc..76ec4d739a3 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -169,4 +169,29 @@ static inline int test_load_other_fdt(struct unit_test_state *uts) return ret; } +/** + * test_set_eth_enable() - Enable / disable Ethernet + * + * Allows control of whether Ethernet packets are actually send/received + * + * @enable: true to enable Ethernet, false to disable + */ +static inline void test_set_eth_enable(bool enable) +{ +#ifdef CONFIG_SANDBOX + sandbox_set_eth_enable(enable); +#endif +} + +/* Allow ethernet to be disabled for testing purposes */ +static inline bool test_eth_enabled(void) +{ + bool enabled = true; + +#ifdef CONFIG_SANDBOX + enabled = sandbox_eth_enabled(); +#endif + return enabled; +} + #endif /* __TEST_TEST_H */ -- cgit v1.2.3 From 70dd88657b45e5439bf762507f2e1c44c2dee289 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 17 Jan 2023 10:47:28 -0700 Subject: sandbox: Allow ethernet bootdevs to be disabled for tests Most tests don't want these and can create a lot of noise. Add a way to disable them. Use that in tests, with a flag provided to enable them for tests that need this feature. Signed-off-by: Simon Glass --- include/test/test.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/test') diff --git a/include/test/test.h b/include/test/test.h index 76ec4d739a3..beabe9333dc 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -71,6 +71,7 @@ enum { * since it cannot access the flags. */ UT_TESTF_MANUAL = BIT(8), + UT_TESTF_ETH_BOOTDEV = BIT(9), /* enable Ethernet bootdevs */ }; /** @@ -194,4 +195,15 @@ static inline bool test_eth_enabled(void) return enabled; } +/* Allow ethernet bootdev to be ignored for testing purposes */ +static inline bool test_eth_bootdev_enabled(void) +{ + bool enabled = true; + +#ifdef CONFIG_SANDBOX + enabled = sandbox_eth_enabled(); +#endif + return enabled; +} + #endif /* __TEST_TEST_H */ -- cgit v1.2.3 From 8b031871218689e72ecf517ad6d584ae4c659aad Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 17 Jan 2023 10:47:36 -0700 Subject: test: Add a generic function to skip delays At present this feature is sandbox-specific. For running tests on boards, we need a nop version. Add one. Signed-off-by: Simon Glass --- include/test/test.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include/test') diff --git a/include/test/test.h b/include/test/test.h index beabe9333dc..752897cf06f 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -170,6 +170,22 @@ static inline int test_load_other_fdt(struct unit_test_state *uts) return ret; } +/** + * Control skipping of time delays + * + * Some tests have unnecessay time delays (e.g. USB). Allow these to be + * skipped to speed up testing + * + * @param skip_delays true to skip delays from now on, false to honour delay + * requests + */ +static inline void test_set_skip_delays(bool skip_delays) +{ +#ifdef CONFIG_SANDBOX + state_set_skip_delays(skip_delays); +#endif +} + /** * test_set_eth_enable() - Enable / disable Ethernet * -- cgit v1.2.3 From 081bdc52c158dd3a4f73910cde3d7e70a5932d56 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 17 Jan 2023 10:48:02 -0700 Subject: sandbox: Allow SPI flash bootdevs to be disabled for tests Most tests don't want these and they can create a lot of noise. Add a way to disable them. Use that in tests, with a flag provided to enable them for tests that need this feature. Signed-off-by: Simon Glass --- include/test/test.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/test') diff --git a/include/test/test.h b/include/test/test.h index 752897cf06f..838e3ce8a8f 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -72,6 +72,7 @@ enum { */ UT_TESTF_MANUAL = BIT(8), UT_TESTF_ETH_BOOTDEV = BIT(9), /* enable Ethernet bootdevs */ + UT_TESTF_SF_BOOTDEV = BIT(10), /* enable SPI flash bootdevs */ }; /** @@ -222,4 +223,22 @@ static inline bool test_eth_bootdev_enabled(void) return enabled; } +/* Allow SPI flash bootdev to be ignored for testing purposes */ +static inline bool test_sf_bootdev_enabled(void) +{ + bool enabled = true; + +#ifdef CONFIG_SANDBOX + enabled = sandbox_sf_bootdev_enabled(); +#endif + return enabled; +} + +static inline void test_sf_set_enable_bootdevs(bool enable) +{ +#ifdef CONFIG_SANDBOX + sandbox_sf_set_enable_bootdevs(enable); +#endif +} + #endif /* __TEST_TEST_H */ -- cgit v1.2.3