Merge pull request #7212 from davidsaada/david_flashiap_test_small_flash

FlashIAP & NVStore tests: Skip test if overwriting code in flash
pull/7890/head
Cruz Monrreal 2018-08-21 09:41:51 -05:00 committed by GitHub
commit c10ad7f544
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 5 deletions

View File

@ -23,12 +23,15 @@
#include "utest/utest_serial.h"
#include "unity/unity.h"
#include "greentea-client/test_env.h"
#include "FlashIAP.h"
#include "unity.h"
#include <algorithm>
#include "mbed.h"
using namespace utest::v1;
void flashiap_init_test()
{
FlashIAP flash_device;
@ -59,6 +62,9 @@ void flashiap_program_test()
// the one before the last sector in the system
uint32_t address = (flash_device.get_flash_start() + flash_device.get_flash_size()) - (sector_size);
TEST_ASSERT_TRUE(address != 0UL);
utest_printf("ROM ends at 0x%lx, test starts at 0x%lx\n", FLASHIAP_ROM_END, address);
TEST_SKIP_UNLESS_MESSAGE(address >= FLASHIAP_ROM_END, "Test skipped. Test region overlaps code.");
ret = flash_device.erase(address, sector_size);
TEST_ASSERT_EQUAL_INT32(0, ret);
@ -93,6 +99,7 @@ void flashiap_program_test()
TEST_ASSERT_EQUAL_INT32(0, ret);
}
void flashiap_cross_sector_program_test()
{
FlashIAP flash_device;
@ -111,6 +118,7 @@ void flashiap_cross_sector_program_test()
agg_size += sector_size;
address -= sector_size;
}
TEST_SKIP_UNLESS_MESSAGE(address >= FLASHIAP_ROM_END, "Test skipped. Test region overlaps code.");
ret = flash_device.erase(address, agg_size);
TEST_ASSERT_EQUAL_INT32(0, ret);
@ -166,6 +174,7 @@ void flashiap_program_error_test()
TEST_ASSERT_TRUE(address != 0UL);
// unaligned address
TEST_SKIP_UNLESS_MESSAGE(address >= FLASHIAP_ROM_END, "Test skipped. Test region overlaps code.");
ret = flash_device.erase(address + 1, sector_size);
TEST_ASSERT_EQUAL_INT32(-1, ret);
if (flash_device.get_page_size() > 1) {
@ -185,7 +194,7 @@ void flashiap_timing_test()
uint32_t ret = flash_device.init();
TEST_ASSERT_EQUAL_INT32(0, ret);
mbed::Timer timer;
int num_write_sizes;
unsigned int num_write_sizes;
unsigned int curr_time, byte_usec_ratio;
unsigned int avg_erase_time = 0;
unsigned int max_erase_time = 0, min_erase_time = (unsigned int) -1;
@ -222,7 +231,7 @@ void flashiap_timing_test()
uint32_t address = base_address;
unsigned int avg_write_time = 0;
unsigned int max_write_time = 0, min_write_time = (unsigned int) -1;
int num_writes;
unsigned int num_writes;
for (num_writes = 0; num_writes < max_writes; num_writes++) {
if ((address + write_size) > end_address) {
break;

View File

@ -66,6 +66,8 @@ static const int race_test_data_size = 128;
static const int race_test_min_stack_size = 768;
static const int race_test_max_stack_size = 1024;
static bool nvstore_overlaps_code = false;
static void gen_random(uint8_t *s, int len)
{
for (int i = 0; i < len; ++i) {
@ -91,6 +93,10 @@ static void nvstore_basic_functionality_test()
size_t area_size;
nvstore.get_area_params(area, area_address, area_size);
printf("Area %d: address 0x%08lx, size %d (0x%x)\n", area, area_address, area_size, area_size);
if (area_address < FLASHIAP_ROM_END) {
nvstore_overlaps_code = true;
}
TEST_SKIP_UNLESS_MESSAGE(!nvstore_overlaps_code, "Test skipped. NVStore region overlaps code.");
}
gen_random(nvstore_testing_buf_set, basic_func_max_data_size);
@ -485,6 +491,8 @@ static void nvstore_multi_thread_test()
NVStore &nvstore = NVStore::get_instance();
TEST_SKIP_UNLESS_MESSAGE(!nvstore_overlaps_code, "Test skipped. NVStore region overlaps code.");
ret = nvstore.reset();
TEST_ASSERT_EQUAL(NVSTORE_SUCCESS, ret);
@ -574,6 +582,8 @@ static void nvstore_race_test()
int num_threads = race_test_num_threads;
uint16_t actual_len_bytes;
TEST_SKIP_UNLESS_MESSAGE(!nvstore_overlaps_code, "Test skipped. NVStore region overlaps code.");
NVStore &nvstore = NVStore::get_instance();
ret = nvstore.reset();

View File

@ -25,11 +25,11 @@ define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFED
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
define block FLASH_CODE_ROM {section FLASH_ROM_init object flash_api.o, section .text_init object tmpm46b_fc.o};
define block FLASH_CODE_RAM {section FLASH_ROM object flash_api.o, section .text object tmpm46b_fc.o};
define block FLASH_CODE_ROM {section FLASH_ROM_init object flash_api.o};
define block FLASH_CODE_RAM {section FLASH_ROM object flash_api.o};
initialize by copy { readwrite };
initialize manually { section FLASH_ROM object flash_api.o, section .text object tmpm46b_fc.o};
initialize manually { section FLASH_ROM object flash_api.o };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };