Skip to content

Reduce test overhead in preperation for CMSIS 5 #4317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions TESTS/events/queue/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

using namespace utest::v1;

#define TEST_EQUEUE_SIZE 1024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bridadan pointed this out to me. Looks great and matches the way we're handling stacks here 👍


// flag for called
volatile bool touched = false;
Expand Down Expand Up @@ -43,7 +44,7 @@ void func0() {

#define SIMPLE_POSTS_TEST(i, ...) \
void simple_posts_test##i() { \
EventQueue queue; \
EventQueue queue(TEST_EQUEUE_SIZE); \
\
touched = false; \
queue.call(func##i,##__VA_ARGS__); \
Expand Down Expand Up @@ -78,7 +79,7 @@ template <int N>
void call_in_test() {
Timer tickers[N];

EventQueue queue;
EventQueue queue(TEST_EQUEUE_SIZE);

for (int i = 0; i < N; i++) {
tickers[i].start();
Expand All @@ -92,7 +93,7 @@ template <int N>
void call_every_test() {
Timer tickers[N];

EventQueue queue;
EventQueue queue(TEST_EQUEUE_SIZE);

for (int i = 0; i < N; i++) {
tickers[i].start();
Expand All @@ -103,7 +104,7 @@ void call_every_test() {
}

void allocate_failure_test() {
EventQueue queue;
EventQueue queue(TEST_EQUEUE_SIZE);
int id;

for (int i = 0; i < 100; i++) {
Expand All @@ -119,7 +120,7 @@ void no() {

template <int N>
void cancel_test1() {
EventQueue queue;
EventQueue queue(TEST_EQUEUE_SIZE);

int ids[N];

Expand Down Expand Up @@ -164,7 +165,7 @@ void count0() {

void event_class_test() {
counter = 0;
EventQueue queue(2048);
EventQueue queue(TEST_EQUEUE_SIZE);

Event<void(int, int, int, int, int)> e5(&queue, count5);
Event<void(int, int, int, int)> e4(&queue, count5, 1);
Expand All @@ -187,7 +188,7 @@ void event_class_test() {

void event_class_helper_test() {
counter = 0;
EventQueue queue(2048);
EventQueue queue(TEST_EQUEUE_SIZE);

Event<void()> e5 = queue.event(count5, 1, 1, 1, 1, 1);
Event<void()> e4 = queue.event(count4, 1, 1, 1, 1);
Expand All @@ -210,7 +211,7 @@ void event_class_helper_test() {

void event_inference_test() {
counter = 0;
EventQueue queue(2048);
EventQueue queue(TEST_EQUEUE_SIZE);

queue.event(count5, 1, 1, 1, 1, 1).post();
queue.event(count5, 1, 1, 1, 1).post(1);
Expand Down
8 changes: 2 additions & 6 deletions TESTS/mbed_drivers/race_test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,18 @@

using namespace utest::v1;

#define TEST_STACK_SIZE 1024
#define TEST_STACK_SIZE 512
static uint32_t instance_count = 0;

class TestClass {
public:
TestClass() {
printf("TestClass ctor start\r\n");
Thread::wait(500);
instance_count++;
printf("TestClass ctor end\r\n");
}

void do_something() {
printf("Do something called\r\n");
Thread::wait(100);
}

~TestClass() {
Expand Down Expand Up @@ -69,7 +67,6 @@ static void main_class_race()

void test_case_func_race()
{
printf("Running function race test\r\n");
Callback<void()> cb(main_func_race);
Thread *t1 = new Thread(osPriorityNormal, TEST_STACK_SIZE);
Thread *t2 = new Thread(osPriorityNormal, TEST_STACK_SIZE);
Expand All @@ -95,7 +92,6 @@ void test_case_func_race()

void test_case_class_race()
{
printf("Running class race test\r\n");
Callback<void()> cb(main_class_race);
Thread *t1 = new Thread(osPriorityNormal, TEST_STACK_SIZE);
Thread *t2 = new Thread(osPriorityNormal, TEST_STACK_SIZE);
Expand Down
7 changes: 1 addition & 6 deletions TESTS/mbed_drivers/stats/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using namespace utest::v1;

#define ALLOCATION_SIZE_DEFAULT 564
#define ALLOCATION_SIZE_SMALL 124
#define ALLOCATION_SIZE_LARGE 790
#define ALLOCATION_SIZE_LARGE 700
#define ALLOCATION_SIZE_FAIL (1024 * 1024 *1024)

typedef void* (*malloc_cb_t) (uint32_t size);
Expand All @@ -49,7 +49,6 @@ malloc_cb_t malloc_thunk_array[] = {

void test_case_malloc_free_size()
{
printf("Initial print to setup stdio buffers\n");
mbed_stats_heap_t stats_start;
mbed_stats_heap_t stats_current;
void *data;
Expand Down Expand Up @@ -127,26 +126,22 @@ void test_case_allocate_fail()

static void* thunk_malloc(uint32_t size)
{
printf("Malloc thunk\n");
return malloc(size);
}

static void* thunk_calloc_1(uint32_t size)
{
printf("Calloc thunk 1 byte\n");
return calloc(size / 1, 1);
}

static void* thunk_calloc_4(uint32_t size)
{
printf("Calloc thunk 4 bytes\n");
return calloc(size / 4, 4);
}


static void* thunk_realloc(uint32_t size)
{
printf("Realloc thunk\n");
return realloc(NULL, size);
}

Expand Down
50 changes: 16 additions & 34 deletions TESTS/mbed_drivers/stl_features/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ using namespace utest::v1;
#define TABLE_SIZE(TAB) (sizeof(TAB) / sizeof(TAB[0]))

#define NEGATIVE_INTEGERS -32768,-3214,-999,-100,-1,0,1,4231,999,4123,32760,99999
#define POSITIVE_INTEGERS 32768,3214,999,100,1,0,1,4231,999,4123,32760,99999
#define FLOATS 0.002,0.92430,15.91320,791.77368,6208.2,25719.4952,426815.982588,6429271.046,42468024.93,212006462.910
#define FLOATS_STR "0.002","0.92430","15.91320","791.77368","6208.2","25719.4952","426815.982588","6429271.046","42468024.93","212006462.910"


namespace {
int p_integers[] = {POSITIVE_INTEGERS};
int n_integers[] = {NEGATIVE_INTEGERS};
float floats[] = {FLOATS};

template <class T, class F>
void BubbleSort(T& _array, size_t array_size, F functor) {
Expand All @@ -59,62 +54,49 @@ void BubbleSort(T& _array, size_t array_size, F functor) {
}
}

struct printInt {
void operator()(int i) { printf("%d ", i); }
};

struct printFloat {
void operator()(float f) { printf("%f ", f); }
};

struct printString {
void operator()(const char* s) { printf("%s ", s); }
};

struct greaterAbs {
bool operator()(int a, int b) { return abs(a) > abs(b); }
};

} // namespace

void test_case_stl_equal() {
std::vector<int> v_pints(p_integers, p_integers + TABLE_SIZE(p_integers));
TEST_ASSERT_TRUE(std::equal(v_pints.begin(), v_pints.end(), p_integers));
const int n_integers[] = {NEGATIVE_INTEGERS};
std::vector<int> v_pints(n_integers, n_integers + TABLE_SIZE(n_integers));
TEST_ASSERT_TRUE(std::equal(v_pints.begin(), v_pints.end(), n_integers));
}

void test_case_stl_transform() {
const float floats[] = {FLOATS};
const char* floats_str[] = {FLOATS_STR};
float floats_transform[TABLE_SIZE(floats_str)] = {0.0};
std::transform(floats_str, floats_str + TABLE_SIZE(floats_str), floats_transform, atof);
//printf("stl_transform::floats_str: ");
//std::for_each(floats_str, floats_str + TABLE_SIZE(floats_str), printString());
//printf("stl_transform::floats_transform: ");
//std::for_each(floats_transform, floats_transform + TABLE_SIZE(floats_transform), printFloat());
//printf("\n");

TEST_ASSERT_TRUE(std::equal(floats_transform, floats_transform + TABLE_SIZE(floats_transform), floats));
}

void test_case_stl_sort_greater() {
Copy link
Contributor

@geky geky May 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope I'm not repeating a discussion, but have we considered if it's worthwhile to keep these stl tests?

You could spend a lifetime trying to add coverage to the stl....

Copy link
Contributor

@0xc0170 0xc0170 May 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove them, shall be done via separate PR

std::vector<int> v_nints_1(n_integers, n_integers + TABLE_SIZE(n_integers));
std::vector<int> v_nints_2(n_integers, n_integers + TABLE_SIZE(n_integers));
int n_integers[] = {NEGATIVE_INTEGERS};
int n_integers2[] = {NEGATIVE_INTEGERS};

BubbleSort(v_nints_1, v_nints_1.size(), std::greater<int>());
std::sort(v_nints_2.begin(), v_nints_2.end(), std::greater<int>());
BubbleSort(n_integers, TABLE_SIZE(n_integers), std::greater<int>());
std::sort(n_integers2, n_integers2 + TABLE_SIZE(n_integers2), std::greater<int>());

TEST_ASSERT_TRUE(std::equal(v_nints_1.begin(), v_nints_1.end(), v_nints_2.begin()));
TEST_ASSERT_TRUE(std::equal(n_integers2, n_integers2 + TABLE_SIZE(n_integers2), n_integers));
}


void test_case_stl_sort_abs() {
std::vector<int> v_nints_1(n_integers, n_integers + TABLE_SIZE(n_integers));
std::vector<int> v_nints_2(n_integers, n_integers + TABLE_SIZE(n_integers));
int n_integers[] = {NEGATIVE_INTEGERS};
int n_integers2[] = {NEGATIVE_INTEGERS};

BubbleSort(v_nints_1, v_nints_1.size(), greaterAbs());
std::sort(v_nints_2.begin(), v_nints_2.end(), greaterAbs());
BubbleSort(n_integers, TABLE_SIZE(n_integers), greaterAbs());
std::sort(n_integers2, n_integers2 + TABLE_SIZE(n_integers2), greaterAbs());

TEST_ASSERT_TRUE(std::equal(v_nints_1.begin(), v_nints_1.end(), v_nints_2.begin()));
TEST_ASSERT_TRUE(std::equal(n_integers2, n_integers2 + TABLE_SIZE(n_integers2), n_integers));
}


utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE;
Expand Down
29 changes: 5 additions & 24 deletions TESTS/mbedmicro-rtos-mbed/basic/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,7 @@
#error [NOT_SUPPORTED] test not supported
#endif

/*
* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
*/
#if defined(TARGET_STM32F070RB) && defined(TOOLCHAIN_GCC)
#define STACK_SIZE DEFAULT_STACK_SIZE/2
#elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
#define STACK_SIZE 512
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
#define STACK_SIZE 768
#elif (defined(TARGET_EFM32GG_STK3700)) && !defined(TOOLCHAIN_ARM_MICRO)
#define STACK_SIZE 1536
#elif defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832)
#define STACK_SIZE 768
#elif defined(TARGET_XDOT_L151CC)
#define STACK_SIZE 1024
#else
#define STACK_SIZE DEFAULT_STACK_SIZE
#endif
#define TEST_STACK_SIZE 768
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


#define SIGNAL_PRINT_TICK 0x01

Expand All @@ -43,15 +24,15 @@ void print_tick_thread() {

int main() {
GREENTEA_SETUP(total_ticks + 5, "timing_drift_auto");
Thread tick_thread(osPriorityNormal, STACK_SIZE);

Thread tick_thread(osPriorityNormal, TEST_STACK_SIZE);
tick_thread.start(print_tick_thread);

for (int i = 0; i <= total_ticks; i++) {
Thread::wait(1000);
tick_thread.signal_set(SIGNAL_PRINT_TICK);
}

tick_thread.join();
GREENTEA_TESTSUITE_RESULT(1);
}
23 changes: 3 additions & 20 deletions TESTS/mbedmicro-rtos-mbed/isr/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,7 @@
#define QUEUE_PUT_ISR_VALUE 128
#define QUEUE_PUT_THREAD_VALUE 127

/*
* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
*/
#if (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
#define STACK_SIZE 512
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
#define STACK_SIZE 768
#elif (defined(TARGET_EFM32GG_STK3700)) && !defined(TOOLCHAIN_ARM_MICRO)
#define STACK_SIZE 1536
#elif defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832)
#define STACK_SIZE 768
#elif defined(TARGET_XDOT_L151CC)
#define STACK_SIZE 1024
#else
#define STACK_SIZE DEFAULT_STACK_SIZE
#endif
#define TEST_STACK_SIZE 512

Queue<uint32_t, QUEUE_SIZE> queue;

Expand All @@ -50,7 +33,7 @@ void queue_thread() {
int main (void) {
GREENTEA_SETUP(20, "default_auto");

Thread thread(osPriorityNormal, STACK_SIZE);
Thread thread(osPriorityNormal, TEST_STACK_SIZE);
thread.start(queue_thread);
Ticker ticker;
ticker.attach(queue_isr, 1.0);
Expand All @@ -60,7 +43,7 @@ int main (void) {
while (true) {
osEvent evt = queue.get();
if (evt.status != osEventMessage) {
printf("QUEUE_GET: Status(0x%02X) ... [FAIL]\r\n", evt.status);
printf("QUEUE_GET: FAIL\r\n");
result = false;
break;
} else {
Expand Down
19 changes: 1 addition & 18 deletions TESTS/mbedmicro-rtos-mbed/mail/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,7 @@ typedef struct {
#define QUEUE_SIZE 16
#define QUEUE_PUT_DELAY 100

/*
* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
*/
#if (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
#define STACK_SIZE 512
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
#define STACK_SIZE 768
#elif (defined(TARGET_EFM32GG_STK3700)) && !defined(TOOLCHAIN_ARM_MICRO)
#define STACK_SIZE 1536
#elif defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832)
#define STACK_SIZE 768
#elif defined(TARGET_XDOT_L151CC)
#define STACK_SIZE 1024
#else
#define STACK_SIZE DEFAULT_STACK_SIZE
#endif
#define STACK_SIZE 1024

Mail<mail_t, QUEUE_SIZE> mail_box;

Expand Down
1 change: 1 addition & 0 deletions TESTS/mbedmicro-rtos-mbed/malloc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#endif

#define NUM_THREADS 5

#if defined(__CORTEX_A9)
#define THREAD_STACK_SIZE DEFAULT_STACK_SIZE
#else
Expand Down
Loading