tests: flash_map: Increase the test coverage of supported platforms

- Increase the test coverage of supported platforms.
- Fix test_flash_area_check_int_sha256 for platforms with
  flash program size >32. Increase the supported flash program size
  to 512 (maximum supported by Zephyr platforms now).
- Fix test_flash_area_get_sectors test for platforms
  with maximum number of sectors per image slot >256.
  Increase the support value to 1024.
- Fix possible stack size overflow.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
This commit is contained in:
Andrej Butok 2024-06-21 14:47:06 +02:00 committed by Anas Nashif
parent 9d9cf4d17d
commit fe2e560577
2 changed files with 70 additions and 8 deletions

View file

@ -1,4 +1,5 @@
CONFIG_ZTEST=y
CONFIG_ZTEST_STACK_SIZE=2048
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y

View file

@ -2,6 +2,7 @@
* Copyright (c) 2017 Nordic Semiconductor ASA
* Copyright (c) 2015 Runtime Inc
* Copyright (c) 2020 Gerson Fernando Budke <nandojve@gmail.com>
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -16,7 +17,7 @@
#define SLOT1_PARTITION_NODE DT_NODELABEL(SLOT1_PARTITION)
extern int flash_map_entries;
struct flash_sector fs_sectors[256];
struct flash_sector fs_sectors[1024];
ZTEST(flash_map, test_flash_area_disabled_device)
{
@ -40,8 +41,8 @@ ZTEST(flash_map, test_flash_area_get_sectors)
int i;
int rc;
off_t off;
uint8_t wd[256];
uint8_t rd[256];
uint8_t wd[512];
uint8_t rd[512];
const struct device *flash_dev;
const struct device *flash_dev_a = SLOT1_PARTITION_DEV;
@ -114,18 +115,78 @@ ZTEST(flash_map, test_flash_area_get_sectors)
ZTEST(flash_map, test_flash_area_check_int_sha256)
{
/* echo $'0123456789abcdef\nfedcba98765432' > tst.sha
/* for i in {1..16}; do echo $'0123456789abcdef\nfedcba98765432' >> tst.sha; done
* hexdump tst.sha
*/
uint8_t tst_vec[] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x0a, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x39,
0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x0a };
/* sha256sum tst.sha */
uint8_t tst_sha[] = { 0x28, 0xf1, 0x6e, 0xea, 0xc3, 0xea, 0x89, 0x8d,
0x80, 0x9e, 0x98, 0xeb, 0x09, 0x49, 0x98, 0x08,
0x40, 0x69, 0x43, 0xa6, 0xef, 0xe1, 0xa3, 0xf9,
0x3d, 0xdf, 0x15, 0x9e, 0x06, 0xf8, 0xdd, 0xbd };
uint8_t tst_sha[] = { 0xae, 0xed, 0x7d, 0x59, 0x53, 0xbd, 0xb7, 0x28,
0x3e, 0x59, 0xc2, 0x65, 0x59, 0x62, 0xe3, 0x7e,
0xfa, 0x97, 0xbd, 0x76, 0xf6, 0xac, 0xc3, 0x92,
0x59, 0x48, 0x4e, 0xc0, 0xaf, 0xa8, 0x49, 0x65 };
const struct flash_area *fa;
struct flash_area_check fac = { NULL, 0, -1, NULL, 0 };