tests/drivers/flash: Add test case for flash_get_size
Add flash_get_size commit and Kconfig option for test to set the expected size of device. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
parent
852c992da5
commit
c03f256fba
2 changed files with 27 additions and 0 deletions
14
tests/drivers/flash/common/Kconfig
Normal file
14
tests/drivers/flash/common/Kconfig
Normal file
|
@ -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"
|
|
@ -325,6 +325,19 @@ static bool flash_callback(const struct flash_pages_info *info, void *data)
|
||||||
return true;
|
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)
|
ZTEST(flash_driver, test_flash_page_layout)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue