mirror of https://github.com/ARMmbed/mbed-os.git
FlashIAP & NVStore tests: Skip test if overwriting code in flash.
parent
62a70f461b
commit
876b5f755b
|
@ -23,12 +23,15 @@
|
||||||
#include "utest/utest_serial.h"
|
#include "utest/utest_serial.h"
|
||||||
#include "unity/unity.h"
|
#include "unity/unity.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
#include "FlashIAP.h"
|
||||||
|
#include "unity.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "mbed.h"
|
#include "mbed.h"
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
|
|
||||||
void flashiap_init_test()
|
void flashiap_init_test()
|
||||||
{
|
{
|
||||||
FlashIAP flash_device;
|
FlashIAP flash_device;
|
||||||
|
@ -59,6 +62,9 @@ void flashiap_program_test()
|
||||||
// the one before the last sector in the system
|
// the one before the last sector in the system
|
||||||
uint32_t address = (flash_device.get_flash_start() + flash_device.get_flash_size()) - (sector_size);
|
uint32_t address = (flash_device.get_flash_start() + flash_device.get_flash_size()) - (sector_size);
|
||||||
TEST_ASSERT_TRUE(address != 0UL);
|
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);
|
ret = flash_device.erase(address, sector_size);
|
||||||
TEST_ASSERT_EQUAL_INT32(0, ret);
|
TEST_ASSERT_EQUAL_INT32(0, ret);
|
||||||
|
|
||||||
|
@ -93,6 +99,7 @@ void flashiap_program_test()
|
||||||
TEST_ASSERT_EQUAL_INT32(0, ret);
|
TEST_ASSERT_EQUAL_INT32(0, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void flashiap_cross_sector_program_test()
|
void flashiap_cross_sector_program_test()
|
||||||
{
|
{
|
||||||
FlashIAP flash_device;
|
FlashIAP flash_device;
|
||||||
|
@ -111,6 +118,7 @@ void flashiap_cross_sector_program_test()
|
||||||
agg_size += sector_size;
|
agg_size += sector_size;
|
||||||
address -= 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);
|
ret = flash_device.erase(address, agg_size);
|
||||||
TEST_ASSERT_EQUAL_INT32(0, ret);
|
TEST_ASSERT_EQUAL_INT32(0, ret);
|
||||||
|
|
||||||
|
@ -166,6 +174,7 @@ void flashiap_program_error_test()
|
||||||
TEST_ASSERT_TRUE(address != 0UL);
|
TEST_ASSERT_TRUE(address != 0UL);
|
||||||
|
|
||||||
// unaligned address
|
// unaligned address
|
||||||
|
TEST_SKIP_UNLESS_MESSAGE(address >= FLASHIAP_ROM_END, "Test skipped. Test region overlaps code.");
|
||||||
ret = flash_device.erase(address + 1, sector_size);
|
ret = flash_device.erase(address + 1, sector_size);
|
||||||
TEST_ASSERT_EQUAL_INT32(-1, ret);
|
TEST_ASSERT_EQUAL_INT32(-1, ret);
|
||||||
if (flash_device.get_page_size() > 1) {
|
if (flash_device.get_page_size() > 1) {
|
||||||
|
@ -185,7 +194,7 @@ void flashiap_timing_test()
|
||||||
uint32_t ret = flash_device.init();
|
uint32_t ret = flash_device.init();
|
||||||
TEST_ASSERT_EQUAL_INT32(0, ret);
|
TEST_ASSERT_EQUAL_INT32(0, ret);
|
||||||
mbed::Timer timer;
|
mbed::Timer timer;
|
||||||
int num_write_sizes;
|
unsigned int num_write_sizes;
|
||||||
unsigned int curr_time, byte_usec_ratio;
|
unsigned int curr_time, byte_usec_ratio;
|
||||||
unsigned int avg_erase_time = 0;
|
unsigned int avg_erase_time = 0;
|
||||||
unsigned int max_erase_time = 0, min_erase_time = (unsigned int) -1;
|
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;
|
uint32_t address = base_address;
|
||||||
unsigned int avg_write_time = 0;
|
unsigned int avg_write_time = 0;
|
||||||
unsigned int max_write_time = 0, min_write_time = (unsigned int) -1;
|
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++) {
|
for (num_writes = 0; num_writes < max_writes; num_writes++) {
|
||||||
if ((address + write_size) > end_address) {
|
if ((address + write_size) > end_address) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -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_min_stack_size = 768;
|
||||||
static const int race_test_max_stack_size = 1024;
|
static const int race_test_max_stack_size = 1024;
|
||||||
|
|
||||||
|
static bool nvstore_overlaps_code = false;
|
||||||
|
|
||||||
static void gen_random(uint8_t *s, int len)
|
static void gen_random(uint8_t *s, int len)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
|
@ -91,6 +93,10 @@ static void nvstore_basic_functionality_test()
|
||||||
size_t area_size;
|
size_t area_size;
|
||||||
nvstore.get_area_params(area, area_address, 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);
|
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);
|
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();
|
NVStore &nvstore = NVStore::get_instance();
|
||||||
|
|
||||||
|
TEST_SKIP_UNLESS_MESSAGE(!nvstore_overlaps_code, "Test skipped. NVStore region overlaps code.");
|
||||||
|
|
||||||
ret = nvstore.reset();
|
ret = nvstore.reset();
|
||||||
TEST_ASSERT_EQUAL(NVSTORE_SUCCESS, ret);
|
TEST_ASSERT_EQUAL(NVSTORE_SUCCESS, ret);
|
||||||
|
|
||||||
|
@ -574,6 +582,8 @@ static void nvstore_race_test()
|
||||||
int num_threads = race_test_num_threads;
|
int num_threads = race_test_num_threads;
|
||||||
uint16_t actual_len_bytes;
|
uint16_t actual_len_bytes;
|
||||||
|
|
||||||
|
TEST_SKIP_UNLESS_MESSAGE(!nvstore_overlaps_code, "Test skipped. NVStore region overlaps code.");
|
||||||
|
|
||||||
NVStore &nvstore = NVStore::get_instance();
|
NVStore &nvstore = NVStore::get_instance();
|
||||||
|
|
||||||
ret = nvstore.reset();
|
ret = nvstore.reset();
|
||||||
|
|
Loading…
Reference in New Issue