Permalink
Browse files

Merge pull request #7753 from ARMmbed/release-candidate

Release candidate for mbed-os-5.9.5
  • Loading branch information...
cmonr committed Aug 13, 2018
2 parents 485bdee + 5dd2904 commit f8b140f8d7cb226e41486c5df66ac4f3ce699219
Showing 390 changed files with 9,432 additions and 4,855 deletions.
@@ -18,7 +18,7 @@
-->
[ ] Fix
[ ] Refactor
[ ] New target
[ ] Target update
[ ] Feature
[ ] Breaking change
@@ -20,6 +20,7 @@
#endif
#include "utest/utest.h"
#include "utest/utest_serial.h"
#include "unity/unity.h"
#include "greentea-client/test_env.h"
#include <algorithm>
@@ -178,15 +179,95 @@ void flashiap_program_error_test()
TEST_ASSERT_EQUAL_INT32(0, ret);
}
void flashiap_timing_test()
{
FlashIAP flash_device;
uint32_t ret = flash_device.init();
TEST_ASSERT_EQUAL_INT32(0, ret);
mbed::Timer timer;
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;
const unsigned int max_writes = 128;
const unsigned int max_write_sizes = 6;
const unsigned int max_byte_usec_ratio = 200;
uint32_t page_size = flash_device.get_page_size();
uint32_t write_size = page_size;
uint32_t end_address = flash_device.get_flash_start() + flash_device.get_flash_size();
utest_printf("\nFlash timing:\n");
uint32_t sector_size = flash_device.get_sector_size(end_address - 1UL);
uint32_t base_address = end_address - sector_size;
timer.start();
for (num_write_sizes = 0; num_write_sizes < max_write_sizes; num_write_sizes++) {
if (write_size > sector_size) {
break;
}
uint8_t *buf = new (std::nothrow) uint8_t[write_size];
if (!buf) {
// Don't fail the test on lack of heap memory for the buffer
break;
}
memset(buf, 0x5A, write_size);
timer.reset();
ret = flash_device.erase(base_address, sector_size);
curr_time = timer.read_us();
avg_erase_time += curr_time;
TEST_ASSERT_EQUAL_INT32(0, ret);
max_erase_time = std::max(max_erase_time, curr_time);
min_erase_time = std::min(min_erase_time, curr_time);
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;
for (num_writes = 0; num_writes < max_writes; num_writes++) {
if ((address + write_size) > end_address) {
break;
}
timer.reset();
ret = flash_device.program(buf, address, write_size);
curr_time = timer.read_us();
avg_write_time += curr_time;
TEST_ASSERT_EQUAL_INT32(0, ret);
max_write_time = std::max(max_write_time, curr_time);
min_write_time = std::min(min_write_time, curr_time);
address += write_size;
}
delete[] buf;
avg_write_time /= num_writes;
utest_printf("Write size %6u bytes: avg %10u, min %10u, max %10u (usec)\n",
write_size, avg_write_time, min_write_time, max_write_time);
byte_usec_ratio = write_size / avg_write_time;
TEST_ASSERT(byte_usec_ratio < max_byte_usec_ratio);
write_size *= 4;
}
if (num_write_sizes) {
avg_erase_time /= num_write_sizes;
utest_printf("\nErase size %6u bytes: avg %10u, min %10u, max %10u (usec)\n\n",
sector_size, avg_erase_time, min_erase_time, max_erase_time);
byte_usec_ratio = sector_size / avg_erase_time;
TEST_ASSERT(byte_usec_ratio < max_byte_usec_ratio);
}
ret = flash_device.deinit();
TEST_ASSERT_EQUAL_INT32(0, ret);
}
Case cases[] = {
Case("FlashIAP - init", flashiap_init_test),
Case("FlashIAP - program", flashiap_program_test),
Case("FlashIAP - program across sectors", flashiap_cross_sector_program_test),
Case("FlashIAP - program errors", flashiap_program_error_test),
Case("FlashIAP - timing", flashiap_timing_test),
};
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
GREENTEA_SETUP(20, "default_auto");
GREENTEA_SETUP(120, "default_auto");
return greentea_test_setup_handler(number_of_cases);
}
@@ -199,6 +199,7 @@ void test_error_logging()
}
#define NUM_TEST_THREADS 5
#define THREAD_STACK_SIZE 512
//Error logger threads
void err_thread_func(mbed_error_status_t *error_status)
@@ -211,16 +212,20 @@ void err_thread_func(mbed_error_status_t *error_status)
*/
void test_error_logging_multithread()
{
uint8_t *dummy = new (std::nothrow) uint8_t[NUM_TEST_THREADS * THREAD_STACK_SIZE];
TEST_SKIP_UNLESS_MESSAGE(dummy, "Not enough memory for test");
delete[] dummy;
mbed_error_ctx error_ctx = {0};
int i=0;
int i;
Thread *errThread[NUM_TEST_THREADS];
mbed_error_status_t error_status[NUM_TEST_THREADS] = {
MBED_ERROR_INVALID_ARGUMENT, MBED_ERROR_INVALID_DATA_DETECTED, MBED_ERROR_INVALID_FORMAT, MBED_ERROR_INVALID_SIZE, MBED_ERROR_INVALID_OPERATION
};
for(; i<NUM_TEST_THREADS; i++) {
errThread[i] = new Thread(osPriorityNormal1, 512, NULL, NULL);
for(i=0; i<NUM_TEST_THREADS; i++) {
errThread[i] = new Thread(osPriorityNormal1, THREAD_STACK_SIZE, NULL, NULL);
errThread[i]->start(callback(err_thread_func, &error_status[i]));
}
wait(2.0);
@@ -43,10 +43,6 @@
#endif
#endif
#ifndef DEVICE_EMAC
#error [NOT_SUPPORTED] Device EMAC has to be enabled for the target
#endif
#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
Oops, something went wrong.

0 comments on commit f8b140f

Please sign in to comment.