From 081bdc52c158dd3a4f73910cde3d7e70a5932d56 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 17 Jan 2023 10:48:02 -0700 Subject: [PATCH] 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 --- arch/sandbox/cpu/state.c | 14 ++++++++++++++ arch/sandbox/include/asm/state.h | 1 + arch/sandbox/include/asm/test.h | 14 ++++++++++++++ include/test/test.h | 19 +++++++++++++++++++ test/test-main.c | 1 + 5 files changed, 49 insertions(+) diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index 267f280..69da378 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -460,6 +460,20 @@ bool sandbox_eth_enabled(void) return !state->disable_eth; } +void sandbox_sf_set_enable_bootdevs(bool enable) +{ + struct sandbox_state *state = state_get_current(); + + state->disable_sf_bootdevs = !enable; +} + +bool sandbox_sf_bootdev_enabled(void) +{ + struct sandbox_state *state = state_get_current(); + + return !state->disable_sf_bootdevs; +} + int state_init(void) { state = &main_state; diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index f125fb8..59a2059 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -97,6 +97,7 @@ struct sandbox_state { bool handle_signals; /* Handle signals within sandbox */ bool autoboot_keyed; /* Use keyed-autoboot feature */ bool disable_eth; /* Disable Ethernet devices */ + bool disable_sf_bootdevs; /* Don't bind SPI flash bootdevs */ /* Pointer to information for each SPI bus/cs */ struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS] diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h index 1c522e3..4853dc94 100644 --- a/arch/sandbox/include/asm/test.h +++ b/arch/sandbox/include/asm/test.h @@ -360,4 +360,18 @@ void sandbox_set_eth_enable(bool enable); */ bool sandbox_eth_enabled(void); +/** + * sandbox_sf_bootdev_enabled() - Check if SPI flash bootdevs should be bound + * + * Returns: true if sandbox should bind bootdevs for SPI flash, false if not + */ +bool sandbox_sf_bootdev_enabled(void); + +/** + * sandbox_sf_set_enable_bootdevs() - Enable / disable the SPI flash bootdevs + * + * @enable: true to bind the SPI flash bootdevs, false to skip + */ +void sandbox_sf_set_enable_bootdevs(bool enable); + #endif diff --git a/include/test/test.h b/include/test/test.h index 752897c..838e3ce 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 */ diff --git a/test/test-main.c b/test/test-main.c index 9d0f664..ea959f4 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -309,6 +309,7 @@ static int test_pre_run(struct unit_test_state *uts, struct unit_test *test) * only set this if we know the ethernet uclass will be created */ eth_set_enable_bootdevs(test->flags & UT_TESTF_ETH_BOOTDEV); + test_sf_set_enable_bootdevs(test->flags & UT_TESTF_SF_BOOTDEV); ut_assertok(dm_extended_scan(false)); } -- 2.7.4