From 2dfb5847f3cda7e794edc65c25cd651c78cbe428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 8 May 2018 11:34:42 +0200 Subject: [PATCH 1/3] tests/mutex_unlock_and_sleep: replace modulo to speed up tests on wsn430 Doing a 32 bit modulo is really slow on wsn430, even when changing to a power of two modulo. Replace modulo by a double counter. --- tests/mutex_unlock_and_sleep/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/mutex_unlock_and_sleep/main.c b/tests/mutex_unlock_and_sleep/main.c index 43f9404cbd..c178e4c141 100644 --- a/tests/mutex_unlock_and_sleep/main.c +++ b/tests/mutex_unlock_and_sleep/main.c @@ -27,6 +27,8 @@ static volatile int indicator; static kernel_pid_t main_pid; static char stack[THREAD_STACKSIZE_DEFAULT]; +static const unsigned KITERATIONS = 100; + static void *second_thread(void *arg) { (void) arg; @@ -42,6 +44,7 @@ static void *second_thread(void *arg) int main(void) { uint32_t count = 0; + uint32_t kcount = 0; indicator = 0; main_pid = thread_getpid(); @@ -64,8 +67,10 @@ int main(void) printf("[ERROR] threads did not sleep properly (%d).\n", indicator); return 1; } - if ((count % 100000) == 0) { - printf("[ALIVE] alternated %"PRIu32"k times.\n", (count / 1000)); + if (count == (KITERATIONS * 1000)) { + count = 0; + kcount += KITERATIONS; + printf("[ALIVE] alternated %"PRIu32"k times.\n", kcount); } mutex_unlock_and_sleep(&mutex); } From 57a2397631d2045b06388f932201f57629a6ec6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 8 May 2018 11:37:00 +0200 Subject: [PATCH 2/3] tests/mutex_unlock_and_sleep: reduce number of iterations on boards Reduce number of iterations, it allows taking less than 3 seconds on wsn430. Tested on wsn430 and iotlab-m3 to check that speed was not too fast to read when executing term. --- tests/mutex_unlock_and_sleep/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/mutex_unlock_and_sleep/main.c b/tests/mutex_unlock_and_sleep/main.c index c178e4c141..3ef949f780 100644 --- a/tests/mutex_unlock_and_sleep/main.c +++ b/tests/mutex_unlock_and_sleep/main.c @@ -27,7 +27,11 @@ static volatile int indicator; static kernel_pid_t main_pid; static char stack[THREAD_STACKSIZE_DEFAULT]; +#ifdef BOARD_NATIVE static const unsigned KITERATIONS = 100; +#else +static const unsigned KITERATIONS = 10; +#endif static void *second_thread(void *arg) { From 4f2521262b5b0241d4a8ed6760aadb23c8ac745a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 8 May 2018 11:38:23 +0200 Subject: [PATCH 3/3] tests/mutex_unlock_and_sleep: reduce number of loops in test Globally speed up automated tests as iterating more does not add anything. Especially usefull for wsn430 that now takes ~30 seconds instead of the double. --- tests/mutex_unlock_and_sleep/tests/01-run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mutex_unlock_and_sleep/tests/01-run.py b/tests/mutex_unlock_and_sleep/tests/01-run.py index 28d12e30af..955095373a 100755 --- a/tests/mutex_unlock_and_sleep/tests/01-run.py +++ b/tests/mutex_unlock_and_sleep/tests/01-run.py @@ -11,7 +11,7 @@ import sys def testfunc(child): - for i in range(20): + for i in range(10): child.expect(r"\[ALIVE\] alternated \d+k times.")