diff --git a/tests/drivers/flash/common/Kconfig b/tests/drivers/flash/common/Kconfig new file mode 100644 index 00000000000..817d0da2f5a --- /dev/null +++ b/tests/drivers/flash/common/Kconfig @@ -0,0 +1,14 @@ +# Copyright (c) 2024, Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +# Device/scenario dependent information that is not available in +# other ways. + +config TEST_DRIVER_FLASH_SIZE + int "Size of flash device under test" + default -1 + help + Expected flash device size the test will validate against. If the flash driver does not + support the get_size() API, leave this set as -1 to skip the test. + +source "Kconfig.zephyr" diff --git a/tests/drivers/flash/common/src/main.c b/tests/drivers/flash/common/src/main.c index a30f533f655..46e4c840049 100644 --- a/tests/drivers/flash/common/src/main.c +++ b/tests/drivers/flash/common/src/main.c @@ -325,6 +325,19 @@ static bool flash_callback(const struct flash_pages_info *info, void *data) return true; } +ZTEST(flash_driver, test_get_size) +{ +#if CONFIG_TEST_DRIVER_FLASH_SIZE != -1 + uint64_t size; + + zassert_ok(flash_get_size(flash_dev, &size)); + zassert_equal(size, CONFIG_TEST_DRIVER_FLASH_SIZE, "Unexpected size"); +#else + /* The test is sipped only because there is no uniform way to get device size */ + ztest_test_skip(); +#endif +} + ZTEST(flash_driver, test_flash_page_layout) { int rc;