From e52bb68f934ebb5a0072435b162625d4b5fe5be7 Mon Sep 17 00:00:00 2001 From: Martin Kojtal Date: Fri, 27 Jul 2018 10:17:07 +0100 Subject: [PATCH 1/2] tests: astyle fix All tests should comply to our coding standard now --- TESTS/events/queue/main.cpp | 96 +- TESTS/events/timing/main.cpp | 41 +- TESTS/integration/basic/main.cpp | 3 +- TESTS/lorawan/loraradio/main.cpp | 28 +- TESTS/mbed_drivers/c_strings/main.cpp | 44 +- TESTS/mbed_drivers/crc/main.cpp | 26 +- TESTS/mbed_drivers/dev_null/main.cpp | 13 +- TESTS/mbed_drivers/echo/main.cpp | 17 +- TESTS/mbed_drivers/flashiap/main.cpp | 12 +- TESTS/mbed_drivers/generic_tests/main.cpp | 43 +- TESTS/mbed_drivers/lp_ticker/main.cpp | 14 +- TESTS/mbed_drivers/lp_timeout/main.cpp | 24 +- TESTS/mbed_drivers/lp_timer/main.cpp | 26 +- TESTS/mbed_drivers/mem_trace/main.cpp | 9 +- TESTS/mbed_drivers/race_test/main.cpp | 13 +- TESTS/mbed_drivers/rtc/main.cpp | 9 +- TESTS/mbed_drivers/sleep_lock/main.cpp | 8 +- TESTS/mbed_drivers/stl_features/main.cpp | 37 +- TESTS/mbed_drivers/ticker/main.cpp | 22 +- TESTS/mbed_drivers/timeout/main.cpp | 18 +- TESTS/mbed_drivers/timeout/timeout_tests.h | 2 +- TESTS/mbed_drivers/timer/main.cpp | 34 +- TESTS/mbed_drivers/timerevent/main.cpp | 55 +- TESTS/mbed_functional/callback/main.cpp | 492 +++++++---- TESTS/mbed_functional/callback_big/main.cpp | 420 ++++++--- TESTS/mbed_functional/callback_small/main.cpp | 420 ++++++--- .../mbed_functional/functionpointer/main.cpp | 364 ++++++-- TESTS/mbed_hal/common_tickers/main.cpp | 38 +- TESTS/mbed_hal/common_tickers_freq/main.cpp | 20 +- TESTS/mbed_hal/crc/main.cpp | 153 ++-- TESTS/mbed_hal/critical_section/main.cpp | 8 +- .../mbed_hal/flash/functional_tests/main.cpp | 47 +- TESTS/mbed_hal/lp_ticker/main.cpp | 8 +- TESTS/mbed_hal/rtc/main.cpp | 24 +- TESTS/mbed_hal/rtc_reset/main.cpp | 2 +- TESTS/mbed_hal/rtc_time/main.cpp | 39 +- TESTS/mbed_hal/rtc_time_conv/main.cpp | 31 +- TESTS/mbed_hal/sleep/main.cpp | 32 +- TESTS/mbed_hal/sleep_manager/main.cpp | 9 +- .../sleep_manager_racecondition/main.cpp | 7 +- TESTS/mbed_hal/ticker/main.cpp | 825 +++++++++--------- TESTS/mbed_hal/us_ticker/main.cpp | 2 +- TESTS/mbed_platform/FileHandle/TestFile.h | 23 +- TESTS/mbed_platform/Transaction/main.cpp | 8 +- TESTS/mbed_platform/critical_section/main.cpp | 10 +- TESTS/mbed_platform/error_handling/main.cpp | 204 ++--- TESTS/mbed_platform/stats_cpu/main.cpp | 2 +- TESTS/mbed_platform/stats_heap/main.cpp | 20 +- TESTS/mbed_platform/stats_thread/main.cpp | 2 +- TESTS/mbedmicro-mbed/attributes/attributes.c | 72 +- TESTS/mbedmicro-mbed/attributes/main.cpp | 9 +- TESTS/mbedmicro-mbed/attributes/weak.c | 6 +- .../mbedmicro-mbed/call_before_main/main.cpp | 8 +- TESTS/mbedmicro-mbed/cpp/main.cpp | 32 +- TESTS/mbedmicro-mbed/div/main.cpp | 15 +- TESTS/mbedmicro-mbed/static_assert/main.cpp | 6 +- TESTS/mbedmicro-mbed/static_assert/test_c.c | 23 +- .../mbedmicro-mbed/static_assert/test_cpp.cpp | 29 +- .../CircularBuffer/main.cpp | 3 +- TESTS/mbedmicro-rtos-mbed/MemoryPool/main.cpp | 28 +- TESTS/mbedmicro-rtos-mbed/basic/main.cpp | 4 +- .../condition_variable/main.cpp | 4 +- .../mbedmicro-rtos-mbed/event_flags/main.cpp | 13 +- .../heap_and_stack/main.cpp | 24 +- TESTS/mbedmicro-rtos-mbed/mail/main.cpp | 16 +- TESTS/mbedmicro-rtos-mbed/malloc/main.cpp | 6 +- TESTS/mbedmicro-rtos-mbed/mutex/main.cpp | 6 +- TESTS/mbedmicro-rtos-mbed/queue/main.cpp | 34 +- TESTS/mbedmicro-rtos-mbed/rtostimer/main.cpp | 8 +- TESTS/mbedmicro-rtos-mbed/semaphore/main.cpp | 8 +- TESTS/mbedmicro-rtos-mbed/signals/main.cpp | 11 +- TESTS/mbedmicro-rtos-mbed/systimer/main.cpp | 4 +- TESTS/mbedmicro-rtos-mbed/threads/LockGuard.h | 12 +- .../threads/SynchronizedIntegral.h | 18 +- TESTS/mbedmicro-rtos-mbed/threads/main.cpp | 75 +- TESTS/mbedtls/multi/main.cpp | 160 ++-- TESTS/mbedtls/selftest/main.cpp | 9 +- TESTS/netsocket/tcp/main.cpp | 28 +- TESTS/netsocket/tcp/tcp_tests.h | 11 +- TESTS/netsocket/tcp/tcpsocket_echotest.cpp | 49 +- .../tcp/tcpsocket_echotest_burst.cpp | 32 +- .../tcp/tcpsocket_endpoint_close.cpp | 41 +- TESTS/netsocket/tcp/tcpsocket_open_limit.cpp | 13 +- TESTS/netsocket/tcp/tcpsocket_recv_100k.cpp | 28 +- .../netsocket/tcp/tcpsocket_recv_timeout.cpp | 14 +- TESTS/netsocket/tcp/tcpsocket_send_repeat.cpp | 2 +- .../netsocket/tcp/tcpsocket_send_timeout.cpp | 4 +- .../tcpsocket_thread_per_socket_safety.cpp | 33 +- TESTS/netsocket/udp/main.cpp | 36 +- TESTS/netsocket/udp/udp_tests.h | 4 +- TESTS/netsocket/udp/udpsocket_echotest.cpp | 49 +- .../udp/udpsocket_echotest_burst.cpp | 78 +- TESTS/netsocket/udp/udpsocket_open_limit.cpp | 13 +- .../netsocket/udp/udpsocket_recv_timeout.cpp | 10 +- .../netsocket/udp/udpsocket_sendto_repeat.cpp | 2 +- TESTS/network/emac/emac_TestMemoryManager.cpp | 5 +- TESTS/network/emac/emac_TestNetworkStack.h | 6 +- TESTS/network/emac/emac_ctp.cpp | 2 +- TESTS/network/emac/emac_test_initialize.cpp | 4 +- TESTS/network/emac/emac_test_memory.cpp | 24 +- TESTS/network/emac/emac_test_unicast.cpp | 4 +- TESTS/network/emac/emac_util.cpp | 62 +- TESTS/network/emac/main.cpp | 3 +- TESTS/network/wifi/get_interface.cpp | 4 +- TESTS/network/wifi/main.cpp | 8 +- TESTS/network/wifi/wifi-constructor.cpp | 3 +- .../wifi/wifi_connect_disconnect_repeat.cpp | 2 +- .../wifi/wifi_connect_params_channel_fail.cpp | 2 +- .../wifi/wifi_connect_params_valid_secure.cpp | 2 +- TESTS/network/wifi/wifi_scan.cpp | 2 +- 110 files changed, 2980 insertions(+), 2047 deletions(-) diff --git a/TESTS/events/queue/main.cpp b/TESTS/events/queue/main.cpp index 7a7253346db..4bde3c8e230 100644 --- a/TESTS/events/queue/main.cpp +++ b/TESTS/events/queue/main.cpp @@ -21,7 +21,7 @@ #include "utest.h" #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif using namespace utest::v1; @@ -38,32 +38,38 @@ using namespace utest::v1; volatile bool touched = false; // static functions -void func5(int a0, int a1, int a2, int a3, int a4) { +void func5(int a0, int a1, int a2, int a3, int a4) +{ touched = true; TEST_ASSERT_EQUAL(a0 | a1 | a2 | a3 | a4, 0x1f); } -void func4(int a0, int a1, int a2, int a3) { +void func4(int a0, int a1, int a2, int a3) +{ touched = true; - TEST_ASSERT_EQUAL(a0 | a1 | a2 | a3, 0xf); + TEST_ASSERT_EQUAL(a0 | a1 | a2 | a3, 0xf); } -void func3(int a0, int a1, int a2) { +void func3(int a0, int a1, int a2) +{ touched = true; TEST_ASSERT_EQUAL(a0 | a1 | a2, 0x7); } -void func2(int a0, int a1) { +void func2(int a0, int a1) +{ touched = true; TEST_ASSERT_EQUAL(a0 | a1, 0x3); } -void func1(int a0) { +void func1(int a0) +{ touched = true; TEST_ASSERT_EQUAL(a0, 0x1); } -void func0() { +void func0() +{ touched = true; } @@ -95,40 +101,44 @@ SIMPLE_POSTS_TEST(1, 0x01) SIMPLE_POSTS_TEST(0) -void time_func(Timer *t, int ms) { +void time_func(Timer *t, int ms) +{ TEST_ASSERT_INT_WITHIN(DELTA(ms), ms, t->read_ms()); t->reset(); } template -void call_in_test() { +void call_in_test() +{ Timer tickers[N]; EventQueue queue(TEST_EQUEUE_SIZE); for (int i = 0; i < N; i++) { tickers[i].start(); - queue.call_in((i+1)*100, time_func, &tickers[i], (i+1)*100); + queue.call_in((i + 1) * 100, time_func, &tickers[i], (i + 1) * 100); } - queue.dispatch(N*100); + queue.dispatch(N * 100); } template -void call_every_test() { +void call_every_test() +{ Timer tickers[N]; EventQueue queue(TEST_EQUEUE_SIZE); for (int i = 0; i < N; i++) { tickers[i].start(); - queue.call_every((i+1)*100, time_func, &tickers[i], (i+1)*100); + queue.call_every((i + 1) * 100, time_func, &tickers[i], (i + 1) * 100); } - queue.dispatch(N*100); + queue.dispatch(N * 100); } -void allocate_failure_test() { +void allocate_failure_test() +{ EventQueue queue(TEST_EQUEUE_SIZE); int id; @@ -139,12 +149,14 @@ void allocate_failure_test() { TEST_ASSERT(!id); } -void no() { +void no() +{ TEST_ASSERT(false); } template -void cancel_test1() { +void cancel_test1() +{ EventQueue queue(TEST_EQUEUE_SIZE); int ids[N]; @@ -153,7 +165,7 @@ void cancel_test1() { ids[i] = queue.call_in(1000, no); } - for (int i = N-1; i >= 0; i--) { + for (int i = N - 1; i >= 0; i--) { queue.cancel(ids[i]); } @@ -164,31 +176,38 @@ void cancel_test1() { // Testing the dynamic arguments to the event class unsigned counter = 0; -void count5(unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a5) { +void count5(unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a5) +{ counter += a0 + a1 + a2 + a3 + a5; } -void count4(unsigned a0, unsigned a1, unsigned a2, unsigned a3) { +void count4(unsigned a0, unsigned a1, unsigned a2, unsigned a3) +{ counter += a0 + a1 + a2 + a3; } -void count3(unsigned a0, unsigned a1, unsigned a2) { +void count3(unsigned a0, unsigned a1, unsigned a2) +{ counter += a0 + a1 + a2; } -void count2(unsigned a0, unsigned a1) { +void count2(unsigned a0, unsigned a1) +{ counter += a0 + a1; } -void count1(unsigned a0) { +void count1(unsigned a0) +{ counter += a0; } -void count0() { +void count0() +{ counter += 0; } -void event_class_test() { +void event_class_test() +{ counter = 0; EventQueue queue(TEST_EQUEUE_SIZE); @@ -211,7 +230,8 @@ void event_class_test() { TEST_ASSERT_EQUAL(counter, 30); } -void event_class_helper_test() { +void event_class_helper_test() +{ counter = 0; EventQueue queue(TEST_EQUEUE_SIZE); @@ -234,7 +254,8 @@ void event_class_helper_test() { TEST_ASSERT_EQUAL(counter, 15); } -void event_inference_test() { +void event_inference_test() +{ counter = 0; EventQueue queue(TEST_EQUEUE_SIZE); @@ -259,23 +280,26 @@ void event_inference_test() { int timeleft_events[2]; -void check_time_left(EventQueue* queue, int index, int expected) { +void check_time_left(EventQueue *queue, int index, int expected) +{ const int event_id = timeleft_events[index]; TEST_ASSERT_INT_WITHIN(2, expected, queue->time_left(event_id)); touched = true; } -void time_left(EventQueue* queue, int index) { +void time_left(EventQueue *queue, int index) +{ const int event_id = timeleft_events[index]; TEST_ASSERT_EQUAL(0, queue->time_left(event_id)); } -void time_left_test() { +void time_left_test() +{ EventQueue queue(TEST_EQUEUE_SIZE); // Enque check events - TEST_ASSERT(queue.call_in(50, check_time_left, &queue, 0, 100-50)); - TEST_ASSERT(queue.call_in(200, check_time_left, &queue, 1, 200-200)); + TEST_ASSERT(queue.call_in(50, check_time_left, &queue, 0, 100 - 50)); + TEST_ASSERT(queue.call_in(200, check_time_left, &queue, 1, 200 - 200)); // Enque events to be checked timeleft_events[0] = queue.call_in(100, time_left, &queue, 0); @@ -299,7 +323,8 @@ void time_left_test() { } // Test setup -utest::v1::status_t test_setup(const size_t number_of_cases) { +utest::v1::status_t test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(20, "default_auto"); return verbose_test_setup_handler(number_of_cases); } @@ -327,7 +352,8 @@ const Case cases[] = { Specification specification(test_setup, cases); -int main() { +int main() +{ return !Harness::run(specification); } diff --git a/TESTS/events/timing/main.cpp b/TESTS/events/timing/main.cpp index e93c75cfb0c..adc001640b2 100644 --- a/TESTS/events/timing/main.cpp +++ b/TESTS/events/timing/main.cpp @@ -25,7 +25,7 @@ using namespace utest::v1; #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif // Test delay @@ -42,16 +42,18 @@ using namespace utest::v1; #endif // Random number generation to skew timing values -float gauss(float mu, float sigma) { - float x = (float)rand() / ((float)RAND_MAX+1); - float y = (float)rand() / ((float)RAND_MAX+1); - float x2pi = x*2.0*M_PI; - float g2rad = sqrt(-2.0 * log(1.0-y)); +float gauss(float mu, float sigma) +{ + float x = (float)rand() / ((float)RAND_MAX + 1); + float y = (float)rand() / ((float)RAND_MAX + 1); + float x2pi = x * 2.0 * M_PI; + float g2rad = sqrt(-2.0 * log(1.0 - y)); float z = cos(x2pi) * g2rad; - return mu + z*sigma; + return mu + z * sigma; } -float chisq(float sigma) { +float chisq(float sigma) +{ return pow(gauss(0, sqrt(sigma)), 2); } @@ -62,16 +64,17 @@ DigitalOut led(LED1); equeue_sema_t sema; // Timer timing test -void timer_timing_test() { +void timer_timing_test() +{ timer.reset(); timer.start(); int prev = timer.read_us(); - while (prev < TEST_EVENTS_TIMING_TIME*1000) { + while (prev < TEST_EVENTS_TIMING_TIME * 1000) { int next = timer.read_us(); if (next < prev) { printf("backwards drift %d -> %d (%08x -> %08x)\r\n", - prev, next, prev, next); + prev, next, prev, next); } TEST_ASSERT(next >= prev); prev = next; @@ -79,7 +82,8 @@ void timer_timing_test() { } // equeue tick timing test -void tick_timing_test() { +void tick_timing_test() +{ unsigned start = equeue_tick(); int prev = 0; @@ -87,7 +91,7 @@ void tick_timing_test() { int next = equeue_tick() - start; if (next < prev) { printf("backwards drift %d -> %d (%08x -> %08x)\r\n", - prev, next, prev, next); + prev, next, prev, next); } TEST_ASSERT(next >= prev); prev = next; @@ -95,7 +99,8 @@ void tick_timing_test() { } // equeue semaphore timing test -void semaphore_timing_test() { +void semaphore_timing_test() +{ srand(0); timer.reset(); timer.start(); @@ -124,8 +129,9 @@ void semaphore_timing_test() { // Test setup -utest::v1::status_t test_setup(const size_t number_of_cases) { - GREENTEA_SETUP((number_of_cases+1)*TEST_EVENTS_TIMING_TIME/1000, "default_auto"); +utest::v1::status_t test_setup(const size_t number_of_cases) +{ + GREENTEA_SETUP((number_of_cases + 1)*TEST_EVENTS_TIMING_TIME / 1000, "default_auto"); return verbose_test_setup_handler(number_of_cases); } @@ -137,7 +143,8 @@ const Case cases[] = { Specification specification(test_setup, cases); -int main() { +int main() +{ return !Harness::run(specification); } diff --git a/TESTS/integration/basic/main.cpp b/TESTS/integration/basic/main.cpp index ec202446879..3989aada9a4 100644 --- a/TESTS/integration/basic/main.cpp +++ b/TESTS/integration/basic/main.cpp @@ -15,7 +15,8 @@ */ #include "test_env.h" -int main() { +int main() +{ GREENTEA_SETUP(15, "default_auto"); GREENTEA_TESTSUITE_RESULT(true); } diff --git a/TESTS/lorawan/loraradio/main.cpp b/TESTS/lorawan/loraradio/main.cpp index 1f5c6d171bd..29ab638c797 100644 --- a/TESTS/lorawan/loraradio/main.cpp +++ b/TESTS/lorawan/loraradio/main.cpp @@ -29,21 +29,20 @@ #define SX1276 0xEE #if (MBED_CONF_APP_LORA_RADIO == SX1272) - #include "SX1272_LoRaRadio.h" +#include "SX1272_LoRaRadio.h" #elif (MBED_CONF_APP_LORA_RADIO == SX1276) - #include "SX1276_LoRaRadio.h" +#include "SX1276_LoRaRadio.h" #else - #error [NOT_SUPPORTED] Requires parameters from application config file. +#error [NOT_SUPPORTED] Requires parameters from application config file. #endif using namespace utest::v1; -static LoRaRadio* radio = NULL; +static LoRaRadio *radio = NULL; rtos::Semaphore event_sem(0); -enum event_t -{ +enum event_t { EV_NONE, EV_TX_DONE, EV_TX_TIMEOUT, @@ -94,8 +93,7 @@ static void rx_error() TEST_ASSERT_EQUAL(osOK, event_sem.release()); } -static radio_events radio_callbacks = -{ +static radio_events radio_callbacks = { .tx_done = tx_done, .tx_timeout = tx_timeout, .rx_done = rx_done, @@ -187,7 +185,8 @@ void test_check_rf_frequency() } // Test setup -utest::v1::status_t test_setup(const size_t number_of_cases) { +utest::v1::status_t test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(20, "default_auto"); mbed_trace_init(); @@ -240,7 +239,7 @@ utest::v1::status_t case_setup_handler(const Case *const source, const size_t in MBED_CONF_APP_LORA_TCXO); #else - #error [NOT_SUPPORTED] Unknown LoRa radio specified (SX1272,SX1276 are valid) +#error [NOT_SUPPORTED] Unknown LoRa radio specified (SX1272,SX1276 are valid) #endif TEST_ASSERT(radio); @@ -255,11 +254,11 @@ utest::v1::status_t case_teardown_handler(const Case *const source, const size_t radio->sleep(); #if (MBED_CONF_APP_LORA_RADIO == SX1272) - delete static_cast(radio); + delete static_cast(radio); #elif (MBED_CONF_APP_LORA_RADIO == SX1276) - delete static_cast(radio); + delete static_cast(radio); #else - #error [NOT_SUPPORTED] Unknown LoRa radio specified (SX1272,SX1276 are valid) +#error [NOT_SUPPORTED] Unknown LoRa radio specified (SX1272,SX1276 are valid) #endif radio = NULL; @@ -277,6 +276,7 @@ const Case cases[] = { Specification specification(test_setup, cases); -int main() { +int main() +{ return !Harness::run(specification); } diff --git a/TESTS/mbed_drivers/c_strings/main.cpp b/TESTS/mbed_drivers/c_strings/main.cpp index 68a25e068dc..beb69e15c1f 100644 --- a/TESTS/mbed_drivers/c_strings/main.cpp +++ b/TESTS/mbed_drivers/c_strings/main.cpp @@ -33,68 +33,76 @@ static char buffer[256] = {0}; using namespace utest::v1; -void test_case_c_string_i_d() { +void test_case_c_string_i_d() +{ CLEAN_BUFFER; sprintf(buffer, "%i %d %i %d %i %d %i %d %i %d %i %i", NEGATIVE_INTEGERS); TEST_ASSERT_EQUAL_STRING("-32768 -3214 -999 -100 -1 0 -1 -4231 -999 -4123 -32760 -99999", buffer); } -void test_case_c_string_u_d() { +void test_case_c_string_u_d() +{ CLEAN_BUFFER; sprintf(buffer, "%u %d %u %d %u %d %u %d %u %d %u %d", POSITIVE_INTEGERS); TEST_ASSERT_EQUAL_STRING("32768 3214 999 100 1 0 1 4231 999 4123 32760 99999", buffer); } -void test_case_c_string_x_E() { +void test_case_c_string_x_E() +{ CLEAN_BUFFER; sprintf(buffer, "%x %X %x %X %x %X %x %X %x %X %x %X", POSITIVE_INTEGERS); TEST_ASSERT_EQUAL_STRING("8000 C8E 3e7 64 1 0 1 1087 3e7 101B 7ff8 1869F", buffer); } -void test_case_c_string_f_f() { +void test_case_c_string_f_f() +{ CLEAN_BUFFER; sprintf(buffer, "%f %f %f %f %f %f %f %f %f %f", FLOATS); TEST_ASSERT_EQUAL_STRING("0.002000 0.924300 15.913200 791.773680 6208.200000 25719.495200 426815.982588 6429271.046000 42468024.930000 212006462.910000", buffer); } -void test_case_c_string_g_g() { +void test_case_c_string_g_g() +{ CLEAN_BUFFER; sprintf(buffer, "%g %g %g %g %g %g %g %g %g %g", FLOATS); TEST_ASSERT_EQUAL_STRING("0.002 0.9243 15.9132 791.774 6208.2 25719.5 426816 6.42927e+06 4.2468e+07 2.12006e+08", buffer); } -void test_case_c_string_e_E() { +void test_case_c_string_e_E() +{ CLEAN_BUFFER; sprintf(buffer, "%e %E %e %E %e %E %e %E %e %E", FLOATS); TEST_ASSERT_EQUAL_STRING("2.000000e-03 9.243000E-01 1.591320e+01 7.917737E+02 6.208200e+03 2.571950E+04 4.268160e+05 6.429271E+06 4.246802e+07 2.120065E+08", buffer); } -void test_case_c_string_strtok() { +void test_case_c_string_strtok() +{ CLEAN_BUFFER; - char str[] ="- This, a sample string."; - char * pch = strtok (str," ,.-"); + char str[] = "- This, a sample string."; + char *pch = strtok(str, " ,.-"); while (pch != NULL) { strcat(buffer, pch); - pch = strtok (NULL, " ,.-"); + pch = strtok(NULL, " ,.-"); } TEST_ASSERT_EQUAL_STRING("Thisasamplestring", buffer); } -void test_case_c_string_strpbrk() { +void test_case_c_string_strpbrk() +{ CLEAN_BUFFER; char str[] = "This is a sample string"; char key[] = "aeiou"; char *pch = strpbrk(str, key); - while (pch != NULL) - { + while (pch != NULL) { char buf[2] = {*pch, '\0'}; strcat(buffer, buf); - pch = strpbrk(pch + 1,key); + pch = strpbrk(pch + 1, key); } TEST_ASSERT_EQUAL_STRING("iiaaei", buffer); } -utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) { +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; } @@ -110,13 +118,15 @@ Case cases[] = { Case("C strings: %g %g float formatting", test_case_c_string_g_g, greentea_failure_handler), }; -utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { +utest::v1::status_t greentea_test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(5, "default_auto"); return greentea_test_setup_handler(number_of_cases); } Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); -int main() { +int main() +{ Harness::run(specification); } diff --git a/TESTS/mbed_drivers/crc/main.cpp b/TESTS/mbed_drivers/crc/main.cpp index 656711efb57..f531f279514 100644 --- a/TESTS/mbed_drivers/crc/main.cpp +++ b/TESTS/mbed_drivers/crc/main.cpp @@ -30,27 +30,27 @@ void test_supported_polynomials() { MbedCRC ct; - TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char*)test), &crc)); + TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char *)test), &crc)); TEST_ASSERT_EQUAL(0xEA, crc); } { MbedCRC ct; - TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char*)test), &crc)); + TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char *)test), &crc)); TEST_ASSERT_EQUAL(0xF4, crc); } { MbedCRC ct; - TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char*)test), &crc)); + TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char *)test), &crc)); TEST_ASSERT_EQUAL(0x29B1, crc); } { MbedCRC ct; - TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char*)test), &crc)); + TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char *)test), &crc)); TEST_ASSERT_EQUAL(0xBB3D, crc); } { MbedCRC ct; - TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char*)test), &crc)); + TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char *)test), &crc)); TEST_ASSERT_EQUAL(0xCBF43926, crc); } } @@ -82,7 +82,7 @@ void test_sd_crc() test[3] = 0x00; test[4] = 0x00; TEST_ASSERT_EQUAL(0, crc7.compute((void *)test, 5, &crc)); - crc = (crc | 0x1 ) & 0xFF; + crc = (crc | 0x1) & 0xFF; TEST_ASSERT_EQUAL(0x95, crc); test[0] = 0x48; @@ -91,7 +91,7 @@ void test_sd_crc() test[3] = 0x01; test[4] = 0xAA; TEST_ASSERT_EQUAL(0, crc7.compute((void *)test, 5, &crc)); - crc = (crc | 0x1 ) & 0xFF; + crc = (crc | 0x1) & 0xFF; TEST_ASSERT_EQUAL(0x87, crc); test[0] = 0x51; @@ -100,7 +100,7 @@ void test_sd_crc() test[3] = 0x00; test[4] = 0x00; TEST_ASSERT_EQUAL(0, crc7.compute((void *)test, 5, &crc)); - crc = (crc | 0x1 ) & 0xFF; + crc = (crc | 0x1) & 0xFF; TEST_ASSERT_EQUAL(0x55, crc); MbedCRC crc16(0, 0, false, false); @@ -115,12 +115,12 @@ void test_any_polynomial() uint32_t crc; { MbedCRC<0x3D65, 16> ct(0x0, 0xFFFF, 0, 0); - TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char*)test), &crc)); + TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char *)test), &crc)); TEST_ASSERT_EQUAL(0xC2B7, crc); } { MbedCRC<0x1EDC6F41, 32> ct(0xFFFFFFFF, 0xFFFFFFFF, 1, 1); - TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char*)test), &crc)); + TEST_ASSERT_EQUAL(0, ct.compute((void *)test, strlen((const char *)test), &crc)); TEST_ASSERT_EQUAL(0xE3069283, crc); } } @@ -132,13 +132,15 @@ Case cases[] = { Case("Test not supported polynomials", test_any_polynomial) }; -utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { +utest::v1::status_t greentea_test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(15, "default_auto"); return greentea_test_setup_handler(number_of_cases); } Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); -int main() { +int main() +{ Harness::run(specification); } diff --git a/TESTS/mbed_drivers/dev_null/main.cpp b/TESTS/mbed_drivers/dev_null/main.cpp index 5513ca64fc4..880979282e3 100644 --- a/TESTS/mbed_drivers/dev_null/main.cpp +++ b/TESTS/mbed_drivers/dev_null/main.cpp @@ -22,17 +22,20 @@ class DevNull : public Stream { DevNull(const char *name = NULL) : Stream(name) {} protected: - virtual int _getc() { + virtual int _getc() + { return 0; } - virtual int _putc(int c) { + virtual int _putc(int c) + { return c; } }; DevNull null("null"); -int main() { +int main() +{ GREENTEA_SETUP(2, "dev_null_auto"); printf("MBED: before re-routing stdout to /null\n"); // This shouldn't appear @@ -45,7 +48,7 @@ int main() { printf("MBED: this printf is already redirected to /null\n"); } - while(1) { - // Success is determined by the host test at this point, so busy wait + while (1) { + // Success is determined by the host test at this point, so busy wait } } diff --git a/TESTS/mbed_drivers/echo/main.cpp b/TESTS/mbed_drivers/echo/main.cpp index 7295ddb4a6d..7ea6e422b38 100644 --- a/TESTS/mbed_drivers/echo/main.cpp +++ b/TESTS/mbed_drivers/echo/main.cpp @@ -26,7 +26,8 @@ using namespace utest::v1; // Fill a buffer with a slice of the ASCII alphabet. -void fill_buffer(char* buffer, unsigned int length, unsigned int index) { +void fill_buffer(char *buffer, unsigned int length, unsigned int index) +{ unsigned int start = length * index; for (int i = 0; i < length - 1; i++) { buffer[i] = 'a' + ((start + i) % 26); @@ -36,7 +37,8 @@ void fill_buffer(char* buffer, unsigned int length, unsigned int index) { // Echo server (echo payload to host) template -void test_case_echo_server_x() { +void test_case_echo_server_x() +{ char _key[11] = {}; char _tx_value[PAYLOAD_LENGTH + 1] = {}; char _rx_value[PAYLOAD_LENGTH + 1] = {}; @@ -55,7 +57,7 @@ void test_case_echo_server_x() { } while (expected_key); TEST_ASSERT_EQUAL_INT(echo_count, atoi(_rx_value)); - for (int i=0; i < echo_count; ++i) { + for (int i = 0; i < echo_count; ++i) { fill_buffer(_tx_value, PAYLOAD_LENGTH, i); greentea_send_kv(_echo_key_const, _tx_value); do { @@ -67,7 +69,8 @@ void test_case_echo_server_x() { } } -utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) { +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; } @@ -76,13 +79,15 @@ Case cases[] = { Case("Echo server: x16", test_case_echo_server_x<16>, greentea_failure_handler), }; -utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { +utest::v1::status_t greentea_test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(30, "device_echo"); return greentea_test_setup_handler(number_of_cases); } Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); -int main() { +int main() +{ Harness::run(specification); } diff --git a/TESTS/mbed_drivers/flashiap/main.cpp b/TESTS/mbed_drivers/flashiap/main.cpp index c69bc9735b7..cf092ef3d33 100644 --- a/TESTS/mbed_drivers/flashiap/main.cpp +++ b/TESTS/mbed_drivers/flashiap/main.cpp @@ -16,7 +16,7 @@ */ #if !DEVICE_FLASH - #error [NOT_SUPPORTED] Flash API not supported for this target +#error [NOT_SUPPORTED] Flash API not supported for this target #endif #include "utest/utest.h" @@ -239,7 +239,7 @@ void flashiap_timing_test() 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); + 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; @@ -248,7 +248,7 @@ void flashiap_timing_test() 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); + 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); } @@ -266,13 +266,15 @@ Case cases[] = { Case("FlashIAP - timing", flashiap_timing_test), }; -utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { +utest::v1::status_t greentea_test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(120, "default_auto"); return greentea_test_setup_handler(number_of_cases); } Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); -int main() { +int main() +{ Harness::run(specification); } diff --git a/TESTS/mbed_drivers/generic_tests/main.cpp b/TESTS/mbed_drivers/generic_tests/main.cpp index dc177e3f4d5..6c30816dc85 100644 --- a/TESTS/mbed_drivers/generic_tests/main.cpp +++ b/TESTS/mbed_drivers/generic_tests/main.cpp @@ -28,48 +28,56 @@ using namespace utest::v1; class CppTestCaseHelperClass { private: - const char* name; + const char *name; const unsigned pattern; public: - CppTestCaseHelperClass(const char* _name) : name(_name), pattern(PATTERN_CHECK_VALUE) { + CppTestCaseHelperClass(const char *_name) : name(_name), pattern(PATTERN_CHECK_VALUE) + { print("init"); } - void print(const char *message) { + void print(const char *message) + { printf("%s::%s\n", name, message); } - bool check_init(void) { + bool check_init(void) + { bool result = (pattern == PATTERN_CHECK_VALUE); print(result ? "check_init: OK" : "check_init: ERROR"); return result; } - void stack_test(void) { + void stack_test(void) + { print("stack_test"); CppTestCaseHelperClass t("Stack"); t.hello(); } - void hello(void) { + void hello(void) + { print("hello"); } - ~CppTestCaseHelperClass() { + ~CppTestCaseHelperClass() + { print("destroy"); } }; -void test_case_basic() { +void test_case_basic() +{ TEST_ASSERT_TRUE(true); TEST_ASSERT_FALSE(false); TEST_ASSERT_EQUAL_STRING("The quick brown fox jumps over the lazy dog", - "The quick brown fox jumps over the lazy dog"); + "The quick brown fox jumps over the lazy dog"); } -void test_case_blinky() { +void test_case_blinky() +{ static DigitalOut myled(LED1); const int cnt_max = 1024; for (int cnt = 0; cnt < cnt_max; ++cnt) { @@ -77,7 +85,8 @@ void test_case_blinky() { } } -void test_case_cpp_stack() { +void test_case_cpp_stack() +{ // Check C++ start-up initialisation CppTestCaseHelperClass s("Static"); @@ -86,7 +95,8 @@ void test_case_cpp_stack() { TEST_ASSERT_TRUE_MESSAGE(s.check_init(), "s.check_init() failed"); } -void test_case_cpp_heap() { +void test_case_cpp_heap() +{ // Heap test object simple test CppTestCaseHelperClass *m = new CppTestCaseHelperClass("Heap"); m->hello(); @@ -94,7 +104,8 @@ void test_case_cpp_heap() { delete m; } -utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) { +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; } @@ -107,13 +118,15 @@ Case cases[] = { Case("C++ heap", test_case_cpp_heap, greentea_failure_handler) }; -utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { +utest::v1::status_t greentea_test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(20, "default_auto"); return greentea_test_setup_handler(number_of_cases); } Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); -int main() { +int main() +{ Harness::run(specification); } diff --git a/TESTS/mbed_drivers/lp_ticker/main.cpp b/TESTS/mbed_drivers/lp_ticker/main.cpp index 35a5b87a435..ece4562f06c 100644 --- a/TESTS/mbed_drivers/lp_ticker/main.cpp +++ b/TESTS/mbed_drivers/lp_ticker/main.cpp @@ -20,7 +20,7 @@ #if !DEVICE_LPTICKER - #error [NOT_SUPPORTED] Low power ticker not supported for this target +#error [NOT_SUPPORTED] Low power ticker not supported for this target #endif using utest::v1::Case; @@ -53,12 +53,12 @@ void sem_release(Semaphore *sem) void stop_gtimer_set_flag(void) { gtimer.stop(); - core_util_atomic_incr_u32((uint32_t*)&ticker_callback_flag, 1); + core_util_atomic_incr_u32((uint32_t *)&ticker_callback_flag, 1); } void increment_multi_counter(void) { - core_util_atomic_incr_u32((uint32_t*)&multi_counter, 1);; + core_util_atomic_incr_u32((uint32_t *)&multi_counter, 1);; } /** Test many tickers run one after the other @@ -83,7 +83,7 @@ void test_multi_ticker(void) TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter); for (int i = 0; i < TICKER_COUNT; i++) { - ticker[i].detach(); + ticker[i].detach(); } // Because detach calls schedule_interrupt in some circumstances // (e.g. when head event is removed), it's good to check if @@ -125,7 +125,7 @@ void test_multi_call_time(void) gtimer.start(); ticker.attach_us(callback(stop_gtimer_set_flag), MULTI_TICKER_TIME_MS * 1000); - while(!ticker_callback_flag); + while (!ticker_callback_flag); time_diff = gtimer.read_us(); TEST_ASSERT_UINT32_WITHIN(TOLERANCE_US(MULTI_TICKER_TIME_MS * 1000), MULTI_TICKER_TIME_MS * 1000, time_diff); @@ -174,7 +174,7 @@ void test_attach_time(void) gtimer.reset(); gtimer.start(); ticker.attach(callback(stop_gtimer_set_flag), ((float)DELAY_US) / 1000000.0f); - while(!ticker_callback_flag); + while (!ticker_callback_flag); ticker.detach(); const int time_diff = gtimer.read_us(); @@ -196,7 +196,7 @@ void test_attach_us_time(void) gtimer.reset(); gtimer.start(); ticker.attach_us(callback(stop_gtimer_set_flag), DELAY_US); - while(!ticker_callback_flag); + while (!ticker_callback_flag); ticker.detach(); const int time_diff = gtimer.read_us(); diff --git a/TESTS/mbed_drivers/lp_timeout/main.cpp b/TESTS/mbed_drivers/lp_timeout/main.cpp index b3cbe7de0ac..ec8f36e60cb 100644 --- a/TESTS/mbed_drivers/lp_timeout/main.cpp +++ b/TESTS/mbed_drivers/lp_timeout/main.cpp @@ -15,7 +15,7 @@ */ #if !DEVICE_LPTICKER - #error [NOT_SUPPORTED] Low power timer not supported for this target +#error [NOT_SUPPORTED] Low power timer not supported for this target #endif #include "mbed.h" @@ -26,7 +26,7 @@ using namespace utest::v1; -utest::v1::status_t greentea_failure_handler(const Case * const source, const failure_t reason) +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; @@ -49,30 +49,30 @@ Case cases[] = { Case("Zero delay (attach_us)", test_no_wait >), Case("10 ms delay accuracy (attach)", test_delay_accuracy, 10000, SHORT_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("10 ms delay accuracy (attach_us)", test_delay_accuracy, 10000, SHORT_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("1 s delay accuracy (attach)", test_delay_accuracy, 1000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("1 s delay accuracy (attach_us)", test_delay_accuracy, 1000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("5 s delay accuracy (attach)", test_delay_accuracy, 5000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("5 s delay accuracy (attach_us)", test_delay_accuracy, 5000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), #if DEVICE_SLEEP Case("1 s delay during sleep (attach)", test_sleep, 1000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("1 s delay during sleep (attach_us)", test_sleep, 1000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("1 s delay during deepsleep (attach)", test_deepsleep, 1000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("1 s delay during deepsleep (attach_us)", test_deepsleep, 1000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), #endif Case("Timing drift (attach)", test_drift >), diff --git a/TESTS/mbed_drivers/lp_timer/main.cpp b/TESTS/mbed_drivers/lp_timer/main.cpp index 56d37fd8d5d..d41fd806aff 100644 --- a/TESTS/mbed_drivers/lp_timer/main.cpp +++ b/TESTS/mbed_drivers/lp_timer/main.cpp @@ -35,17 +35,17 @@ extern uint32_t SystemCoreClock; * timer we need to adjust delta. */ - /* - * Define tolerance as follows: - * tolerance = 500 us + 5% of measured time - * - * e.g. - * 1 ms delay: tolerance = 550 us - * 10 ms delay: tolerance = 1000 us - * 100 ms delay: tolerance = 5500 us - * 1000 ms delay: tolerance = 50500 us - * - * */ +/* +* Define tolerance as follows: +* tolerance = 500 us + 5% of measured time +* +* e.g. +* 1 ms delay: tolerance = 550 us +* 10 ms delay: tolerance = 1000 us +* 100 ms delay: tolerance = 5500 us +* 1000 ms delay: tolerance = 50500 us +* +* */ #define US_PER_SEC 1000000 #define US_PER_MSEC 1000 @@ -292,7 +292,7 @@ void test_lptimer_float_operator() lp_timer.stop(); /* Check result - 10 ms elapsed. */ - TEST_ASSERT_FLOAT_WITHIN(DELTA_S(10), 0.010f, (float )(lp_timer)); + TEST_ASSERT_FLOAT_WITHIN(DELTA_S(10), 0.010f, (float)(lp_timer)); } /* This test verifies if time counted by the low power timer is @@ -320,7 +320,7 @@ void test_lptimer_time_measurement() lp_timer.stop(); /* Check results - wait_val_us us have elapsed. */ - TEST_ASSERT_FLOAT_WITHIN(DELTA_S(delta_ms), (float )wait_val_us / 1000000, lp_timer.read()); + TEST_ASSERT_FLOAT_WITHIN(DELTA_S(delta_ms), (float)wait_val_us / 1000000, lp_timer.read()); TEST_ASSERT_INT32_WITHIN(DELTA_MS(delta_ms), wait_val_us / 1000, lp_timer.read_ms()); TEST_ASSERT_INT32_WITHIN(DELTA_US(delta_ms), wait_val_us, lp_timer.read_us()); TEST_ASSERT_UINT64_WITHIN(DELTA_US(delta_ms), wait_val_us, lp_timer.read_high_resolution_us()); diff --git a/TESTS/mbed_drivers/mem_trace/main.cpp b/TESTS/mbed_drivers/mem_trace/main.cpp index 286be0377b0..77dd39716ca 100644 --- a/TESTS/mbed_drivers/mem_trace/main.cpp +++ b/TESTS/mbed_drivers/mem_trace/main.cpp @@ -25,7 +25,7 @@ #include #ifndef MBED_MEM_TRACING_ENABLED - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif using utest::v1::Case; @@ -99,7 +99,7 @@ extern "C" void test_trace_cb(uint8_t op, void *res, void *caller, ...) va_start(va, caller); pmem->op = op; pmem->res = res; - switch(op) { + switch (op) { case MBED_MEM_TRACE_MALLOC: pmem->malloc_info.arg_size = va_arg(va, size_t); break; @@ -180,7 +180,7 @@ void malloc_free(volatile bool *thread_continue) { const size_t block_size = 126; - while(*thread_continue) { + while (*thread_continue) { void *p = malloc(block_size); TEST_ASSERT_NOT_EQUAL(p, NULL); free(p); @@ -403,8 +403,7 @@ static void test_case_multithread_malloc_free() -static Case cases[] = -{ +static Case cases[] = { Case("Test single malloc/free trace", test_case_single_malloc_free), Case("Test all memory operations trace", test_case_all_memory_ops), Case("Test trace off", test_case_trace_off), diff --git a/TESTS/mbed_drivers/race_test/main.cpp b/TESTS/mbed_drivers/race_test/main.cpp index d1fb39f1d53..ca03daaaf43 100644 --- a/TESTS/mbed_drivers/race_test/main.cpp +++ b/TESTS/mbed_drivers/race_test/main.cpp @@ -23,7 +23,7 @@ #include #ifdef MBED_RTOS_SINGLE_THREAD - #error [NOT_SUPPORTED] test not supported for single threaded enviroment +#error [NOT_SUPPORTED] test not supported for single threaded enviroment #endif #if !DEVICE_USTICKER @@ -37,21 +37,24 @@ static uint32_t instance_count = 0; class TestClass { public: - TestClass() { + TestClass() + { Thread::wait(500); instance_count++; } - void do_something() { + void do_something() + { Thread::wait(100); } - ~TestClass() { + ~TestClass() + { instance_count--; } }; -static TestClass* get_test_class() +static TestClass *get_test_class() { static TestClass tc; return &tc; diff --git a/TESTS/mbed_drivers/rtc/main.cpp b/TESTS/mbed_drivers/rtc/main.cpp index d0ebba2c72b..460785b1203 100644 --- a/TESTS/mbed_drivers/rtc/main.cpp +++ b/TESTS/mbed_drivers/rtc/main.cpp @@ -56,9 +56,9 @@ static time_t read_rtc_stub(void) /* Stub of RTC write function. */ static void write_rtc_stub(time_t t) { - rtc_write_called = true; + rtc_write_called = true; - rtc_time_val = t; + rtc_time_val = t; } /* Stub of RTC init function. */ @@ -294,7 +294,7 @@ void test_time_read_RTC_func_undefined() seconds = time(NULL); /* Check if expected value has been returned. */ - TEST_ASSERT_EQUAL((time_t)-1, seconds); + TEST_ASSERT_EQUAL((time_t) -1, seconds); } /* This test verifies if time() function stores @@ -490,6 +490,7 @@ Case cases[] = { Specification specification(test_setup, cases); -int main() { +int main() +{ return !Harness::run(specification); } diff --git a/TESTS/mbed_drivers/sleep_lock/main.cpp b/TESTS/mbed_drivers/sleep_lock/main.cpp index 2e1bcbd80a2..234c70dc2d2 100644 --- a/TESTS/mbed_drivers/sleep_lock/main.cpp +++ b/TESTS/mbed_drivers/sleep_lock/main.cpp @@ -16,7 +16,7 @@ */ #if !DEVICE_SLEEP - #error [NOT_SUPPORTED] Sleep not supported for this target +#error [NOT_SUPPORTED] Sleep not supported for this target #endif #include "utest/utest.h" @@ -120,13 +120,15 @@ Case cases[] = { Case("timer lock test", timer_lock_test), }; -utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { +utest::v1::status_t greentea_test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(20, "default_auto"); return greentea_test_setup_handler(number_of_cases); } Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); -int main() { +int main() +{ Harness::run(specification); } diff --git a/TESTS/mbed_drivers/stl_features/main.cpp b/TESTS/mbed_drivers/stl_features/main.cpp index a8a8f904e24..7d0b289e331 100644 --- a/TESTS/mbed_drivers/stl_features/main.cpp +++ b/TESTS/mbed_drivers/stl_features/main.cpp @@ -39,16 +39,17 @@ using namespace utest::v1; namespace { template -void BubbleSort(T& _array, size_t array_size, F functor) { +void BubbleSort(T &_array, size_t array_size, F functor) +{ bool flag = true; size_t numLength = array_size; - for(size_t i = 1; (i <= numLength) && flag; i++) { + for (size_t i = 1; (i <= numLength) && flag; i++) { flag = false; for (size_t j = 0; j < (numLength - 1); j++) { - if (functor(_array[j+1], _array[j])) { + if (functor(_array[j + 1], _array[j])) { int temp = _array[j]; _array[j] = _array[j + 1]; - _array[j+1] = temp; + _array[j + 1] = temp; flag = true; } } @@ -56,27 +57,33 @@ void BubbleSort(T& _array, size_t array_size, F functor) { } struct greaterAbs { - bool operator()(int a, int b) { return abs(a) > abs(b); } + bool operator()(int a, int b) + { + return abs(a) > abs(b); + } }; } // namespace -void test_case_stl_equal() { +void test_case_stl_equal() +{ const int n_integers[] = {NEGATIVE_INTEGERS}; std::vector 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() { +void test_case_stl_transform() +{ const float floats[] = {FLOATS}; - const char* floats_str[] = {FLOATS_STR}; + 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); TEST_ASSERT_TRUE(std::equal(floats_transform, floats_transform + TABLE_SIZE(floats_transform), floats)); } -void test_case_stl_sort_greater() { +void test_case_stl_sort_greater() +{ int n_integers[] = {NEGATIVE_INTEGERS}; int n_integers2[] = {NEGATIVE_INTEGERS}; @@ -87,7 +94,8 @@ void test_case_stl_sort_greater() { } -void test_case_stl_sort_abs() { +void test_case_stl_sort_abs() +{ int n_integers[] = {NEGATIVE_INTEGERS}; int n_integers2[] = {NEGATIVE_INTEGERS}; @@ -98,7 +106,8 @@ void test_case_stl_sort_abs() { } -utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) { +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; } @@ -110,13 +119,15 @@ Case cases[] = { Case("STL std::sort abs", test_case_stl_sort_abs, greentea_failure_handler) }; -utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { +utest::v1::status_t greentea_test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(5, "default_auto"); return greentea_test_setup_handler(number_of_cases); } Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); -int main() { +int main() +{ Harness::run(specification); } diff --git a/TESTS/mbed_drivers/ticker/main.cpp b/TESTS/mbed_drivers/ticker/main.cpp index 70e2ea99550..35e696e5f92 100644 --- a/TESTS/mbed_drivers/ticker/main.cpp +++ b/TESTS/mbed_drivers/ticker/main.cpp @@ -19,7 +19,7 @@ #include "unity/unity.h" #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif using utest::v1::Case; @@ -48,7 +48,7 @@ volatile int ticker_count = 0; void switch_led1_state(void) { // blink 3 times per second - if((callback_trigger_count % 333) == 0) { + if ((callback_trigger_count % 333) == 0) { led1 = !led1; } } @@ -57,7 +57,7 @@ void switch_led2_state(void) { // blink 3 times per second // make led2 blink at the same callback_trigger_count value as led1 - if(((callback_trigger_count - 1) % 333) == 0) { + if (((callback_trigger_count - 1) % 333) == 0) { led2 = !led2; } } @@ -84,12 +84,12 @@ void sem_release(Semaphore *sem) void stop_gtimer_set_flag(void) { gtimer.stop(); - core_util_atomic_incr_u32((uint32_t*)&ticker_callback_flag, 1); + core_util_atomic_incr_u32((uint32_t *)&ticker_callback_flag, 1); } void increment_multi_counter(void) { - core_util_atomic_incr_u32((uint32_t*)&multi_counter, 1); + core_util_atomic_incr_u32((uint32_t *)&multi_counter, 1); } @@ -130,7 +130,7 @@ void test_case_1x_ticker() //get the results from host greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); - TEST_ASSERT_EQUAL_STRING_MESSAGE("pass", _key,"Host side script reported a fail..."); + TEST_ASSERT_EQUAL_STRING_MESSAGE("pass", _key, "Host side script reported a fail..."); } /* Tests is to measure the accuracy of Ticker over a period of time @@ -174,7 +174,7 @@ void test_case_2x_ticker() //get the results from host greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); - TEST_ASSERT_EQUAL_STRING_MESSAGE("pass", _key,"Host side script reported a fail..."); + TEST_ASSERT_EQUAL_STRING_MESSAGE("pass", _key, "Host side script reported a fail..."); } /** Test many tickers run one after the other @@ -199,7 +199,7 @@ void test_multi_ticker(void) TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter); for (int i = 0; i < TICKER_COUNT; i++) { - ticker[i].detach(); + ticker[i].detach(); } // Because detach calls schedule_interrupt in some circumstances // (e.g. when head event is removed), it's good to check if @@ -241,7 +241,7 @@ void test_multi_call_time(void) gtimer.start(); ticker.attach_us(callback(stop_gtimer_set_flag), MULTI_TICKER_TIME_MS * 1000); - while(!ticker_callback_flag); + while (!ticker_callback_flag); time_diff = gtimer.read_us(); TEST_ASSERT_UINT32_WITHIN(TOLERANCE_US, MULTI_TICKER_TIME_MS * 1000, time_diff); @@ -290,7 +290,7 @@ void test_attach_time(void) gtimer.reset(); gtimer.start(); ticker.attach(callback(stop_gtimer_set_flag), ((float)DELAY_US) / 1000000.0f); - while(!ticker_callback_flag); + while (!ticker_callback_flag); ticker.detach(); const int time_diff = gtimer.read_us(); @@ -312,7 +312,7 @@ void test_attach_us_time(void) gtimer.reset(); gtimer.start(); ticker.attach_us(callback(stop_gtimer_set_flag), DELAY_US); - while(!ticker_callback_flag); + while (!ticker_callback_flag); ticker.detach(); const int time_diff = gtimer.read_us(); diff --git a/TESTS/mbed_drivers/timeout/main.cpp b/TESTS/mbed_drivers/timeout/main.cpp index 8670a7300dd..2be400a8b44 100644 --- a/TESTS/mbed_drivers/timeout/main.cpp +++ b/TESTS/mbed_drivers/timeout/main.cpp @@ -25,7 +25,7 @@ using namespace utest::v1; -utest::v1::status_t greentea_failure_handler(const Case * const source, const failure_t reason) +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; @@ -48,25 +48,25 @@ Case cases[] = { Case("Zero delay (attach_us)", test_no_wait >), Case("10 ms delay accuracy (attach)", test_delay_accuracy, 10000, SHORT_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("10 ms delay accuracy (attach_us)", test_delay_accuracy, 10000, SHORT_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("1 s delay accuracy (attach)", test_delay_accuracy, 1000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("1 s delay accuracy (attach_us)", test_delay_accuracy, 1000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("5 s delay accuracy (attach)", test_delay_accuracy, 5000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("5 s delay accuracy (attach_us)", test_delay_accuracy, 5000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), #if DEVICE_SLEEP Case("1 s delay during sleep (attach)", test_sleep, 1000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), Case("1 s delay during sleep (attach_us)", test_sleep, 1000000, LONG_DELTA_US>, - greentea_failure_handler), + greentea_failure_handler), #endif Case("Timing drift (attach)", test_drift >), diff --git a/TESTS/mbed_drivers/timeout/timeout_tests.h b/TESTS/mbed_drivers/timeout/timeout_tests.h index 390432848bb..ae149c5e96e 100644 --- a/TESTS/mbed_drivers/timeout/timeout_tests.h +++ b/TESTS/mbed_drivers/timeout/timeout_tests.h @@ -340,7 +340,7 @@ template class TimeoutDriftTester { public: TimeoutDriftTester(us_timestamp_t period = 1000) : - _callback_count(0), _period(period), _timeout() + _callback_count(0), _period(period), _timeout() { } diff --git a/TESTS/mbed_drivers/timer/main.cpp b/TESTS/mbed_drivers/timer/main.cpp index 2f75e27b0a3..d102468a329 100644 --- a/TESTS/mbed_drivers/timer/main.cpp +++ b/TESTS/mbed_drivers/timer/main.cpp @@ -23,7 +23,7 @@ #include "hal/us_ticker_api.h" #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif using namespace utest::v1; @@ -34,17 +34,17 @@ extern uint32_t SystemCoreClock; #define US_PER_MSEC 1000 #define MSEC_PER_SEC 1000 - /* - * Define tolerance as follows: - * tolerance = 500 us + 2% of measured time - * - * e.g. - * 1 ms delay: tolerance = 520 us - * 10 ms delay: tolerance = 700 us - * 100 ms delay: tolerance = 2500 us - * 1000 ms delay: tolerance = 20500 us - * - * */ +/* +* Define tolerance as follows: +* tolerance = 500 us + 2% of measured time +* +* e.g. +* 1 ms delay: tolerance = 520 us +* 10 ms delay: tolerance = 700 us +* 100 ms delay: tolerance = 2500 us +* 1000 ms delay: tolerance = 20500 us +* +* */ #ifdef NO_SYSTICK #define TOLERANCE 5 #else @@ -112,7 +112,7 @@ static void stub_free(void) ticker_info_t info = { TICKER_FREQ_1MHZ, TICKER_BITS }; -const ticker_info_t * stub_get_info(void) +const ticker_info_t *stub_get_info(void) { return &info; } @@ -139,7 +139,7 @@ static const ticker_data_t us_data = { }; /* Function which returns user ticker data. */ -const ticker_data_t* get_user_ticker_data(void) +const ticker_data_t *get_user_ticker_data(void) { return &us_data; } @@ -740,7 +740,8 @@ void test_timer_time_measurement() TEST_ASSERT_UINT64_WITHIN(DELTA_US(wait_val_us / US_PER_MSEC), wait_val_us, p_timer->read_high_resolution_us()); } -utest::v1::status_t test_setup(const size_t number_of_cases) { +utest::v1::status_t test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(15, "default_auto"); return verbose_test_setup_handler(number_of_cases); } @@ -769,7 +770,8 @@ Case cases[] = { Specification specification(test_setup, cases); -int main() { +int main() +{ return !Harness::run(specification); } diff --git a/TESTS/mbed_drivers/timerevent/main.cpp b/TESTS/mbed_drivers/timerevent/main.cpp index 817a8606a6a..8231edc8f77 100644 --- a/TESTS/mbed_drivers/timerevent/main.cpp +++ b/TESTS/mbed_drivers/timerevent/main.cpp @@ -28,7 +28,7 @@ using namespace utest::v1; #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #define TEST_DELAY_US 50000ULL @@ -37,22 +37,26 @@ using namespace utest::v1; class TestTimerEvent: public TimerEvent { private: Semaphore sem; - virtual void handler() { + virtual void handler() + { sem.release(); } public: TestTimerEvent() : - TimerEvent(), sem(0, 1) { + TimerEvent(), sem(0, 1) + { sleep_manager_lock_deep_sleep(); } TestTimerEvent(const ticker_data_t *data) : - TimerEvent(data), sem(0, 1) { + TimerEvent(data), sem(0, 1) + { } - virtual ~TestTimerEvent() { + virtual ~TestTimerEvent() + { sleep_manager_unlock_deep_sleep(); } @@ -61,7 +65,8 @@ class TestTimerEvent: public TimerEvent { using TimerEvent::insert_absolute; using TimerEvent::remove; - int32_t sem_wait(uint32_t millisec) { + int32_t sem_wait(uint32_t millisec) + { return sem.wait(millisec); } }; @@ -70,19 +75,23 @@ class TestTimerEventRelative: public TestTimerEvent { public: static const int32_t SEM_SLOTS_AFTER_PAST_TS_INSERTED = 0; TestTimerEventRelative() : - TestTimerEvent() { + TestTimerEvent() + { } TestTimerEventRelative(const ticker_data_t *data) : - TestTimerEvent(data) { + TestTimerEvent(data) + { } // Set relative timestamp of internal event to present_time + ts - void set_future_timestamp(timestamp_t ts) { + void set_future_timestamp(timestamp_t ts) + { insert(::ticker_read(_ticker_data) + ts); } - void set_past_timestamp(void) { + void set_past_timestamp(void) + { insert(::ticker_read(_ticker_data) - 1UL); } }; @@ -91,19 +100,23 @@ class TestTimerEventAbsolute: public TestTimerEvent { public: static const int32_t SEM_SLOTS_AFTER_PAST_TS_INSERTED = 1; TestTimerEventAbsolute() : - TestTimerEvent() { + TestTimerEvent() + { } TestTimerEventAbsolute(const ticker_data_t *data) : - TestTimerEvent(data) { + TestTimerEvent(data) + { } // Set absolute timestamp of internal event to present_time + ts - void set_future_timestamp(us_timestamp_t ts) { + void set_future_timestamp(us_timestamp_t ts) + { insert_absolute(::ticker_read_us(_ticker_data) + ts); } - void set_past_timestamp(void) { + void set_past_timestamp(void) + { insert_absolute(::ticker_read_us(_ticker_data) - 1ULL); } }; @@ -123,7 +136,8 @@ class TestTimerEventAbsolute: public TestTimerEvent { * Then an event handler is called */ template -void test_insert(void) { +void test_insert(void) +{ T tte; tte.set_future_timestamp(TEST_DELAY_US); @@ -151,7 +165,8 @@ void test_insert(void) { * Then the event handler is never called */ template -void test_remove(void) { +void test_remove(void) +{ T tte; tte.set_future_timestamp(TEST_DELAY_US * 2); @@ -168,7 +183,8 @@ void test_remove(void) { * When a timestamp of 0 us is set with @a insert_absolute() * Then an event handler is called instantly */ -void test_insert_zero(void) { +void test_insert_zero(void) +{ TestTimerEvent tte; tte.insert_absolute(0ULL); @@ -194,7 +210,8 @@ void test_insert_zero(void) { * Then an event handler is called instantly */ template -void test_insert_past(void) { +void test_insert_past(void) +{ T tte; tte.set_past_timestamp(); @@ -205,7 +222,7 @@ void test_insert_past(void) { } utest::v1::status_t test_setup(const size_t number_of_cases) - { +{ GREENTEA_SETUP(5, "default_auto"); return verbose_test_setup_handler(number_of_cases); } diff --git a/TESTS/mbed_functional/callback/main.cpp b/TESTS/mbed_functional/callback/main.cpp index f14d7537937..ea941fd7719 100644 --- a/TESTS/mbed_functional/callback/main.cpp +++ b/TESTS/mbed_functional/callback/main.cpp @@ -24,22 +24,34 @@ using namespace utest::v1; // static functions template T static_func0() - { return 0; } +{ + return 0; +} template T static_func1(T a0) - { return 0 | a0; } +{ + return 0 | a0; +} template T static_func2(T a0, T a1) - { return 0 | a0 | a1; } +{ + return 0 | a0 | a1; +} template T static_func3(T a0, T a1, T a2) - { return 0 | a0 | a1 | a2; } +{ + return 0 | a0 | a1 | a2; +} template T static_func4(T a0, T a1, T a2, T a3) - { return 0 | a0 | a1 | a2 | a3; } +{ + return 0 | a0 | a1 | a2 | a3; +} template T static_func5(T a0, T a1, T a2, T a3, T a4) - { return 0 | a0 | a1 | a2 | a3 | a4; } +{ + return 0 | a0 | a1 | a2 | a3 | a4; +} // class functions template @@ -48,205 +60,349 @@ struct Thing { Thing() : t(0x80) {} T member_func0() - { return t; } + { + return t; + } T member_func1(T a0) - { return t | a0; } + { + return t | a0; + } T member_func2(T a0, T a1) - { return t | a0 | a1; } + { + return t | a0 | a1; + } T member_func3(T a0, T a1, T a2) - { return t | a0 | a1 | a2; } + { + return t | a0 | a1 | a2; + } T member_func4(T a0, T a1, T a2, T a3) - { return t | a0 | a1 | a2 | a3; } + { + return t | a0 | a1 | a2 | a3; + } T member_func5(T a0, T a1, T a2, T a3, T a4) - { return t | a0 | a1 | a2 | a3 | a4; } + { + return t | a0 | a1 | a2 | a3 | a4; + } T const_member_func0() const - { return t; } + { + return t; + } T const_member_func1(T a0) const - { return t | a0; } + { + return t | a0; + } T const_member_func2(T a0, T a1) const - { return t | a0 | a1; } + { + return t | a0 | a1; + } T const_member_func3(T a0, T a1, T a2) const - { return t | a0 | a1 | a2; } + { + return t | a0 | a1 | a2; + } T const_member_func4(T a0, T a1, T a2, T a3) const - { return t | a0 | a1 | a2 | a3; } + { + return t | a0 | a1 | a2 | a3; + } T const_member_func5(T a0, T a1, T a2, T a3, T a4) const - { return t | a0 | a1 | a2 | a3 | a4; } + { + return t | a0 | a1 | a2 | a3 | a4; + } T volatile_member_func0() volatile - { return t; } + { + return t; + } T volatile_member_func1(T a0) volatile - { return t | a0; } + { + return t | a0; + } T volatile_member_func2(T a0, T a1) volatile - { return t | a0 | a1; } + { + return t | a0 | a1; + } T volatile_member_func3(T a0, T a1, T a2) volatile - { return t | a0 | a1 | a2; } + { + return t | a0 | a1 | a2; + } T volatile_member_func4(T a0, T a1, T a2, T a3) volatile - { return t | a0 | a1 | a2 | a3; } + { + return t | a0 | a1 | a2 | a3; + } T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile - { return t | a0 | a1 | a2 | a3 | a4; } + { + return t | a0 | a1 | a2 | a3 | a4; + } T const_volatile_member_func0() const volatile - { return t; } + { + return t; + } T const_volatile_member_func1(T a0) const volatile - { return t | a0; } + { + return t | a0; + } T const_volatile_member_func2(T a0, T a1) const volatile - { return t | a0 | a1; } + { + return t | a0 | a1; + } T const_volatile_member_func3(T a0, T a1, T a2) const volatile - { return t | a0 | a1 | a2; } + { + return t | a0 | a1 | a2; + } T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile - { return t | a0 | a1 | a2 | a3; } + { + return t | a0 | a1 | a2 | a3; + } T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile - { return t | a0 | a1 | a2 | a3 | a4; } + { + return t | a0 | a1 | a2 | a3 | a4; + } }; // bound functions template T bound_func0(Thing *t) - { return t->t; } +{ + return t->t; +} template T bound_func1(Thing *t, T a0) - { return t->t | a0; } +{ + return t->t | a0; +} template T bound_func2(Thing *t, T a0, T a1) - { return t->t | a0 | a1; } +{ + return t->t | a0 | a1; +} template T bound_func3(Thing *t, T a0, T a1, T a2) - { return t->t | a0 | a1 | a2; } +{ + return t->t | a0 | a1 | a2; +} template T bound_func4(Thing *t, T a0, T a1, T a2, T a3) - { return t->t | a0 | a1 | a2 | a3; } +{ + return t->t | a0 | a1 | a2 | a3; +} template T bound_func5(Thing *t, T a0, T a1, T a2, T a3, T a4) - { return t->t | a0 | a1 | a2 | a3 | a4; } +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} template T const_bound_func0(const Thing *t) - { return t->t; } +{ + return t->t; +} template T const_bound_func1(const Thing *t, T a0) - { return t->t | a0; } +{ + return t->t | a0; +} template T const_bound_func2(const Thing *t, T a0, T a1) - { return t->t | a0 | a1; } +{ + return t->t | a0 | a1; +} template T const_bound_func3(const Thing *t, T a0, T a1, T a2) - { return t->t | a0 | a1 | a2; } +{ + return t->t | a0 | a1 | a2; +} template T const_bound_func4(const Thing *t, T a0, T a1, T a2, T a3) - { return t->t | a0 | a1 | a2 | a3; } +{ + return t->t | a0 | a1 | a2 | a3; +} template T const_bound_func5(const Thing *t, T a0, T a1, T a2, T a3, T a4) - { return t->t | a0 | a1 | a2 | a3 | a4; } +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} template T volatile_bound_func0(volatile Thing *t) - { return t->t; } +{ + return t->t; +} template T volatile_bound_func1(volatile Thing *t, T a0) - { return t->t | a0; } +{ + return t->t | a0; +} template T volatile_bound_func2(volatile Thing *t, T a0, T a1) - { return t->t | a0 | a1; } +{ + return t->t | a0 | a1; +} template T volatile_bound_func3(volatile Thing *t, T a0, T a1, T a2) - { return t->t | a0 | a1 | a2; } +{ + return t->t | a0 | a1 | a2; +} template T volatile_bound_func4(volatile Thing *t, T a0, T a1, T a2, T a3) - { return t->t | a0 | a1 | a2 | a3; } +{ + return t->t | a0 | a1 | a2 | a3; +} template T volatile_bound_func5(volatile Thing *t, T a0, T a1, T a2, T a3, T a4) - { return t->t | a0 | a1 | a2 | a3 | a4; } +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} template T const_volatile_bound_func0(const volatile Thing *t) - { return t->t; } +{ + return t->t; +} template T const_volatile_bound_func1(const volatile Thing *t, T a0) - { return t->t | a0; } +{ + return t->t | a0; +} template T const_volatile_bound_func2(const volatile Thing *t, T a0, T a1) - { return t->t | a0 | a1; } +{ + return t->t | a0 | a1; +} template T const_volatile_bound_func3(const volatile Thing *t, T a0, T a1, T a2) - { return t->t | a0 | a1 | a2; } +{ + return t->t | a0 | a1 | a2; +} template T const_volatile_bound_func4(const volatile Thing *t, T a0, T a1, T a2, T a3) - { return t->t | a0 | a1 | a2 | a3; } +{ + return t->t | a0 | a1 | a2 | a3; +} template T const_volatile_bound_func5(const volatile Thing *t, T a0, T a1, T a2, T a3, T a4) - { return t->t | a0 | a1 | a2 | a3 | a4; } +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} // void functions template T void_func0(void *t) - { return static_cast*>(t)->t; } +{ + return static_cast*>(t)->t; +} template T void_func1(void *t, T a0) - { return static_cast*>(t)->t | a0; } +{ + return static_cast*>(t)->t | a0; +} template T void_func2(void *t, T a0, T a1) - { return static_cast*>(t)->t | a0 | a1; } +{ + return static_cast*>(t)->t | a0 | a1; +} template T void_func3(void *t, T a0, T a1, T a2) - { return static_cast*>(t)->t | a0 | a1 | a2; } +{ + return static_cast*>(t)->t | a0 | a1 | a2; +} template T void_func4(void *t, T a0, T a1, T a2, T a3) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3; +} template T void_func5(void *t, T a0, T a1, T a2, T a3, T a4) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; +} template T const_void_func0(const void *t) - { return static_cast*>(t)->t; } +{ + return static_cast*>(t)->t; +} template T const_void_func1(const void *t, T a0) - { return static_cast*>(t)->t | a0; } +{ + return static_cast*>(t)->t | a0; +} template T const_void_func2(const void *t, T a0, T a1) - { return static_cast*>(t)->t | a0 | a1; } +{ + return static_cast*>(t)->t | a0 | a1; +} template T const_void_func3(const void *t, T a0, T a1, T a2) - { return static_cast*>(t)->t | a0 | a1 | a2; } +{ + return static_cast*>(t)->t | a0 | a1 | a2; +} template T const_void_func4(const void *t, T a0, T a1, T a2, T a3) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3; +} template T const_void_func5(const void *t, T a0, T a1, T a2, T a3, T a4) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; +} template T volatile_void_func0(volatile void *t) - { return static_cast*>(t)->t; } +{ + return static_cast*>(t)->t; +} template T volatile_void_func1(volatile void *t, T a0) - { return static_cast*>(t)->t | a0; } +{ + return static_cast*>(t)->t | a0; +} template T volatile_void_func2(volatile void *t, T a0, T a1) - { return static_cast*>(t)->t | a0 | a1; } +{ + return static_cast*>(t)->t | a0 | a1; +} template T volatile_void_func3(volatile void *t, T a0, T a1, T a2) - { return static_cast*>(t)->t | a0 | a1 | a2; } +{ + return static_cast*>(t)->t | a0 | a1 | a2; +} template T volatile_void_func4(volatile void *t, T a0, T a1, T a2, T a3) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3; +} template T volatile_void_func5(volatile void *t, T a0, T a1, T a2, T a3, T a4) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; +} template T const_volatile_void_func0(const volatile void *t) - { return static_cast*>(t)->t; } +{ + return static_cast*>(t)->t; +} template T const_volatile_void_func1(const volatile void *t, T a0) - { return static_cast*>(t)->t | a0; } +{ + return static_cast*>(t)->t | a0; +} template T const_volatile_void_func2(const volatile void *t, T a0, T a1) - { return static_cast*>(t)->t | a0 | a1; } +{ + return static_cast*>(t)->t | a0 | a1; +} template T const_volatile_void_func3(const volatile void *t, T a0, T a1, T a2) - { return static_cast*>(t)->t | a0 | a1 | a2; } +{ + return static_cast*>(t)->t | a0 | a1 | a2; +} template T const_volatile_void_func4(const volatile void *t, T a0, T a1, T a2, T a3) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3; +} template T const_volatile_void_func5(const volatile void *t, T a0, T a1, T a2, T a3, T a4) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; +} // Inheriting class template @@ -257,73 +413,85 @@ class Thing2 : public Thing { // function call and result verification template struct Verifier { - static void verify0(Callback func) { + static void verify0(Callback func) + { T result = func(); TEST_ASSERT_EQUAL(result, 0x00); } template - static void verify0(O *obj, M method) { + static void verify0(O *obj, M method) + { Callback func(obj, method); T result = func(); TEST_ASSERT_EQUAL(result, 0x80); } - static void verify1(Callback func) { + static void verify1(Callback func) + { T result = func((1 << 0)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0)); } template - static void verify1(O *obj, M method) { + static void verify1(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0)); } - static void verify2(Callback func) { + static void verify2(Callback func) + { T result = func((1 << 0), (1 << 1)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1)); } template - static void verify2(O *obj, M method) { + static void verify2(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1)); } - static void verify3(Callback func) { + static void verify3(Callback func) + { T result = func((1 << 0), (1 << 1), (1 << 2)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2)); } template - static void verify3(O *obj, M method) { + static void verify3(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1), (1 << 2)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2)); } - static void verify4(Callback func) { + static void verify4(Callback func) + { T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); } template - static void verify4(O *obj, M method) { + static void verify4(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); } - static void verify5(Callback func) { + static void verify5(Callback func) + { T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); } template - static void verify5(O *obj, M method) { + static void verify5(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); @@ -333,24 +501,25 @@ struct Verifier { // test dispatch template -void test_dispatch0() { +void test_dispatch0() +{ Thing thing; Thing2 thing2; Verifier::verify0(static_func0); Verifier::verify0(&thing, &Thing::member_func0); - Verifier::verify0((const Thing*)&thing, &Thing::const_member_func0); - Verifier::verify0((volatile Thing*)&thing, &Thing::volatile_member_func0); - Verifier::verify0((const volatile Thing*)&thing, &Thing::const_volatile_member_func0); + Verifier::verify0((const Thing *)&thing, &Thing::const_member_func0); + Verifier::verify0((volatile Thing *)&thing, &Thing::volatile_member_func0); + Verifier::verify0((const volatile Thing *)&thing, &Thing::const_volatile_member_func0); Verifier::verify0(&thing2, &Thing2::member_func0); Verifier::verify0(&bound_func0, &thing); - Verifier::verify0(&const_bound_func0, (const Thing*)&thing); - Verifier::verify0(&volatile_bound_func0, (volatile Thing*)&thing); - Verifier::verify0(&const_volatile_bound_func0, (const volatile Thing*)&thing); + Verifier::verify0(&const_bound_func0, (const Thing *)&thing); + Verifier::verify0(&volatile_bound_func0, (volatile Thing *)&thing); + Verifier::verify0(&const_volatile_bound_func0, (const volatile Thing *)&thing); Verifier::verify0(&bound_func0, &thing2); Verifier::verify0(&void_func0, &thing); - Verifier::verify0(&const_void_func0, (const Thing*)&thing); - Verifier::verify0(&volatile_void_func0, (volatile Thing*)&thing); - Verifier::verify0(&const_volatile_void_func0, (const volatile Thing*)&thing); + Verifier::verify0(&const_void_func0, (const Thing *)&thing); + Verifier::verify0(&volatile_void_func0, (volatile Thing *)&thing); + Verifier::verify0(&const_volatile_void_func0, (const volatile Thing *)&thing); Verifier::verify0(callback(static_func0)); Callback cb(static_func0); @@ -359,28 +528,29 @@ void test_dispatch0() { Verifier::verify0(cb); cb.attach(&bound_func0, &thing); Verifier::verify0(&cb, &Callback::call); - Verifier::verify0(&Callback::thunk, (void*)&cb); + Verifier::verify0(&Callback::thunk, (void *)&cb); } template -void test_dispatch1() { +void test_dispatch1() +{ Thing thing; Thing2 thing2; Verifier::verify1(static_func1); Verifier::verify1(&thing, &Thing::member_func1); - Verifier::verify1((const Thing*)&thing, &Thing::const_member_func1); - Verifier::verify1((volatile Thing*)&thing, &Thing::volatile_member_func1); - Verifier::verify1((const volatile Thing*)&thing, &Thing::const_volatile_member_func1); + Verifier::verify1((const Thing *)&thing, &Thing::const_member_func1); + Verifier::verify1((volatile Thing *)&thing, &Thing::volatile_member_func1); + Verifier::verify1((const volatile Thing *)&thing, &Thing::const_volatile_member_func1); Verifier::verify1(&thing2, &Thing2::member_func1); Verifier::verify1(&bound_func1, &thing); - Verifier::verify1(&const_bound_func1, (const Thing*)&thing); - Verifier::verify1(&volatile_bound_func1, (volatile Thing*)&thing); - Verifier::verify1(&const_volatile_bound_func1, (const volatile Thing*)&thing); + Verifier::verify1(&const_bound_func1, (const Thing *)&thing); + Verifier::verify1(&volatile_bound_func1, (volatile Thing *)&thing); + Verifier::verify1(&const_volatile_bound_func1, (const volatile Thing *)&thing); Verifier::verify1(&bound_func1, &thing2); Verifier::verify1(&void_func1, &thing); - Verifier::verify1(&const_void_func1, (const Thing*)&thing); - Verifier::verify1(&volatile_void_func1, (volatile Thing*)&thing); - Verifier::verify1(&const_volatile_void_func1, (const volatile Thing*)&thing); + Verifier::verify1(&const_void_func1, (const Thing *)&thing); + Verifier::verify1(&volatile_void_func1, (volatile Thing *)&thing); + Verifier::verify1(&const_volatile_void_func1, (const volatile Thing *)&thing); Verifier::verify1(callback(static_func1)); Callback cb(static_func1); @@ -389,28 +559,29 @@ void test_dispatch1() { Verifier::verify1(cb); cb.attach(&bound_func1, &thing); Verifier::verify1(&cb, &Callback::call); - Verifier::verify1(&Callback::thunk, (void*)&cb); + Verifier::verify1(&Callback::thunk, (void *)&cb); } template -void test_dispatch2() { +void test_dispatch2() +{ Thing thing; Thing2 thing2; Verifier::verify2(static_func2); Verifier::verify2(&thing, &Thing::member_func2); - Verifier::verify2((const Thing*)&thing, &Thing::const_member_func2); - Verifier::verify2((volatile Thing*)&thing, &Thing::volatile_member_func2); - Verifier::verify2((const volatile Thing*)&thing, &Thing::const_volatile_member_func2); + Verifier::verify2((const Thing *)&thing, &Thing::const_member_func2); + Verifier::verify2((volatile Thing *)&thing, &Thing::volatile_member_func2); + Verifier::verify2((const volatile Thing *)&thing, &Thing::const_volatile_member_func2); Verifier::verify2(&thing2, &Thing2::member_func2); Verifier::verify2(&bound_func2, &thing); - Verifier::verify2(&const_bound_func2, (const Thing*)&thing); - Verifier::verify2(&volatile_bound_func2, (volatile Thing*)&thing); - Verifier::verify2(&const_volatile_bound_func2, (const volatile Thing*)&thing); + Verifier::verify2(&const_bound_func2, (const Thing *)&thing); + Verifier::verify2(&volatile_bound_func2, (volatile Thing *)&thing); + Verifier::verify2(&const_volatile_bound_func2, (const volatile Thing *)&thing); Verifier::verify2(&bound_func2, &thing2); Verifier::verify2(&void_func2, &thing); - Verifier::verify2(&const_void_func2, (const Thing*)&thing); - Verifier::verify2(&volatile_void_func2, (volatile Thing*)&thing); - Verifier::verify2(&const_volatile_void_func2, (const volatile Thing*)&thing); + Verifier::verify2(&const_void_func2, (const Thing *)&thing); + Verifier::verify2(&volatile_void_func2, (volatile Thing *)&thing); + Verifier::verify2(&const_volatile_void_func2, (const volatile Thing *)&thing); Verifier::verify2(callback(static_func2)); Callback cb(static_func2); @@ -419,28 +590,29 @@ void test_dispatch2() { Verifier::verify2(cb); cb.attach(&bound_func2, &thing); Verifier::verify2(&cb, &Callback::call); - Verifier::verify2(&Callback::thunk, (void*)&cb); + Verifier::verify2(&Callback::thunk, (void *)&cb); } template -void test_dispatch3() { +void test_dispatch3() +{ Thing thing; Thing2 thing2; Verifier::verify3(static_func3); Verifier::verify3(&thing, &Thing::member_func3); - Verifier::verify3((const Thing*)&thing, &Thing::const_member_func3); - Verifier::verify3((volatile Thing*)&thing, &Thing::volatile_member_func3); - Verifier::verify3((const volatile Thing*)&thing, &Thing::const_volatile_member_func3); + Verifier::verify3((const Thing *)&thing, &Thing::const_member_func3); + Verifier::verify3((volatile Thing *)&thing, &Thing::volatile_member_func3); + Verifier::verify3((const volatile Thing *)&thing, &Thing::const_volatile_member_func3); Verifier::verify3(&thing2, &Thing2::member_func3); Verifier::verify3(&bound_func3, &thing); - Verifier::verify3(&const_bound_func3, (const Thing*)&thing); - Verifier::verify3(&volatile_bound_func3, (volatile Thing*)&thing); - Verifier::verify3(&const_volatile_bound_func3, (const volatile Thing*)&thing); + Verifier::verify3(&const_bound_func3, (const Thing *)&thing); + Verifier::verify3(&volatile_bound_func3, (volatile Thing *)&thing); + Verifier::verify3(&const_volatile_bound_func3, (const volatile Thing *)&thing); Verifier::verify3(&bound_func3, &thing2); Verifier::verify3(&void_func3, &thing); - Verifier::verify3(&const_void_func3, (const Thing*)&thing); - Verifier::verify3(&volatile_void_func3, (volatile Thing*)&thing); - Verifier::verify3(&const_volatile_void_func3, (const volatile Thing*)&thing); + Verifier::verify3(&const_void_func3, (const Thing *)&thing); + Verifier::verify3(&volatile_void_func3, (volatile Thing *)&thing); + Verifier::verify3(&const_volatile_void_func3, (const volatile Thing *)&thing); Verifier::verify3(callback(static_func3)); Callback cb(static_func3); @@ -449,28 +621,29 @@ void test_dispatch3() { Verifier::verify3(cb); cb.attach(&bound_func3, &thing); Verifier::verify3(&cb, &Callback::call); - Verifier::verify3(&Callback::thunk, (void*)&cb); + Verifier::verify3(&Callback::thunk, (void *)&cb); } template -void test_dispatch4() { +void test_dispatch4() +{ Thing thing; Thing2 thing2; Verifier::verify4(static_func4); Verifier::verify4(&thing, &Thing::member_func4); - Verifier::verify4((const Thing*)&thing, &Thing::const_member_func4); - Verifier::verify4((volatile Thing*)&thing, &Thing::volatile_member_func4); - Verifier::verify4((const volatile Thing*)&thing, &Thing::const_volatile_member_func4); + Verifier::verify4((const Thing *)&thing, &Thing::const_member_func4); + Verifier::verify4((volatile Thing *)&thing, &Thing::volatile_member_func4); + Verifier::verify4((const volatile Thing *)&thing, &Thing::const_volatile_member_func4); Verifier::verify4(&thing2, &Thing2::member_func4); Verifier::verify4(&bound_func4, &thing); - Verifier::verify4(&const_bound_func4, (const Thing*)&thing); - Verifier::verify4(&volatile_bound_func4, (volatile Thing*)&thing); - Verifier::verify4(&const_volatile_bound_func4, (const volatile Thing*)&thing); + Verifier::verify4(&const_bound_func4, (const Thing *)&thing); + Verifier::verify4(&volatile_bound_func4, (volatile Thing *)&thing); + Verifier::verify4(&const_volatile_bound_func4, (const volatile Thing *)&thing); Verifier::verify4(&bound_func4, &thing2); Verifier::verify4(&void_func4, &thing); - Verifier::verify4(&const_void_func4, (const Thing*)&thing); - Verifier::verify4(&volatile_void_func4, (volatile Thing*)&thing); - Verifier::verify4(&const_volatile_void_func4, (const volatile Thing*)&thing); + Verifier::verify4(&const_void_func4, (const Thing *)&thing); + Verifier::verify4(&volatile_void_func4, (volatile Thing *)&thing); + Verifier::verify4(&const_volatile_void_func4, (const volatile Thing *)&thing); Verifier::verify4(callback(static_func4)); Callback cb(static_func4); @@ -479,28 +652,29 @@ void test_dispatch4() { Verifier::verify4(cb); cb.attach(&bound_func4, &thing); Verifier::verify4(&cb, &Callback::call); - Verifier::verify4(&Callback::thunk, (void*)&cb); + Verifier::verify4(&Callback::thunk, (void *)&cb); } template -void test_dispatch5() { +void test_dispatch5() +{ Thing thing; Thing2 thing2; Verifier::verify5(static_func5); Verifier::verify5(&thing, &Thing::member_func5); - Verifier::verify5((const Thing*)&thing, &Thing::const_member_func5); - Verifier::verify5((volatile Thing*)&thing, &Thing::volatile_member_func5); - Verifier::verify5((const volatile Thing*)&thing, &Thing::const_volatile_member_func5); + Verifier::verify5((const Thing *)&thing, &Thing::const_member_func5); + Verifier::verify5((volatile Thing *)&thing, &Thing::volatile_member_func5); + Verifier::verify5((const volatile Thing *)&thing, &Thing::const_volatile_member_func5); Verifier::verify5(&thing2, &Thing2::member_func5); Verifier::verify5(&bound_func5, &thing); - Verifier::verify5(&const_bound_func5, (const Thing*)&thing); - Verifier::verify5(&volatile_bound_func5, (volatile Thing*)&thing); - Verifier::verify5(&const_volatile_bound_func5, (const volatile Thing*)&thing); + Verifier::verify5(&const_bound_func5, (const Thing *)&thing); + Verifier::verify5(&volatile_bound_func5, (volatile Thing *)&thing); + Verifier::verify5(&const_volatile_bound_func5, (const volatile Thing *)&thing); Verifier::verify5(&bound_func5, &thing2); Verifier::verify5(&void_func5, &thing); - Verifier::verify5(&const_void_func5, (const Thing*)&thing); - Verifier::verify5(&volatile_void_func5, (volatile Thing*)&thing); - Verifier::verify5(&const_volatile_void_func5, (const volatile Thing*)&thing); + Verifier::verify5(&const_void_func5, (const Thing *)&thing); + Verifier::verify5(&volatile_void_func5, (volatile Thing *)&thing); + Verifier::verify5(&const_volatile_void_func5, (const volatile Thing *)&thing); Verifier::verify5(callback(static_func5)); Callback cb(static_func5); @@ -509,12 +683,13 @@ void test_dispatch5() { Verifier::verify5(cb); cb.attach(&bound_func5, &thing); Verifier::verify5(&cb, &Callback::call); - Verifier::verify5(&Callback::thunk, (void*)&cb); + Verifier::verify5(&Callback::thunk, (void *)&cb); } // Test setup -utest::v1::status_t test_setup(const size_t number_of_cases) { +utest::v1::status_t test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(10, "default_auto"); return verbose_test_setup_handler(number_of_cases); } @@ -530,6 +705,7 @@ Case cases[] = { Specification specification(test_setup, cases); -int main() { +int main() +{ return !Harness::run(specification); } diff --git a/TESTS/mbed_functional/callback_big/main.cpp b/TESTS/mbed_functional/callback_big/main.cpp index 1aec88470e7..cac6827171a 100644 --- a/TESTS/mbed_functional/callback_big/main.cpp +++ b/TESTS/mbed_functional/callback_big/main.cpp @@ -23,17 +23,35 @@ using namespace utest::v1; // static functions template -T static_func0() { return 0; } +T static_func0() +{ + return 0; +} template -T static_func1(T a0) { return 0 | a0; } +T static_func1(T a0) +{ + return 0 | a0; +} template -T static_func2(T a0, T a1) { return 0 | a0 | a1; } +T static_func2(T a0, T a1) +{ + return 0 | a0 | a1; +} template -T static_func3(T a0, T a1, T a2) { return 0 | a0 | a1 | a2; } +T static_func3(T a0, T a1, T a2) +{ + return 0 | a0 | a1 | a2; +} template -T static_func4(T a0, T a1, T a2, T a3) { return 0 | a0 | a1 | a2 | a3; } +T static_func4(T a0, T a1, T a2, T a3) +{ + return 0 | a0 | a1 | a2 | a3; +} template -T static_func5(T a0, T a1, T a2, T a3, T a4) { return 0 | a0 | a1 | a2 | a3 | a4; } +T static_func5(T a0, T a1, T a2, T a3, T a4) +{ + return 0 | a0 | a1 | a2 | a3 | a4; +} // class functions template @@ -41,162 +59,318 @@ struct Thing { T t; Thing() : t(0x80) {} - T member_func0() { return t; } - T member_func1(T a0) { return t | a0; } - T member_func2(T a0, T a1) { return t | a0 | a1; } - T member_func3(T a0, T a1, T a2) { return t | a0 | a1 | a2; } - T member_func4(T a0, T a1, T a2, T a3) { return t | a0 | a1 | a2 | a3; } - T member_func5(T a0, T a1, T a2, T a3, T a4) { return t | a0 | a1 | a2 | a3 | a4; } - - T const_member_func0() const { return t; } - T const_member_func1(T a0) const { return t | a0; } - T const_member_func2(T a0, T a1) const { return t | a0 | a1; } - T const_member_func3(T a0, T a1, T a2) const { return t | a0 | a1 | a2; } - T const_member_func4(T a0, T a1, T a2, T a3) const { return t | a0 | a1 | a2 | a3; } - T const_member_func5(T a0, T a1, T a2, T a3, T a4) const { return t | a0 | a1 | a2 | a3 | a4; } - - T volatile_member_func0() volatile { return t; } - T volatile_member_func1(T a0) volatile { return t | a0; } - T volatile_member_func2(T a0, T a1) volatile { return t | a0 | a1; } - T volatile_member_func3(T a0, T a1, T a2) volatile { return t | a0 | a1 | a2; } - T volatile_member_func4(T a0, T a1, T a2, T a3) volatile { return t | a0 | a1 | a2 | a3; } - T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile { return t | a0 | a1 | a2 | a3 | a4; } - - T const_volatile_member_func0() const volatile { return t; } - T const_volatile_member_func1(T a0) const volatile { return t | a0; } - T const_volatile_member_func2(T a0, T a1) const volatile { return t | a0 | a1; } - T const_volatile_member_func3(T a0, T a1, T a2) const volatile { return t | a0 | a1 | a2; } - T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile { return t | a0 | a1 | a2 | a3; } - T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile { return t | a0 | a1 | a2 | a3 | a4; } + T member_func0() + { + return t; + } + T member_func1(T a0) + { + return t | a0; + } + T member_func2(T a0, T a1) + { + return t | a0 | a1; + } + T member_func3(T a0, T a1, T a2) + { + return t | a0 | a1 | a2; + } + T member_func4(T a0, T a1, T a2, T a3) + { + return t | a0 | a1 | a2 | a3; + } + T member_func5(T a0, T a1, T a2, T a3, T a4) + { + return t | a0 | a1 | a2 | a3 | a4; + } + + T const_member_func0() const + { + return t; + } + T const_member_func1(T a0) const + { + return t | a0; + } + T const_member_func2(T a0, T a1) const + { + return t | a0 | a1; + } + T const_member_func3(T a0, T a1, T a2) const + { + return t | a0 | a1 | a2; + } + T const_member_func4(T a0, T a1, T a2, T a3) const + { + return t | a0 | a1 | a2 | a3; + } + T const_member_func5(T a0, T a1, T a2, T a3, T a4) const + { + return t | a0 | a1 | a2 | a3 | a4; + } + + T volatile_member_func0() volatile + { + return t; + } + T volatile_member_func1(T a0) volatile + { + return t | a0; + } + T volatile_member_func2(T a0, T a1) volatile + { + return t | a0 | a1; + } + T volatile_member_func3(T a0, T a1, T a2) volatile + { + return t | a0 | a1 | a2; + } + T volatile_member_func4(T a0, T a1, T a2, T a3) volatile + { + return t | a0 | a1 | a2 | a3; + } + T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile + { + return t | a0 | a1 | a2 | a3 | a4; + } + + T const_volatile_member_func0() const volatile + { + return t; + } + T const_volatile_member_func1(T a0) const volatile + { + return t | a0; + } + T const_volatile_member_func2(T a0, T a1) const volatile + { + return t | a0 | a1; + } + T const_volatile_member_func3(T a0, T a1, T a2) const volatile + { + return t | a0 | a1 | a2; + } + T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile + { + return t | a0 | a1 | a2 | a3; + } + T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile + { + return t | a0 | a1 | a2 | a3 | a4; + } }; // bound functions template -T bound_func0(Thing *t) { return t->t; } +T bound_func0(Thing *t) +{ + return t->t; +} template -T bound_func1(Thing *t, T a0) { return t->t | a0; } +T bound_func1(Thing *t, T a0) +{ + return t->t | a0; +} template -T bound_func2(Thing *t, T a0, T a1) { return t->t | a0 | a1; } +T bound_func2(Thing *t, T a0, T a1) +{ + return t->t | a0 | a1; +} template -T bound_func3(Thing *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; } +T bound_func3(Thing *t, T a0, T a1, T a2) +{ + return t->t | a0 | a1 | a2; +} template -T bound_func4(Thing *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; } +T bound_func4(Thing *t, T a0, T a1, T a2, T a3) +{ + return t->t | a0 | a1 | a2 | a3; +} template -T bound_func5(Thing *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; } +T bound_func5(Thing *t, T a0, T a1, T a2, T a3, T a4) +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} // const bound functions template -T const_func0(const Thing *t) { return t->t; } +T const_func0(const Thing *t) +{ + return t->t; +} template -T const_func1(const Thing *t, T a0) { return t->t | a0; } +T const_func1(const Thing *t, T a0) +{ + return t->t | a0; +} template -T const_func2(const Thing *t, T a0, T a1) { return t->t | a0 | a1; } +T const_func2(const Thing *t, T a0, T a1) +{ + return t->t | a0 | a1; +} template -T const_func3(const Thing *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; } +T const_func3(const Thing *t, T a0, T a1, T a2) +{ + return t->t | a0 | a1 | a2; +} template -T const_func4(const Thing *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; } +T const_func4(const Thing *t, T a0, T a1, T a2, T a3) +{ + return t->t | a0 | a1 | a2 | a3; +} template -T const_func5(const Thing *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; } +T const_func5(const Thing *t, T a0, T a1, T a2, T a3, T a4) +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} // volatile bound functions template -T volatile_func0(volatile Thing *t) { return t->t; } +T volatile_func0(volatile Thing *t) +{ + return t->t; +} template -T volatile_func1(volatile Thing *t, T a0) { return t->t | a0; } +T volatile_func1(volatile Thing *t, T a0) +{ + return t->t | a0; +} template -T volatile_func2(volatile Thing *t, T a0, T a1) { return t->t | a0 | a1; } +T volatile_func2(volatile Thing *t, T a0, T a1) +{ + return t->t | a0 | a1; +} template -T volatile_func3(volatile Thing *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; } +T volatile_func3(volatile Thing *t, T a0, T a1, T a2) +{ + return t->t | a0 | a1 | a2; +} template -T volatile_func4(volatile Thing *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; } +T volatile_func4(volatile Thing *t, T a0, T a1, T a2, T a3) +{ + return t->t | a0 | a1 | a2 | a3; +} template -T volatile_func5(volatile Thing *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; } +T volatile_func5(volatile Thing *t, T a0, T a1, T a2, T a3, T a4) +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} // const volatile bound functions template -T const_volatile_func0(const volatile Thing *t) { return t->t; } +T const_volatile_func0(const volatile Thing *t) +{ + return t->t; +} template -T const_volatile_func1(const volatile Thing *t, T a0) { return t->t | a0; } +T const_volatile_func1(const volatile Thing *t, T a0) +{ + return t->t | a0; +} template -T const_volatile_func2(const volatile Thing *t, T a0, T a1) { return t->t | a0 | a1; } +T const_volatile_func2(const volatile Thing *t, T a0, T a1) +{ + return t->t | a0 | a1; +} template -T const_volatile_func3(const volatile Thing *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; } +T const_volatile_func3(const volatile Thing *t, T a0, T a1, T a2) +{ + return t->t | a0 | a1 | a2; +} template -T const_volatile_func4(const volatile Thing *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; } +T const_volatile_func4(const volatile Thing *t, T a0, T a1, T a2, T a3) +{ + return t->t | a0 | a1 | a2 | a3; +} template -T const_volatile_func5(const volatile Thing *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; } +T const_volatile_func5(const volatile Thing *t, T a0, T a1, T a2, T a3, T a4) +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} // function call and result verification template struct Verifier { - static void verify0(Callback func) { + static void verify0(Callback func) + { T result = func(); TEST_ASSERT_EQUAL(result, 0x00); } template - static void verify0(O *obj, M method) { + static void verify0(O *obj, M method) + { Callback func(obj, method); T result = func(); TEST_ASSERT_EQUAL(result, 0x80); } - static void verify1(Callback func) { + static void verify1(Callback func) + { T result = func((1 << 0)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0)); } template - static void verify1(O *obj, M method) { + static void verify1(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0)); } - static void verify2(Callback func) { + static void verify2(Callback func) + { T result = func((1 << 0), (1 << 1)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1)); } template - static void verify2(O *obj, M method) { + static void verify2(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1)); } - static void verify3(Callback func) { + static void verify3(Callback func) + { T result = func((1 << 0), (1 << 1), (1 << 2)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2)); } template - static void verify3(O *obj, M method) { + static void verify3(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1), (1 << 2)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2)); } - static void verify4(Callback func) { + static void verify4(Callback func) + { T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); } template - static void verify4(O *obj, M method) { + static void verify4(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); } - static void verify5(Callback func) { + static void verify5(Callback func) + { T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); } template - static void verify5(O *obj, M method) { + static void verify5(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); @@ -206,17 +380,18 @@ struct Verifier { // test dispatch template -void test_dispatch0() { +void test_dispatch0() +{ Thing thing; Verifier::verify0(static_func0); Verifier::verify0(&thing, &Thing::member_func0); - Verifier::verify0((const Thing*)&thing, &Thing::const_member_func0); - Verifier::verify0((volatile Thing*)&thing, &Thing::volatile_member_func0); - Verifier::verify0((const volatile Thing*)&thing, &Thing::const_volatile_member_func0); + Verifier::verify0((const Thing *)&thing, &Thing::const_member_func0); + Verifier::verify0((volatile Thing *)&thing, &Thing::volatile_member_func0); + Verifier::verify0((const volatile Thing *)&thing, &Thing::const_volatile_member_func0); Verifier::verify0(&bound_func0, &thing); - Verifier::verify0(&const_func0, (const Thing*)&thing); - Verifier::verify0(&volatile_func0, (volatile Thing*)&thing); - Verifier::verify0(&const_volatile_func0, (const volatile Thing*)&thing); + Verifier::verify0(&const_func0, (const Thing *)&thing); + Verifier::verify0(&volatile_func0, (volatile Thing *)&thing); + Verifier::verify0(&const_volatile_func0, (const volatile Thing *)&thing); Verifier::verify0(callback(static_func0)); Callback cb(static_func0); @@ -225,21 +400,22 @@ void test_dispatch0() { Verifier::verify0(cb); cb.attach(&bound_func0, &thing); Verifier::verify0(&cb, &Callback::call); - Verifier::verify0(&Callback::thunk, (void*)&cb); + Verifier::verify0(&Callback::thunk, (void *)&cb); } template -void test_dispatch1() { +void test_dispatch1() +{ Thing thing; Verifier::verify1(static_func1); Verifier::verify1(&thing, &Thing::member_func1); - Verifier::verify1((const Thing*)&thing, &Thing::const_member_func1); - Verifier::verify1((volatile Thing*)&thing, &Thing::volatile_member_func1); - Verifier::verify1((const volatile Thing*)&thing, &Thing::const_volatile_member_func1); + Verifier::verify1((const Thing *)&thing, &Thing::const_member_func1); + Verifier::verify1((volatile Thing *)&thing, &Thing::volatile_member_func1); + Verifier::verify1((const volatile Thing *)&thing, &Thing::const_volatile_member_func1); Verifier::verify1(&bound_func1, &thing); - Verifier::verify1(&const_func1, (const Thing*)&thing); - Verifier::verify1(&volatile_func1, (volatile Thing*)&thing); - Verifier::verify1(&const_volatile_func1, (const volatile Thing*)&thing); + Verifier::verify1(&const_func1, (const Thing *)&thing); + Verifier::verify1(&volatile_func1, (volatile Thing *)&thing); + Verifier::verify1(&const_volatile_func1, (const volatile Thing *)&thing); Verifier::verify1(callback(static_func1)); Callback cb(static_func1); @@ -248,21 +424,22 @@ void test_dispatch1() { Verifier::verify1(cb); cb.attach(&bound_func1, &thing); Verifier::verify1(&cb, &Callback::call); - Verifier::verify1(&Callback::thunk, (void*)&cb); + Verifier::verify1(&Callback::thunk, (void *)&cb); } template -void test_dispatch2() { +void test_dispatch2() +{ Thing thing; Verifier::verify2(static_func2); Verifier::verify2(&thing, &Thing::member_func2); - Verifier::verify2((const Thing*)&thing, &Thing::const_member_func2); - Verifier::verify2((volatile Thing*)&thing, &Thing::volatile_member_func2); - Verifier::verify2((const volatile Thing*)&thing, &Thing::const_volatile_member_func2); + Verifier::verify2((const Thing *)&thing, &Thing::const_member_func2); + Verifier::verify2((volatile Thing *)&thing, &Thing::volatile_member_func2); + Verifier::verify2((const volatile Thing *)&thing, &Thing::const_volatile_member_func2); Verifier::verify2(&bound_func2, &thing); - Verifier::verify2(&const_func2, (const Thing*)&thing); - Verifier::verify2(&volatile_func2, (volatile Thing*)&thing); - Verifier::verify2(&const_volatile_func2, (const volatile Thing*)&thing); + Verifier::verify2(&const_func2, (const Thing *)&thing); + Verifier::verify2(&volatile_func2, (volatile Thing *)&thing); + Verifier::verify2(&const_volatile_func2, (const volatile Thing *)&thing); Verifier::verify2(callback(static_func2)); Callback cb(static_func2); @@ -271,21 +448,22 @@ void test_dispatch2() { Verifier::verify2(cb); cb.attach(&bound_func2, &thing); Verifier::verify2(&cb, &Callback::call); - Verifier::verify2(&Callback::thunk, (void*)&cb); + Verifier::verify2(&Callback::thunk, (void *)&cb); } template -void test_dispatch3() { +void test_dispatch3() +{ Thing thing; Verifier::verify3(static_func3); Verifier::verify3(&thing, &Thing::member_func3); - Verifier::verify3((const Thing*)&thing, &Thing::const_member_func3); - Verifier::verify3((volatile Thing*)&thing, &Thing::volatile_member_func3); - Verifier::verify3((const volatile Thing*)&thing, &Thing::const_volatile_member_func3); + Verifier::verify3((const Thing *)&thing, &Thing::const_member_func3); + Verifier::verify3((volatile Thing *)&thing, &Thing::volatile_member_func3); + Verifier::verify3((const volatile Thing *)&thing, &Thing::const_volatile_member_func3); Verifier::verify3(&bound_func3, &thing); - Verifier::verify3(&const_func3, (const Thing*)&thing); - Verifier::verify3(&volatile_func3, (volatile Thing*)&thing); - Verifier::verify3(&const_volatile_func3, (const volatile Thing*)&thing); + Verifier::verify3(&const_func3, (const Thing *)&thing); + Verifier::verify3(&volatile_func3, (volatile Thing *)&thing); + Verifier::verify3(&const_volatile_func3, (const volatile Thing *)&thing); Verifier::verify3(callback(static_func3)); Callback cb(static_func3); @@ -294,21 +472,22 @@ void test_dispatch3() { Verifier::verify3(cb); cb.attach(&bound_func3, &thing); Verifier::verify3(&cb, &Callback::call); - Verifier::verify3(&Callback::thunk, (void*)&cb); + Verifier::verify3(&Callback::thunk, (void *)&cb); } template -void test_dispatch4() { +void test_dispatch4() +{ Thing thing; Verifier::verify4(static_func4); Verifier::verify4(&thing, &Thing::member_func4); - Verifier::verify4((const Thing*)&thing, &Thing::const_member_func4); - Verifier::verify4((volatile Thing*)&thing, &Thing::volatile_member_func4); - Verifier::verify4((const volatile Thing*)&thing, &Thing::const_volatile_member_func4); + Verifier::verify4((const Thing *)&thing, &Thing::const_member_func4); + Verifier::verify4((volatile Thing *)&thing, &Thing::volatile_member_func4); + Verifier::verify4((const volatile Thing *)&thing, &Thing::const_volatile_member_func4); Verifier::verify4(&bound_func4, &thing); - Verifier::verify4(&const_func4, (const Thing*)&thing); - Verifier::verify4(&volatile_func4, (volatile Thing*)&thing); - Verifier::verify4(&const_volatile_func4, (const volatile Thing*)&thing); + Verifier::verify4(&const_func4, (const Thing *)&thing); + Verifier::verify4(&volatile_func4, (volatile Thing *)&thing); + Verifier::verify4(&const_volatile_func4, (const volatile Thing *)&thing); Verifier::verify4(callback(static_func4)); Callback cb(static_func4); @@ -317,21 +496,22 @@ void test_dispatch4() { Verifier::verify4(cb); cb.attach(&bound_func4, &thing); Verifier::verify4(&cb, &Callback::call); - Verifier::verify4(&Callback::thunk, (void*)&cb); + Verifier::verify4(&Callback::thunk, (void *)&cb); } template -void test_dispatch5() { +void test_dispatch5() +{ Thing thing; Verifier::verify5(static_func5); Verifier::verify5(&thing, &Thing::member_func5); - Verifier::verify5((const Thing*)&thing, &Thing::const_member_func5); - Verifier::verify5((volatile Thing*)&thing, &Thing::volatile_member_func5); - Verifier::verify5((const volatile Thing*)&thing, &Thing::const_volatile_member_func5); + Verifier::verify5((const Thing *)&thing, &Thing::const_member_func5); + Verifier::verify5((volatile Thing *)&thing, &Thing::volatile_member_func5); + Verifier::verify5((const volatile Thing *)&thing, &Thing::const_volatile_member_func5); Verifier::verify5(&bound_func5, &thing); - Verifier::verify5(&const_func5, (const Thing*)&thing); - Verifier::verify5(&volatile_func5, (volatile Thing*)&thing); - Verifier::verify5(&const_volatile_func5, (const volatile Thing*)&thing); + Verifier::verify5(&const_func5, (const Thing *)&thing); + Verifier::verify5(&volatile_func5, (volatile Thing *)&thing); + Verifier::verify5(&const_volatile_func5, (const volatile Thing *)&thing); Verifier::verify5(callback(static_func5)); Callback cb(static_func5); @@ -340,12 +520,13 @@ void test_dispatch5() { Verifier::verify5(cb); cb.attach(&bound_func5, &thing); Verifier::verify5(&cb, &Callback::call); - Verifier::verify5(&Callback::thunk, (void*)&cb); + Verifier::verify5(&Callback::thunk, (void *)&cb); } // Test setup -utest::v1::status_t test_setup(const size_t number_of_cases) { +utest::v1::status_t test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(10, "default_auto"); return verbose_test_setup_handler(number_of_cases); } @@ -361,6 +542,7 @@ Case cases[] = { Specification specification(test_setup, cases); -int main() { +int main() +{ return !Harness::run(specification); } diff --git a/TESTS/mbed_functional/callback_small/main.cpp b/TESTS/mbed_functional/callback_small/main.cpp index 583b8d0f534..262f69948e9 100644 --- a/TESTS/mbed_functional/callback_small/main.cpp +++ b/TESTS/mbed_functional/callback_small/main.cpp @@ -23,17 +23,35 @@ using namespace utest::v1; // static functions template -T static_func0() { return 0; } +T static_func0() +{ + return 0; +} template -T static_func1(T a0) { return 0 | a0; } +T static_func1(T a0) +{ + return 0 | a0; +} template -T static_func2(T a0, T a1) { return 0 | a0 | a1; } +T static_func2(T a0, T a1) +{ + return 0 | a0 | a1; +} template -T static_func3(T a0, T a1, T a2) { return 0 | a0 | a1 | a2; } +T static_func3(T a0, T a1, T a2) +{ + return 0 | a0 | a1 | a2; +} template -T static_func4(T a0, T a1, T a2, T a3) { return 0 | a0 | a1 | a2 | a3; } +T static_func4(T a0, T a1, T a2, T a3) +{ + return 0 | a0 | a1 | a2 | a3; +} template -T static_func5(T a0, T a1, T a2, T a3, T a4) { return 0 | a0 | a1 | a2 | a3 | a4; } +T static_func5(T a0, T a1, T a2, T a3, T a4) +{ + return 0 | a0 | a1 | a2 | a3 | a4; +} // class functions template @@ -41,162 +59,318 @@ struct Thing { T t; Thing() : t(0x80) {} - T member_func0() { return t; } - T member_func1(T a0) { return t | a0; } - T member_func2(T a0, T a1) { return t | a0 | a1; } - T member_func3(T a0, T a1, T a2) { return t | a0 | a1 | a2; } - T member_func4(T a0, T a1, T a2, T a3) { return t | a0 | a1 | a2 | a3; } - T member_func5(T a0, T a1, T a2, T a3, T a4) { return t | a0 | a1 | a2 | a3 | a4; } - - T const_member_func0() const { return t; } - T const_member_func1(T a0) const { return t | a0; } - T const_member_func2(T a0, T a1) const { return t | a0 | a1; } - T const_member_func3(T a0, T a1, T a2) const { return t | a0 | a1 | a2; } - T const_member_func4(T a0, T a1, T a2, T a3) const { return t | a0 | a1 | a2 | a3; } - T const_member_func5(T a0, T a1, T a2, T a3, T a4) const { return t | a0 | a1 | a2 | a3 | a4; } - - T volatile_member_func0() volatile { return t; } - T volatile_member_func1(T a0) volatile { return t | a0; } - T volatile_member_func2(T a0, T a1) volatile { return t | a0 | a1; } - T volatile_member_func3(T a0, T a1, T a2) volatile { return t | a0 | a1 | a2; } - T volatile_member_func4(T a0, T a1, T a2, T a3) volatile { return t | a0 | a1 | a2 | a3; } - T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile { return t | a0 | a1 | a2 | a3 | a4; } - - T const_volatile_member_func0() const volatile { return t; } - T const_volatile_member_func1(T a0) const volatile { return t | a0; } - T const_volatile_member_func2(T a0, T a1) const volatile { return t | a0 | a1; } - T const_volatile_member_func3(T a0, T a1, T a2) const volatile { return t | a0 | a1 | a2; } - T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile { return t | a0 | a1 | a2 | a3; } - T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile { return t | a0 | a1 | a2 | a3 | a4; } + T member_func0() + { + return t; + } + T member_func1(T a0) + { + return t | a0; + } + T member_func2(T a0, T a1) + { + return t | a0 | a1; + } + T member_func3(T a0, T a1, T a2) + { + return t | a0 | a1 | a2; + } + T member_func4(T a0, T a1, T a2, T a3) + { + return t | a0 | a1 | a2 | a3; + } + T member_func5(T a0, T a1, T a2, T a3, T a4) + { + return t | a0 | a1 | a2 | a3 | a4; + } + + T const_member_func0() const + { + return t; + } + T const_member_func1(T a0) const + { + return t | a0; + } + T const_member_func2(T a0, T a1) const + { + return t | a0 | a1; + } + T const_member_func3(T a0, T a1, T a2) const + { + return t | a0 | a1 | a2; + } + T const_member_func4(T a0, T a1, T a2, T a3) const + { + return t | a0 | a1 | a2 | a3; + } + T const_member_func5(T a0, T a1, T a2, T a3, T a4) const + { + return t | a0 | a1 | a2 | a3 | a4; + } + + T volatile_member_func0() volatile + { + return t; + } + T volatile_member_func1(T a0) volatile + { + return t | a0; + } + T volatile_member_func2(T a0, T a1) volatile + { + return t | a0 | a1; + } + T volatile_member_func3(T a0, T a1, T a2) volatile + { + return t | a0 | a1 | a2; + } + T volatile_member_func4(T a0, T a1, T a2, T a3) volatile + { + return t | a0 | a1 | a2 | a3; + } + T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile + { + return t | a0 | a1 | a2 | a3 | a4; + } + + T const_volatile_member_func0() const volatile + { + return t; + } + T const_volatile_member_func1(T a0) const volatile + { + return t | a0; + } + T const_volatile_member_func2(T a0, T a1) const volatile + { + return t | a0 | a1; + } + T const_volatile_member_func3(T a0, T a1, T a2) const volatile + { + return t | a0 | a1 | a2; + } + T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile + { + return t | a0 | a1 | a2 | a3; + } + T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile + { + return t | a0 | a1 | a2 | a3 | a4; + } }; // bound functions template -T bound_func0(Thing *t) { return t->t; } +T bound_func0(Thing *t) +{ + return t->t; +} template -T bound_func1(Thing *t, T a0) { return t->t | a0; } +T bound_func1(Thing *t, T a0) +{ + return t->t | a0; +} template -T bound_func2(Thing *t, T a0, T a1) { return t->t | a0 | a1; } +T bound_func2(Thing *t, T a0, T a1) +{ + return t->t | a0 | a1; +} template -T bound_func3(Thing *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; } +T bound_func3(Thing *t, T a0, T a1, T a2) +{ + return t->t | a0 | a1 | a2; +} template -T bound_func4(Thing *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; } +T bound_func4(Thing *t, T a0, T a1, T a2, T a3) +{ + return t->t | a0 | a1 | a2 | a3; +} template -T bound_func5(Thing *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; } +T bound_func5(Thing *t, T a0, T a1, T a2, T a3, T a4) +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} // const bound functions template -T const_func0(const Thing *t) { return t->t; } +T const_func0(const Thing *t) +{ + return t->t; +} template -T const_func1(const Thing *t, T a0) { return t->t | a0; } +T const_func1(const Thing *t, T a0) +{ + return t->t | a0; +} template -T const_func2(const Thing *t, T a0, T a1) { return t->t | a0 | a1; } +T const_func2(const Thing *t, T a0, T a1) +{ + return t->t | a0 | a1; +} template -T const_func3(const Thing *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; } +T const_func3(const Thing *t, T a0, T a1, T a2) +{ + return t->t | a0 | a1 | a2; +} template -T const_func4(const Thing *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; } +T const_func4(const Thing *t, T a0, T a1, T a2, T a3) +{ + return t->t | a0 | a1 | a2 | a3; +} template -T const_func5(const Thing *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; } +T const_func5(const Thing *t, T a0, T a1, T a2, T a3, T a4) +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} // volatile bound functions template -T volatile_func0(volatile Thing *t) { return t->t; } +T volatile_func0(volatile Thing *t) +{ + return t->t; +} template -T volatile_func1(volatile Thing *t, T a0) { return t->t | a0; } +T volatile_func1(volatile Thing *t, T a0) +{ + return t->t | a0; +} template -T volatile_func2(volatile Thing *t, T a0, T a1) { return t->t | a0 | a1; } +T volatile_func2(volatile Thing *t, T a0, T a1) +{ + return t->t | a0 | a1; +} template -T volatile_func3(volatile Thing *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; } +T volatile_func3(volatile Thing *t, T a0, T a1, T a2) +{ + return t->t | a0 | a1 | a2; +} template -T volatile_func4(volatile Thing *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; } +T volatile_func4(volatile Thing *t, T a0, T a1, T a2, T a3) +{ + return t->t | a0 | a1 | a2 | a3; +} template -T volatile_func5(volatile Thing *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; } +T volatile_func5(volatile Thing *t, T a0, T a1, T a2, T a3, T a4) +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} // const volatile bound functions template -T const_volatile_func0(const volatile Thing *t) { return t->t; } +T const_volatile_func0(const volatile Thing *t) +{ + return t->t; +} template -T const_volatile_func1(const volatile Thing *t, T a0) { return t->t | a0; } +T const_volatile_func1(const volatile Thing *t, T a0) +{ + return t->t | a0; +} template -T const_volatile_func2(const volatile Thing *t, T a0, T a1) { return t->t | a0 | a1; } +T const_volatile_func2(const volatile Thing *t, T a0, T a1) +{ + return t->t | a0 | a1; +} template -T const_volatile_func3(const volatile Thing *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; } +T const_volatile_func3(const volatile Thing *t, T a0, T a1, T a2) +{ + return t->t | a0 | a1 | a2; +} template -T const_volatile_func4(const volatile Thing *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; } +T const_volatile_func4(const volatile Thing *t, T a0, T a1, T a2, T a3) +{ + return t->t | a0 | a1 | a2 | a3; +} template -T const_volatile_func5(const volatile Thing *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; } +T const_volatile_func5(const volatile Thing *t, T a0, T a1, T a2, T a3, T a4) +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} // function call and result verification template struct Verifier { - static void verify0(Callback func) { + static void verify0(Callback func) + { T result = func(); TEST_ASSERT_EQUAL(result, 0x00); } template - static void verify0(O *obj, M method) { + static void verify0(O *obj, M method) + { Callback func(obj, method); T result = func(); TEST_ASSERT_EQUAL(result, 0x80); } - static void verify1(Callback func) { + static void verify1(Callback func) + { T result = func((1 << 0)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0)); } template - static void verify1(O *obj, M method) { + static void verify1(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0)); } - static void verify2(Callback func) { + static void verify2(Callback func) + { T result = func((1 << 0), (1 << 1)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1)); } template - static void verify2(O *obj, M method) { + static void verify2(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1)); } - static void verify3(Callback func) { + static void verify3(Callback func) + { T result = func((1 << 0), (1 << 1), (1 << 2)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2)); } template - static void verify3(O *obj, M method) { + static void verify3(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1), (1 << 2)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2)); } - static void verify4(Callback func) { + static void verify4(Callback func) + { T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); } template - static void verify4(O *obj, M method) { + static void verify4(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); } - static void verify5(Callback func) { + static void verify5(Callback func) + { T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); } template - static void verify5(O *obj, M method) { + static void verify5(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); @@ -206,17 +380,18 @@ struct Verifier { // test dispatch template -void test_dispatch0() { +void test_dispatch0() +{ Thing thing; Verifier::verify0(static_func0); Verifier::verify0(&thing, &Thing::member_func0); - Verifier::verify0((const Thing*)&thing, &Thing::const_member_func0); - Verifier::verify0((volatile Thing*)&thing, &Thing::volatile_member_func0); - Verifier::verify0((const volatile Thing*)&thing, &Thing::const_volatile_member_func0); + Verifier::verify0((const Thing *)&thing, &Thing::const_member_func0); + Verifier::verify0((volatile Thing *)&thing, &Thing::volatile_member_func0); + Verifier::verify0((const volatile Thing *)&thing, &Thing::const_volatile_member_func0); Verifier::verify0(&bound_func0, &thing); - Verifier::verify0(&const_func0, (const Thing*)&thing); - Verifier::verify0(&volatile_func0, (volatile Thing*)&thing); - Verifier::verify0(&const_volatile_func0, (const volatile Thing*)&thing); + Verifier::verify0(&const_func0, (const Thing *)&thing); + Verifier::verify0(&volatile_func0, (volatile Thing *)&thing); + Verifier::verify0(&const_volatile_func0, (const volatile Thing *)&thing); Verifier::verify0(callback(static_func0)); Callback cb(static_func0); @@ -225,21 +400,22 @@ void test_dispatch0() { Verifier::verify0(cb); cb.attach(&bound_func0, &thing); Verifier::verify0(&cb, &Callback::call); - Verifier::verify0(&Callback::thunk, (void*)&cb); + Verifier::verify0(&Callback::thunk, (void *)&cb); } template -void test_dispatch1() { +void test_dispatch1() +{ Thing thing; Verifier::verify1(static_func1); Verifier::verify1(&thing, &Thing::member_func1); - Verifier::verify1((const Thing*)&thing, &Thing::const_member_func1); - Verifier::verify1((volatile Thing*)&thing, &Thing::volatile_member_func1); - Verifier::verify1((const volatile Thing*)&thing, &Thing::const_volatile_member_func1); + Verifier::verify1((const Thing *)&thing, &Thing::const_member_func1); + Verifier::verify1((volatile Thing *)&thing, &Thing::volatile_member_func1); + Verifier::verify1((const volatile Thing *)&thing, &Thing::const_volatile_member_func1); Verifier::verify1(&bound_func1, &thing); - Verifier::verify1(&const_func1, (const Thing*)&thing); - Verifier::verify1(&volatile_func1, (volatile Thing*)&thing); - Verifier::verify1(&const_volatile_func1, (const volatile Thing*)&thing); + Verifier::verify1(&const_func1, (const Thing *)&thing); + Verifier::verify1(&volatile_func1, (volatile Thing *)&thing); + Verifier::verify1(&const_volatile_func1, (const volatile Thing *)&thing); Verifier::verify1(callback(static_func1)); Callback cb(static_func1); @@ -248,21 +424,22 @@ void test_dispatch1() { Verifier::verify1(cb); cb.attach(&bound_func1, &thing); Verifier::verify1(&cb, &Callback::call); - Verifier::verify1(&Callback::thunk, (void*)&cb); + Verifier::verify1(&Callback::thunk, (void *)&cb); } template -void test_dispatch2() { +void test_dispatch2() +{ Thing thing; Verifier::verify2(static_func2); Verifier::verify2(&thing, &Thing::member_func2); - Verifier::verify2((const Thing*)&thing, &Thing::const_member_func2); - Verifier::verify2((volatile Thing*)&thing, &Thing::volatile_member_func2); - Verifier::verify2((const volatile Thing*)&thing, &Thing::const_volatile_member_func2); + Verifier::verify2((const Thing *)&thing, &Thing::const_member_func2); + Verifier::verify2((volatile Thing *)&thing, &Thing::volatile_member_func2); + Verifier::verify2((const volatile Thing *)&thing, &Thing::const_volatile_member_func2); Verifier::verify2(&bound_func2, &thing); - Verifier::verify2(&const_func2, (const Thing*)&thing); - Verifier::verify2(&volatile_func2, (volatile Thing*)&thing); - Verifier::verify2(&const_volatile_func2, (const volatile Thing*)&thing); + Verifier::verify2(&const_func2, (const Thing *)&thing); + Verifier::verify2(&volatile_func2, (volatile Thing *)&thing); + Verifier::verify2(&const_volatile_func2, (const volatile Thing *)&thing); Verifier::verify2(callback(static_func2)); Callback cb(static_func2); @@ -271,21 +448,22 @@ void test_dispatch2() { Verifier::verify2(cb); cb.attach(&bound_func2, &thing); Verifier::verify2(&cb, &Callback::call); - Verifier::verify2(&Callback::thunk, (void*)&cb); + Verifier::verify2(&Callback::thunk, (void *)&cb); } template -void test_dispatch3() { +void test_dispatch3() +{ Thing thing; Verifier::verify3(static_func3); Verifier::verify3(&thing, &Thing::member_func3); - Verifier::verify3((const Thing*)&thing, &Thing::const_member_func3); - Verifier::verify3((volatile Thing*)&thing, &Thing::volatile_member_func3); - Verifier::verify3((const volatile Thing*)&thing, &Thing::const_volatile_member_func3); + Verifier::verify3((const Thing *)&thing, &Thing::const_member_func3); + Verifier::verify3((volatile Thing *)&thing, &Thing::volatile_member_func3); + Verifier::verify3((const volatile Thing *)&thing, &Thing::const_volatile_member_func3); Verifier::verify3(&bound_func3, &thing); - Verifier::verify3(&const_func3, (const Thing*)&thing); - Verifier::verify3(&volatile_func3, (volatile Thing*)&thing); - Verifier::verify3(&const_volatile_func3, (const volatile Thing*)&thing); + Verifier::verify3(&const_func3, (const Thing *)&thing); + Verifier::verify3(&volatile_func3, (volatile Thing *)&thing); + Verifier::verify3(&const_volatile_func3, (const volatile Thing *)&thing); Verifier::verify3(callback(static_func3)); Callback cb(static_func3); @@ -294,21 +472,22 @@ void test_dispatch3() { Verifier::verify3(cb); cb.attach(&bound_func3, &thing); Verifier::verify3(&cb, &Callback::call); - Verifier::verify3(&Callback::thunk, (void*)&cb); + Verifier::verify3(&Callback::thunk, (void *)&cb); } template -void test_dispatch4() { +void test_dispatch4() +{ Thing thing; Verifier::verify4(static_func4); Verifier::verify4(&thing, &Thing::member_func4); - Verifier::verify4((const Thing*)&thing, &Thing::const_member_func4); - Verifier::verify4((volatile Thing*)&thing, &Thing::volatile_member_func4); - Verifier::verify4((const volatile Thing*)&thing, &Thing::const_volatile_member_func4); + Verifier::verify4((const Thing *)&thing, &Thing::const_member_func4); + Verifier::verify4((volatile Thing *)&thing, &Thing::volatile_member_func4); + Verifier::verify4((const volatile Thing *)&thing, &Thing::const_volatile_member_func4); Verifier::verify4(&bound_func4, &thing); - Verifier::verify4(&const_func4, (const Thing*)&thing); - Verifier::verify4(&volatile_func4, (volatile Thing*)&thing); - Verifier::verify4(&const_volatile_func4, (const volatile Thing*)&thing); + Verifier::verify4(&const_func4, (const Thing *)&thing); + Verifier::verify4(&volatile_func4, (volatile Thing *)&thing); + Verifier::verify4(&const_volatile_func4, (const volatile Thing *)&thing); Verifier::verify4(callback(static_func4)); Callback cb(static_func4); @@ -317,21 +496,22 @@ void test_dispatch4() { Verifier::verify4(cb); cb.attach(&bound_func4, &thing); Verifier::verify4(&cb, &Callback::call); - Verifier::verify4(&Callback::thunk, (void*)&cb); + Verifier::verify4(&Callback::thunk, (void *)&cb); } template -void test_dispatch5() { +void test_dispatch5() +{ Thing thing; Verifier::verify5(static_func5); Verifier::verify5(&thing, &Thing::member_func5); - Verifier::verify5((const Thing*)&thing, &Thing::const_member_func5); - Verifier::verify5((volatile Thing*)&thing, &Thing::volatile_member_func5); - Verifier::verify5((const volatile Thing*)&thing, &Thing::const_volatile_member_func5); + Verifier::verify5((const Thing *)&thing, &Thing::const_member_func5); + Verifier::verify5((volatile Thing *)&thing, &Thing::volatile_member_func5); + Verifier::verify5((const volatile Thing *)&thing, &Thing::const_volatile_member_func5); Verifier::verify5(&bound_func5, &thing); - Verifier::verify5(&const_func5, (const Thing*)&thing); - Verifier::verify5(&volatile_func5, (volatile Thing*)&thing); - Verifier::verify5(&const_volatile_func5, (const volatile Thing*)&thing); + Verifier::verify5(&const_func5, (const Thing *)&thing); + Verifier::verify5(&volatile_func5, (volatile Thing *)&thing); + Verifier::verify5(&const_volatile_func5, (const volatile Thing *)&thing); Verifier::verify5(callback(static_func5)); Callback cb(static_func5); @@ -340,12 +520,13 @@ void test_dispatch5() { Verifier::verify5(cb); cb.attach(&bound_func5, &thing); Verifier::verify5(&cb, &Callback::call); - Verifier::verify5(&Callback::thunk, (void*)&cb); + Verifier::verify5(&Callback::thunk, (void *)&cb); } // Test setup -utest::v1::status_t test_setup(const size_t number_of_cases) { +utest::v1::status_t test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(10, "default_auto"); return verbose_test_setup_handler(number_of_cases); } @@ -361,6 +542,7 @@ Case cases[] = { Specification specification(test_setup, cases); -int main() { +int main() +{ return !Harness::run(specification); } diff --git a/TESTS/mbed_functional/functionpointer/main.cpp b/TESTS/mbed_functional/functionpointer/main.cpp index 0850cf0da0b..ff4f370b06a 100644 --- a/TESTS/mbed_functional/functionpointer/main.cpp +++ b/TESTS/mbed_functional/functionpointer/main.cpp @@ -24,22 +24,34 @@ using namespace utest::v1; // static functions template T static_func0() - { return 0; } +{ + return 0; +} template T static_func1(T a0) - { return 0 | a0; } +{ + return 0 | a0; +} template T static_func2(T a0, T a1) - { return 0 | a0 | a1; } +{ + return 0 | a0 | a1; +} template T static_func3(T a0, T a1, T a2) - { return 0 | a0 | a1 | a2; } +{ + return 0 | a0 | a1 | a2; +} template T static_func4(T a0, T a1, T a2, T a3) - { return 0 | a0 | a1 | a2 | a3; } +{ + return 0 | a0 | a1 | a2 | a3; +} template T static_func5(T a0, T a1, T a2, T a3, T a4) - { return 0 | a0 | a1 | a2 | a3 | a4; } +{ + return 0 | a0 | a1 | a2 | a3 | a4; +} // class functions template @@ -48,277 +60,433 @@ struct Thing { Thing() : t(0x80) {} T member_func0() - { return t; } + { + return t; + } T member_func1(T a0) - { return t | a0; } + { + return t | a0; + } T member_func2(T a0, T a1) - { return t | a0 | a1; } + { + return t | a0 | a1; + } T member_func3(T a0, T a1, T a2) - { return t | a0 | a1 | a2; } + { + return t | a0 | a1 | a2; + } T member_func4(T a0, T a1, T a2, T a3) - { return t | a0 | a1 | a2 | a3; } + { + return t | a0 | a1 | a2 | a3; + } T member_func5(T a0, T a1, T a2, T a3, T a4) - { return t | a0 | a1 | a2 | a3 | a4; } + { + return t | a0 | a1 | a2 | a3 | a4; + } T const_member_func0() const - { return t; } + { + return t; + } T const_member_func1(T a0) const - { return t | a0; } + { + return t | a0; + } T const_member_func2(T a0, T a1) const - { return t | a0 | a1; } + { + return t | a0 | a1; + } T const_member_func3(T a0, T a1, T a2) const - { return t | a0 | a1 | a2; } + { + return t | a0 | a1 | a2; + } T const_member_func4(T a0, T a1, T a2, T a3) const - { return t | a0 | a1 | a2 | a3; } + { + return t | a0 | a1 | a2 | a3; + } T const_member_func5(T a0, T a1, T a2, T a3, T a4) const - { return t | a0 | a1 | a2 | a3 | a4; } + { + return t | a0 | a1 | a2 | a3 | a4; + } T volatile_member_func0() volatile - { return t; } + { + return t; + } T volatile_member_func1(T a0) volatile - { return t | a0; } + { + return t | a0; + } T volatile_member_func2(T a0, T a1) volatile - { return t | a0 | a1; } + { + return t | a0 | a1; + } T volatile_member_func3(T a0, T a1, T a2) volatile - { return t | a0 | a1 | a2; } + { + return t | a0 | a1 | a2; + } T volatile_member_func4(T a0, T a1, T a2, T a3) volatile - { return t | a0 | a1 | a2 | a3; } + { + return t | a0 | a1 | a2 | a3; + } T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile - { return t | a0 | a1 | a2 | a3 | a4; } + { + return t | a0 | a1 | a2 | a3 | a4; + } T const_volatile_member_func0() const volatile - { return t; } + { + return t; + } T const_volatile_member_func1(T a0) const volatile - { return t | a0; } + { + return t | a0; + } T const_volatile_member_func2(T a0, T a1) const volatile - { return t | a0 | a1; } + { + return t | a0 | a1; + } T const_volatile_member_func3(T a0, T a1, T a2) const volatile - { return t | a0 | a1 | a2; } + { + return t | a0 | a1 | a2; + } T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile - { return t | a0 | a1 | a2 | a3; } + { + return t | a0 | a1 | a2 | a3; + } T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile - { return t | a0 | a1 | a2 | a3 | a4; } + { + return t | a0 | a1 | a2 | a3 | a4; + } }; // bound functions template T bound_func0(Thing *t) - { return t->t; } +{ + return t->t; +} template T bound_func1(Thing *t, T a0) - { return t->t | a0; } +{ + return t->t | a0; +} template T bound_func2(Thing *t, T a0, T a1) - { return t->t | a0 | a1; } +{ + return t->t | a0 | a1; +} template T bound_func3(Thing *t, T a0, T a1, T a2) - { return t->t | a0 | a1 | a2; } +{ + return t->t | a0 | a1 | a2; +} template T bound_func4(Thing *t, T a0, T a1, T a2, T a3) - { return t->t | a0 | a1 | a2 | a3; } +{ + return t->t | a0 | a1 | a2 | a3; +} template T bound_func5(Thing *t, T a0, T a1, T a2, T a3, T a4) - { return t->t | a0 | a1 | a2 | a3 | a4; } +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} template T const_bound_func0(const Thing *t) - { return t->t; } +{ + return t->t; +} template T const_bound_func1(const Thing *t, T a0) - { return t->t | a0; } +{ + return t->t | a0; +} template T const_bound_func2(const Thing *t, T a0, T a1) - { return t->t | a0 | a1; } +{ + return t->t | a0 | a1; +} template T const_bound_func3(const Thing *t, T a0, T a1, T a2) - { return t->t | a0 | a1 | a2; } +{ + return t->t | a0 | a1 | a2; +} template T const_bound_func4(const Thing *t, T a0, T a1, T a2, T a3) - { return t->t | a0 | a1 | a2 | a3; } +{ + return t->t | a0 | a1 | a2 | a3; +} template T const_bound_func5(const Thing *t, T a0, T a1, T a2, T a3, T a4) - { return t->t | a0 | a1 | a2 | a3 | a4; } +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} template T volatile_bound_func0(volatile Thing *t) - { return t->t; } +{ + return t->t; +} template T volatile_bound_func1(volatile Thing *t, T a0) - { return t->t | a0; } +{ + return t->t | a0; +} template T volatile_bound_func2(volatile Thing *t, T a0, T a1) - { return t->t | a0 | a1; } +{ + return t->t | a0 | a1; +} template T volatile_bound_func3(volatile Thing *t, T a0, T a1, T a2) - { return t->t | a0 | a1 | a2; } +{ + return t->t | a0 | a1 | a2; +} template T volatile_bound_func4(volatile Thing *t, T a0, T a1, T a2, T a3) - { return t->t | a0 | a1 | a2 | a3; } +{ + return t->t | a0 | a1 | a2 | a3; +} template T volatile_bound_func5(volatile Thing *t, T a0, T a1, T a2, T a3, T a4) - { return t->t | a0 | a1 | a2 | a3 | a4; } +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} template T const_volatile_bound_func0(const volatile Thing *t) - { return t->t; } +{ + return t->t; +} template T const_volatile_bound_func1(const volatile Thing *t, T a0) - { return t->t | a0; } +{ + return t->t | a0; +} template T const_volatile_bound_func2(const volatile Thing *t, T a0, T a1) - { return t->t | a0 | a1; } +{ + return t->t | a0 | a1; +} template T const_volatile_bound_func3(const volatile Thing *t, T a0, T a1, T a2) - { return t->t | a0 | a1 | a2; } +{ + return t->t | a0 | a1 | a2; +} template T const_volatile_bound_func4(const volatile Thing *t, T a0, T a1, T a2, T a3) - { return t->t | a0 | a1 | a2 | a3; } +{ + return t->t | a0 | a1 | a2 | a3; +} template T const_volatile_bound_func5(const volatile Thing *t, T a0, T a1, T a2, T a3, T a4) - { return t->t | a0 | a1 | a2 | a3 | a4; } +{ + return t->t | a0 | a1 | a2 | a3 | a4; +} // void functions template T void_func0(void *t) - { return static_cast*>(t)->t; } +{ + return static_cast*>(t)->t; +} template T void_func1(void *t, T a0) - { return static_cast*>(t)->t | a0; } +{ + return static_cast*>(t)->t | a0; +} template T void_func2(void *t, T a0, T a1) - { return static_cast*>(t)->t | a0 | a1; } +{ + return static_cast*>(t)->t | a0 | a1; +} template T void_func3(void *t, T a0, T a1, T a2) - { return static_cast*>(t)->t | a0 | a1 | a2; } +{ + return static_cast*>(t)->t | a0 | a1 | a2; +} template T void_func4(void *t, T a0, T a1, T a2, T a3) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3; +} template T void_func5(void *t, T a0, T a1, T a2, T a3, T a4) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; +} template T const_void_func0(const void *t) - { return static_cast*>(t)->t; } +{ + return static_cast*>(t)->t; +} template T const_void_func1(const void *t, T a0) - { return static_cast*>(t)->t | a0; } +{ + return static_cast*>(t)->t | a0; +} template T const_void_func2(const void *t, T a0, T a1) - { return static_cast*>(t)->t | a0 | a1; } +{ + return static_cast*>(t)->t | a0 | a1; +} template T const_void_func3(const void *t, T a0, T a1, T a2) - { return static_cast*>(t)->t | a0 | a1 | a2; } +{ + return static_cast*>(t)->t | a0 | a1 | a2; +} template T const_void_func4(const void *t, T a0, T a1, T a2, T a3) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3; +} template T const_void_func5(const void *t, T a0, T a1, T a2, T a3, T a4) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; +} template T volatile_void_func0(volatile void *t) - { return static_cast*>(t)->t; } +{ + return static_cast*>(t)->t; +} template T volatile_void_func1(volatile void *t, T a0) - { return static_cast*>(t)->t | a0; } +{ + return static_cast*>(t)->t | a0; +} template T volatile_void_func2(volatile void *t, T a0, T a1) - { return static_cast*>(t)->t | a0 | a1; } +{ + return static_cast*>(t)->t | a0 | a1; +} template T volatile_void_func3(volatile void *t, T a0, T a1, T a2) - { return static_cast*>(t)->t | a0 | a1 | a2; } +{ + return static_cast*>(t)->t | a0 | a1 | a2; +} template T volatile_void_func4(volatile void *t, T a0, T a1, T a2, T a3) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3; +} template T volatile_void_func5(volatile void *t, T a0, T a1, T a2, T a3, T a4) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; +} template T const_volatile_void_func0(const volatile void *t) - { return static_cast*>(t)->t; } +{ + return static_cast*>(t)->t; +} template T const_volatile_void_func1(const volatile void *t, T a0) - { return static_cast*>(t)->t | a0; } +{ + return static_cast*>(t)->t | a0; +} template T const_volatile_void_func2(const volatile void *t, T a0, T a1) - { return static_cast*>(t)->t | a0 | a1; } +{ + return static_cast*>(t)->t | a0 | a1; +} template T const_volatile_void_func3(const volatile void *t, T a0, T a1, T a2) - { return static_cast*>(t)->t | a0 | a1 | a2; } +{ + return static_cast*>(t)->t | a0 | a1 | a2; +} template T const_volatile_void_func4(const volatile void *t, T a0, T a1, T a2, T a3) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3; +} template T const_volatile_void_func5(const volatile void *t, T a0, T a1, T a2, T a3, T a4) - { return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; } +{ + return static_cast*>(t)->t | a0 | a1 | a2 | a3 | a4; +} // function call and result verification template struct Verifier { - static void verify0(Callback func) { + static void verify0(Callback func) + { T result = func(); TEST_ASSERT_EQUAL(result, 0x00); } template - static void verify0(O *obj, M method) { + static void verify0(O *obj, M method) + { Callback func(obj, method); T result = func(); TEST_ASSERT_EQUAL(result, 0x80); } - static void verify1(Callback func) { + static void verify1(Callback func) + { T result = func((1 << 0)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0)); } template - static void verify1(O *obj, M method) { + static void verify1(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0)); } - static void verify2(Callback func) { + static void verify2(Callback func) + { T result = func((1 << 0), (1 << 1)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1)); } template - static void verify2(O *obj, M method) { + static void verify2(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1)); } - static void verify3(Callback func) { + static void verify3(Callback func) + { T result = func((1 << 0), (1 << 1), (1 << 2)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2)); } template - static void verify3(O *obj, M method) { + static void verify3(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1), (1 << 2)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2)); } - static void verify4(Callback func) { + static void verify4(Callback func) + { T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); } template - static void verify4(O *obj, M method) { + static void verify4(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)); } - static void verify5(Callback func) { + static void verify5(Callback func) + { T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); } template - static void verify5(O *obj, M method) { + static void verify5(O *obj, M method) + { Callback func(obj, method); T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4)); TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); @@ -328,24 +496,27 @@ struct Verifier { // test dispatch template -void test_fparg1() { +void test_fparg1() +{ Thing thing; - FunctionPointerArg1 fp(static_func1); + FunctionPointerArg1 fp(static_func1); Verifier::verify1(fp); Verifier::verify1(fp.get_function()); } template -void test_fparg0() { +void test_fparg0() +{ Thing thing; - FunctionPointerArg1 fp(static_func0); + FunctionPointerArg1 fp(static_func0); Verifier::verify0(fp); Verifier::verify0(fp.get_function()); } // Test setup -utest::v1::status_t test_setup(const size_t number_of_cases) { +utest::v1::status_t test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(10, "default_auto"); return verbose_test_setup_handler(number_of_cases); } @@ -357,6 +528,7 @@ Case cases[] = { Specification specification(test_setup, cases); -int main() { +int main() +{ return !Harness::run(specification); } diff --git a/TESTS/mbed_hal/common_tickers/main.cpp b/TESTS/mbed_hal/common_tickers/main.cpp index 093e1220539..4b32d905aab 100644 --- a/TESTS/mbed_hal/common_tickers/main.cpp +++ b/TESTS/mbed_hal/common_tickers/main.cpp @@ -59,7 +59,7 @@ extern "C" { using namespace utest::v1; volatile int intFlag = 0; -const ticker_interface_t* intf; +const ticker_interface_t *intf; ticker_irq_handler_type prev_irq_handler; /* Some targets might fail overflow test uncertainly due to getting trapped in busy * intf->read() loop. In the loop, some ticker values wouldn't get caught in time @@ -67,7 +67,7 @@ ticker_irq_handler_type prev_irq_handler; * 1. Lower CPU clock * 2. Compiled code with worse performance * 3. Interrupt at that time - * + * * We fix it by checking small ticker value range rather than one exact ticker point * in near overflow check. */ @@ -81,7 +81,7 @@ uint32_t count_ticks(uint32_t cycles, uint32_t step) { register uint32_t reg_cycles = cycles; - const ticker_info_t* p_ticker_info = intf->get_info(); + const ticker_info_t *p_ticker_info = intf->get_info(); const uint32_t max_count = ((1 << p_ticker_info->bits) - 1); core_util_critical_section_enter(); @@ -120,7 +120,7 @@ void overflow_protect() } const uint32_t ticks_now = intf->read(); - const ticker_info_t* p_ticker_info = intf->get_info(); + const ticker_info_t *p_ticker_info = intf->get_info(); const uint32_t max_count = ((1 << p_ticker_info->bits) - 1); @@ -131,7 +131,7 @@ void overflow_protect() while (intf->read() > ticks_now); } -void ticker_event_handler_stub(const ticker_data_t * const ticker) +void ticker_event_handler_stub(const ticker_data_t *const ticker) { if (ticker == get_us_ticker_data()) { us_ticker_clear_interrupt(); @@ -156,13 +156,13 @@ void wait_cycles(volatile unsigned int cycles) * This function returns number of us between and * taking into account counter roll-over, counter size and frequency. */ -uint32_t diff_us(uint32_t start_ticks, uint32_t stop_ticks, const ticker_info_t * info) +uint32_t diff_us(uint32_t start_ticks, uint32_t stop_ticks, const ticker_info_t *info) { uint32_t counter_mask = ((1 << info->bits) - 1); uint32_t diff_ticks = ((stop_ticks - start_ticks) & counter_mask); - return (uint32_t) ((uint64_t) diff_ticks * US_PER_S / info->frequency); + return (uint32_t)((uint64_t) diff_ticks * US_PER_S / info->frequency); } /* Test that ticker_init can be called multiple times and @@ -201,7 +201,7 @@ void ticker_init_test() /* Test that ticker frequency is non-zero and counter is at least 8 bits */ void ticker_info_test(void) { - const ticker_info_t* p_ticker_info = intf->get_info(); + const ticker_info_t *p_ticker_info = intf->get_info(); TEST_ASSERT(p_ticker_info->frequency != 0); TEST_ASSERT(p_ticker_info->bits >= 8); @@ -313,7 +313,7 @@ void ticker_fire_now_test(void) /* Test that the ticker correctly handles overflow. */ void ticker_overflow_test(void) { - const ticker_info_t* p_ticker_info = intf->get_info(); + const ticker_info_t *p_ticker_info = intf->get_info(); /* We need to check how long it will take to overflow. * We will perform this test only if this time is no longer than 30 sec. @@ -331,7 +331,7 @@ void ticker_overflow_test(void) /* Wait for max count. */ while (intf->read() >= (max_count - ticker_overflow_delta2) && - intf->read() <= (max_count - ticker_overflow_delta1)) { + intf->read() <= (max_count - ticker_overflow_delta1)) { /* Just wait. */ } @@ -368,7 +368,7 @@ void ticker_overflow_test(void) /* Test that the ticker increments by one on each tick. */ void ticker_increment_test(void) { - const ticker_info_t* p_ticker_info = intf->get_info(); + const ticker_info_t *p_ticker_info = intf->get_info(); /* Perform test based on ticker speed. */ if (p_ticker_info->frequency <= 250000) { // low frequency tickers @@ -408,7 +408,7 @@ void ticker_increment_test(void) } else { /* Check if we got 1 tick diff. */ if (next_tick_count - base_tick_count == 1 || - base_tick_count - next_tick_count == 1) { + base_tick_count - next_tick_count == 1) { break; } @@ -439,13 +439,13 @@ void ticker_speed_test(void) uint32_t start; uint32_t stop; - const ticker_info_t * us_ticker_info = get_us_ticker_data()->interface->get_info(); + const ticker_info_t *us_ticker_info = get_us_ticker_data()->interface->get_info(); /* Free function will disable the ticker. For time measurement * we need to use other one if available. */ #if DEVICE_LPTICKER - const ticker_info_t * lp_ticker_info = get_lp_ticker_data()->interface->get_info(); + const ticker_info_t *lp_ticker_info = get_lp_ticker_data()->interface->get_info(); bool us_ticker_test = (intf == get_us_ticker_data()->interface); #endif @@ -522,7 +522,7 @@ void ticker_free_interrupt_test(void) uint32_t cycles_500_ticks = 50; uint32_t reference_ticks_count = 0; - while(reference_ticks_count < TICKER_500_TICKS) { + while (reference_ticks_count < TICKER_500_TICKS) { cycles_500_ticks *= 2; const uint32_t start = intf->read(); wait_cycles(cycles_500_ticks); @@ -579,8 +579,8 @@ utest::v1::status_t us_ticker_setup(const Case *const source, const size_t index return greentea_case_setup_handler(source, index_of_case); } -utest::v1::status_t us_ticker_teardown(const Case * const source, const size_t passed, const size_t failed, - const failure_t reason) +utest::v1::status_t us_ticker_teardown(const Case *const source, const size_t passed, const size_t failed, + const failure_t reason) { set_us_ticker_irq_handler(prev_irq_handler); @@ -608,8 +608,8 @@ utest::v1::status_t lp_ticker_setup(const Case *const source, const size_t index return greentea_case_setup_handler(source, index_of_case); } -utest::v1::status_t lp_ticker_teardown(const Case * const source, const size_t passed, const size_t failed, - const failure_t reason) +utest::v1::status_t lp_ticker_teardown(const Case *const source, const size_t passed, const size_t failed, + const failure_t reason) { set_lp_ticker_irq_handler(prev_irq_handler); diff --git a/TESTS/mbed_hal/common_tickers_freq/main.cpp b/TESTS/mbed_hal/common_tickers_freq/main.cpp index c9952f11616..c34527b2184 100644 --- a/TESTS/mbed_hal/common_tickers_freq/main.cpp +++ b/TESTS/mbed_hal/common_tickers_freq/main.cpp @@ -37,7 +37,7 @@ using namespace utest::v1; -const ticker_interface_t* intf; +const ticker_interface_t *intf; static volatile unsigned int overflowCounter; @@ -46,7 +46,7 @@ uint32_t ticks_to_us(uint32_t ticks, uint32_t freq) return (uint32_t)((uint64_t)ticks * US_PER_S / freq); } -void ticker_event_handler_stub(const ticker_data_t * const ticker) +void ticker_event_handler_stub(const ticker_data_t *const ticker) { if (ticker == get_us_ticker_data()) { us_ticker_clear_interrupt(); @@ -99,12 +99,12 @@ void ticker_frequency_test() /* Get the results from host. */ greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); - TEST_ASSERT_EQUAL_STRING_MESSAGE("pass", _key,"Host side script reported a fail..."); + TEST_ASSERT_EQUAL_STRING_MESSAGE("pass", _key, "Host side script reported a fail..."); intf->disable_interrupt(); } -utest::v1::status_t us_ticker_case_setup_handler_t(const Case * const source, const size_t index_of_case) +utest::v1::status_t us_ticker_case_setup_handler_t(const Case *const source, const size_t index_of_case) { intf = get_us_ticker_data()->interface; set_us_ticker_irq_handler(ticker_event_handler_stub); @@ -112,7 +112,7 @@ utest::v1::status_t us_ticker_case_setup_handler_t(const Case * const source, co } #if DEVICE_LPTICKER -utest::v1::status_t lp_ticker_case_setup_handler_t(const Case * const source, const size_t index_of_case) +utest::v1::status_t lp_ticker_case_setup_handler_t(const Case *const source, const size_t index_of_case) { intf = get_lp_ticker_data()->interface; set_lp_ticker_irq_handler(ticker_event_handler_stub); @@ -120,8 +120,8 @@ utest::v1::status_t lp_ticker_case_setup_handler_t(const Case * const source, co } #endif -utest::v1::status_t ticker_case_teardown_handler_t(const Case * const source, const size_t passed, const size_t failed, - const failure_t reason) +utest::v1::status_t ticker_case_teardown_handler_t(const Case *const source, const size_t passed, const size_t failed, + const failure_t reason) { return greentea_case_teardown_handler(source, passed, failed, reason); } @@ -129,12 +129,12 @@ utest::v1::status_t ticker_case_teardown_handler_t(const Case * const source, co // Test cases Case cases[] = { Case("Microsecond ticker frequency test", us_ticker_case_setup_handler_t, ticker_frequency_test, - ticker_case_teardown_handler_t), + ticker_case_teardown_handler_t), #if DEVICE_LPTICKER Case("Low power ticker frequency test", lp_ticker_case_setup_handler_t, ticker_frequency_test, - ticker_case_teardown_handler_t), + ticker_case_teardown_handler_t), #endif - }; +}; utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { diff --git a/TESTS/mbed_hal/crc/main.cpp b/TESTS/mbed_hal/crc/main.cpp index 27f32341600..51ecdcc962f 100644 --- a/TESTS/mbed_hal/crc/main.cpp +++ b/TESTS/mbed_hal/crc/main.cpp @@ -35,8 +35,7 @@ using namespace utest::v1; const uint8_t input_data[] = "123456789"; -typedef struct -{ +typedef struct { const crc_mbed_config config_data; uint32_t expected_result; @@ -72,7 +71,7 @@ void crc_calc_single_test() if (hal_crc_is_supported(&test_cases[i].config_data) == true) { hal_crc_compute_partial_start(&test_cases[i].config_data); - hal_crc_compute_partial((uint8_t*) input_data, strlen((const char*) input_data)); + hal_crc_compute_partial((uint8_t *) input_data, strlen((const char *) input_data)); const uint32_t crc = hal_crc_get_result(); TEST_ASSERT_EQUAL(test_cases[i].expected_result, crc); @@ -89,14 +88,14 @@ void crc_calc_multi_test() const uint32_t first_part_bytes = 3; const uint32_t second_part_bytes = 1; - const uint32_t third_part_bytes = strlen((const char*) input_data) - first_part_bytes - - second_part_bytes; + const uint32_t third_part_bytes = strlen((const char *) input_data) - first_part_bytes + - second_part_bytes; hal_crc_compute_partial_start(&test_cases[i].config_data); - hal_crc_compute_partial((uint8_t*) input_data, first_part_bytes); - hal_crc_compute_partial((uint8_t*) (input_data + first_part_bytes), second_part_bytes); - hal_crc_compute_partial((uint8_t*) (input_data + first_part_bytes + second_part_bytes), - third_part_bytes); + hal_crc_compute_partial((uint8_t *) input_data, first_part_bytes); + hal_crc_compute_partial((uint8_t *)(input_data + first_part_bytes), second_part_bytes); + hal_crc_compute_partial((uint8_t *)(input_data + first_part_bytes + second_part_bytes), + third_part_bytes); const uint32_t crc = hal_crc_get_result(); TEST_ASSERT_EQUAL(test_cases[i].expected_result, crc); @@ -137,7 +136,7 @@ void crc_reconfigure_test() /* Init CRC module and provide some data, but do not read the result. */ hal_crc_compute_partial_start(&test_cases[pol_idx[pol_cnt]].config_data); - hal_crc_compute_partial((uint8_t*) dummy_input_data, strlen((const char*) dummy_input_data)); + hal_crc_compute_partial((uint8_t *) dummy_input_data, strlen((const char *) dummy_input_data)); /* Change index only if more than one supported polynomial has been found. */ if (pol_idx[POL_CNT - 1] != UNSUPPORTED) { @@ -146,7 +145,7 @@ void crc_reconfigure_test() /* Now re-init CRC module and provide new data and check the result. */ hal_crc_compute_partial_start(&test_cases[pol_idx[pol_cnt]].config_data); - hal_crc_compute_partial((uint8_t*) input_data, strlen((const char*) input_data)); + hal_crc_compute_partial((uint8_t *) input_data, strlen((const char *) input_data)); const uint32_t crc = hal_crc_get_result(); TEST_ASSERT_EQUAL(test_cases[pol_idx[pol_cnt]].expected_result, crc); @@ -165,12 +164,12 @@ void crc_compute_partial_invalid_param_test() hal_crc_compute_partial_start(&test_cases[i].config_data); /* Call hal_crc_compute_partial() with invalid parameters. */ - hal_crc_compute_partial((uint8_t*) NULL, strlen((const char*) input_data)); - hal_crc_compute_partial((uint8_t*) input_data, 0); + hal_crc_compute_partial((uint8_t *) NULL, strlen((const char *) input_data)); + hal_crc_compute_partial((uint8_t *) input_data, 0); /* Now use valid parameters. */ - hal_crc_compute_partial((uint8_t*) input_data, - strlen((const char*) input_data)); + hal_crc_compute_partial((uint8_t *) input_data, + strlen((const char *) input_data)); crc = hal_crc_get_result(); @@ -208,70 +207,70 @@ int main() { TEST_CASE local_test_cases[] = { /* Predefined polynomials. */ -/* 00 */{ {POLY_7BIT_SD , 7, 0x00000000, 0x00000000, false, false}, 0xEA }, -/* 01 */{ {POLY_7BIT_SD , 7, 0x0000007F, 0x00000000, false, false}, 0xA0 }, -/* 02 */{ {POLY_7BIT_SD , 7, 0x0000002B, 0x00000000, false, false}, 0x74 }, -/* 03 */{ {POLY_7BIT_SD , 7, 0x00000000, 0x0000007F, false, false}, 0x95 }, -/* 04 */{ {POLY_7BIT_SD , 7, 0x00000000, 0x0000002B, false, false}, 0xC1 }, -/* 05 */{ {POLY_7BIT_SD , 7, 0x00000000, 0x00000000, true , false}, 0xA4 }, -/* 06 */{ {POLY_7BIT_SD , 7, 0x00000000, 0x00000000, false, true }, 0x57 }, - -/* 07 */{ {POLY_8BIT_CCITT , 8, 0x00000000, 0x00000000, false, false}, 0xF4 }, -/* 08 */{ {POLY_8BIT_CCITT , 8, 0x000000FF, 0x00000000, false, false}, 0xFB }, -/* 09 */{ {POLY_8BIT_CCITT , 8, 0x000000AB, 0x00000000, false, false}, 0x87 }, -/* 10 */{ {POLY_8BIT_CCITT , 8, 0x00000000, 0x000000FF, false, false}, 0x0B }, -/* 11 */{ {POLY_8BIT_CCITT , 8, 0x00000000, 0x000000AB, false, false}, 0x5F }, -/* 12 */{ {POLY_8BIT_CCITT , 8, 0x00000000, 0x00000000, true , false}, 0x04 }, -/* 13 */{ {POLY_8BIT_CCITT , 8, 0x00000000, 0x00000000, false, true }, 0x2F }, - -/* 14 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x00000000, false, false}, 0x31C3 }, -/* 15 */{ {POLY_16BIT_CCITT , 16, 0x0000FFFF, 0x00000000, false, false}, 0x29B1 }, -/* 16 */{ {POLY_16BIT_CCITT , 16, 0x0000ABAB, 0x00000000, false, false}, 0x7D70 }, -/* 17 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x0000FFFF, false, false}, 0xCE3C }, -/* 18 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x0000ABAB, false, false}, 0x9A68 }, -/* 19 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x00000000, true , false}, 0x9184 }, -/* 20 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x00000000, false, true }, 0xC38C }, - -/* 21 */{ {POLY_16BIT_IBM , 16, 0x00000000, 0x00000000, false, false}, 0xFEE8 }, -/* 22 */{ {POLY_16BIT_IBM , 16, 0x0000FFFF, 0x00000000, false, false}, 0xAEE7 }, -/* 23 */{ {POLY_16BIT_IBM , 16, 0x0000ABAB, 0x00000000, false, false}, 0x0887 }, -/* 24 */{ {POLY_16BIT_IBM , 16, 0x00000000, 0x0000FFFF, false, false}, 0x0117 }, -/* 25 */{ {POLY_16BIT_IBM , 16, 0x00000000, 0x0000ABAB, false, false}, 0x5543 }, -/* 26 */{ {POLY_16BIT_IBM , 16, 0x00000000, 0x00000000, true , false}, 0xBCDD }, -/* 27 */{ {POLY_16BIT_IBM , 16, 0x00000000, 0x00000000, false, true }, 0x177F }, - -/* 28 */{ {POLY_32BIT_ANSI , 32, 0x00000000, 0x00000000, false, false}, 0x89A1897F }, -/* 29 */{ {POLY_32BIT_ANSI , 32, 0xFFFFFFFF, 0x00000000, false, false}, 0x0376E6E7 }, -/* 30 */{ {POLY_32BIT_ANSI , 32, 0xABABABAB, 0x00000000, false, false}, 0x871A2FAA }, -/* 31 */{ {POLY_32BIT_ANSI , 32, 0x00000000, 0xFFFFFFFF, false, false}, 0x765E7680 }, -/* 32 */{ {POLY_32BIT_ANSI , 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4 }, -/* 33 */{ {POLY_32BIT_ANSI , 32, 0x00000000, 0x00000000, true , false}, 0x11B4BFB4 }, -/* 34 */{ {POLY_32BIT_ANSI , 32, 0x00000000, 0x00000000, false, true }, 0xFE918591 }, + /* 00 */{ {POLY_7BIT_SD, 7, 0x00000000, 0x00000000, false, false}, 0xEA }, + /* 01 */{ {POLY_7BIT_SD, 7, 0x0000007F, 0x00000000, false, false}, 0xA0 }, + /* 02 */{ {POLY_7BIT_SD, 7, 0x0000002B, 0x00000000, false, false}, 0x74 }, + /* 03 */{ {POLY_7BIT_SD, 7, 0x00000000, 0x0000007F, false, false}, 0x95 }, + /* 04 */{ {POLY_7BIT_SD, 7, 0x00000000, 0x0000002B, false, false}, 0xC1 }, + /* 05 */{ {POLY_7BIT_SD, 7, 0x00000000, 0x00000000, true, false}, 0xA4 }, + /* 06 */{ {POLY_7BIT_SD, 7, 0x00000000, 0x00000000, false, true }, 0x57 }, + + /* 07 */{ {POLY_8BIT_CCITT, 8, 0x00000000, 0x00000000, false, false}, 0xF4 }, + /* 08 */{ {POLY_8BIT_CCITT, 8, 0x000000FF, 0x00000000, false, false}, 0xFB }, + /* 09 */{ {POLY_8BIT_CCITT, 8, 0x000000AB, 0x00000000, false, false}, 0x87 }, + /* 10 */{ {POLY_8BIT_CCITT, 8, 0x00000000, 0x000000FF, false, false}, 0x0B }, + /* 11 */{ {POLY_8BIT_CCITT, 8, 0x00000000, 0x000000AB, false, false}, 0x5F }, + /* 12 */{ {POLY_8BIT_CCITT, 8, 0x00000000, 0x00000000, true, false}, 0x04 }, + /* 13 */{ {POLY_8BIT_CCITT, 8, 0x00000000, 0x00000000, false, true }, 0x2F }, + + /* 14 */{ {POLY_16BIT_CCITT, 16, 0x00000000, 0x00000000, false, false}, 0x31C3 }, + /* 15 */{ {POLY_16BIT_CCITT, 16, 0x0000FFFF, 0x00000000, false, false}, 0x29B1 }, + /* 16 */{ {POLY_16BIT_CCITT, 16, 0x0000ABAB, 0x00000000, false, false}, 0x7D70 }, + /* 17 */{ {POLY_16BIT_CCITT, 16, 0x00000000, 0x0000FFFF, false, false}, 0xCE3C }, + /* 18 */{ {POLY_16BIT_CCITT, 16, 0x00000000, 0x0000ABAB, false, false}, 0x9A68 }, + /* 19 */{ {POLY_16BIT_CCITT, 16, 0x00000000, 0x00000000, true, false}, 0x9184 }, + /* 20 */{ {POLY_16BIT_CCITT, 16, 0x00000000, 0x00000000, false, true }, 0xC38C }, + + /* 21 */{ {POLY_16BIT_IBM, 16, 0x00000000, 0x00000000, false, false}, 0xFEE8 }, + /* 22 */{ {POLY_16BIT_IBM, 16, 0x0000FFFF, 0x00000000, false, false}, 0xAEE7 }, + /* 23 */{ {POLY_16BIT_IBM, 16, 0x0000ABAB, 0x00000000, false, false}, 0x0887 }, + /* 24 */{ {POLY_16BIT_IBM, 16, 0x00000000, 0x0000FFFF, false, false}, 0x0117 }, + /* 25 */{ {POLY_16BIT_IBM, 16, 0x00000000, 0x0000ABAB, false, false}, 0x5543 }, + /* 26 */{ {POLY_16BIT_IBM, 16, 0x00000000, 0x00000000, true, false}, 0xBCDD }, + /* 27 */{ {POLY_16BIT_IBM, 16, 0x00000000, 0x00000000, false, true }, 0x177F }, + + /* 28 */{ {POLY_32BIT_ANSI, 32, 0x00000000, 0x00000000, false, false}, 0x89A1897F }, + /* 29 */{ {POLY_32BIT_ANSI, 32, 0xFFFFFFFF, 0x00000000, false, false}, 0x0376E6E7 }, + /* 30 */{ {POLY_32BIT_ANSI, 32, 0xABABABAB, 0x00000000, false, false}, 0x871A2FAA }, + /* 31 */{ {POLY_32BIT_ANSI, 32, 0x00000000, 0xFFFFFFFF, false, false}, 0x765E7680 }, + /* 32 */{ {POLY_32BIT_ANSI, 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4 }, + /* 33 */{ {POLY_32BIT_ANSI, 32, 0x00000000, 0x00000000, true, false}, 0x11B4BFB4 }, + /* 34 */{ {POLY_32BIT_ANSI, 32, 0x00000000, 0x00000000, false, true }, 0xFE918591 }, /* Not-predefined polynomials. */ -/* 35 */{ {POLY_8BIT_MAXIM , 8, 0x00000000, 0x00000000, false, false}, 0xA2 }, -/* 36 */{ {POLY_8BIT_MAXIM , 8, 0x000000FF, 0x00000000, false, false}, 0xF7 }, -/* 37 */{ {POLY_8BIT_MAXIM , 8, 0x000000AB, 0x00000000, false, false}, 0x71 }, -/* 38 */{ {POLY_8BIT_MAXIM , 8, 0x00000000, 0x000000FF, false, false}, 0x5D }, -/* 39 */{ {POLY_8BIT_MAXIM , 8, 0x00000000, 0x000000AB, false, false}, 0x09 }, -/* 40 */{ {POLY_8BIT_MAXIM , 8, 0x00000000, 0x00000000, true , false}, 0x85 }, -/* 41 */{ {POLY_8BIT_MAXIM , 8, 0x00000000, 0x00000000, false, true }, 0x45 }, - -/* 42 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x00000000, false, false}, 0xFEE8 }, -/* 43 */{ {POLY_16BIT_MAXIM , 16, 0x0000FFFF, 0x00000000, false, false}, 0xAEE7 }, -/* 44 */{ {POLY_16BIT_MAXIM , 16, 0x0000ABAB, 0x00000000, false, false}, 0x0887 }, -/* 45 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x0000FFFF, false, false}, 0x0117 }, -/* 46 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x0000ABAB, false, false}, 0x5543 }, -/* 47 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x00000000, true , false}, 0xBCDD }, -/* 48 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x00000000, false, true }, 0x177F }, - -/* 49 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0x00000000, false, false}, 0x89A1897F }, -/* 50 */{ {POLY_32BIT_POSIX , 32, 0xFFFFFFFF, 0x00000000, false, false}, 0x0376E6E7 }, -/* 51 */{ {POLY_32BIT_POSIX , 32, 0xABABABAB, 0x00000000, false, false}, 0x871A2FAA }, -/* 52 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0xFFFFFFFF, false, false}, 0x765E7680 }, -/* 53 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4 }, -/* 54 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0x00000000, true , false}, 0x11B4BFB4 }, -/* 55 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0x00000000, false, true }, 0xFE918591 }, + /* 35 */{ {POLY_8BIT_MAXIM, 8, 0x00000000, 0x00000000, false, false}, 0xA2 }, + /* 36 */{ {POLY_8BIT_MAXIM, 8, 0x000000FF, 0x00000000, false, false}, 0xF7 }, + /* 37 */{ {POLY_8BIT_MAXIM, 8, 0x000000AB, 0x00000000, false, false}, 0x71 }, + /* 38 */{ {POLY_8BIT_MAXIM, 8, 0x00000000, 0x000000FF, false, false}, 0x5D }, + /* 39 */{ {POLY_8BIT_MAXIM, 8, 0x00000000, 0x000000AB, false, false}, 0x09 }, + /* 40 */{ {POLY_8BIT_MAXIM, 8, 0x00000000, 0x00000000, true, false}, 0x85 }, + /* 41 */{ {POLY_8BIT_MAXIM, 8, 0x00000000, 0x00000000, false, true }, 0x45 }, + + /* 42 */{ {POLY_16BIT_MAXIM, 16, 0x00000000, 0x00000000, false, false}, 0xFEE8 }, + /* 43 */{ {POLY_16BIT_MAXIM, 16, 0x0000FFFF, 0x00000000, false, false}, 0xAEE7 }, + /* 44 */{ {POLY_16BIT_MAXIM, 16, 0x0000ABAB, 0x00000000, false, false}, 0x0887 }, + /* 45 */{ {POLY_16BIT_MAXIM, 16, 0x00000000, 0x0000FFFF, false, false}, 0x0117 }, + /* 46 */{ {POLY_16BIT_MAXIM, 16, 0x00000000, 0x0000ABAB, false, false}, 0x5543 }, + /* 47 */{ {POLY_16BIT_MAXIM, 16, 0x00000000, 0x00000000, true, false}, 0xBCDD }, + /* 48 */{ {POLY_16BIT_MAXIM, 16, 0x00000000, 0x00000000, false, true }, 0x177F }, + + /* 49 */{ {POLY_32BIT_POSIX, 32, 0x00000000, 0x00000000, false, false}, 0x89A1897F }, + /* 50 */{ {POLY_32BIT_POSIX, 32, 0xFFFFFFFF, 0x00000000, false, false}, 0x0376E6E7 }, + /* 51 */{ {POLY_32BIT_POSIX, 32, 0xABABABAB, 0x00000000, false, false}, 0x871A2FAA }, + /* 52 */{ {POLY_32BIT_POSIX, 32, 0x00000000, 0xFFFFFFFF, false, false}, 0x765E7680 }, + /* 53 */{ {POLY_32BIT_POSIX, 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4 }, + /* 54 */{ {POLY_32BIT_POSIX, 32, 0x00000000, 0x00000000, true, false}, 0x11B4BFB4 }, + /* 55 */{ {POLY_32BIT_POSIX, 32, 0x00000000, 0x00000000, false, true }, 0xFE918591 }, }; test_cases = local_test_cases; diff --git a/TESTS/mbed_hal/critical_section/main.cpp b/TESTS/mbed_hal/critical_section/main.cpp index e8dc26daee2..c3ae160e335 100644 --- a/TESTS/mbed_hal/critical_section/main.cpp +++ b/TESTS/mbed_hal/critical_section/main.cpp @@ -31,11 +31,11 @@ bool test_are_interrupts_enabled(void) // NRF5x targets don't disable interrupts when in critical section, instead they mask application interrupts this is due to BLE stack // (BLE to be operational requires some interrupts to be always enabled) #if defined(TARGET_NRF52) - // check if APP interrupts are masked for NRF52 boards - return (((NVIC->ISER[0] & __NRF_NVIC_APP_IRQS_0) != 0) || ((NVIC->ISER[1] & __NRF_NVIC_APP_IRQS_1) != 0)); + // check if APP interrupts are masked for NRF52 boards + return (((NVIC->ISER[0] & __NRF_NVIC_APP_IRQS_0) != 0) || ((NVIC->ISER[1] & __NRF_NVIC_APP_IRQS_1) != 0)); #elif defined(TARGET_NRF51) - // check if APP interrupts are masked for other NRF51 boards - return ((NVIC->ISER[0] & __NRF_NVIC_APP_IRQS_0) != 0); + // check if APP interrupts are masked for other NRF51 boards + return ((NVIC->ISER[0] & __NRF_NVIC_APP_IRQS_0) != 0); #else #if defined(__CORTEX_A9) return ((__get_CPSR() & 0x80) == 0); diff --git a/TESTS/mbed_hal/flash/functional_tests/main.cpp b/TESTS/mbed_hal/flash/functional_tests/main.cpp index 808ab18e54a..aec1ffea813 100644 --- a/TESTS/mbed_hal/flash/functional_tests/main.cpp +++ b/TESTS/mbed_hal/flash/functional_tests/main.cpp @@ -15,7 +15,7 @@ */ #if !DEVICE_FLASH - #error [NOT_SUPPORTED] Flash API not supported for this target +#error [NOT_SUPPORTED] Flash API not supported for this target #endif #include "utest/utest.h" @@ -57,40 +57,43 @@ static void erase_range(flash_t *flash, uint32_t addr, uint32_t size) MBED_NOINLINE __asm static void delay_loop(uint32_t count) { +// AStyle should not format inline assembly +// *INDENT-OFF* 1 SUBS a1, a1, #1 BCS %BT1 BX lr +// *INDENT-ON* } #elif defined (__ICCARM__) MBED_NOINLINE static void delay_loop(uint32_t count) { - __asm volatile( - "loop: \n" - " SUBS %0, %0, #1 \n" - " BCS.n loop\n" - : "+r" (count) - : - : "cc" - ); + __asm volatile( + "loop: \n" + " SUBS %0, %0, #1 \n" + " BCS.n loop\n" + : "+r"(count) + : + : "cc" + ); } #elif defined ( __GNUC__ ) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) MBED_NOINLINE static void delay_loop(uint32_t count) { - __asm__ volatile ( - "%=:\n\t" + __asm__ volatile( + "%=:\n\t" #if defined(__thumb__) && !defined(__thumb2__) && !defined(__ARMCC_VERSION) - "SUB %0, #1\n\t" + "SUB %0, #1\n\t" #else - "SUBS %0, %0, #1\n\t" + "SUBS %0, %0, #1\n\t" #endif - "BCS %=b\n\t" - : "+l" (count) - : - : "cc" - ); + "BCS %=b\n\t" + : "+l"(count) + : + : "cc" + ); } #endif @@ -193,7 +196,7 @@ void flash_program_page_test() } // the one before the last page in the system - uint32_t address = flash_get_start_address(&test_flash) + flash_get_size(&test_flash) - (2*test_size); + uint32_t address = flash_get_start_address(&test_flash) + flash_get_size(&test_flash) - (2 * test_size); // sector size might not be same as page size uint32_t erase_sector_boundary = ALIGN_DOWN(address, flash_get_sector_size(&test_flash, address)); @@ -246,13 +249,15 @@ Case cases[] = { Case("Flash - clock and cache test", flash_clock_and_cache_test), }; -utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { +utest::v1::status_t greentea_test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(20, "default_auto"); return greentea_test_setup_handler(number_of_cases); } Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); -int main() { +int main() +{ Harness::run(specification); } diff --git a/TESTS/mbed_hal/lp_ticker/main.cpp b/TESTS/mbed_hal/lp_ticker/main.cpp index fa1fea7ffb8..f8cd8f1abf9 100644 --- a/TESTS/mbed_hal/lp_ticker/main.cpp +++ b/TESTS/mbed_hal/lp_ticker/main.cpp @@ -22,7 +22,7 @@ #include "hal/lp_ticker_api.h" #if !DEVICE_LPTICKER - #error [NOT_SUPPORTED] Low power timer not supported for this target +#error [NOT_SUPPORTED] Low power timer not supported for this target #endif using namespace utest::v1; @@ -74,7 +74,7 @@ void overflow_protect() time_window = LP_TICKER_OV_LIMIT; const uint32_t ticks_now = lp_ticker_read(); - const ticker_info_t* p_ticker_info = lp_ticker_get_info(); + const ticker_info_t *p_ticker_info = lp_ticker_get_info(); const uint32_t max_count = ((1 << p_ticker_info->bits) - 1); @@ -85,7 +85,7 @@ void overflow_protect() while (lp_ticker_read() > ticks_now); } -void ticker_event_handler_stub(const ticker_data_t * const ticker) +void ticker_event_handler_stub(const ticker_data_t *const ticker) { /* Indicate that ISR has been executed in interrupt context. */ if (core_util_is_isr_active()) { @@ -100,7 +100,7 @@ void ticker_event_handler_stub(const ticker_data_t * const ticker) /* Test that the ticker has the correct frequency and number of bits. */ void lp_ticker_info_test() { - const ticker_info_t* p_ticker_info = lp_ticker_get_info(); + const ticker_info_t *p_ticker_info = lp_ticker_get_info(); TEST_ASSERT(p_ticker_info->frequency >= 4000); TEST_ASSERT(p_ticker_info->frequency <= 64000); diff --git a/TESTS/mbed_hal/rtc/main.cpp b/TESTS/mbed_hal/rtc/main.cpp index 0aab34531d1..87cc3acf3d1 100644 --- a/TESTS/mbed_hal/rtc/main.cpp +++ b/TESTS/mbed_hal/rtc/main.cpp @@ -15,7 +15,7 @@ */ #if !DEVICE_RTC - #error [NOT_SUPPORTED] RTC API not supported for this target +#error [NOT_SUPPORTED] RTC API not supported for this target #endif #include "utest/utest.h" @@ -37,7 +37,7 @@ static const uint32_t WAIT_TOLERANCE = 1; static const uint32_t DELAY_4S = 4; static const uint32_t DELAY_10S = 10; static const uint32_t RTC_TOLERANCE = 1; -static const uint32_t TOLERANCE_ACCURACY_US = (DELAY_10S * US_PER_SEC / ACCURACY_FACTOR); +static const uint32_t TOLERANCE_ACCURACY_US = (DELAY_10S *US_PER_SEC / ACCURACY_FACTOR); #if DEVICE_LPTICKER volatile bool expired; @@ -49,7 +49,7 @@ void callback(void) /* Auxiliary function to test if RTC continue counting in * sleep and deep-sleep modes. */ -void rtc_sleep_test_support (bool deepsleep_mode) +void rtc_sleep_test_support(bool deepsleep_mode) { LowPowerTimeout timeout; const uint32_t start = 100; @@ -66,7 +66,7 @@ void rtc_sleep_test_support (bool deepsleep_mode) rtc_init(); - if(deepsleep_mode == false) { + if (deepsleep_mode == false) { sleep_manager_lock_deep_sleep(); } @@ -76,7 +76,9 @@ void rtc_sleep_test_support (bool deepsleep_mode) TEST_ASSERT(sleep_manager_can_deep_sleep() == deepsleep_mode); - while(!expired) sleep(); + while (!expired) { + sleep(); + } const uint32_t stop = rtc_read(); @@ -84,7 +86,7 @@ void rtc_sleep_test_support (bool deepsleep_mode) timeout.detach(); - if(deepsleep_mode == false) { + if (deepsleep_mode == false) { sleep_manager_unlock_deep_sleep(); } @@ -155,10 +157,10 @@ void rtc_glitch_test() void rtc_range_test() { static const uint32_t starts[] = { - 0x00000000, - 0xEFFFFFFF, - 0x00001000, - 0x00010000, + 0x00000000, + 0xEFFFFFFF, + 0x00001000, + 0x00010000, }; rtc_init(); @@ -182,7 +184,7 @@ void rtc_accuracy_test() rtc_write(start); timer1.start(); - while(rtc_read() < (start + DELAY_10S)) { + while (rtc_read() < (start + DELAY_10S)) { /* Just wait. */ } timer1.stop(); diff --git a/TESTS/mbed_hal/rtc_reset/main.cpp b/TESTS/mbed_hal/rtc_reset/main.cpp index f07b194e9d6..de9fdf85c6a 100644 --- a/TESTS/mbed_hal/rtc_reset/main.cpp +++ b/TESTS/mbed_hal/rtc_reset/main.cpp @@ -15,7 +15,7 @@ */ #if !DEVICE_RTC - #error [NOT_SUPPORTED] RTC API not supported for this target +#error [NOT_SUPPORTED] RTC API not supported for this target #endif #include "utest/utest.h" diff --git a/TESTS/mbed_hal/rtc_time/main.cpp b/TESTS/mbed_hal/rtc_time/main.cpp index c101e19b625..fe063296772 100644 --- a/TESTS/mbed_hal/rtc_time/main.cpp +++ b/TESTS/mbed_hal/rtc_time/main.cpp @@ -73,8 +73,7 @@ void test_is_leap_year() } /* Structure to test border values for _rtc_maketime(). */ -typedef struct -{ +typedef struct { struct tm timeinfo; time_t exp_seconds; // if result is false then exp_seconds is irrelevant bool result; @@ -85,7 +84,7 @@ typedef struct * Expected range: the 1st of January 1970 at 00:00:00 (seconds: 0) to the 7th of February 2106 at 06:28:15 (seconds: UINT_MAX). */ test_mk_time_struct test_mk_time_arr_full[] = { - {{ 0, 0, 0, 1, 0, 70, 0, 0, 0 }, (time_t) 0, true}, // valid lower bound - the 1st of January 1970 at 00:00:00 + {{ 0, 0, 0, 1, 0, 70, 0, 0, 0 }, (time_t) 0, true}, // valid lower bound - the 1st of January 1970 at 00:00:00 {{ 59, 59, 23, 31, 11, 59, 0, 0, 0 }, (time_t) 0, false }, // invalid lower bound - the 31st of December 1969 at 23:59:59 {{ 15, 28, 6, 7, 1, 206, 0, 0, 0 }, (time_t)(UINT_MAX), true }, // valid upper bound - the 7th of February 2106 at 06:28:15 @@ -98,7 +97,7 @@ test_mk_time_struct test_mk_time_arr_full[] = { * Expected range: the 1st of January 1970 at 00:00:00 (seconds: 0) to the 6th of February 2106 at 06:28:15 (seconds: UINT_MAX). */ test_mk_time_struct test_mk_time_arr_partial[] = { - {{ 0, 0, 0, 1, 0, 70, 0, 0, 0 }, (time_t) 0, true}, // valid lower bound - the 1st of January 1970 at 00:00:00 + {{ 0, 0, 0, 1, 0, 70, 0, 0, 0 }, (time_t) 0, true}, // valid lower bound - the 1st of January 1970 at 00:00:00 {{ 59, 59, 23, 31, 11, 59, 0, 0, 0 }, (time_t) 0, false }, // invalid lower bound - the 31st of December 1969 at 23:59:59 {{ 15, 28, 6, 6, 1, 206, 0, 0, 0 }, (time_t)(UINT_MAX), true }, // valid upper bound - the 6th of February 2106 at 06:28:15 @@ -152,10 +151,10 @@ void test_mk_time_invalid_param() time_t seconds; struct tm timeinfo; - TEST_ASSERT_EQUAL(false, _rtc_maketime(NULL, &seconds, RTC_FULL_LEAP_YEAR_SUPPORT )); - TEST_ASSERT_EQUAL(false, _rtc_maketime(NULL, &seconds, RTC_4_YEAR_LEAP_YEAR_SUPPORT )); - TEST_ASSERT_EQUAL(false, _rtc_maketime(&timeinfo, NULL, RTC_FULL_LEAP_YEAR_SUPPORT )); - TEST_ASSERT_EQUAL(false, _rtc_maketime(&timeinfo, NULL, RTC_4_YEAR_LEAP_YEAR_SUPPORT )); + TEST_ASSERT_EQUAL(false, _rtc_maketime(NULL, &seconds, RTC_FULL_LEAP_YEAR_SUPPORT)); + TEST_ASSERT_EQUAL(false, _rtc_maketime(NULL, &seconds, RTC_4_YEAR_LEAP_YEAR_SUPPORT)); + TEST_ASSERT_EQUAL(false, _rtc_maketime(&timeinfo, NULL, RTC_FULL_LEAP_YEAR_SUPPORT)); + TEST_ASSERT_EQUAL(false, _rtc_maketime(&timeinfo, NULL, RTC_4_YEAR_LEAP_YEAR_SUPPORT)); } /* Test _rtc_localtime() function - call with invalid parameters. @@ -166,24 +165,24 @@ void test_mk_time_invalid_param() */ void test_local_time_invalid_param() { - TEST_ASSERT_EQUAL(false, _rtc_localtime(1, NULL, RTC_FULL_LEAP_YEAR_SUPPORT )); - TEST_ASSERT_EQUAL(false, _rtc_localtime(1, NULL, RTC_4_YEAR_LEAP_YEAR_SUPPORT )); + TEST_ASSERT_EQUAL(false, _rtc_localtime(1, NULL, RTC_FULL_LEAP_YEAR_SUPPORT)); + TEST_ASSERT_EQUAL(false, _rtc_localtime(1, NULL, RTC_4_YEAR_LEAP_YEAR_SUPPORT)); } -utest::v1::status_t teardown_handler_t(const Case * const source, const size_t passed, const size_t failed, - const failure_t reason) +utest::v1::status_t teardown_handler_t(const Case *const source, const size_t passed, const size_t failed, + const failure_t reason) { return greentea_case_teardown_handler(source, passed, failed, reason); } -utest::v1::status_t full_leap_year_case_setup_handler_t(const Case * const source, const size_t index_of_case) +utest::v1::status_t full_leap_year_case_setup_handler_t(const Case *const source, const size_t index_of_case) { rtc_leap_year_support = RTC_FULL_LEAP_YEAR_SUPPORT; return greentea_case_setup_handler(source, index_of_case); } -utest::v1::status_t partial_leap_year_case_setup_handler_t(const Case * const source, const size_t index_of_case) +utest::v1::status_t partial_leap_year_case_setup_handler_t(const Case *const source, const size_t index_of_case) { rtc_leap_year_support = RTC_4_YEAR_LEAP_YEAR_SUPPORT; @@ -191,12 +190,12 @@ utest::v1::status_t partial_leap_year_case_setup_handler_t(const Case * const so } Case cases[] = { - Case("test is leap year - RTC leap years full support", full_leap_year_case_setup_handler_t, test_is_leap_year, teardown_handler_t), - Case("test is leap year - RTC leap years partial support", partial_leap_year_case_setup_handler_t, test_is_leap_year, teardown_handler_t), - Case("test make time boundary values - RTC leap years full support", full_leap_year_case_setup_handler_t, test_mk_time_boundary, teardown_handler_t), - Case("test make time boundary values - RTC leap years partial support", partial_leap_year_case_setup_handler_t, test_mk_time_boundary, teardown_handler_t), - Case("test make time - invalid param", test_mk_time_invalid_param, teardown_handler_t), - Case("test local time - invalid param", test_local_time_invalid_param, teardown_handler_t), + Case("test is leap year - RTC leap years full support", full_leap_year_case_setup_handler_t, test_is_leap_year, teardown_handler_t), + Case("test is leap year - RTC leap years partial support", partial_leap_year_case_setup_handler_t, test_is_leap_year, teardown_handler_t), + Case("test make time boundary values - RTC leap years full support", full_leap_year_case_setup_handler_t, test_mk_time_boundary, teardown_handler_t), + Case("test make time boundary values - RTC leap years partial support", partial_leap_year_case_setup_handler_t, test_mk_time_boundary, teardown_handler_t), + Case("test make time - invalid param", test_mk_time_invalid_param, teardown_handler_t), + Case("test local time - invalid param", test_local_time_invalid_param, teardown_handler_t), }; utest::v1::status_t greentea_test_setup(const size_t number_of_cases) diff --git a/TESTS/mbed_hal/rtc_time_conv/main.cpp b/TESTS/mbed_hal/rtc_time_conv/main.cpp index a33b363492d..0a716542403 100644 --- a/TESTS/mbed_hal/rtc_time_conv/main.cpp +++ b/TESTS/mbed_hal/rtc_time_conv/main.cpp @@ -51,8 +51,8 @@ bool is_leap_year(int year) struct tm make_time_info(int year, int month, int day, int hours, int minutes, int seconds) { - struct tm timeinfo = - { seconds, // tm_sec + struct tm timeinfo = { + seconds, // tm_sec minutes, // tm_min hours, // tm_hour day, // tm_mday @@ -61,7 +61,7 @@ struct tm make_time_info(int year, int month, int day, int hours, int minutes, i 0, // tm_wday 0, // tm_yday 0, // tm_isdst - }; + }; return timeinfo; } @@ -79,9 +79,9 @@ struct tm make_time_info(int year, int month, int day, int hours, int minutes, i void test_case_mktime_localtime() { char _key[11] = - { }; + { }; char _value[128] = - { }; + { }; size_t years[] = {70, 71, 100, 196, 200, 205}; @@ -89,7 +89,7 @@ void test_case_mktime_localtime() greentea_send_kv("leap_year_setup", rtc_leap_year_support); /* Check the first and last last day of each month. */ - for (size_t year_id = 0; year_id < (sizeof(years) /sizeof(size_t)) ; ++year_id) { + for (size_t year_id = 0; year_id < (sizeof(years) / sizeof(size_t)) ; ++year_id) { for (size_t month = 0; month < 12; ++month) { for (size_t dayid = 0; dayid < 2; ++dayid) { @@ -100,8 +100,7 @@ void test_case_mktime_localtime() * day 0 - first, * day 1 - last * */ - switch (dayid) - { + switch (dayid) { case 0: day = 1; break; @@ -122,7 +121,7 @@ void test_case_mktime_localtime() } /* Additional conditions for RTCs with partial leap year support. */ - if(month == 1 && year == 200 && rtc_leap_year_support == RTC_4_YEAR_LEAP_YEAR_SUPPORT) { + if (month == 1 && year == 200 && rtc_leap_year_support == RTC_4_YEAR_LEAP_YEAR_SUPPORT) { day = 29; } @@ -172,30 +171,30 @@ void test_case_mktime_localtime() } } -utest::v1::status_t full_leap_year_case_setup_handler_t(const Case * const source, const size_t index_of_case) +utest::v1::status_t full_leap_year_case_setup_handler_t(const Case *const source, const size_t index_of_case) { rtc_leap_year_support = RTC_FULL_LEAP_YEAR_SUPPORT; return greentea_case_setup_handler(source, index_of_case); } -utest::v1::status_t partial_leap_year_case_setup_handler_t(const Case * const source, const size_t index_of_case) +utest::v1::status_t partial_leap_year_case_setup_handler_t(const Case *const source, const size_t index_of_case) { rtc_leap_year_support = RTC_4_YEAR_LEAP_YEAR_SUPPORT; return greentea_case_setup_handler(source, index_of_case); } -utest::v1::status_t teardown_handler_t(const Case * const source, const size_t passed, const size_t failed, - const failure_t reason) +utest::v1::status_t teardown_handler_t(const Case *const source, const size_t passed, const size_t failed, + const failure_t reason) { return greentea_case_teardown_handler(source, passed, failed, reason); } // Test cases -Case cases[] ={ - Case("test make time and local time - RTC leap years full support", full_leap_year_case_setup_handler_t, test_case_mktime_localtime, teardown_handler_t), - Case("test make time and local time - RTC leap years partial support", partial_leap_year_case_setup_handler_t, test_case_mktime_localtime, teardown_handler_t), +Case cases[] = { + Case("test make time and local time - RTC leap years full support", full_leap_year_case_setup_handler_t, test_case_mktime_localtime, teardown_handler_t), + Case("test make time and local time - RTC leap years partial support", partial_leap_year_case_setup_handler_t, test_case_mktime_localtime, teardown_handler_t), }; utest::v1::status_t greentea_test_setup(const size_t number_of_cases) diff --git a/TESTS/mbed_hal/sleep/main.cpp b/TESTS/mbed_hal/sleep/main.cpp index 23e5839f26c..5d64b8517be 100644 --- a/TESTS/mbed_hal/sleep/main.cpp +++ b/TESTS/mbed_hal/sleep/main.cpp @@ -66,12 +66,12 @@ static const uint32_t deepsleep_mode_delta_us = (10000 + 125 + 5); unsigned int ticks_to_us(unsigned int ticks, unsigned int freq) { - return (unsigned int) ((unsigned long long) ticks * US_PER_S / freq); + return (unsigned int)((unsigned long long) ticks * US_PER_S / freq); } unsigned int us_to_ticks(unsigned int us, unsigned int freq) { - return (unsigned int) ((unsigned long long) us * freq / US_PER_S); + return (unsigned int)((unsigned long long) us * freq / US_PER_S); } unsigned int overflow_protect(unsigned int timestamp, unsigned int ticker_width) @@ -103,7 +103,7 @@ bool compare_timestamps(unsigned int delta_ticks, unsigned int ticker_width, uns } } -void us_ticker_isr(const ticker_data_t * const ticker_data) +void us_ticker_isr(const ticker_data_t *const ticker_data) { us_ticker_clear_interrupt(); } @@ -119,7 +119,7 @@ void lp_ticker_isr(const ticker_data_t *const ticker_data) * high frequency ticker interrupt can wake-up target from sleep. */ void sleep_usticker_test() { - const ticker_data_t * ticker = get_us_ticker_data(); + const ticker_data_t *ticker = get_us_ticker_data(); const unsigned int ticker_freq = ticker->interface->get_info()->frequency; const unsigned int ticker_width = ticker->interface->get_info()->bits; @@ -144,7 +144,7 @@ void sleep_usticker_test() for (timestamp_t i = 100; i < 1000; i += 100) { /* note: us_ticker_read() operates on ticks. */ const timestamp_t next_match_timestamp = overflow_protect(us_ticker_read() + us_to_ticks(i, ticker_freq), - ticker_width); + ticker_width); us_ticker_set_interrupt(next_match_timestamp); @@ -153,8 +153,8 @@ void sleep_usticker_test() const unsigned int wakeup_timestamp = us_ticker_read(); TEST_ASSERT( - compare_timestamps(us_to_ticks(sleep_mode_delta_us, ticker_freq), ticker_width, next_match_timestamp, - wakeup_timestamp)); + compare_timestamps(us_to_ticks(sleep_mode_delta_us, ticker_freq), ticker_width, next_match_timestamp, + wakeup_timestamp)); } set_us_ticker_irq_handler(us_ticker_irq_handler_org); @@ -169,7 +169,7 @@ void sleep_usticker_test() * low power ticker interrupt can wake-up target from sleep. */ void deepsleep_lpticker_test() { - const ticker_data_t * ticker = get_lp_ticker_data(); + const ticker_data_t *ticker = get_lp_ticker_data(); const unsigned int ticker_freq = ticker->interface->get_info()->frequency; const unsigned int ticker_width = ticker->interface->get_info()->bits; @@ -207,8 +207,8 @@ void deepsleep_lpticker_test() void deepsleep_high_speed_clocks_turned_off_test() { - const ticker_data_t * us_ticker = get_us_ticker_data(); - const ticker_data_t * lp_ticker = get_lp_ticker_data(); + const ticker_data_t *us_ticker = get_us_ticker_data(); + const ticker_data_t *lp_ticker = get_lp_ticker_data(); const unsigned int us_ticker_freq = us_ticker->interface->get_info()->frequency; const unsigned int lp_ticker_freq = lp_ticker->interface->get_info()->frequency; const unsigned int us_ticker_width = us_ticker->interface->get_info()->bits; @@ -247,7 +247,7 @@ void deepsleep_high_speed_clocks_turned_off_test() #endif -utest::v1::status_t greentea_failure_handler(const Case * const source, const failure_t reason) +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; @@ -265,13 +265,13 @@ utest::v1::status_t greentea_test_setup(const size_t number_of_cases) return greentea_test_setup_handler(number_of_cases); } -Case cases[] = - { Case("sleep - source of wake-up - us ticker", sleep_usticker_test, greentea_failure_handler), +Case cases[] = { + Case("sleep - source of wake-up - us ticker", sleep_usticker_test, greentea_failure_handler), #if DEVICE_LPTICKER - Case("deep-sleep - source of wake-up - lp ticker",deepsleep_lpticker_test, greentea_failure_handler), - Case("deep-sleep - high-speed clocks are turned off",deepsleep_high_speed_clocks_turned_off_test, greentea_failure_handler), + Case("deep-sleep - source of wake-up - lp ticker", deepsleep_lpticker_test, greentea_failure_handler), + Case("deep-sleep - high-speed clocks are turned off", deepsleep_high_speed_clocks_turned_off_test, greentea_failure_handler), #endif - }; +}; Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); diff --git a/TESTS/mbed_hal/sleep_manager/main.cpp b/TESTS/mbed_hal/sleep_manager/main.cpp index 07353f17d78..c04daca78c1 100644 --- a/TESTS/mbed_hal/sleep_manager/main.cpp +++ b/TESTS/mbed_hal/sleep_manager/main.cpp @@ -27,7 +27,7 @@ void sleep_manager_deepsleep_counter_test() { bool deep_sleep_allowed = sleep_manager_can_deep_sleep(); TEST_ASSERT_TRUE(deep_sleep_allowed); - + sleep_manager_lock_deep_sleep(); deep_sleep_allowed = sleep_manager_can_deep_sleep(); TEST_ASSERT_FALSE(deep_sleep_allowed); @@ -37,13 +37,13 @@ void sleep_manager_deepsleep_counter_test() TEST_ASSERT_TRUE(deep_sleep_allowed); } -utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) +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; } -utest::v1::status_t greentea_test_setup(const size_t number_of_cases) +utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { GREENTEA_SETUP(20, "default_auto"); return greentea_test_setup_handler(number_of_cases); @@ -55,6 +55,7 @@ Case cases[] = { Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); -int main() { +int main() +{ Harness::run(specification); } diff --git a/TESTS/mbed_hal/sleep_manager_racecondition/main.cpp b/TESTS/mbed_hal/sleep_manager_racecondition/main.cpp index ee4158fa131..710f3caf16a 100644 --- a/TESTS/mbed_hal/sleep_manager_racecondition/main.cpp +++ b/TESTS/mbed_hal/sleep_manager_racecondition/main.cpp @@ -23,7 +23,7 @@ #endif #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif using namespace utest::v1; @@ -87,7 +87,7 @@ void sleep_manager_irq_test() TEST_ASSERT_TRUE_MESSAGE(deep_sleep_allowed, "Deep sleep should be allowed"); } -utest::v1::status_t greentea_test_setup(const size_t number_of_cases) +utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { GREENTEA_SETUP(30, "default_auto"); return greentea_test_setup_handler(number_of_cases); @@ -100,6 +100,7 @@ Case cases[] = { Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); -int main() { +int main() +{ Harness::run(specification); } diff --git a/TESTS/mbed_hal/ticker/main.cpp b/TESTS/mbed_hal/ticker/main.cpp index c81b8e368af..6d5708af53e 100644 --- a/TESTS/mbed_hal/ticker/main.cpp +++ b/TESTS/mbed_hal/ticker/main.cpp @@ -32,12 +32,12 @@ using namespace utest::v1; #define TIMESTAMP_MAX_DELTA_BITS(bits) ((uint64_t)(0x7 << ((bits) - 4))) #define TIMESTAMP_MAX_DELTA TIMESTAMP_MAX_DELTA_BITS(32) -struct ticker_interface_stub_t { +struct ticker_interface_stub_t { ticker_interface_t interface; - bool initialized; + bool initialized; bool interrupt_flag; timestamp_t timestamp ; - timestamp_t interrupt_timestamp; + timestamp_t interrupt_timestamp; unsigned int init_call; unsigned int read_call; unsigned int disable_interrupt_call; @@ -60,10 +60,10 @@ static uint32_t ticker_interface_stub_read() { ++interface_stub.read_call; return interface_stub.timestamp; -} +} static void ticker_interface_stub_disable_interrupt() -{ +{ ++interface_stub.disable_interrupt_call; } @@ -76,7 +76,7 @@ static void ticker_interface_stub_clear_interrupt() static void ticker_interface_stub_set_interrupt(timestamp_t timestamp) { ++interface_stub.set_interrupt_call; - interface_stub.interrupt_timestamp = timestamp; + interface_stub.interrupt_timestamp = timestamp; } static void ticker_interface_stub_fire_interrupt() @@ -94,11 +94,11 @@ static void reset_ticker_interface_stub() { interface_stub.interface.init = ticker_interface_stub_init; interface_stub.interface.read = ticker_interface_stub_read; - interface_stub.interface.disable_interrupt = + interface_stub.interface.disable_interrupt = ticker_interface_stub_disable_interrupt; - interface_stub.interface.clear_interrupt = + interface_stub.interface.clear_interrupt = ticker_interface_stub_clear_interrupt; - interface_stub.interface.set_interrupt =ticker_interface_stub_set_interrupt; + interface_stub.interface.set_interrupt = ticker_interface_stub_set_interrupt; interface_stub.interface.fire_interrupt = ticker_interface_stub_fire_interrupt; interface_stub.interface.get_info = ticker_interface_stub_get_info; interface_stub.initialized = false; @@ -116,7 +116,7 @@ static void reset_ticker_interface_stub() interface_info_stub.bits = 32; } -// stub of the event queue +// stub of the event queue static ticker_event_queue_t queue_stub = { /* event handler */ NULL, /* head */ NULL, @@ -180,7 +180,8 @@ static void test_over_frequency_and_width(void) static utest::v1::status_t case_setup_handler( const Case *const source, const size_t index_of_case -) { +) +{ utest::v1::status_t status = greentea_case_setup_handler(source, index_of_case); reset_ticker_stub(); return status; @@ -188,20 +189,22 @@ static utest::v1::status_t case_setup_handler( static utest::v1::status_t case_teardown_handler( const Case *const source, const size_t passed, const size_t failed, const failure_t reason -) { +) +{ reset_ticker_stub(); utest::v1::status_t status = greentea_case_teardown_handler( - source, passed, failed, reason - ); + source, passed, failed, reason + ); return status; } static utest::v1::status_t greentea_failure_handler( const Case *const source, const failure_t reason -) { +) +{ utest::v1::status_t status = greentea_case_failure_abort_handler( - source, reason - ); + source, reason + ); return status; } @@ -217,13 +220,13 @@ static utest::v1::status_t greentea_failure_handler( } /** - * Given an unitialized ticker_data instance. - * When the ticker is initialized - * Then: - * - The ticker interface should be initialized + * Given an unitialized ticker_data instance. + * When the ticker is initialized + * Then: + * - The ticker interface should be initialized * - The queue handler should be set to the handler provided in parameter * - The internal ticker timestamp should be zero - * - interrupt should be scheduled in current timestamp + + * - interrupt should be scheduled in current timestamp + * TIMESTAMP_MAX_DELTA * - The queue should not contains any event */ @@ -231,7 +234,7 @@ static void test_ticker_initialization() { ticker_event_handler dummy_handler = (ticker_event_handler)0xDEADBEEF; - // setup of the stub + // setup of the stub interface_stub.timestamp = 0xFEEDBABE; ticker_set_handler(&ticker_stub, dummy_handler); @@ -249,9 +252,9 @@ static void test_ticker_initialization() } /** - * Given an initialized ticker_data instance. - * When the ticker handler is set to a new value - * Then: + * Given an initialized ticker_data instance. + * When the ticker handler is set to a new value + * Then: * - The ticker interface initialization function should not be called. * - The queue handler should be set to the new handler. * - The events in the queue should remains the same. @@ -260,10 +263,10 @@ static void test_ticker_re_initialization() { ticker_event_handler dummy_handler = (ticker_event_handler) 0xDEADBEEF; ticker_event_handler expected_handler = (ticker_event_handler) 0xFEEDDEAF; - - ticker_event_t first_event = { 0 }; - ticker_event_t second_event = { 0 }; - ticker_event_t third_event = { 0 }; + + ticker_event_t first_event = { 0 }; + ticker_event_t second_event = { 0 }; + ticker_event_t third_event = { 0 }; first_event.next = &second_event; second_event.next = &third_event; @@ -287,15 +290,15 @@ static void test_ticker_re_initialization() } /** - * Given an initialized ticker_data instance. - * When the ticker is read + * Given an initialized ticker_data instance. + * When the ticker is read * Then it should return the value present in the ticker interface */ static void test_ticker_read() { ticker_set_handler(&ticker_stub, NULL); - timestamp_t timestamps[] = { + timestamp_t timestamps[] = { 0xA, 0xAA, 0xAAA, @@ -316,19 +319,19 @@ static void test_ticker_read() } /** - * Given an initialized ticker_data instance. - * When the ticker is read and the value read is less than the previous + * Given an initialized ticker_data instance. + * When the ticker is read and the value read is less than the previous * value read. * Then: - * - ticker_read should return the value read in the ticker interface - * - ticker_read_us should return a value where: + * - ticker_read should return the value read in the ticker interface + * - ticker_read_us should return a value where: * + lower 8 bytes should be equal to the value in the ticker interface * + upper 8 bytes should be equal to the previous value of upper 8 bytes * plus one. */ static void test_ticker_read_overflow() { - const timestamp_t timestamps[] = { + const timestamp_t timestamps[] = { 0xAAAAAAAA, 0xAAAAAAA, 0xAAAAAA, @@ -356,15 +359,15 @@ static void test_ticker_read_overflow() } /** - * Given an initialized ticker without user registered events. - * When an event is inserted with ticker_insert_event and the timestamp passed - * in parameter is in range [ticker_timestamp : ticker_timestamp + + * Given an initialized ticker without user registered events. + * When an event is inserted with ticker_insert_event and the timestamp passed + * in parameter is in range [ticker_timestamp : ticker_timestamp + * TIMESTAMP_MAX_DELTA[. - * Then + * Then * - The event should be in the queue - * - The interrupt timestamp should be equal to the timestamp of the event - * - The timestamp of the event should reflect the timestamp requested. - * - The id of the event should be equal to the id passed in parameter. + * - The interrupt timestamp should be equal to the timestamp of the event + * - The timestamp of the event should reflect the timestamp requested. + * - The id of the event should be equal to the id passed in parameter. */ static void test_legacy_insert_event_outside_overflow_range() { @@ -373,17 +376,17 @@ static void test_legacy_insert_event_outside_overflow_range() // test the end of the range ticker_event_t last_event = { 0 }; - const timestamp_t timestamp_last_event = - interface_stub.timestamp + TIMESTAMP_MAX_DELTA; + const timestamp_t timestamp_last_event = + interface_stub.timestamp + TIMESTAMP_MAX_DELTA; const uint32_t id_last_event = 0xDEADDEAF; ticker_insert_event( - &ticker_stub, + &ticker_stub, &last_event, timestamp_last_event, id_last_event ); TEST_ASSERT_EQUAL_PTR(&last_event, queue_stub.head); - TEST_ASSERT_EQUAL(1, interface_stub.set_interrupt_call); + TEST_ASSERT_EQUAL(1, interface_stub.set_interrupt_call); TEST_ASSERT_EQUAL_UINT32( timestamp_last_event, interface_stub.interrupt_timestamp ); @@ -397,12 +400,12 @@ static void test_legacy_insert_event_outside_overflow_range() const uint32_t id_first_event = 0xAAAAAAAA; ticker_insert_event( - &ticker_stub, + &ticker_stub, &first_event, timestamp_first_event, id_first_event ); TEST_ASSERT_EQUAL_PTR(&first_event, queue_stub.head); - TEST_ASSERT_EQUAL(2, interface_stub.set_interrupt_call); + TEST_ASSERT_EQUAL(2, interface_stub.set_interrupt_call); TEST_ASSERT_EQUAL_UINT32( timestamp_first_event, interface_stub.interrupt_timestamp ); @@ -413,19 +416,19 @@ static void test_legacy_insert_event_outside_overflow_range() TEST_ASSERT_EQUAL_UINT32(id_first_event, first_event.id); TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); -} +} /** - * Given an initialized ticker without user registered events. - * When an event is inserted with ticker_insert_event and a timestamp in the - * range [ticker_timestamp + TIMESTAMP_MAX_DELTA + 1 : + * Given an initialized ticker without user registered events. + * When an event is inserted with ticker_insert_event and a timestamp in the + * range [ticker_timestamp + TIMESTAMP_MAX_DELTA + 1 : * ticker_timestamp + UINT32MAX [ - * Then + * Then * - The event should be in the queue - * - The interrupt timestamp should be equal to - * TIMESTAMP_MAX_DELTA - * - The timestamp of the event should reflect the timestamp requested. - * - The id of the event should be equal to the id passed in parameter. + * - The interrupt timestamp should be equal to + * TIMESTAMP_MAX_DELTA + * - The timestamp of the event should reflect the timestamp requested. + * - The id of the event should be equal to the id passed in parameter. */ static void test_legacy_insert_event_in_overflow_range() { @@ -434,19 +437,19 @@ static void test_legacy_insert_event_in_overflow_range() // test the end of the range ticker_event_t last_event = { 0 }; - const timestamp_t timestamp_last_event = - interface_stub.timestamp + UINT32_MAX; + const timestamp_t timestamp_last_event = + interface_stub.timestamp + UINT32_MAX; const uint32_t id_last_event = 0xDEADDEAF; ticker_insert_event( - &ticker_stub, + &ticker_stub, &last_event, timestamp_last_event, id_last_event ); TEST_ASSERT_EQUAL_PTR(&last_event, queue_stub.head); - TEST_ASSERT_EQUAL(1, interface_stub.set_interrupt_call); + TEST_ASSERT_EQUAL(1, interface_stub.set_interrupt_call); TEST_ASSERT_EQUAL_UINT32( - interface_stub.timestamp + TIMESTAMP_MAX_DELTA, + interface_stub.timestamp + TIMESTAMP_MAX_DELTA, interface_stub.interrupt_timestamp ); TEST_ASSERT_EQUAL_PTR(NULL, queue_stub.head->next); @@ -457,19 +460,19 @@ static void test_legacy_insert_event_in_overflow_range() ++interface_stub.timestamp; ticker_event_t first_event = { 0 }; - const timestamp_t timestamp_first_event = - interface_stub.timestamp + TIMESTAMP_MAX_DELTA + 1; + const timestamp_t timestamp_first_event = + interface_stub.timestamp + TIMESTAMP_MAX_DELTA + 1; const uint32_t id_first_event = 0xAAAAAAAA; ticker_insert_event( - &ticker_stub, + &ticker_stub, &first_event, timestamp_first_event, id_first_event ); TEST_ASSERT_EQUAL_PTR(&first_event, queue_stub.head); - TEST_ASSERT_EQUAL(2, interface_stub.set_interrupt_call); + TEST_ASSERT_EQUAL(2, interface_stub.set_interrupt_call); TEST_ASSERT_EQUAL_UINT32( - interface_stub.timestamp + TIMESTAMP_MAX_DELTA, + interface_stub.timestamp + TIMESTAMP_MAX_DELTA, interface_stub.interrupt_timestamp ); TEST_ASSERT_EQUAL_PTR(&last_event, queue_stub.head->next); @@ -479,21 +482,22 @@ static void test_legacy_insert_event_in_overflow_range() TEST_ASSERT_EQUAL_UINT32(id_first_event, first_event.id); TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); -} +} /** - * Given an initialized ticker without user registered events. - * When an event is inserted with ticker_insert_event and the timestamp in + * Given an initialized ticker without user registered events. + * When an event is inserted with ticker_insert_event and the timestamp in * parameter is less than the current timestamp value. - * Then + * Then * - The event should be in the queue * - The timestamp of the event should reflect the timestamp requested: - * + lower 8 bytes should be equal to the timestamp in input. + * + lower 8 bytes should be equal to the timestamp in input. * + upper 8 bytes should be equal to the upper of the upper 8 bytes of the * timestamp state stored in the queue plus one. - * - The id of the event should be equal to the id passed in parameter. + * - The id of the event should be equal to the id passed in parameter. */ -static void test_legacy_insert_event_overflow(){ +static void test_legacy_insert_event_overflow() +{ ticker_set_handler(&ticker_stub, NULL); interface_stub.set_interrupt_call = 0; @@ -501,23 +505,23 @@ static void test_legacy_insert_event_overflow(){ ticker_read(&ticker_stub); ticker_event_t event = { 0 }; - const timestamp_t expected_timestamp = - interface_stub.timestamp + - TIMESTAMP_MAX_DELTA + - 1; - const us_timestamp_t expected_us_timestamp = + const timestamp_t expected_timestamp = + interface_stub.timestamp + + TIMESTAMP_MAX_DELTA + + 1; + const us_timestamp_t expected_us_timestamp = (((queue_stub.present_time >> 32) + 1) << 32) | expected_timestamp; const uint32_t expected_id = 0xDEADDEAF; ticker_insert_event( - &ticker_stub, + &ticker_stub, &event, expected_timestamp, expected_id ); TEST_ASSERT_EQUAL_PTR(&event, queue_stub.head); - TEST_ASSERT_EQUAL(1, interface_stub.set_interrupt_call); + TEST_ASSERT_EQUAL(1, interface_stub.set_interrupt_call); TEST_ASSERT_EQUAL_UINT32( - interface_stub.timestamp + TIMESTAMP_MAX_DELTA, + interface_stub.timestamp + TIMESTAMP_MAX_DELTA, interface_stub.interrupt_timestamp ); TEST_ASSERT_EQUAL_PTR(NULL, queue_stub.head->next); @@ -525,18 +529,18 @@ static void test_legacy_insert_event_overflow(){ TEST_ASSERT_EQUAL_UINT32(expected_id, event.id); TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); -} +} /** * Given an initialized ticker. - * When an event is inserted with ticker_insert_event and a timestamp less than + * When an event is inserted with ticker_insert_event and a timestamp less than * the one for the next scheduled timestamp. - * Then + * Then * - The event inserted should be the first in the queue - * - The interrupt timestamp should be equal to the timestamp of the event or + * - The interrupt timestamp should be equal to the timestamp of the event or * TIMESTAMP_MAX_DELTA if in the overflow range. * - The timestamp of the event should reflect the timestamp requested. - * - The id of the event should be equal to the id passed in parameter. + * - The id of the event should be equal to the id passed in parameter. * - Events in the queue should remained ordered by timestamp. */ static void test_legacy_insert_event_head() @@ -544,7 +548,7 @@ static void test_legacy_insert_event_head() ticker_set_handler(&ticker_stub, NULL); interface_stub.set_interrupt_call = 0; - const timestamp_t timestamps[] = { + const timestamp_t timestamps[] = { UINT32_MAX, TIMESTAMP_MAX_DELTA + 1, TIMESTAMP_MAX_DELTA, @@ -555,22 +559,22 @@ static void test_legacy_insert_event_head() }; ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 }; - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_insert_event( - &ticker_stub, + &ticker_stub, &events[i], timestamps[i], i ); TEST_ASSERT_EQUAL_PTR(&events[i], queue_stub.head); - TEST_ASSERT_EQUAL(i + 1, interface_stub.set_interrupt_call); - if (timestamps[i] < TIMESTAMP_MAX_DELTA) { + TEST_ASSERT_EQUAL(i + 1, interface_stub.set_interrupt_call); + if (timestamps[i] < TIMESTAMP_MAX_DELTA) { TEST_ASSERT_EQUAL_UINT32( - timestamps[i], + timestamps[i], interface_stub.interrupt_timestamp ); - } else { + } else { TEST_ASSERT_EQUAL_UINT32( - TIMESTAMP_MAX_DELTA, + TIMESTAMP_MAX_DELTA, interface_stub.interrupt_timestamp ); } @@ -580,13 +584,13 @@ static void test_legacy_insert_event_head() ); TEST_ASSERT_EQUAL_UINT32(i, events[i].id); - ticker_event_t* e = &events[i]; - while (e) { + ticker_event_t *e = &events[i]; + while (e) { TEST_ASSERT_EQUAL_UINT32(timestamps[e->id], e->timestamp); - if (e->next) { + if (e->next) { TEST_ASSERT_TRUE(e->id > e->next->id); TEST_ASSERT_TRUE(e->timestamp < e->next->timestamp); - } else { + } else { TEST_ASSERT_EQUAL_UINT32(0, e->id); } e = e->next; @@ -594,18 +598,18 @@ static void test_legacy_insert_event_head() } TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); -} +} -/** +/** * Given an initialized ticker. - * When an event is inserted with ticker_insert_event and its timestamp is bigger + * When an event is inserted with ticker_insert_event and its timestamp is bigger * than the one of the last event in the queue. - * Then + * Then * - The event inserted should be the last in the queue - * - The interrupt timestamp should remains equal to the interrupt timestamp + * - The interrupt timestamp should remains equal to the interrupt timestamp * of the head event . * - The timestamp of the event should reflect the timestamp requested. - * - The id of the event should be equal to the id passed in parameter. + * - The id of the event should be equal to the id passed in parameter. * - Events in the queue should remained ordered by timestamp. */ static void test_legacy_insert_event_tail() @@ -613,7 +617,7 @@ static void test_legacy_insert_event_tail() ticker_set_handler(&ticker_stub, NULL); interface_stub.set_interrupt_call = 0; - const timestamp_t timestamps[] = { + const timestamp_t timestamps[] = { 0xA, 0xAA, 0xAAA, @@ -625,9 +629,9 @@ static void test_legacy_insert_event_tail() }; ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 }; - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_insert_event( - &ticker_stub, + &ticker_stub, &events[i], timestamps[i], i ); @@ -639,13 +643,13 @@ static void test_legacy_insert_event_tail() TEST_ASSERT_EQUAL_UINT32(timestamps[i], events[i].timestamp); TEST_ASSERT_EQUAL_UINT32(i, events[i].id); - ticker_event_t* e = queue_stub.head; - while (e) { + ticker_event_t *e = queue_stub.head; + while (e) { TEST_ASSERT_EQUAL_UINT32(timestamps[e->id], e->timestamp); - if (e->next) { + if (e->next) { TEST_ASSERT_TRUE(e->id < e->next->id); TEST_ASSERT_TRUE(e->timestamp < e->next->timestamp); - } else { + } else { TEST_ASSERT_EQUAL_UINT32(&events[i], e); } e = e->next; @@ -653,19 +657,19 @@ static void test_legacy_insert_event_tail() } TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); -} +} /** * Given an initialized ticker. - * When an event is inserted with ticker_insert_event and a timestamp less - * than the current timestamp in the interface and less than the relative + * When an event is inserted with ticker_insert_event and a timestamp less + * than the current timestamp in the interface and less than the relative * timestamp of the next event to execute. - * Then + * Then * - The event inserted should be after the head - * - The interrupt timestamp should remains equal to the interrupt timestamp + * - The interrupt timestamp should remains equal to the interrupt timestamp * of the head event . * - The timestamp of the event should reflect the timestamp requested (overflow) - * - The id of the event should be equal to the id passed in parameter. + * - The id of the event should be equal to the id passed in parameter. * - Events in the queue should remained ordered by timestamp. */ static void test_legacy_insert_event_multiple_overflow() @@ -673,7 +677,7 @@ static void test_legacy_insert_event_multiple_overflow() ticker_set_handler(&ticker_stub, NULL); interface_stub.set_interrupt_call = 0; - const timestamp_t timestamps[] = { + const timestamp_t timestamps[] = { 0xA, 0xAA, 0xAAA, @@ -688,20 +692,20 @@ static void test_legacy_insert_event_multiple_overflow() ticker_event_t ref_event; timestamp_t ref_event_timestamp = 0xCCCCCCCC; ticker_insert_event( - &ticker_stub, + &ticker_stub, &ref_event, ref_event_timestamp, 0xDEADBEEF ); - timestamp_t last_timestamp_to_insert = + timestamp_t last_timestamp_to_insert = timestamps[MBED_ARRAY_SIZE(timestamps) - 1]; - interface_stub.timestamp = - last_timestamp_to_insert + + interface_stub.timestamp = + last_timestamp_to_insert + ((ref_event_timestamp - last_timestamp_to_insert) / 2); ticker_irq_handler(&ticker_stub); - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_insert_event( - &ticker_stub, + &ticker_stub, &events[i], timestamps[i], i ); @@ -714,13 +718,13 @@ static void test_legacy_insert_event_multiple_overflow() TEST_ASSERT_EQUAL_UINT32(timestamps[i], events[i].timestamp); TEST_ASSERT_EQUAL_UINT32(i, events[i].id); - ticker_event_t* e = queue_stub.head->next; - while (e) { + ticker_event_t *e = queue_stub.head->next; + while (e) { TEST_ASSERT_EQUAL_UINT32(timestamps[e->id], e->timestamp); - if (e->next) { + if (e->next) { TEST_ASSERT_TRUE(e->id < e->next->id); TEST_ASSERT_TRUE(e->timestamp < e->next->timestamp); - } else { + } else { TEST_ASSERT_EQUAL_UINT32(&events[i], e); } e = e->next; @@ -733,14 +737,14 @@ static void test_legacy_insert_event_multiple_overflow() /** * Given an initialized ticker. * When an event is inserted with ticker_insert_event. - * Then + * Then * - The event inserted should be at the correct position in the queue * - The event queue should remain ordered by timestamp - * - The interrupt timestamp should be equal to the interrupt timestamp - * of the head event or TIMESTAMP_MAX_DELTA if the + * - The interrupt timestamp should be equal to the interrupt timestamp + * of the head event or TIMESTAMP_MAX_DELTA if the * timestamp is in the overflow range. * - The timestamp of the event should reflect the timestamp requested (overflow) - * - The id of the event should be equal to the id passed in parameter. + * - The id of the event should be equal to the id passed in parameter. * - Events in the queue should remained ordered by timestamp. */ static void test_legacy_insert_event_multiple_random() @@ -751,9 +755,9 @@ static void test_legacy_insert_event_multiple_random() const timestamp_t ref_timestamp = UINT32_MAX / 2; interface_stub.timestamp = ref_timestamp; - // insert first event at the head of the queue + // insert first event at the head of the queue ticker_event_t first_event; - const timestamp_t first_event_timestamp = + const timestamp_t first_event_timestamp = ref_timestamp + TIMESTAMP_MAX_DELTA + 100; ticker_insert_event( @@ -769,7 +773,7 @@ static void test_legacy_insert_event_multiple_random() TEST_ASSERT_EQUAL_UINT32(first_event_timestamp, first_event.timestamp); TEST_ASSERT_EQUAL_UINT64( first_event.timestamp, - first_event_timestamp + + first_event_timestamp + ((first_event_timestamp < ref_timestamp) ? (1ULL << 32) : 0) ); TEST_ASSERT_EQUAL_UINT32((uint32_t) &first_event, first_event.id); @@ -792,7 +796,7 @@ static void test_legacy_insert_event_multiple_random() TEST_ASSERT_EQUAL_UINT32(second_event_timestamp, second_event.timestamp); TEST_ASSERT_EQUAL_UINT64( second_event.timestamp, - second_event_timestamp + + second_event_timestamp + ((second_event_timestamp < ref_timestamp) ? (1ULL << 32) : 0) ); TEST_ASSERT_EQUAL_UINT32((uint32_t) &second_event, second_event.id); @@ -800,7 +804,7 @@ static void test_legacy_insert_event_multiple_random() // insert third event at the head of the queue out the overflow zone ticker_event_t third_event; - const timestamp_t third_event_timestamp = + const timestamp_t third_event_timestamp = ref_timestamp + TIMESTAMP_MAX_DELTA - 100; ticker_insert_event( @@ -818,7 +822,7 @@ static void test_legacy_insert_event_multiple_random() TEST_ASSERT_EQUAL_UINT32(third_event_timestamp, third_event.timestamp); TEST_ASSERT_EQUAL_UINT64( third_event.timestamp, - third_event_timestamp + + third_event_timestamp + ((third_event_timestamp < ref_timestamp) ? (1ULL << 32) : 0) ); TEST_ASSERT_EQUAL_UINT32((uint32_t) &third_event, third_event.id); @@ -843,7 +847,7 @@ static void test_legacy_insert_event_multiple_random() TEST_ASSERT_EQUAL_UINT32(fourth_event_timestamp, fourth_event.timestamp); TEST_ASSERT_EQUAL_UINT64( fourth_event.timestamp, - fourth_event_timestamp + + fourth_event_timestamp + ((fourth_event_timestamp < ref_timestamp) ? (1ULL << 32) : 0) ); TEST_ASSERT_EQUAL_UINT32((uint32_t) &fourth_event, fourth_event.id); @@ -852,15 +856,15 @@ static void test_legacy_insert_event_multiple_random() } /** - * Given an initialized ticker without user registered events. - * When an event is inserted with ticker_insert_event_us and the timestamp passed - * in parameter is in range [ticker_timestamp : ticker_timestamp + + * Given an initialized ticker without user registered events. + * When an event is inserted with ticker_insert_event_us and the timestamp passed + * in parameter is in range [ticker_timestamp : ticker_timestamp + * TIMESTAMP_MAX_DELTA[. - * Then + * Then * - The event should be in the queue - * - The interrupt timestamp should be equal to the lower 8 bytes of the event. - * - The timestamp of the event should be equal to the timestamp requested. - * - The id of the event should be equal to the id passed in parameter. + * - The interrupt timestamp should be equal to the lower 8 bytes of the event. + * - The timestamp of the event should be equal to the timestamp requested. + * - The id of the event should be equal to the id passed in parameter. */ static void test_insert_event_us_outside_overflow_range() { @@ -872,17 +876,17 @@ static void test_insert_event_us_outside_overflow_range() // test the end of the range ticker_event_t last_event = { 0 }; - const us_timestamp_t timestamp_last_event = + const us_timestamp_t timestamp_last_event = queue_stub.present_time + TIMESTAMP_MAX_DELTA; const uint32_t id_last_event = 0xDEADDEAF; ticker_insert_event_us( - &ticker_stub, + &ticker_stub, &last_event, timestamp_last_event, id_last_event ); TEST_ASSERT_EQUAL_PTR(&last_event, queue_stub.head); - TEST_ASSERT_EQUAL(1, interface_stub.set_interrupt_call); + TEST_ASSERT_EQUAL(1, interface_stub.set_interrupt_call); TEST_ASSERT_EQUAL_UINT32( timestamp_last_event, interface_stub.interrupt_timestamp ); @@ -896,12 +900,12 @@ static void test_insert_event_us_outside_overflow_range() const uint32_t id_first_event = 0xAAAAAAAA; ticker_insert_event_us( - &ticker_stub, + &ticker_stub, &first_event, timestamp_first_event, id_first_event ); TEST_ASSERT_EQUAL_PTR(&first_event, queue_stub.head); - TEST_ASSERT_EQUAL(2, interface_stub.set_interrupt_call); + TEST_ASSERT_EQUAL(2, interface_stub.set_interrupt_call); TEST_ASSERT_EQUAL_UINT32( timestamp_first_event, interface_stub.interrupt_timestamp ); @@ -912,17 +916,17 @@ static void test_insert_event_us_outside_overflow_range() TEST_ASSERT_EQUAL_UINT32(id_first_event, first_event.id); TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); -} +} /** - * Given an initialized ticker without user registered events. - * When an event is inserted with ticker_insert_event_us and a timestamp in the - * range [ticker_timestamp + TIMESTAMP_MAX_DELTA + 1 : UINT64_MAX [ - * Then + * Given an initialized ticker without user registered events. + * When an event is inserted with ticker_insert_event_us and a timestamp in the + * range [ticker_timestamp + TIMESTAMP_MAX_DELTA + 1 : UINT64_MAX [ + * Then * - The event should be in the queue - * - The interrupt timestamp should be equal to TIMESTAMP_MAX_DELTA - * - The timestamp of the event should be equal to the timestamp in parameter. - * - The id of the event should be equal to the id passed in parameter. + * - The interrupt timestamp should be equal to TIMESTAMP_MAX_DELTA + * - The timestamp of the event should be equal to the timestamp in parameter. + * - The id of the event should be equal to the id passed in parameter. */ static void test_insert_event_us_in_overflow_range() { @@ -934,18 +938,18 @@ static void test_insert_event_us_in_overflow_range() // test the end of the range ticker_event_t last_event = { 0 }; - const us_timestamp_t timestamp_last_event = UINT64_MAX; + const us_timestamp_t timestamp_last_event = UINT64_MAX; const uint32_t id_last_event = 0xDEADDEAF; ticker_insert_event_us( - &ticker_stub, + &ticker_stub, &last_event, timestamp_last_event, id_last_event ); TEST_ASSERT_EQUAL_PTR(&last_event, queue_stub.head); - TEST_ASSERT_EQUAL(1, interface_stub.set_interrupt_call); + TEST_ASSERT_EQUAL(1, interface_stub.set_interrupt_call); TEST_ASSERT_EQUAL_UINT32( - interface_stub.timestamp + TIMESTAMP_MAX_DELTA, + interface_stub.timestamp + TIMESTAMP_MAX_DELTA, interface_stub.interrupt_timestamp ); TEST_ASSERT_EQUAL_PTR(NULL, queue_stub.head->next); @@ -957,18 +961,18 @@ static void test_insert_event_us_in_overflow_range() ++queue_stub.present_time; ticker_event_t first_event = { 0 }; - const us_timestamp_t timestamp_first_event = + const us_timestamp_t timestamp_first_event = queue_stub.present_time + TIMESTAMP_MAX_DELTA + 1; uint32_t id_first_event = 0xAAAAAAAA; - ticker_insert_event_us(&ticker_stub, - &first_event, timestamp_first_event, id_first_event - ); + ticker_insert_event_us(&ticker_stub, + &first_event, timestamp_first_event, id_first_event + ); TEST_ASSERT_EQUAL_PTR(&first_event, queue_stub.head); - TEST_ASSERT_EQUAL(2, interface_stub.set_interrupt_call); + TEST_ASSERT_EQUAL(2, interface_stub.set_interrupt_call); TEST_ASSERT_EQUAL_UINT32( - interface_stub.timestamp + TIMESTAMP_MAX_DELTA, + interface_stub.timestamp + TIMESTAMP_MAX_DELTA, interface_stub.interrupt_timestamp ); TEST_ASSERT_EQUAL_PTR(&last_event, queue_stub.head->next); @@ -976,13 +980,13 @@ static void test_insert_event_us_in_overflow_range() TEST_ASSERT_EQUAL_UINT32(id_first_event, first_event.id); TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); -} +} /** - * Given an initialized ticker without user registered events. - * When an event is inserted with ticker_insert_event_us and a timestamp less + * Given an initialized ticker without user registered events. + * When an event is inserted with ticker_insert_event_us and a timestamp less * than timestamp value in the ticker interface. - * Then + * Then * - The event should be in the queue * - The interrupt timestamp should be set to interface_stub.timestamp so it * is scheduled immediately. @@ -1010,18 +1014,18 @@ static void test_insert_event_us_underflow() TEST_ASSERT_EQUAL(1, interface_stub.fire_interrupt_call); TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); -} +} /** * Given an initialized ticker. - * When an event is inserted with ticker_insert_event_us and a timestamp less + * When an event is inserted with ticker_insert_event_us and a timestamp less * than the one for the next scheduled timestamp. - * Then + * Then * - The event inserted should be the first in the queue - * - The interrupt timestamp should be equal to the timestamp of the event or + * - The interrupt timestamp should be equal to the timestamp of the event or * TIMESTAMP_MAX_DELTA if in the overflow range. - * - The timestamp of the event should be equal to the timestamp in parameter. - * - The id of the event should be equal to the id passed in parameter. + * - The timestamp of the event should be equal to the timestamp in parameter. + * - The id of the event should be equal to the id passed in parameter. * - Events in the queue should remained ordered by timestamp. */ static void test_insert_event_us_head() @@ -1032,7 +1036,7 @@ static void test_insert_event_us_head() queue_stub.tick_last_read = interface_stub.timestamp; queue_stub.present_time = 10ULL << 32 | interface_stub.timestamp; - const us_timestamp_t timestamps[] = { + const us_timestamp_t timestamps[] = { UINT64_MAX, queue_stub.present_time + TIMESTAMP_MAX_DELTA + 1, queue_stub.present_time + TIMESTAMP_MAX_DELTA, @@ -1043,19 +1047,19 @@ static void test_insert_event_us_head() }; ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 }; - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_insert_event_us( - &ticker_stub, + &ticker_stub, &events[i], timestamps[i], i ); TEST_ASSERT_EQUAL_PTR(&events[i], queue_stub.head); if ((timestamps[i] - queue_stub.present_time) < TIMESTAMP_MAX_DELTA) { TEST_ASSERT_EQUAL_UINT32( - timestamps[i], + timestamps[i], interface_stub.interrupt_timestamp ); - } else { + } else { TEST_ASSERT_EQUAL_UINT32( queue_stub.present_time + TIMESTAMP_MAX_DELTA, interface_stub.interrupt_timestamp @@ -1065,13 +1069,13 @@ static void test_insert_event_us_head() TEST_ASSERT_EQUAL_UINT64(timestamps[i], events[i].timestamp); TEST_ASSERT_EQUAL_UINT32(i, events[i].id); - ticker_event_t* e = &events[i]; - while (e) { + ticker_event_t *e = &events[i]; + while (e) { TEST_ASSERT_EQUAL_UINT32(timestamps[e->id], e->timestamp); - if (e->next) { + if (e->next) { TEST_ASSERT_TRUE(e->id > e->next->id); TEST_ASSERT_TRUE(e->timestamp < e->next->timestamp); - } else { + } else { TEST_ASSERT_EQUAL_UINT32(0, e->id); } e = e->next; @@ -1079,18 +1083,18 @@ static void test_insert_event_us_head() } TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); -} +} -/** +/** * Given an initialized ticker. - * When an event is inserted with ticker_insert_event_us and its timestamp is + * When an event is inserted with ticker_insert_event_us and its timestamp is * bigger than the one of the last event in the queue. - * Then + * Then * - The event inserted should be the last in the queue - * - The interrupt timestamp should remains equal to the interrupt timestamp + * - The interrupt timestamp should remains equal to the interrupt timestamp * of the head event . * - The timestamp of the event should reflect the timestamp requested. - * - The id of the event should be equal to the id passed in parameter. + * - The id of the event should be equal to the id passed in parameter. * - Events in the queue should remained ordered by timestamp. */ static void test_insert_event_us_tail() @@ -1098,7 +1102,7 @@ static void test_insert_event_us_tail() ticker_set_handler(&ticker_stub, NULL); interface_stub.set_interrupt_call = 0; - const us_timestamp_t timestamps[] = { + const us_timestamp_t timestamps[] = { 0xA, (1ULL << 32), (2ULL << 32), @@ -1110,26 +1114,26 @@ static void test_insert_event_us_tail() }; ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 }; - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_insert_event_us( - &ticker_stub, + &ticker_stub, &events[i], timestamps[i], i ); - TEST_ASSERT_EQUAL_PTR(&events[0], queue_stub.head); + TEST_ASSERT_EQUAL_PTR(&events[0], queue_stub.head); TEST_ASSERT_EQUAL_UINT32( timestamps[0], interface_stub.interrupt_timestamp ); TEST_ASSERT_EQUAL_UINT64(timestamps[i], events[i].timestamp); TEST_ASSERT_EQUAL_UINT32(i, events[i].id); - ticker_event_t* e = queue_stub.head; - while (e) { + ticker_event_t *e = queue_stub.head; + while (e) { TEST_ASSERT_EQUAL_UINT32(timestamps[e->id], e->timestamp); - if (e->next) { + if (e->next) { TEST_ASSERT_TRUE(e->id < e->next->id); TEST_ASSERT_TRUE(e->timestamp < e->next->timestamp); - } else { + } else { TEST_ASSERT_EQUAL_UINT32(&events[i], e); } e = e->next; @@ -1137,19 +1141,19 @@ static void test_insert_event_us_tail() } TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); -} +} /** * Given an initialized ticker. * When an event is inserted with ticker_insert_event_us. - * Then + * Then * - The event inserted should be at the correct position in the queue * - The event queue should remain ordered by timestamp - * - The interrupt timestamp should be equal to the interrupt timestamp - * of the head event or TIMESTAMP_MAX_DELTA if the + * - The interrupt timestamp should be equal to the interrupt timestamp + * of the head event or TIMESTAMP_MAX_DELTA if the * timestamp is in the overflow range. * - The timestamp of the event should be equal to the timestamp parameter. - * - The id of the event should be equal to the id passed in parameter. + * - The id of the event should be equal to the id passed in parameter. * - Events in the queue should remained ordered by timestamp. */ static void test_insert_event_us_multiple_random() @@ -1160,9 +1164,9 @@ static void test_insert_event_us_multiple_random() const timestamp_t ref_timestamp = UINT32_MAX / 2; interface_stub.timestamp = ref_timestamp; - // insert first event at the head of the queue + // insert first event at the head of the queue ticker_event_t first_event; - const us_timestamp_t first_event_timestamp = + const us_timestamp_t first_event_timestamp = ref_timestamp + TIMESTAMP_MAX_DELTA + 100; ticker_insert_event_us( @@ -1199,7 +1203,7 @@ static void test_insert_event_us_multiple_random() // insert third event at the head of the queue out the overflow zone ticker_event_t third_event; - const us_timestamp_t third_event_timestamp = + const us_timestamp_t third_event_timestamp = ref_timestamp + TIMESTAMP_MAX_DELTA - 100; ticker_insert_event_us( @@ -1241,17 +1245,17 @@ static void test_insert_event_us_multiple_random() } /** - * Given an initialized ticker with multiple events registered. + * Given an initialized ticker with multiple events registered. * When the event at the tail of the queue is removed from the queue. - * Then: + * Then: * - The event should not be in the queue. * - The events in the queue should remain ordered - * - The interrupt timestamp should be unchanged. + * - The interrupt timestamp should be unchanged. */ static void test_remove_event_tail() { ticker_set_handler(&ticker_stub, NULL); - const us_timestamp_t timestamps[] = { + const us_timestamp_t timestamps[] = { 0xA, (1ULL << 32), (2ULL << 32), @@ -1263,21 +1267,21 @@ static void test_remove_event_tail() }; ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 }; - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_insert_event_us( - &ticker_stub, + &ticker_stub, &events[i], timestamps[i], i ); } - for (ssize_t i = MBED_ARRAY_SIZE(events) - 1; i >= 0; --i) { + for (ssize_t i = MBED_ARRAY_SIZE(events) - 1; i >= 0; --i) { ticker_remove_event(&ticker_stub, &events[i]); - ticker_event_t* e = queue_stub.head; + ticker_event_t *e = queue_stub.head; size_t event_count = 0; - while (e) { + while (e) { TEST_ASSERT_NOT_EQUAL(e, &events[i]); - if (e->next) { + if (e->next) { TEST_ASSERT_TRUE(e->timestamp <= e->next->timestamp); } e = e->next; @@ -1286,12 +1290,12 @@ static void test_remove_event_tail() TEST_ASSERT_EQUAL(i, event_count); - if (i != 0 ) { + if (i != 0) { TEST_ASSERT_EQUAL( timestamps[0], interface_stub.interrupt_timestamp ); - } else { + } else { TEST_ASSERT_EQUAL( interface_stub.timestamp + TIMESTAMP_MAX_DELTA, interface_stub.interrupt_timestamp @@ -1303,20 +1307,20 @@ static void test_remove_event_tail() } /** - * Given an initialized ticker with multiple events registered. + * Given an initialized ticker with multiple events registered. * When the event at the head of the queue is removed from the queue. - * Then: + * Then: * - The event should not be in the queue. - * - The event at the head of the queue should be the equal to the one + * - The event at the head of the queue should be the equal to the one * after the event removed. - * - The interrupt timestamp should be equal to the interrupt timestamp - * of the head event or TIMESTAMP_MAX_DELTA if the + * - The interrupt timestamp should be equal to the interrupt timestamp + * of the head event or TIMESTAMP_MAX_DELTA if the * timestamp is in the overflow range. */ static void test_remove_event_head() { ticker_set_handler(&ticker_stub, NULL); - const us_timestamp_t timestamps[] = { + const us_timestamp_t timestamps[] = { TIMESTAMP_MAX_DELTA / 8, TIMESTAMP_MAX_DELTA / 4, TIMESTAMP_MAX_DELTA / 2, @@ -1328,20 +1332,20 @@ static void test_remove_event_head() }; ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 }; - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { - ticker_insert_event_us(&ticker_stub, - &events[i], timestamps[i], i - ); + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + ticker_insert_event_us(&ticker_stub, + &events[i], timestamps[i], i + ); } - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_remove_event(&ticker_stub, &events[i]); - ticker_event_t* e = queue_stub.head; + ticker_event_t *e = queue_stub.head; size_t event_count = 0; - while (e) { + while (e) { TEST_ASSERT_NOT_EQUAL(e, &events[i]); - if (e->next) { + if (e->next) { TEST_ASSERT_TRUE(e->timestamp <= e->next->timestamp); } e = e->next; @@ -1350,15 +1354,15 @@ static void test_remove_event_head() TEST_ASSERT_EQUAL(MBED_ARRAY_SIZE(events) - i - 1, event_count); - if (event_count) { + if (event_count) { TEST_ASSERT_EQUAL( std::min( - timestamps[i + 1], + timestamps[i + 1], interface_stub.timestamp + TIMESTAMP_MAX_DELTA ), interface_stub.interrupt_timestamp ); - } else { + } else { TEST_ASSERT_EQUAL( interface_stub.timestamp + TIMESTAMP_MAX_DELTA, interface_stub.interrupt_timestamp @@ -1371,14 +1375,14 @@ static void test_remove_event_head() } /** - * Given an initialized ticker with multiple events registered. + * Given an initialized ticker with multiple events registered. * When an event not in the queue is attempted to be removed. * Then the queue should remains identical as before. */ static void test_remove_event_invalid() { ticker_set_handler(&ticker_stub, NULL); - const us_timestamp_t timestamps[] = { + const us_timestamp_t timestamps[] = { TIMESTAMP_MAX_DELTA / 8, TIMESTAMP_MAX_DELTA / 4, TIMESTAMP_MAX_DELTA / 2, @@ -1390,9 +1394,9 @@ static void test_remove_event_invalid() }; ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 }; - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_insert_event_us( - &ticker_stub, + &ticker_stub, &events[i], timestamps[i], i ); } @@ -1402,9 +1406,9 @@ static void test_remove_event_invalid() TEST_ASSERT_EQUAL(&events[0], queue_stub.head); - ticker_event_t* e = queue_stub.head; + ticker_event_t *e = queue_stub.head; size_t event_count = 0; - while (e) { + while (e) { TEST_ASSERT_EQUAL(e, &events[event_count]); e = e->next; ++event_count; @@ -1418,8 +1422,8 @@ static void test_remove_event_invalid() * Then: * - the event should not be in the queue * - the queue should remain ordered - * - the interrupt timestamp should be set to either head->timestamp or - * TIMESTAMP_MAX_DELTA depending on the distance between the current time + * - the interrupt timestamp should be set to either head->timestamp or + * TIMESTAMP_MAX_DELTA depending on the distance between the current time * ans the timestamp of the event at the head of the queue. */ static void test_remove_random() @@ -1430,9 +1434,9 @@ static void test_remove_random() const timestamp_t ref_timestamp = UINT32_MAX / 2; interface_stub.timestamp = ref_timestamp; - // insert all events + // insert all events ticker_event_t first_event; - const us_timestamp_t first_event_timestamp = + const us_timestamp_t first_event_timestamp = ref_timestamp + TIMESTAMP_MAX_DELTA + 100; ticker_insert_event_us( @@ -1450,7 +1454,7 @@ static void test_remove_random() ); ticker_event_t third_event; - const us_timestamp_t third_event_timestamp = + const us_timestamp_t third_event_timestamp = ref_timestamp + TIMESTAMP_MAX_DELTA - 100; ticker_insert_event_us( @@ -1466,7 +1470,7 @@ static void test_remove_random() &fourth_event, fourth_event_timestamp, (uint32_t) &fourth_event ); - // test that the queue is in the correct state + // test that the queue is in the correct state TEST_ASSERT_EQUAL_PTR(&third_event, queue_stub.head); TEST_ASSERT_EQUAL_PTR(&fourth_event, third_event.next); TEST_ASSERT_EQUAL_PTR(&first_event, fourth_event.next); @@ -1478,7 +1482,7 @@ static void test_remove_random() TEST_ASSERT_EQUAL_UINT64(fourth_event_timestamp, fourth_event.timestamp); TEST_ASSERT_EQUAL_UINT32((uint32_t) &fourth_event, fourth_event.id); - // remove fourth event + // remove fourth event ticker_remove_event(&ticker_stub, &fourth_event); TEST_ASSERT_EQUAL_PTR(&third_event, queue_stub.head); @@ -1491,7 +1495,7 @@ static void test_remove_random() TEST_ASSERT_EQUAL_UINT64(third_event_timestamp, third_event.timestamp); TEST_ASSERT_EQUAL_UINT32((uint32_t) &third_event, third_event.id); - // remove third event + // remove third event ticker_remove_event(&ticker_stub, &third_event); TEST_ASSERT_EQUAL_PTR(&first_event, queue_stub.head); @@ -1503,7 +1507,7 @@ static void test_remove_random() TEST_ASSERT_EQUAL_UINT64(second_event_timestamp, second_event.timestamp); TEST_ASSERT_EQUAL_UINT32((uint32_t) &second_event, second_event.id); - // remove second event + // remove second event ticker_remove_event(&ticker_stub, &second_event); TEST_ASSERT_EQUAL_PTR(&first_event, queue_stub.head); @@ -1514,7 +1518,7 @@ static void test_remove_random() TEST_ASSERT_EQUAL_UINT64(first_event.timestamp, first_event_timestamp); TEST_ASSERT_EQUAL_UINT32((uint32_t) &first_event, first_event.id); - // remove first event + // remove first event ticker_remove_event(&ticker_stub, &first_event); TEST_ASSERT_EQUAL_PTR(NULL, queue_stub.head); @@ -1526,21 +1530,22 @@ static void test_remove_random() TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); } -/** - * Given an initialized ticker without user registered events and a ticker - * interface timestamp equal or bigger than the one registered by the overflow +/** + * Given an initialized ticker without user registered events and a ticker + * interface timestamp equal or bigger than the one registered by the overflow * event. * When the interrupt handler is called. * Then: - * - The interrupt timestamp should be updated to the timestamp of the ticker - * interface plus TIMESTAMP_MAX_DELTA. + * - The interrupt timestamp should be updated to the timestamp of the ticker + * interface plus TIMESTAMP_MAX_DELTA. * - The irq handler registered should not be called. */ static void test_overflow_event_update() { static uint32_t handler_call = 0; - struct irq_handler_stub_t { - static void event_handler(uint32_t id) { + struct irq_handler_stub_t { + static void event_handler(uint32_t id) + { ++handler_call; } }; @@ -1551,10 +1556,10 @@ static void test_overflow_event_update() for (size_t i = 0; i < 8; ++i) { us_timestamp_t previous_timestamp = queue_stub.present_time; - timestamp_t interface_timestamp = + timestamp_t interface_timestamp = previous_timestamp + (TIMESTAMP_MAX_DELTA + i * 100); interface_stub.timestamp = interface_timestamp; - + ticker_irq_handler(&ticker_stub); TEST_ASSERT_EQUAL(i + 1, interface_stub.clear_interrupt_call); @@ -1567,22 +1572,23 @@ static void test_overflow_event_update() } TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); -} +} -/** - * Given an initialized ticker without user registered events and a ticker +/** + * Given an initialized ticker without user registered events and a ticker * interface timestamp less than the one registered to handle overflow. * When the interrupt handler is called. * Then: - * - The interrupt timestamp should be updated to the timestamp of the ticker - * interface plus TIMESTAMP_MAX_DELTA. + * - The interrupt timestamp should be updated to the timestamp of the ticker + * interface plus TIMESTAMP_MAX_DELTA. * - The irq handler registered should not be called. */ static void test_overflow_event_update_when_spurious_interrupt() { static uint32_t handler_call = 0; - struct irq_handler_stub_t { - static void event_handler(uint32_t id) { + struct irq_handler_stub_t { + static void event_handler(uint32_t id) + { ++handler_call; } }; @@ -1593,10 +1599,10 @@ static void test_overflow_event_update_when_spurious_interrupt() for (size_t i = 0; i < 8; ++i) { us_timestamp_t previous_timestamp = queue_stub.present_time; - timestamp_t interface_timestamp = + timestamp_t interface_timestamp = previous_timestamp + (TIMESTAMP_MAX_DELTA / (2 + i)); interface_stub.timestamp = interface_timestamp; - + ticker_irq_handler(&ticker_stub); TEST_ASSERT_EQUAL(i + 1, interface_stub.clear_interrupt_call); @@ -1609,18 +1615,18 @@ static void test_overflow_event_update_when_spurious_interrupt() } TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); -} +} /** - * Given an initialized ticker with a single ticker event inserted and a ticker - * interface timestamp bigger than the one set for interrupt. + * Given an initialized ticker with a single ticker event inserted and a ticker + * interface timestamp bigger than the one set for interrupt. * When ticker_irq_handler is called. - * Then: - * - The IRQ handler should be called with the id of the event at the head of + * Then: + * - The IRQ handler should be called with the id of the event at the head of * the queue. * - The event at the head of the queue should be replaced by the next event. - * - The interrupt timestamp in the ticker interface should be set to the - * value of the interface timestamp + TIMESTAMP_MAX_DELTA + * - The interrupt timestamp in the ticker interface should be set to the + * value of the interface timestamp + TIMESTAMP_MAX_DELTA */ static void test_irq_handler_single_event() { @@ -1628,9 +1634,10 @@ static void test_irq_handler_single_event() static const timestamp_t interface_timestamp_after_irq = event_timestamp + 100; uint32_t handler_call = 0; - struct irq_handler_stub_t { - static void event_handler(uint32_t id) { - ++ (*((uint32_t*) id)); + struct irq_handler_stub_t { + static void event_handler(uint32_t id) + { + ++ (*((uint32_t *) id)); interface_stub.timestamp = interface_timestamp_after_irq; } }; @@ -1638,7 +1645,7 @@ static void test_irq_handler_single_event() ticker_set_handler(&ticker_stub, irq_handler_stub_t::event_handler); interface_stub.set_interrupt_call = 0; - ticker_event_t e; + ticker_event_t e; ticker_insert_event(&ticker_stub, &e, event_timestamp, (uint32_t) &handler_call); interface_stub.timestamp = event_timestamp; @@ -1660,19 +1667,20 @@ static void test_irq_handler_single_event() } /** - * Given an initialized ticker with at least a ticker event inserted and a ticker - * interface timestamp less than the one set for interrupt. + * Given an initialized ticker with at least a ticker event inserted and a ticker + * interface timestamp less than the one set for interrupt. * When ticker_irq_handler is called. - * Then: + * Then: * - The IRQ handler should not be called. * - The event at the head of the queue should remains the same. - * - The interrupt timestamp in the ticker interface should be set to the - * value of the event timestamp + * - The interrupt timestamp in the ticker interface should be set to the + * value of the event timestamp */ static void test_irq_handler_single_event_spurious() { - struct irq_handler_stub_t { - static void event_handler(uint32_t id) { + struct irq_handler_stub_t { + static void event_handler(uint32_t id) + { TEST_FAIL(); } }; @@ -1681,17 +1689,17 @@ static void test_irq_handler_single_event_spurious() interface_stub.set_interrupt_call = 0; const us_timestamp_t timestamps [] = { - UINT32_MAX, - TIMESTAMP_MAX_DELTA + 1, + UINT32_MAX, + TIMESTAMP_MAX_DELTA + 1, TIMESTAMP_MAX_DELTA, TIMESTAMP_MAX_DELTA - 1 }; ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 }; - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_insert_event_us( - &ticker_stub, + &ticker_stub, &events[i], timestamps[i], timestamps[i] ); interface_stub.set_interrupt_call = 0; @@ -1711,11 +1719,11 @@ static void test_irq_handler_single_event_spurious() } /** - * Given an initialized ticker with multiple ticker event inserted, its - * interface timestamp at greater than the timestamp of the next schedule event + * Given an initialized ticker with multiple ticker event inserted, its + * interface timestamp at greater than the timestamp of the next schedule event * and all event execution time taking at least the time befor ethe next event. * When ticker_irq_handler is called. - * Then: + * Then: * - The IRQ handler should have been called for every event. * - The head of the queue should be set to NULL. * - The interrupt timestamp in the ticker interface should be scheduled in @@ -1724,19 +1732,20 @@ static void test_irq_handler_single_event_spurious() static void test_irq_handler_multiple_event_multiple_dequeue() { const us_timestamp_t timestamps [] = { - 10, + 10, 10 + TIMESTAMP_MAX_DELTA - 1, 10 + TIMESTAMP_MAX_DELTA, - 10 + TIMESTAMP_MAX_DELTA + 1, + 10 + TIMESTAMP_MAX_DELTA + 1, UINT32_MAX }; static size_t handler_called = 0; - struct irq_handler_stub_t { - static void event_handler(uint32_t id) { + struct irq_handler_stub_t { + static void event_handler(uint32_t id) + { ++handler_called; - ticker_event_t* e = (ticker_event_t*) id; - if (e->next) { + ticker_event_t *e = (ticker_event_t *) id; + if (e->next) { interface_stub.timestamp = e->next->timestamp; } } @@ -1748,9 +1757,9 @@ static void test_irq_handler_multiple_event_multiple_dequeue() ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 }; - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_insert_event_us( - &ticker_stub, + &ticker_stub, &events[i], timestamps[i], (uint32_t) &events[i] ); } @@ -1758,7 +1767,7 @@ static void test_irq_handler_multiple_event_multiple_dequeue() interface_stub.set_interrupt_call = 0; interface_stub.clear_interrupt_call = 0; interface_stub.timestamp = timestamps[0]; - + ticker_irq_handler(&ticker_stub); TEST_ASSERT_EQUAL(1, interface_stub.clear_interrupt_call); @@ -1774,11 +1783,11 @@ static void test_irq_handler_multiple_event_multiple_dequeue() } /** - * Given an initialized ticker with two ticker event inserted scheduled from more - * than TIMESTAMP_MAX_DELTA from one another. The interface - * timestamp is equal to the timestamp of the first event. + * Given an initialized ticker with two ticker event inserted scheduled from more + * than TIMESTAMP_MAX_DELTA from one another. The interface + * timestamp is equal to the timestamp of the first event. * When ticker_irq_handler is called. - * Then: + * Then: * - The IRQ handler should have been called for the first event. * - The head of the queue should be set to the event after the first event. * - The interrupt timestamp in the ticker interface should be scheduled in @@ -1787,14 +1796,15 @@ static void test_irq_handler_multiple_event_multiple_dequeue() static void test_irq_handler_multiple_event_single_dequeue_overflow() { const us_timestamp_t timestamps [] = { - 10, + 10, 10 + TIMESTAMP_MAX_DELTA + 1 }; size_t handler_called = 0; - struct irq_handler_stub_t { - static void event_handler(uint32_t id) { - ++ (*((size_t*) id)); + struct irq_handler_stub_t { + static void event_handler(uint32_t id) + { + ++ (*((size_t *) id)); } }; @@ -1803,9 +1813,9 @@ static void test_irq_handler_multiple_event_single_dequeue_overflow() ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 }; - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_insert_event_us( - &ticker_stub, + &ticker_stub, &events[i], timestamps[i], (uint32_t) &handler_called ); } @@ -1813,7 +1823,7 @@ static void test_irq_handler_multiple_event_single_dequeue_overflow() interface_stub.set_interrupt_call = 0; interface_stub.clear_interrupt_call = 0; interface_stub.timestamp = timestamps[0]; - + ticker_irq_handler(&ticker_stub); TEST_ASSERT_EQUAL(1, interface_stub.clear_interrupt_call); @@ -1829,27 +1839,28 @@ static void test_irq_handler_multiple_event_single_dequeue_overflow() } /** - * Given an initialized ticker with two ticker event inserted scheduled from less - * than TIMESTAMP_MAX_DELTA from one another. The interface - * timestamp is equal to the timestamp of the first event. + * Given an initialized ticker with two ticker event inserted scheduled from less + * than TIMESTAMP_MAX_DELTA from one another. The interface + * timestamp is equal to the timestamp of the first event. * When ticker_irq_handler is called. - * Then: + * Then: * - The IRQ handler should have been called for the first event. * - The head of the queue should be set to second event. - * - The interrupt timestamp in the ticker interface should be equal to the + * - The interrupt timestamp in the ticker interface should be equal to the * timestamp of the second event. */ static void test_irq_handler_multiple_event_single_dequeue() { const us_timestamp_t timestamps [] = { - 10, + 10, 10 + TIMESTAMP_MAX_DELTA - 1 }; size_t handler_called = 0; - struct irq_handler_stub_t { - static void event_handler(uint32_t id) { - ++ (*((size_t*) id)); + struct irq_handler_stub_t { + static void event_handler(uint32_t id) + { + ++ (*((size_t *) id)); } }; @@ -1858,9 +1869,9 @@ static void test_irq_handler_multiple_event_single_dequeue() ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 }; - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_insert_event_us( - &ticker_stub, + &ticker_stub, &events[i], timestamps[i], (uint32_t) &handler_called ); } @@ -1868,7 +1879,7 @@ static void test_irq_handler_multiple_event_single_dequeue() interface_stub.set_interrupt_call = 0; interface_stub.clear_interrupt_call = 0; interface_stub.timestamp = timestamps[0]; - + ticker_irq_handler(&ticker_stub); TEST_ASSERT_EQUAL(1, interface_stub.clear_interrupt_call); @@ -1884,47 +1895,48 @@ static void test_irq_handler_multiple_event_single_dequeue() } /** - * Given an initialized ticker with multiple ticker event inserted and the + * Given an initialized ticker with multiple ticker event inserted and the * interface timestamp is equal to the timestamp of the first event. The first - * event to execute will insert an events in the ticker which have to be executed + * event to execute will insert an events in the ticker which have to be executed * immediately. * When ticker_irq_handler is called. - * Then: - * - The IRQ handler should have been called for the first event and the event + * Then: + * - The IRQ handler should have been called for the first event and the event * inserted during irq. * - The head of the queue should be set correctly. - * - The interrupt timestamp in the ticker interface should be equal to + * - The interrupt timestamp in the ticker interface should be equal to * timestamp of the head event. */ static void test_irq_handler_insert_immediate_in_irq() { static const us_timestamp_t timestamps [] = { - 10, + 10, 10 + TIMESTAMP_MAX_DELTA - 1 }; - static const us_timestamp_t expected_timestamp = + static const us_timestamp_t expected_timestamp = ((timestamps[1] - timestamps[0]) / 2) + timestamps[0]; - struct ctrl_block_t { + struct ctrl_block_t { bool irq_event_called; - ticker_event_t immediate_event; + ticker_event_t immediate_event; size_t handler_called; }; ctrl_block_t ctrl_block = { 0 }; - struct irq_handler_stub_t { - static void event_handler(uint32_t id) { - ctrl_block_t* ctrl_block = (ctrl_block_t*) id; + struct irq_handler_stub_t { + static void event_handler(uint32_t id) + { + ctrl_block_t *ctrl_block = (ctrl_block_t *) id; if (ctrl_block->handler_called == 0) { ticker_insert_event( - &ticker_stub, + &ticker_stub, &ctrl_block->immediate_event, expected_timestamp, id ); interface_stub.timestamp = expected_timestamp; - } else if (ctrl_block->handler_called > 1) { + } else if (ctrl_block->handler_called > 1) { TEST_FAIL(); } ++ctrl_block->handler_called; @@ -1936,9 +1948,9 @@ static void test_irq_handler_insert_immediate_in_irq() ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 }; - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_insert_event_us( - &ticker_stub, + &ticker_stub, &events[i], timestamps[i], (uint32_t) &ctrl_block ); } @@ -1946,7 +1958,7 @@ static void test_irq_handler_insert_immediate_in_irq() interface_stub.set_interrupt_call = 0; interface_stub.clear_interrupt_call = 0; interface_stub.timestamp = timestamps[0]; - + ticker_irq_handler(&ticker_stub); TEST_ASSERT_EQUAL(1, interface_stub.clear_interrupt_call); @@ -1961,45 +1973,46 @@ static void test_irq_handler_insert_immediate_in_irq() } /** - * Given an initialized ticker with multiple ticker event inserted and the + * Given an initialized ticker with multiple ticker event inserted and the * interface timestamp is equal to the timestamp of the first event. The first - * event to execute will insert an events in the ticker which does not have to + * event to execute will insert an events in the ticker which does not have to * be executed immediately. * When ticker_irq_handler is called. - * Then: + * Then: * - The IRQ handler should have been called for the first event. * - The head of the queue should be set to the event inserted in IRQ. - * - The interrupt timestamp in the ticker interface should be equal to + * - The interrupt timestamp in the ticker interface should be equal to * timestamp of the head event. */ static void test_irq_handler_insert_non_immediate_in_irq() { static const us_timestamp_t timestamps [] = { - 10, + 10, 10 + TIMESTAMP_MAX_DELTA - 1 }; - static const us_timestamp_t expected_timestamp = + static const us_timestamp_t expected_timestamp = ((timestamps[1] - timestamps[0]) / 2) + timestamps[0]; - struct ctrl_block_t { + struct ctrl_block_t { bool irq_event_called; - ticker_event_t non_immediate_event; + ticker_event_t non_immediate_event; size_t handler_called; }; ctrl_block_t ctrl_block = { 0 }; - struct irq_handler_stub_t { - static void event_handler(uint32_t id) { - ctrl_block_t* ctrl_block = (ctrl_block_t*) id; + struct irq_handler_stub_t { + static void event_handler(uint32_t id) + { + ctrl_block_t *ctrl_block = (ctrl_block_t *) id; if (ctrl_block->handler_called == 0) { ticker_insert_event( - &ticker_stub, + &ticker_stub, &ctrl_block->non_immediate_event, expected_timestamp, id ); - } else { + } else { TEST_FAIL(); } ++ctrl_block->handler_called; @@ -2012,9 +2025,9 @@ static void test_irq_handler_insert_non_immediate_in_irq() ticker_event_t events[MBED_ARRAY_SIZE(timestamps)] = { 0 }; - for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { + for (size_t i = 0; i < MBED_ARRAY_SIZE(events); ++i) { ticker_insert_event_us( - &ticker_stub, + &ticker_stub, &events[i], timestamps[i], (uint32_t) &ctrl_block ); } @@ -2022,7 +2035,7 @@ static void test_irq_handler_insert_non_immediate_in_irq() interface_stub.set_interrupt_call = 0; interface_stub.clear_interrupt_call = 0; interface_stub.timestamp = timestamps[0]; - + ticker_irq_handler(&ticker_stub); TEST_ASSERT_EQUAL(1, interface_stub.clear_interrupt_call); @@ -2046,7 +2059,7 @@ static uint32_t ticker_interface_stub_read_interrupt_time() } else { return interface_stub.timestamp; } -} +} /** * Test to insert an event that is already in the past, the fire_interrupt should @@ -2223,28 +2236,28 @@ typedef struct { static void test_match_interval_passed_table() { static const match_interval_entry_t test_values[] = { - /* prev, cur, match, result */ - {0x00000000, 0x00000000, 0x00000000, false}, - {0x00000000, 0x00000000, 0xffffffff, false}, - {0x00000000, 0x00000000, 0x00000001, false}, - {0x00000000, 0xffffffff, 0x00000000, false}, - {0x00000000, 0x00000001, 0x00000000, false}, - {0xffffffff, 0x00000000, 0x00000000, true}, - {0x00000001, 0x00000000, 0x00000000, true}, - {0x00005555, 0x00005555, 0x00005555, false}, - {0x00005555, 0x00005555, 0x00005554, false}, - {0x00005555, 0x00005555, 0x00005556, false}, - {0x00005555, 0x00005554, 0x00005555, false}, - {0x00005555, 0x00005556, 0x00005555, false}, - {0x00005554, 0x00005555, 0x00005555, true}, - {0x00005556, 0x00005555, 0x00005555, true}, - {0xffffffff, 0xffffffff, 0xffffffff, false}, - {0xffffffff, 0xffffffff, 0xfffffffe, false}, - {0xffffffff, 0xffffffff, 0x00000000, false}, - {0xffffffff, 0xfffffffe, 0xffffffff, false}, - {0xffffffff, 0x00000000, 0xffffffff, false}, - {0xfffffffe, 0xffffffff, 0xffffffff, true}, - {0x00000000, 0xffffffff, 0xffffffff, true}, + /* prev, cur, match, result */ + {0x00000000, 0x00000000, 0x00000000, false}, + {0x00000000, 0x00000000, 0xffffffff, false}, + {0x00000000, 0x00000000, 0x00000001, false}, + {0x00000000, 0xffffffff, 0x00000000, false}, + {0x00000000, 0x00000001, 0x00000000, false}, + {0xffffffff, 0x00000000, 0x00000000, true}, + {0x00000001, 0x00000000, 0x00000000, true}, + {0x00005555, 0x00005555, 0x00005555, false}, + {0x00005555, 0x00005555, 0x00005554, false}, + {0x00005555, 0x00005555, 0x00005556, false}, + {0x00005555, 0x00005554, 0x00005555, false}, + {0x00005555, 0x00005556, 0x00005555, false}, + {0x00005554, 0x00005555, 0x00005555, true}, + {0x00005556, 0x00005555, 0x00005555, true}, + {0xffffffff, 0xffffffff, 0xffffffff, false}, + {0xffffffff, 0xffffffff, 0xfffffffe, false}, + {0xffffffff, 0xffffffff, 0x00000000, false}, + {0xffffffff, 0xfffffffe, 0xffffffff, false}, + {0xffffffff, 0x00000000, 0xffffffff, false}, + {0xfffffffe, 0xffffffff, 0xffffffff, true}, + {0x00000000, 0xffffffff, 0xffffffff, true}, }; for (int i = 0; i < MBED_ARRAY_SIZE(test_values); i++) { const uint32_t prev = test_values[i].prev; @@ -2263,11 +2276,11 @@ static const case_t cases[] = { MAKE_TEST_CASE("ticker read", test_ticker_read), MAKE_TEST_CASE("ticker read overflow", test_ticker_read_overflow), MAKE_TEST_CASE( - "legacy insert event outside overflow range", + "legacy insert event outside overflow range", test_legacy_insert_event_outside_overflow_range ), MAKE_TEST_CASE( - "legacy insert event in overflow range", + "legacy insert event in overflow range", test_legacy_insert_event_in_overflow_range ), MAKE_TEST_CASE( @@ -2280,19 +2293,19 @@ static const case_t cases[] = { "legacy insert event tail", test_legacy_insert_event_tail ), MAKE_TEST_CASE( - "legacy insert event multiple overflow", + "legacy insert event multiple overflow", test_legacy_insert_event_multiple_overflow ), MAKE_TEST_CASE( - "test_legacy_insert_event_multiple_random", + "test_legacy_insert_event_multiple_random", test_legacy_insert_event_multiple_random ), MAKE_TEST_CASE( - "test_insert_event_us_outside_overflow_range", + "test_insert_event_us_outside_overflow_range", test_insert_event_us_outside_overflow_range ), MAKE_TEST_CASE( - "test_insert_event_us_in_overflow_range", + "test_insert_event_us_in_overflow_range", test_insert_event_us_in_overflow_range ), MAKE_TEST_CASE( @@ -2301,7 +2314,7 @@ static const case_t cases[] = { MAKE_TEST_CASE("test_insert_event_us_head", test_insert_event_us_head), MAKE_TEST_CASE("test_insert_event_us_tail", test_insert_event_us_tail), MAKE_TEST_CASE( - "test_insert_event_us_multiple_random", + "test_insert_event_us_multiple_random", test_insert_event_us_multiple_random ), MAKE_TEST_CASE("test_remove_event_tail", test_remove_event_tail), @@ -2310,42 +2323,42 @@ static const case_t cases[] = { MAKE_TEST_CASE("test_remove_random", test_remove_random), MAKE_TEST_CASE("update overflow guard", test_overflow_event_update), MAKE_TEST_CASE( - "update overflow guard in case of spurious interrupt", + "update overflow guard in case of spurious interrupt", test_overflow_event_update_when_spurious_interrupt ), MAKE_TEST_CASE( "test_irq_handler_single_event", test_irq_handler_single_event ), MAKE_TEST_CASE( - "test_irq_handler_single_event_spurious", + "test_irq_handler_single_event_spurious", test_irq_handler_single_event_spurious ), MAKE_TEST_CASE( - "test_irq_handler_multiple_event_multiple_dequeue", + "test_irq_handler_multiple_event_multiple_dequeue", test_irq_handler_multiple_event_multiple_dequeue ), MAKE_TEST_CASE( - "test_irq_handler_multiple_event_single_dequeue_overflow", + "test_irq_handler_multiple_event_single_dequeue_overflow", test_irq_handler_multiple_event_single_dequeue_overflow ), MAKE_TEST_CASE( - "test_irq_handler_multiple_event_single_dequeue", + "test_irq_handler_multiple_event_single_dequeue", test_irq_handler_multiple_event_single_dequeue ), MAKE_TEST_CASE( - "test_irq_handler_insert_immediate_in_irq", + "test_irq_handler_insert_immediate_in_irq", test_irq_handler_insert_immediate_in_irq ), MAKE_TEST_CASE( - "test_irq_handler_insert_non_immediate_in_irq", + "test_irq_handler_insert_non_immediate_in_irq", test_irq_handler_insert_non_immediate_in_irq ), MAKE_TEST_CASE( - "test_set_interrupt_past_time", + "test_set_interrupt_past_time", test_set_interrupt_past_time ), MAKE_TEST_CASE( - "test_set_interrupt_past_time_with_delay", + "test_set_interrupt_past_time_with_delay", test_set_interrupt_past_time_with_delay ), MAKE_TEST_CASE( diff --git a/TESTS/mbed_hal/us_ticker/main.cpp b/TESTS/mbed_hal/us_ticker/main.cpp index 0aa8550817b..c701066f703 100644 --- a/TESTS/mbed_hal/us_ticker/main.cpp +++ b/TESTS/mbed_hal/us_ticker/main.cpp @@ -29,7 +29,7 @@ using namespace utest::v1; /* Test that the ticker has the correct frequency and number of bits. */ void us_ticker_info_test() { - const ticker_info_t* p_ticker_info = us_ticker_get_info(); + const ticker_info_t *p_ticker_info = us_ticker_get_info(); TEST_ASSERT(p_ticker_info->frequency >= 250000); TEST_ASSERT(p_ticker_info->frequency <= 8000000); diff --git a/TESTS/mbed_platform/FileHandle/TestFile.h b/TESTS/mbed_platform/FileHandle/TestFile.h index 1ec0315c49b..38e001ad009 100644 --- a/TESTS/mbed_platform/FileHandle/TestFile.h +++ b/TESTS/mbed_platform/FileHandle/TestFile.h @@ -39,10 +39,9 @@ class TestFile : public FileHandle { ssize_t read; _fnCalled = fnRead; - for(read = 0; (size_t)read < size; read++) - { - if(POS_IS_VALID(_pos)) { - ((uint8_t*)buffer)[read] = _data[_pos++]; + for (read = 0; (size_t)read < size; read++) { + if (POS_IS_VALID(_pos)) { + ((uint8_t *)buffer)[read] = _data[_pos++]; } else { break; } @@ -55,17 +54,16 @@ class TestFile : public FileHandle { ssize_t written; _fnCalled = fnWrite; - for(written = 0; (size_t)written < size; written++) - { - if(NEW_POS_IS_VALID(_pos)) { - _data[_pos++] = ((uint8_t*)buffer)[written]; + for (written = 0; (size_t)written < size; written++) { + if (NEW_POS_IS_VALID(_pos)) { + _data[_pos++] = ((uint8_t *)buffer)[written]; } else { - if(0 == written) { + if (0 == written) { return -ENOSPC; } break; } - if(_end < _pos) { + if (_end < _pos) { _end++; } } // for @@ -77,8 +75,7 @@ class TestFile : public FileHandle { _fnCalled = fnSeek; int32_t new_pos = INVALID_POS; - switch(whence) - { + switch (whence) { case SEEK_SET: new_pos = offset; break; @@ -96,7 +93,7 @@ class TestFile : public FileHandle { break; } - if(SEEK_POS_IS_VALID(new_pos)) { + if (SEEK_POS_IS_VALID(new_pos)) { _pos = new_pos; } else { return -EINVAL; diff --git a/TESTS/mbed_platform/Transaction/main.cpp b/TESTS/mbed_platform/Transaction/main.cpp index 0b2029be73d..46eb5768bef 100644 --- a/TESTS/mbed_platform/Transaction/main.cpp +++ b/TESTS/mbed_platform/Transaction/main.cpp @@ -23,7 +23,7 @@ using utest::v1::Case; static void dummy_callback(int) { - /* do nothing. */ + /* do nothing. */ } /** Test Transaction class - creation with initialisation @@ -43,7 +43,7 @@ void test_Transaction_init() const uint8_t word_width = 8; unsigned char tx_buffer[tx_buffer_size]; unsigned char rx_buffer[rx_buffer_size]; - const event_callback_t& callback = dummy_callback; + const event_callback_t &callback = dummy_callback; transaction_t transaction_data = { tx_buffer, tx_buffer_size, rx_buffer, rx_buffer_size, event_id, callback, word_width }; @@ -51,8 +51,8 @@ void test_Transaction_init() TEST_ASSERT_EQUAL(&object, test_transaction.get_object()); - TEST_ASSERT_EQUAL((void*)tx_buffer, test_transaction.get_transaction()->tx_buffer); - TEST_ASSERT_EQUAL((void*)rx_buffer, test_transaction.get_transaction()->rx_buffer); + TEST_ASSERT_EQUAL((void *)tx_buffer, test_transaction.get_transaction()->tx_buffer); + TEST_ASSERT_EQUAL((void *)rx_buffer, test_transaction.get_transaction()->rx_buffer); TEST_ASSERT_EQUAL(tx_buffer_size, test_transaction.get_transaction()->tx_length); TEST_ASSERT_EQUAL(rx_buffer_size, test_transaction.get_transaction()->rx_length); TEST_ASSERT_EQUAL(event_id, test_transaction.get_transaction()->event); diff --git a/TESTS/mbed_platform/critical_section/main.cpp b/TESTS/mbed_platform/critical_section/main.cpp index 16054310b65..43ce94c4fcf 100644 --- a/TESTS/mbed_platform/critical_section/main.cpp +++ b/TESTS/mbed_platform/critical_section/main.cpp @@ -38,7 +38,7 @@ void critical_section_raii_recursive(Timeout &timeout) depth++; TEST_ASSERT_TRUE(core_util_in_critical_section()); - if(depth < N) { + if (depth < N) { critical_section_raii_recursive(timeout); } else { // max depth reached - do the test @@ -87,7 +87,7 @@ void test_C_API(void) wait_us(wait_time_us); TEST_ASSERT_TRUE(callback_called); - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { core_util_critical_section_enter(); TEST_ASSERT_TRUE(core_util_in_critical_section()); } @@ -98,7 +98,7 @@ void test_C_API(void) TEST_ASSERT_FALSE(callback_called); TEST_ASSERT_TRUE(core_util_in_critical_section()); - for(int i = 0; i < N - 1; i++) { + for (int i = 0; i < N - 1; i++) { core_util_critical_section_exit(); TEST_ASSERT_TRUE(core_util_in_critical_section()); TEST_ASSERT_FALSE(callback_called); @@ -184,7 +184,7 @@ void test_CPP_API_enable_disable(void) wait_us(wait_time_us); TEST_ASSERT_TRUE(callback_called); - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { CriticalSectionLock::enable(); TEST_ASSERT_TRUE(core_util_in_critical_section()); } @@ -195,7 +195,7 @@ void test_CPP_API_enable_disable(void) TEST_ASSERT_FALSE(callback_called); TEST_ASSERT_TRUE(core_util_in_critical_section()); - for(int i = 0; i < N - 1; i++) { + for (int i = 0; i < N - 1; i++) { CriticalSectionLock::disable(); TEST_ASSERT_TRUE(core_util_in_critical_section()); TEST_ASSERT_FALSE(callback_called); diff --git a/TESTS/mbed_platform/error_handling/main.cpp b/TESTS/mbed_platform/error_handling/main.cpp index cca30aa1cb6..ca7602a1ce9 100644 --- a/TESTS/mbed_platform/error_handling/main.cpp +++ b/TESTS/mbed_platform/error_handling/main.cpp @@ -28,20 +28,20 @@ using utest::v1::Case; void test_error_count_and_reset() { int count = 7; - + //Log multiple errors and get the error count and make sure its 15 - for(int i=0; ithread_addr, error_ctx.thread_entry_address); @@ -134,7 +134,7 @@ void test_error_context_capture() TEST_ASSERT_EQUAL_UINT((uint32_t)current_thread->stack_mem, error_ctx.thread_stack_mem); #if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED TEST_ASSERT_EQUAL_STRING(MBED_FILENAME, error_ctx.error_filename); -#endif +#endif } #if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED @@ -143,59 +143,59 @@ void test_error_context_capture() void test_error_logging() { mbed_error_ctx error_ctx = {0}; - + //clear the current errors first mbed_clear_all_errors(); - + //log 3 errors and retrieve them to ensure they are correct - MBED_WARNING1(MBED_ERROR_INVALID_ARGUMENT, "Invalid argument", 1 ); - MBED_WARNING1(MBED_ERROR_INVALID_SIZE, "Invalid size", 2 ); - MBED_WARNING1(MBED_ERROR_INVALID_FORMAT, "Invalid format", 3 ); - - mbed_error_status_t status = mbed_get_error_hist_info( 0, &error_ctx ); + MBED_WARNING1(MBED_ERROR_INVALID_ARGUMENT, "Invalid argument", 1); + MBED_WARNING1(MBED_ERROR_INVALID_SIZE, "Invalid size", 2); + MBED_WARNING1(MBED_ERROR_INVALID_FORMAT, "Invalid format", 3); + + mbed_error_status_t status = mbed_get_error_hist_info(0, &error_ctx); TEST_ASSERT_EQUAL_UINT(MBED_ERROR_INVALID_ARGUMENT, error_ctx.error_status); TEST_ASSERT_EQUAL_UINT(1, error_ctx.error_value); - - status = mbed_get_error_hist_info( 1, &error_ctx ); + + status = mbed_get_error_hist_info(1, &error_ctx); TEST_ASSERT_EQUAL_UINT(MBED_ERROR_INVALID_SIZE, error_ctx.error_status); TEST_ASSERT_EQUAL_UINT(2, error_ctx.error_value); - - status = mbed_get_error_hist_info( 2, &error_ctx ); + + status = mbed_get_error_hist_info(2, &error_ctx); TEST_ASSERT_EQUAL_UINT(MBED_ERROR_INVALID_FORMAT, error_ctx.error_status); TEST_ASSERT_EQUAL_UINT(3, error_ctx.error_value); - + //Log a bunch of errors to overflow the error log and retrieve them - MBED_WARNING1(MBED_ERROR_INVALID_ARGUMENT, "Invalid argument", 6 ); - MBED_WARNING1(MBED_ERROR_INVALID_SIZE, "Invalid size", 7 ); - MBED_WARNING1(MBED_ERROR_INVALID_FORMAT, "Invalid format", 8 ); - MBED_WARNING1(MBED_ERROR_NOT_READY, "Not ready error", 9 ); - + MBED_WARNING1(MBED_ERROR_INVALID_ARGUMENT, "Invalid argument", 6); + MBED_WARNING1(MBED_ERROR_INVALID_SIZE, "Invalid size", 7); + MBED_WARNING1(MBED_ERROR_INVALID_FORMAT, "Invalid format", 8); + MBED_WARNING1(MBED_ERROR_NOT_READY, "Not ready error", 9); + //Last 4 entries - MBED_WARNING1(MBED_ERROR_TIME_OUT, "Timeout error", 10 ); - MBED_WARNING1(MBED_ERROR_ALREADY_IN_USE, "Already in use error", 11 ); - MBED_WARNING1(MBED_ERROR_UNSUPPORTED, "Not supported", 12 ); - MBED_WARNING1(MBED_ERROR_ACCESS_DENIED, "Access denied", 13 ); - - status = mbed_get_error_hist_info( 0, &error_ctx ); + MBED_WARNING1(MBED_ERROR_TIME_OUT, "Timeout error", 10); + MBED_WARNING1(MBED_ERROR_ALREADY_IN_USE, "Already in use error", 11); + MBED_WARNING1(MBED_ERROR_UNSUPPORTED, "Not supported", 12); + MBED_WARNING1(MBED_ERROR_ACCESS_DENIED, "Access denied", 13); + + status = mbed_get_error_hist_info(0, &error_ctx); TEST_ASSERT_EQUAL_UINT(MBED_ERROR_TIME_OUT, error_ctx.error_status); TEST_ASSERT_EQUAL_UINT(10, error_ctx.error_value); - - status = mbed_get_error_hist_info( 1, &error_ctx ); + + status = mbed_get_error_hist_info(1, &error_ctx); TEST_ASSERT_EQUAL_UINT(MBED_ERROR_ALREADY_IN_USE, error_ctx.error_status); TEST_ASSERT_EQUAL_UINT(11, error_ctx.error_value); - - status = mbed_get_error_hist_info( 2, &error_ctx ); + + status = mbed_get_error_hist_info(2, &error_ctx); TEST_ASSERT_EQUAL_UINT(MBED_ERROR_UNSUPPORTED, error_ctx.error_status); TEST_ASSERT_EQUAL_UINT(12, error_ctx.error_value); - - status = mbed_get_error_hist_info( 3, &error_ctx ); + + status = mbed_get_error_hist_info(3, &error_ctx); TEST_ASSERT_EQUAL_UINT(MBED_ERROR_ACCESS_DENIED, error_ctx.error_status); TEST_ASSERT_EQUAL_UINT(13, error_ctx.error_value); - + //Try an index which is invalid, we should get ERROR_INVALID_ARGUMENT back - status = mbed_get_error_hist_info( 99, &error_ctx ); + status = mbed_get_error_hist_info(99, &error_ctx); TEST_ASSERT_EQUAL_UINT(MBED_ERROR_INVALID_ARGUMENT, status); - + } #define NUM_TEST_THREADS 5 @@ -204,7 +204,7 @@ void test_error_logging() //Error logger threads void err_thread_func(mbed_error_status_t *error_status) { - MBED_WARNING1(*error_status, "Error from Multi-Threaded error logging test", *error_status ); + MBED_WARNING1(*error_status, "Error from Multi-Threaded error logging test", *error_status); } @@ -219,28 +219,28 @@ void test_error_logging_multithread() mbed_error_ctx error_ctx = {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 + 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=0; istart(callback(err_thread_func, &error_status[i])); } wait(2.0); - for(i=0; ijoin(); } - - i = mbed_get_error_hist_count()-1; - - for(;i>=0;--i) { - mbed_error_status_t status = mbed_get_error_hist_info( i, &error_ctx ); - if(status != MBED_SUCCESS) { + + i = mbed_get_error_hist_count() - 1; + + for (; i >= 0; --i) { + mbed_error_status_t status = mbed_get_error_hist_info(i, &error_ctx); + if (status != MBED_SUCCESS) { TEST_FAIL(); } - + TEST_ASSERT_EQUAL_UINT((unsigned int)error_ctx.error_value, (unsigned int)error_ctx.error_status); } } @@ -256,13 +256,13 @@ void MyErrorHook(const mbed_error_ctx *error_ctx) */ void test_error_hook() { - if( MBED_SUCCESS != mbed_set_error_hook(MyErrorHook)) { + if (MBED_SUCCESS != mbed_set_error_hook(MyErrorHook)) { TEST_FAIL(); } - + MBED_WARNING1(MBED_ERROR_INVALID_ARGUMENT, "Test for error hook", 1234); int32_t sem_status = callback_sem.wait(5000); - + TEST_ASSERT(sem_status > 0); } @@ -301,42 +301,42 @@ MBED_TEST_SIM_BLOCKDEVICE_DECL; void test_save_error_log() { //Log some errors - MBED_WARNING1(MBED_ERROR_TIME_OUT, "Timeout error", 1 ); - MBED_WARNING1(MBED_ERROR_ALREADY_IN_USE, "Already in use error", 2 ); - MBED_WARNING1(MBED_ERROR_UNSUPPORTED, "Not supported error", 3 ); - MBED_WARNING1(MBED_ERROR_ACCESS_DENIED, "Access denied error", 4 ); - MBED_WARNING1(MBED_ERROR_ITEM_NOT_FOUND, "Not found error", 5 ); - + MBED_WARNING1(MBED_ERROR_TIME_OUT, "Timeout error", 1); + MBED_WARNING1(MBED_ERROR_ALREADY_IN_USE, "Already in use error", 2); + MBED_WARNING1(MBED_ERROR_UNSUPPORTED, "Not supported error", 3); + MBED_WARNING1(MBED_ERROR_ACCESS_DENIED, "Access denied error", 4); + MBED_WARNING1(MBED_ERROR_ITEM_NOT_FOUND, "Not found error", 5); + int error = 0; - + error = MBED_TEST_FILESYSTEM::format(&fd); - if(error < 0) { + if (error < 0) { TEST_FAIL_MESSAGE("Failed formatting"); } - + error = fs.mount(&fd); - if(error < 0) { + if (error < 0) { TEST_FAIL_MESSAGE("Failed mounting fs"); } - - if(MBED_SUCCESS != mbed_save_error_hist("/fs/errors.log")) { + + if (MBED_SUCCESS != mbed_save_error_hist("/fs/errors.log")) { TEST_FAIL_MESSAGE("Failed saving error log"); } - + FILE *error_file = fopen("/fs/errors.log", "r"); - if(error_file == NULL) { + if (error_file == NULL) { TEST_FAIL_MESSAGE("Unable to find error log in fs"); } - + char buff[64] = {0}; - while (!feof(error_file)){ - int size = fread(&buff[0], 1, 15, error_file); - fwrite(&buff[0], 1, size, stdout); + while (!feof(error_file)) { + int size = fread(&buff[0], 1, 15, error_file); + fwrite(&buff[0], 1, size, stdout); } fclose(error_file); - + error = fs.unmount(); - if(error < 0) { + if (error < 0) { TEST_FAIL_MESSAGE("Failed unmounting fs"); } } @@ -356,7 +356,7 @@ Case cases[] = { Case("Test error context capture", test_error_context_capture), #endif //MBED_CONF_RTOS_PRESENT Case("Test error hook", test_error_hook), -#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED +#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED Case("Test error logging", test_error_logging), #if MBED_CONF_RTOS_PRESENT Case("Test error handling multi-threaded", test_error_logging_multithread), diff --git a/TESTS/mbed_platform/stats_cpu/main.cpp b/TESTS/mbed_platform/stats_cpu/main.cpp index 077d7199f29..9ae162b245d 100644 --- a/TESTS/mbed_platform/stats_cpu/main.cpp +++ b/TESTS/mbed_platform/stats_cpu/main.cpp @@ -38,7 +38,7 @@ static int32_t wait_time = 5000; static void busy_thread() { volatile uint64_t i = ~0; - + while (i--) { led1 = !led1; wait_us(wait_time); diff --git a/TESTS/mbed_platform/stats_heap/main.cpp b/TESTS/mbed_platform/stats_heap/main.cpp index b99adead2f1..2d7d6b27e90 100644 --- a/TESTS/mbed_platform/stats_heap/main.cpp +++ b/TESTS/mbed_platform/stats_heap/main.cpp @@ -23,7 +23,7 @@ #include #if !defined(MBED_HEAP_STATS_ENABLED) - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif using namespace utest::v1; @@ -33,12 +33,12 @@ using namespace utest::v1; #define ALLOCATION_SIZE_LARGE 700 #define ALLOCATION_SIZE_FAIL (1024 * 1024 *1024) -typedef void* (*malloc_cb_t) (uint32_t size); +typedef void *(*malloc_cb_t)(uint32_t size); -static void* thunk_malloc(uint32_t size); -static void* thunk_calloc_1(uint32_t size); -static void* thunk_calloc_4(uint32_t size); -static void* thunk_realloc(uint32_t size); +static void *thunk_malloc(uint32_t size); +static void *thunk_calloc_1(uint32_t size); +static void *thunk_calloc_4(uint32_t size); +static void *thunk_realloc(uint32_t size); malloc_cb_t malloc_thunk_array[] = { thunk_malloc, @@ -124,23 +124,23 @@ void test_case_allocate_fail() } } -static void* thunk_malloc(uint32_t size) +static void *thunk_malloc(uint32_t size) { return malloc(size); } -static void* thunk_calloc_1(uint32_t size) +static void *thunk_calloc_1(uint32_t size) { return calloc(size / 1, 1); } -static void* thunk_calloc_4(uint32_t size) +static void *thunk_calloc_4(uint32_t size) { return calloc(size / 4, 4); } -static void* thunk_realloc(uint32_t size) +static void *thunk_realloc(uint32_t size) { return realloc(NULL, size); } diff --git a/TESTS/mbed_platform/stats_thread/main.cpp b/TESTS/mbed_platform/stats_thread/main.cpp index 399267f5ee9..f79375db93a 100644 --- a/TESTS/mbed_platform/stats_thread/main.cpp +++ b/TESTS/mbed_platform/stats_thread/main.cpp @@ -101,7 +101,7 @@ void test_case_multi_threads_blocked() TEST_ASSERT_EQUAL(TEST_STACK_SIZE, stats[i].stack_size); TEST_ASSERT_EQUAL(osPriorityNormal1, stats[i].priority); TEST_ASSERT_EQUAL(osThreadBlocked, stats[i].state); - } else if (0 == strcmp (stats[i].name, "Th1")) { + } else if (0 == strcmp(stats[i].name, "Th1")) { TEST_ASSERT_EQUAL(TEST_STACK_SIZE, stats[i].stack_size); TEST_ASSERT_EQUAL(osPriorityNormal, stats[i].priority); } diff --git a/TESTS/mbedmicro-mbed/attributes/attributes.c b/TESTS/mbedmicro-mbed/attributes/attributes.c index e08f124f0c8..5329b8a3c5e 100644 --- a/TESTS/mbedmicro-mbed/attributes/attributes.c +++ b/TESTS/mbedmicro-mbed/attributes/attributes.c @@ -9,12 +9,15 @@ MBED_PACKED(struct) TestAttrPackedStruct1 { int x; }; -typedef MBED_PACKED(struct) { +typedef MBED_PACKED(struct) +{ char a; int x; -} TestAttrPackedStruct2; +} +TestAttrPackedStruct2; -int testPacked() { +int testPacked() +{ int failed = 0; if (sizeof(struct TestAttrPackedStruct1) != sizeof(int) + sizeof(char)) { @@ -35,22 +38,23 @@ MBED_ALIGN(16) char c; MBED_ALIGN(8) char d; MBED_ALIGN(16) char e; -int testAlign() { +int testAlign() +{ int failed = 0; - if(((uintptr_t)&a) & 0x7){ + if (((uintptr_t)&a) & 0x7) { failed++; } - if(((uintptr_t)&b) & 0x7){ + if (((uintptr_t)&b) & 0x7) { failed++; } - if(((uintptr_t)&c) & 0xf){ + if (((uintptr_t)&c) & 0xf) { failed++; } - if(((uintptr_t)&d) & 0x7){ + if (((uintptr_t)&d) & 0x7) { failed++; } - if(((uintptr_t)&e) & 0xf){ + if (((uintptr_t)&e) & 0xf) { failed++; } @@ -58,11 +62,13 @@ int testAlign() { } -int testUnused1(MBED_UNUSED int arg) { +int testUnused1(MBED_UNUSED int arg) +{ return 0; } -int testUnused() { +int testUnused() +{ return testUnused1(0); } @@ -70,42 +76,51 @@ int testUnused() { int testWeak1(); int testWeak2(); -MBED_WEAK int testWeak1() { +MBED_WEAK int testWeak1() +{ return 1; } -int testWeak2() { +int testWeak2() +{ return 0; } -int testWeak() { +int testWeak() +{ return testWeak1() | testWeak2(); } -MBED_PURE int testPure1() { +MBED_PURE int testPure1() +{ return 0; } -int testPure() { +int testPure() +{ return testPure1(); } -MBED_FORCEINLINE int testForceInline1() { +MBED_FORCEINLINE int testForceInline1() +{ return 0; } -int testForceInline() { +int testForceInline() +{ return testForceInline1(); } -MBED_NORETURN int testNoReturn1() { +MBED_NORETURN int testNoReturn1() +{ while (1) {} } -int testNoReturn() { +int testNoReturn() +{ if (0) { testNoReturn1(); } @@ -113,7 +128,8 @@ int testNoReturn() { } -int testUnreachable1(int i) { +int testUnreachable1(int i) +{ switch (i) { case 0: return 0; @@ -122,18 +138,20 @@ int testUnreachable1(int i) { MBED_UNREACHABLE; } -int testUnreachable() { +int testUnreachable() +{ return testUnreachable1(0); } MBED_DEPRECATED("this message should not be displayed") -void testDeprecatedUnused(); +void testDeprecatedUnused(); void testDeprecatedUnused() { } MBED_DEPRECATED("this message should be displayed") int testDeprecatedUsed(); -int testDeprecatedUsed() { +int testDeprecatedUsed() +{ return 0; } @@ -143,11 +161,13 @@ void testDeprecatedSinceUnused() { } MBED_DEPRECATED_SINCE("mbed-os-3.14", "this message should be displayed") int testDeprecatedSinceUsed(); -int testDeprecatedSinceUsed() { +int testDeprecatedSinceUsed() +{ return 0; } -int testDeprecated() { +int testDeprecated() +{ return testDeprecatedUsed() + testDeprecatedSinceUsed(); } diff --git a/TESTS/mbedmicro-mbed/attributes/main.cpp b/TESTS/mbedmicro-mbed/attributes/main.cpp index c64c29cba79..31d014e4ba3 100644 --- a/TESTS/mbedmicro-mbed/attributes/main.cpp +++ b/TESTS/mbedmicro-mbed/attributes/main.cpp @@ -40,11 +40,13 @@ extern "C" { // Test wrapper and test cases for utest template -void test_wrapper() { +void test_wrapper() +{ TEST_ASSERT_UNLESS(F()); } -utest::v1::status_t test_setup(const size_t number_of_cases) { +utest::v1::status_t test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(5, "default_auto"); return verbose_test_setup_handler(number_of_cases); } @@ -63,6 +65,7 @@ Case cases[] = { Specification specification(test_setup, cases); -int main() { +int main() +{ return !Harness::run(specification); } diff --git a/TESTS/mbedmicro-mbed/attributes/weak.c b/TESTS/mbedmicro-mbed/attributes/weak.c index 4bf279614b4..7b2f862177a 100644 --- a/TESTS/mbedmicro-mbed/attributes/weak.c +++ b/TESTS/mbedmicro-mbed/attributes/weak.c @@ -1,10 +1,12 @@ #include "mbed_toolchain.h" -int testWeak1() { +int testWeak1() +{ return 0; } -MBED_WEAK int testWeak2() { +MBED_WEAK int testWeak2() +{ return 1; } diff --git a/TESTS/mbedmicro-mbed/call_before_main/main.cpp b/TESTS/mbedmicro-mbed/call_before_main/main.cpp index 1d6266b7b6f..c185c5959bd 100644 --- a/TESTS/mbedmicro-mbed/call_before_main/main.cpp +++ b/TESTS/mbedmicro-mbed/call_before_main/main.cpp @@ -16,15 +16,17 @@ #include "greentea-client/test_env.h" namespace { - bool mbed_main_called = false; +bool mbed_main_called = false; } -extern "C" void mbed_main() { +extern "C" void mbed_main() +{ printf("MBED: mbed_main() call before main()\r\n"); mbed_main_called = true; } -int main() { +int main() +{ GREENTEA_SETUP(5, "default_auto"); printf("MBED: main() starts now!\r\n"); GREENTEA_TESTSUITE_RESULT(mbed_main_called); diff --git a/TESTS/mbedmicro-mbed/cpp/main.cpp b/TESTS/mbedmicro-mbed/cpp/main.cpp index 931748e316b..5597831f26e 100644 --- a/TESTS/mbedmicro-mbed/cpp/main.cpp +++ b/TESTS/mbedmicro-mbed/cpp/main.cpp @@ -20,37 +20,43 @@ class Test { private: - const char* name; + const char *name; const int pattern; public: - Test(const char* _name, bool print_message=true) : name(_name), pattern(PATTERN_CHECK_VALUE) { + Test(const char *_name, bool print_message = true) : name(_name), pattern(PATTERN_CHECK_VALUE) + { if (print_message) { print("init"); } } - void print(const char *message) { + void print(const char *message) + { printf("%s::%s\n", name, message); } - bool check_init(void) { + bool check_init(void) + { bool result = (pattern == PATTERN_CHECK_VALUE); print(result ? "check_init: OK" : "check_init: ERROR"); return result; } - void stack_test(void) { + void stack_test(void) + { print("stack_test"); Test t("Stack"); t.hello(); } - void hello(void) { + void hello(void) + { print("hello"); } - ~Test() { + ~Test() + { print("destroy"); } }; @@ -70,17 +76,16 @@ Heap::init Heap::hello Heap::destroy *******************/ -int main (void) { +int main(void) +{ GREENTEA_SETUP(10, "default_auto"); bool result = true; - for (;;) - { + for (;;) { s.print("init"); // Global stack object simple test s.stack_test(); - if (s.check_init() == false) - { + if (s.check_init() == false) { result = false; break; } @@ -89,8 +94,7 @@ int main (void) { Test *m = new Test("Heap"); m->hello(); - if (m->check_init() == false) - { + if (m->check_init() == false) { result = false; } delete m; diff --git a/TESTS/mbedmicro-mbed/div/main.cpp b/TESTS/mbedmicro-mbed/div/main.cpp index 1e9fc4cd589..05a018b59ae 100644 --- a/TESTS/mbedmicro-mbed/div/main.cpp +++ b/TESTS/mbedmicro-mbed/div/main.cpp @@ -17,7 +17,8 @@ #include "mbed.h" #include "greentea-client/test_env.h" -uint32_t test_64(uint64_t ticks) { +uint32_t test_64(uint64_t ticks) +{ ticks >>= 3; // divide by 8 if (ticks > 0xFFFFFFFF) { ticks /= 3; @@ -27,16 +28,19 @@ uint32_t test_64(uint64_t ticks) { return (uint32_t)(0xFFFFFFFF & ticks); } -const char *result_str(bool result) { +const char *result_str(bool result) +{ return result ? "[OK]" : "[FAIL]"; } -int main() { +int main() +{ GREENTEA_SETUP(5, "default_auto"); bool result = true; - { // 0xFFFFFFFF * 8 = 0x7fffffff8 + { + // 0xFFFFFFFF * 8 = 0x7fffffff8 std::pair values = std::make_pair(0x55555555, 0x7FFFFFFF8); uint32_t test_ret = test_64(values.second); bool test_res = values.first == test_ret; @@ -44,7 +48,8 @@ int main() { printf("64bit: 0x7FFFFFFF8: expected 0x%lX got 0x%lX ... %s\r\n", values.first, test_ret, result_str(test_res)); } - { // 0xFFFFFFFF * 24 = 0x17ffffffe8 + { + // 0xFFFFFFFF * 24 = 0x17ffffffe8 std::pair values = std::make_pair(0xFFFFFFFF, 0x17FFFFFFE8); uint32_t test_ret = test_64(values.second); bool test_res = values.first == test_ret; diff --git a/TESTS/mbedmicro-mbed/static_assert/main.cpp b/TESTS/mbedmicro-mbed/static_assert/main.cpp index 844a60aff44..dd963e0c25b 100644 --- a/TESTS/mbedmicro-mbed/static_assert/main.cpp +++ b/TESTS/mbedmicro-mbed/static_assert/main.cpp @@ -25,7 +25,8 @@ using namespace utest::v1; void no_test() {} -utest::v1::status_t test_setup(const size_t number_of_cases) { +utest::v1::status_t test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(5, "default_auto"); return verbose_test_setup_handler(number_of_cases); } @@ -36,6 +37,7 @@ Case cases[] = { Specification specification(test_setup, cases); -int main() { +int main() +{ return !Harness::run(specification); } diff --git a/TESTS/mbedmicro-mbed/static_assert/test_c.c b/TESTS/mbedmicro-mbed/static_assert/test_c.c index e0f9923415a..b908a2e872d 100644 --- a/TESTS/mbedmicro-mbed/static_assert/test_c.c +++ b/TESTS/mbedmicro-mbed/static_assert/test_c.c @@ -6,34 +6,35 @@ // Test for static asserts in global context MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char), - "An int must be larger than char"); + "An int must be larger than char"); MBED_STATIC_ASSERT(2 + 2 == 4, - "Hopefully the universe is mathematically consistent"); + "Hopefully the universe is mathematically consistent"); MBED_STATIC_ASSERT(THE_ANSWER == 42, - "Said Deep Thought, with infinite majesty and calm"); + "Said Deep Thought, with infinite majesty and calm"); struct test { int dummy; // Test for static asserts in struct context MBED_STRUCT_STATIC_ASSERT(sizeof(int) >= sizeof(char), - "An int must be larger than char"); + "An int must be larger than char"); MBED_STRUCT_STATIC_ASSERT(2 + 2 == 4, - "Hopefully the universe is mathematically consistent"); + "Hopefully the universe is mathematically consistent"); MBED_STRUCT_STATIC_ASSERT(THE_ANSWER == 42, - "Said Deep Thought, with infinite majesty and calm"); + "Said Deep Thought, with infinite majesty and calm"); }; MBED_STATIC_ASSERT(sizeof(struct test) == sizeof(int), - "Static assertions should not change the size of a struct"); + "Static assertions should not change the size of a struct"); -void doit_c(void) { +void doit_c(void) +{ // Test for static asserts in function context MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char), - "An int must be larger than char"); + "An int must be larger than char"); MBED_STATIC_ASSERT(2 + 2 == 4, - "Hopefully the universe is mathematically consistent"); + "Hopefully the universe is mathematically consistent"); MBED_STATIC_ASSERT(THE_ANSWER == 42, - "Said Deep Thought, with infinite majesty and calm"); + "Said Deep Thought, with infinite majesty and calm"); } diff --git a/TESTS/mbedmicro-mbed/static_assert/test_cpp.cpp b/TESTS/mbedmicro-mbed/static_assert/test_cpp.cpp index 05741d32158..2bff2780cb9 100644 --- a/TESTS/mbedmicro-mbed/static_assert/test_cpp.cpp +++ b/TESTS/mbedmicro-mbed/static_assert/test_cpp.cpp @@ -6,41 +6,42 @@ // Test for static asserts in global context MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char), - "An int must be larger than char"); + "An int must be larger than char"); MBED_STATIC_ASSERT(2 + 2 == 4, - "Hopefully the universe is mathematically consistent"); + "Hopefully the universe is mathematically consistent"); MBED_STATIC_ASSERT(THE_ANSWER == 42, - "Said Deep Thought, with infinite majesty and calm"); + "Said Deep Thought, with infinite majesty and calm"); struct test { int dummy; // Test for static asserts in struct context MBED_STRUCT_STATIC_ASSERT(sizeof(int) >= sizeof(char), - "An int must be larger than char"); + "An int must be larger than char"); MBED_STRUCT_STATIC_ASSERT(2 + 2 == 4, - "Hopefully the universe is mathematically consistent"); + "Hopefully the universe is mathematically consistent"); MBED_STRUCT_STATIC_ASSERT(THE_ANSWER == 42, - "Said Deep Thought, with infinite majesty and calm"); + "Said Deep Thought, with infinite majesty and calm"); MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char), - "An int must be larger than char"); + "An int must be larger than char"); MBED_STATIC_ASSERT(2 + 2 == 4, - "Hopefully the universe is mathematically consistent"); + "Hopefully the universe is mathematically consistent"); MBED_STATIC_ASSERT(THE_ANSWER == 42, - "Said Deep Thought, with infinite majesty and calm"); + "Said Deep Thought, with infinite majesty and calm"); }; MBED_STATIC_ASSERT(sizeof(struct test) == sizeof(int), - "Static assertions should not change the size of a struct"); + "Static assertions should not change the size of a struct"); -void doit_c(void) { +void doit_c(void) +{ // Test for static asserts in function context MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char), - "An int must be larger than char"); + "An int must be larger than char"); MBED_STATIC_ASSERT(2 + 2 == 4, - "Hopefully the universe is mathematically consistent"); + "Hopefully the universe is mathematically consistent"); MBED_STATIC_ASSERT(THE_ANSWER == 42, - "Said Deep Thought, with infinite majesty and calm"); + "Said Deep Thought, with infinite majesty and calm"); } diff --git a/TESTS/mbedmicro-rtos-mbed/CircularBuffer/main.cpp b/TESTS/mbedmicro-rtos-mbed/CircularBuffer/main.cpp index bc7e0c6d781..418194fc37c 100644 --- a/TESTS/mbedmicro-rtos-mbed/CircularBuffer/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/CircularBuffer/main.cpp @@ -23,8 +23,7 @@ using namespace utest::v1; /* Structure for complex type. */ -typedef struct -{ +typedef struct { int a; char b; int c; diff --git a/TESTS/mbedmicro-rtos-mbed/MemoryPool/main.cpp b/TESTS/mbedmicro-rtos-mbed/MemoryPool/main.cpp index 1428d48e948..30e335873a1 100644 --- a/TESTS/mbedmicro-rtos-mbed/MemoryPool/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/MemoryPool/main.cpp @@ -21,14 +21,12 @@ using namespace utest::v1; /* Enum used to select block allocation method. */ -typedef enum -{ +typedef enum { ALLOC, CALLOC } AllocType; /* Structure for complex block type. */ -typedef struct -{ +typedef struct { int a; char b; int c; @@ -75,7 +73,7 @@ template void test_mem_pool_alloc_success(AllocType atype) { MemoryPool mem_pool; - T * p_blocks[numOfEntries]; + T *p_blocks[numOfEntries]; uint32_t i; /* Test alloc()/calloc() methods - try to allocate max number of @@ -121,7 +119,7 @@ template void test_mem_pool_alloc_success_complex(AllocType atype) { MemoryPool mem_pool; - T * p_blocks[numOfEntries]; + T *p_blocks[numOfEntries]; uint32_t i; /* Test alloc()/calloc() methods - try to allocate max number of @@ -164,8 +162,8 @@ template void test_mem_pool_alloc_fail(AllocType atype) { MemoryPool mem_pool; - T * p_blocks[numOfEntries]; - T * p_extra_block; + T *p_blocks[numOfEntries]; + T *p_extra_block; uint32_t i; /* Allocate all available blocks. */ @@ -203,7 +201,7 @@ template void test_mem_pool_free_success(AllocType atype) { MemoryPool mem_pool; - T * p_blocks[numOfEntries]; + T *p_blocks[numOfEntries]; uint32_t i; osStatus status; @@ -243,7 +241,7 @@ template void test_mem_pool_free_realloc_last(AllocType atype) { MemoryPool mem_pool; - T * p_blocks[numOfEntries]; + T *p_blocks[numOfEntries]; uint32_t i; osStatus status; @@ -299,7 +297,7 @@ template void test_mem_pool_free_realloc_last_complex(AllocType atype) { MemoryPool mem_pool; - T * p_blocks[numOfEntries]; + T *p_blocks[numOfEntries]; uint32_t i; osStatus status; @@ -355,7 +353,7 @@ template void test_mem_pool_free_realloc_first(AllocType atype) { MemoryPool mem_pool; - T * p_blocks[numOfEntries]; + T *p_blocks[numOfEntries]; uint32_t i; osStatus status; @@ -411,7 +409,7 @@ template void test_mem_pool_free_realloc_first_complex(AllocType atype) { MemoryPool mem_pool; - T * p_blocks[numOfEntries]; + T *p_blocks[numOfEntries]; uint32_t i; osStatus status; @@ -462,7 +460,7 @@ void test_mem_pool_free_realloc_first_complex(AllocType atype) void test_mem_pool_free_on_freed_block() { MemoryPool mem_pool; - int * p_block; + int *p_block; osStatus status; /* Allocate memory block. */ @@ -518,7 +516,7 @@ void free_block_invalid_parameter() osStatus status; /* Try to free block passing invalid parameter (variable address). */ - status = mem_pool.free(reinterpret_cast(&status)); + status = mem_pool.free(reinterpret_cast(&status)); /* Check operation status. */ TEST_ASSERT_EQUAL(osErrorParameter, status); diff --git a/TESTS/mbedmicro-rtos-mbed/basic/main.cpp b/TESTS/mbedmicro-rtos-mbed/basic/main.cpp index 72aa241931f..a266fdb51b7 100644 --- a/TESTS/mbedmicro-rtos-mbed/basic/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/basic/main.cpp @@ -24,7 +24,7 @@ #endif #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif using utest::v1::Case; @@ -100,7 +100,7 @@ void test(void) //get the results from host greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); - TEST_ASSERT_EQUAL_STRING_MESSAGE("pass", _key,"Host side script reported a fail..."); + TEST_ASSERT_EQUAL_STRING_MESSAGE("pass", _key, "Host side script reported a fail..."); } Case cases[] = { diff --git a/TESTS/mbedmicro-rtos-mbed/condition_variable/main.cpp b/TESTS/mbedmicro-rtos-mbed/condition_variable/main.cpp index 9d63b20afb3..3592f0a93ec 100644 --- a/TESTS/mbedmicro-rtos-mbed/condition_variable/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/condition_variable/main.cpp @@ -20,11 +20,11 @@ #include "rtos.h" #if defined(MBED_RTOS_SINGLE_THREAD) - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif using namespace utest::v1; diff --git a/TESTS/mbedmicro-rtos-mbed/event_flags/main.cpp b/TESTS/mbedmicro-rtos-mbed/event_flags/main.cpp index c07a0062af6..a519cb165bb 100644 --- a/TESTS/mbedmicro-rtos-mbed/event_flags/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/event_flags/main.cpp @@ -23,11 +23,11 @@ using utest::v1::Case; #if defined(MBED_RTOS_SINGLE_THREAD) - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #if defined(__CORTEX_M23) || defined(__CORTEX_M33) @@ -56,12 +56,13 @@ Semaphore sync_sem(0, 1); * which aborts test program. */ #if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED -void error(const char* format, ...) { +void error(const char *format, ...) +{ (void) format; } -//Override the set_error function to trap the errors -mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) +//Override the set_error function to trap the errors +mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) { return MBED_SUCCESS; } @@ -278,7 +279,7 @@ void test_multi_thread_any_timeout(void) EventFlags ef; uint32_t ret; Thread thread(osPriorityNormal, THREAD_STACK_SIZE); - thread.start(callback(send_thread_sync, &ef)); + thread.start(callback(send_thread_sync < FLAG01 | FLAG02 | FLAG03, 1 >, &ef)); for (int i = 0; i <= MAX_FLAG_POS; i++) { uint32_t flag = 1 << i; diff --git a/TESTS/mbedmicro-rtos-mbed/heap_and_stack/main.cpp b/TESTS/mbedmicro-rtos-mbed/heap_and_stack/main.cpp index af6511c25a3..d4334ad6f63 100644 --- a/TESTS/mbedmicro-rtos-mbed/heap_and_stack/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/heap_and_stack/main.cpp @@ -16,11 +16,11 @@ */ #if defined(TARGET_CORTEX_A) - #error [NOT_SUPPORTED] This function not supported for this target +#error [NOT_SUPPORTED] This function not supported for this target #endif #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #include @@ -50,7 +50,7 @@ extern uint32_t mbed_stack_isr_size; struct linked_list { - linked_list * next; + linked_list *next; uint8_t data[MALLOC_TEST_SIZE]; }; @@ -90,7 +90,7 @@ static bool rangeinrange(uint32_t addr, uint32_t size, uint32_t start, uint32_t /* * Return true if the region is filled only with the specified value */ -static bool valid_fill(uint8_t * data, uint32_t size, uint8_t fill) +static bool valid_fill(uint8_t *data, uint32_t size, uint8_t fill) { for (uint32_t i = 0; i < size; i++) { if (data[i] != fill) { @@ -104,18 +104,18 @@ static void allocate_and_fill_heap(linked_list *&head) { linked_list *current; - current = (linked_list*) malloc(sizeof(linked_list)); + current = (linked_list *) malloc(sizeof(linked_list)); TEST_ASSERT_NOT_NULL(current); current->next = NULL; - memset((void*) current->data, MALLOC_FILL, sizeof(current->data)); + memset((void *) current->data, MALLOC_FILL, sizeof(current->data)); // Allocate until malloc returns NULL head = current; while (true) { // Allocate - linked_list *temp = (linked_list*) malloc(sizeof(linked_list)); + linked_list *temp = (linked_list *) malloc(sizeof(linked_list)); if (NULL == temp) { break; @@ -126,7 +126,7 @@ static void allocate_and_fill_heap(linked_list *&head) // Init temp->next = NULL; - memset((void*) temp->data, MALLOC_FILL, sizeof(current->data)); + memset((void *) temp->data, MALLOC_FILL, sizeof(current->data)); // Add to list current->next = temp; @@ -137,7 +137,7 @@ static void allocate_and_fill_heap(linked_list *&head) static void check_and_free_heap(linked_list *head, uint32_t &max_allocation_size) { uint32_t total_size = 0; - linked_list * current = head; + linked_list *current = head; while (current != NULL) { total_size += sizeof(linked_list); @@ -145,7 +145,7 @@ static void check_and_free_heap(linked_list *head, uint32_t &max_allocation_size TEST_ASSERT_TRUE_MESSAGE(result, "Memory fill check failed"); - linked_list * next = current->next; + linked_list *next = current->next; free(current); current = next; } @@ -165,7 +165,7 @@ void test_heap_in_range(void) char *initial_heap; // Sanity check malloc - initial_heap = (char*) malloc(1); + initial_heap = (char *) malloc(1); TEST_ASSERT_NOT_NULL(initial_heap); bool result = inrange((uint32_t) initial_heap, mbed_heap_start, mbed_heap_size); @@ -185,7 +185,7 @@ void test_main_stack_in_range(void) mbed_rtos_storage_thread_t *thread = (mbed_rtos_storage_thread_t *) osThreadGetId(); uint32_t psp = __get_PSP(); - uint8_t *stack_mem = (uint8_t*) thread->stack_mem; + uint8_t *stack_mem = (uint8_t *) thread->stack_mem; uint32_t stack_size = thread->stack_size; // PSP stack should be somewhere in the middle diff --git a/TESTS/mbedmicro-rtos-mbed/mail/main.cpp b/TESTS/mbedmicro-rtos-mbed/mail/main.cpp index 47ad767fa8f..8594c88565c 100644 --- a/TESTS/mbedmicro-rtos-mbed/mail/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/mail/main.cpp @@ -20,11 +20,11 @@ #include "rtos.h" #if defined(MBED_RTOS_SINGLE_THREAD) - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif using namespace utest::v1; @@ -74,7 +74,7 @@ void receive_thread(Mail *m) for (uint32_t i = 0; i < queue_size; i++) { osEvent evt = m->get(); if (evt.status == osEventMail) { - mail_t *mail = (mail_t*)evt.value.p; + mail_t *mail = (mail_t *)evt.value.p; const uint8_t id = mail->thread_id; // verify thread id @@ -112,7 +112,7 @@ void test_single_thread_order(void) // mail receive (main thread) osEvent evt = mail_box.get(); if (evt.status == osEventMail) { - mail_t *mail = (mail_t*)evt.value.p; + mail_t *mail = (mail_t *)evt.value.p; const uint8_t id = mail->thread_id; // verify thread id @@ -154,7 +154,7 @@ void test_multi_thread_order(void) // mail receive (main thread) osEvent evt = mail_box.get(); if (evt.status == osEventMail) { - mail_t *mail = (mail_t*)evt.value.p; + mail_t *mail = (mail_t *)evt.value.p; const uint8_t id = mail->thread_id; // verify thread id @@ -351,13 +351,13 @@ void test_order(void) evt = mail_box.get(); TEST_ASSERT_EQUAL(evt.status, osEventMail); - mail1 = (int32_t*)evt.value.p; + mail1 = (int32_t *)evt.value.p; TEST_ASSERT_EQUAL(TEST_VAL1, *mail1); evt = mail_box.get(); TEST_ASSERT_EQUAL(evt.status, osEventMail); - mail2 = (int32_t*)evt.value.p; + mail2 = (int32_t *)evt.value.p; TEST_ASSERT_EQUAL(TEST_VAL2, *mail2); @@ -439,7 +439,7 @@ void test_data_type(void) osEvent evt = mail_box.get(); TEST_ASSERT_EQUAL(evt.status, osEventMail); - mail = (T*)evt.value.p; + mail = (T *)evt.value.p; TEST_ASSERT_EQUAL(TEST_VAL, *mail); diff --git a/TESTS/mbedmicro-rtos-mbed/malloc/main.cpp b/TESTS/mbedmicro-rtos-mbed/malloc/main.cpp index e97e78833c1..a16577b5951 100644 --- a/TESTS/mbedmicro-rtos-mbed/malloc/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/malloc/main.cpp @@ -20,11 +20,11 @@ #if defined(MBED_RTOS_SINGLE_THREAD) - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif using utest::v1::Case; @@ -138,7 +138,7 @@ void test_zero_allocation(void) void *data = NULL; data = malloc(0); - if(data != NULL) { + if (data != NULL) { free(data); } TEST_ASSERT_MESSAGE(true, "malloc(0) succeed - no undefined behaviour happens"); diff --git a/TESTS/mbedmicro-rtos-mbed/mutex/main.cpp b/TESTS/mbedmicro-rtos-mbed/mutex/main.cpp index 4e07d4b5bb3..846476c6fff 100644 --- a/TESTS/mbedmicro-rtos-mbed/mutex/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/mutex/main.cpp @@ -20,11 +20,11 @@ #include "rtos.h" #if defined(MBED_RTOS_SINGLE_THREAD) - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif using namespace utest::v1; @@ -204,7 +204,7 @@ void test_dual_thread_lock_lock_thread(Mutex *mutex) osStatus stat = mutex->lock(TEST_DELAY); TEST_ASSERT_EQUAL(osErrorTimeout, stat); - TEST_ASSERT_UINT32_WITHIN(5000, TEST_DELAY*1000, timer.read_us()); + TEST_ASSERT_UINT32_WITHIN(5000, TEST_DELAY * 1000, timer.read_us()); } /** Test dual thread lock diff --git a/TESTS/mbedmicro-rtos-mbed/queue/main.cpp b/TESTS/mbedmicro-rtos-mbed/queue/main.cpp index efa5d9a30ea..b2a1c0257e5 100644 --- a/TESTS/mbedmicro-rtos-mbed/queue/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/queue/main.cpp @@ -20,7 +20,7 @@ #include "rtos.h" #if defined(MBED_RTOS_SINGLE_THREAD) - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #if !DEVICE_USTICKER @@ -38,7 +38,7 @@ template void thread_put_uint_msg(Queue *q) { Thread::wait(ms); - osStatus stat = q->put((uint32_t*) TEST_UINT_MSG); + osStatus stat = q->put((uint32_t *) TEST_UINT_MSG); TEST_ASSERT_EQUAL(osOK, stat); } @@ -61,7 +61,7 @@ void thread_get_uint_msg(Queue *q) void test_pass_uint() { Queue q; - osStatus stat = q.put((uint32_t*)TEST_UINT_MSG); + osStatus stat = q.put((uint32_t *)TEST_UINT_MSG); TEST_ASSERT_EQUAL(osOK, stat); osEvent evt = q.get(); @@ -81,14 +81,14 @@ void test_pass_uint() void test_pass_uint_twice() { Queue q; - osStatus stat = q.put((uint32_t*)TEST_UINT_MSG); + osStatus stat = q.put((uint32_t *)TEST_UINT_MSG); TEST_ASSERT_EQUAL(osOK, stat); osEvent evt = q.get(); TEST_ASSERT_EQUAL(osEventMessage, evt.status); TEST_ASSERT_EQUAL(TEST_UINT_MSG, evt.value.v); - stat = q.put((uint32_t*)TEST_UINT_MSG2); + stat = q.put((uint32_t *)TEST_UINT_MSG2); TEST_ASSERT_EQUAL(osOK, stat); evt = q.get(); @@ -181,10 +181,10 @@ void test_put_full_no_timeout() { Queue q; - osStatus stat = q.put((uint32_t*) TEST_UINT_MSG); + osStatus stat = q.put((uint32_t *) TEST_UINT_MSG); TEST_ASSERT_EQUAL(osOK, stat); - stat = q.put((uint32_t*) TEST_UINT_MSG); + stat = q.put((uint32_t *) TEST_UINT_MSG); TEST_ASSERT_EQUAL(osErrorResource, stat); } @@ -198,13 +198,13 @@ void test_put_full_timeout() { Queue q; - osStatus stat = q.put((uint32_t*) TEST_UINT_MSG, TEST_TIMEOUT); + osStatus stat = q.put((uint32_t *) TEST_UINT_MSG, TEST_TIMEOUT); TEST_ASSERT_EQUAL(osOK, stat); Timer timer; timer.start(); - stat = q.put((uint32_t*) TEST_UINT_MSG, TEST_TIMEOUT); + stat = q.put((uint32_t *) TEST_UINT_MSG, TEST_TIMEOUT); TEST_ASSERT_EQUAL(osErrorTimeout, stat); TEST_ASSERT_UINT32_WITHIN(TEST_TIMEOUT * 100, TEST_TIMEOUT * 1000, timer.read_us()); } @@ -224,12 +224,12 @@ void test_put_full_waitforever() t.start(callback(thread_get_uint_msg, &q)); - osStatus stat = q.put((uint32_t*) TEST_UINT_MSG); + osStatus stat = q.put((uint32_t *) TEST_UINT_MSG); TEST_ASSERT_EQUAL(osOK, stat); Timer timer; timer.start(); - stat = q.put((uint32_t*) TEST_UINT_MSG, osWaitForever); + stat = q.put((uint32_t *) TEST_UINT_MSG, osWaitForever); TEST_ASSERT_EQUAL(osOK, stat); TEST_ASSERT_UINT32_WITHIN(TEST_TIMEOUT * 100, TEST_TIMEOUT * 1000, timer.read_us()); @@ -246,10 +246,10 @@ void test_msg_order() { Queue q; - osStatus stat = q.put((uint32_t*) TEST_UINT_MSG, TEST_TIMEOUT); + osStatus stat = q.put((uint32_t *) TEST_UINT_MSG, TEST_TIMEOUT); TEST_ASSERT_EQUAL(osOK, stat); - stat = q.put((uint32_t*) TEST_UINT_MSG2, TEST_TIMEOUT); + stat = q.put((uint32_t *) TEST_UINT_MSG2, TEST_TIMEOUT); TEST_ASSERT_EQUAL(osOK, stat); osEvent evt = q.get(); @@ -271,10 +271,10 @@ void test_msg_prio() { Queue q; - osStatus stat = q.put((uint32_t*) TEST_UINT_MSG, TEST_TIMEOUT, 0); + osStatus stat = q.put((uint32_t *) TEST_UINT_MSG, TEST_TIMEOUT, 0); TEST_ASSERT_EQUAL(osOK, stat); - stat = q.put((uint32_t*) TEST_UINT_MSG2, TEST_TIMEOUT, 1); + stat = q.put((uint32_t *) TEST_UINT_MSG2, TEST_TIMEOUT, 1); TEST_ASSERT_EQUAL(osOK, stat); osEvent evt = q.get(); @@ -298,7 +298,7 @@ void test_queue_empty() TEST_ASSERT_EQUAL(true, q.empty()); - q.put((uint32_t*) TEST_UINT_MSG, TEST_TIMEOUT, 1); + q.put((uint32_t *) TEST_UINT_MSG, TEST_TIMEOUT, 1); TEST_ASSERT_EQUAL(false, q.empty()); } @@ -315,7 +315,7 @@ void test_queue_full() TEST_ASSERT_EQUAL(false, q.full()); - q.put((uint32_t*) TEST_UINT_MSG, TEST_TIMEOUT, 1); + q.put((uint32_t *) TEST_UINT_MSG, TEST_TIMEOUT, 1); TEST_ASSERT_EQUAL(true, q.full()); } diff --git a/TESTS/mbedmicro-rtos-mbed/rtostimer/main.cpp b/TESTS/mbedmicro-rtos-mbed/rtostimer/main.cpp index 12baae3b65e..cf81729f722 100644 --- a/TESTS/mbedmicro-rtos-mbed/rtostimer/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/rtostimer/main.cpp @@ -31,7 +31,7 @@ using namespace utest::v1; #endif #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif class Stopwatch: public Timer { @@ -40,7 +40,7 @@ class Stopwatch: public Timer { public: Stopwatch() : - Timer(), _sem(1) + Timer(), _sem(1) { } @@ -85,12 +85,12 @@ void sem_callback(Semaphore *sem) * which aborts test program. */ #if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED -void error(const char* format, ...) +void error(const char *format, ...) { (void) format; } -mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) +mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) { return MBED_SUCCESS; } diff --git a/TESTS/mbedmicro-rtos-mbed/semaphore/main.cpp b/TESTS/mbedmicro-rtos-mbed/semaphore/main.cpp index 7e23c1f6091..69c92fdbcfb 100644 --- a/TESTS/mbedmicro-rtos-mbed/semaphore/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/semaphore/main.cpp @@ -22,11 +22,11 @@ using namespace utest::v1; #if defined(MBED_RTOS_SINGLE_THREAD) - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #define THREAD_DELAY 30 @@ -204,7 +204,7 @@ void test_multiple_tokens_wait() { Semaphore sem(5); - for(int i = 5; i >= 0; i--) { + for (int i = 5; i >= 0; i--) { int32_t cnt = sem.wait(0); TEST_ASSERT_EQUAL(i, cnt); } @@ -220,7 +220,7 @@ void test_multiple_tokens_release() { Semaphore sem(0, 5); - for(int i = 5; i > 0; i--) { + for (int i = 5; i > 0; i--) { osStatus stat = sem.release(); TEST_ASSERT_EQUAL(osOK, stat); } diff --git a/TESTS/mbedmicro-rtos-mbed/signals/main.cpp b/TESTS/mbedmicro-rtos-mbed/signals/main.cpp index 2e66b5d86db..cd852b2ef09 100644 --- a/TESTS/mbedmicro-rtos-mbed/signals/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/signals/main.cpp @@ -21,11 +21,11 @@ using utest::v1::Case; #if defined(MBED_RTOS_SINGLE_THREAD) - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #define TEST_STACK_SIZE 512 @@ -55,11 +55,12 @@ struct Sync { * which aborts test program. */ #if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED -void error(const char* format, ...) { +void error(const char *format, ...) +{ (void) format; } -mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) +mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number) { return MBED_SUCCESS; } @@ -364,7 +365,7 @@ void test_set_double(void) Semaphore sem(0, 1); Thread t(osPriorityNormal, TEST_STACK_SIZE); - t.start(callback(run_release_signal_wait, &sem)); + t.start(callback(run_release_signal_wait < SIGNAL1 | SIGNAL2 | SIGNAL3, osWaitForever, osEventSignal >, &sem)); sem.wait(); TEST_ASSERT_EQUAL(Thread::WaitingThreadFlag, t.get_state()); diff --git a/TESTS/mbedmicro-rtos-mbed/systimer/main.cpp b/TESTS/mbedmicro-rtos-mbed/systimer/main.cpp index ffad492990e..27cdae531a7 100644 --- a/TESTS/mbedmicro-rtos-mbed/systimer/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/systimer/main.cpp @@ -53,12 +53,12 @@ class SysTimerTest: public rtos::internal::SysTimer { public: SysTimerTest() : - SysTimer(), _sem(0, 1) + SysTimer(), _sem(0, 1) { } SysTimerTest(const ticker_data_t *data) : - SysTimer(data), _sem(0, 1) + SysTimer(data), _sem(0, 1) { } diff --git a/TESTS/mbedmicro-rtos-mbed/threads/LockGuard.h b/TESTS/mbedmicro-rtos-mbed/threads/LockGuard.h index 1db70631091..fd5fd657197 100644 --- a/TESTS/mbedmicro-rtos-mbed/threads/LockGuard.h +++ b/TESTS/mbedmicro-rtos-mbed/threads/LockGuard.h @@ -31,21 +31,23 @@ class LockGuard { * Construct a LockGuard instance and ackire ownership of mutex in input. * @param mutex The mutex to ackire ownership of. */ - LockGuard(rtos::Mutex& mutex) : _mutex(mutex) { + LockGuard(rtos::Mutex &mutex) : _mutex(mutex) + { _mutex.lock(); } /** * Destruct the lock and release the inner mutex. */ - ~LockGuard() { + ~LockGuard() + { _mutex.unlock(); } private: - LockGuard(const LockGuard&); - LockGuard& operator=(const LockGuard&); - rtos::Mutex& _mutex; + LockGuard(const LockGuard &); + LockGuard &operator=(const LockGuard &); + rtos::Mutex &_mutex; }; #endif /* MBEDMICRO_RTOS_MBED_THREADS_LOCK_GUARD */ diff --git a/TESTS/mbedmicro-rtos-mbed/threads/SynchronizedIntegral.h b/TESTS/mbedmicro-rtos-mbed/threads/SynchronizedIntegral.h index a7b66255301..afb3ce0ef42 100644 --- a/TESTS/mbedmicro-rtos-mbed/threads/SynchronizedIntegral.h +++ b/TESTS/mbedmicro-rtos-mbed/threads/SynchronizedIntegral.h @@ -31,37 +31,43 @@ class SynchronizedIntegral { SynchronizedIntegral(T value) : _mutex(), _value(value) { } // preincrement operator - T operator++() { + T operator++() + { LockGuard lock(_mutex); return ++_value; } // predecrement operator - T operator--() { + T operator--() + { LockGuard lock(_mutex); return --_value; } // post increment operator - T operator++(int) { + T operator++(int) + { LockGuard lock(_mutex); return _value++; } // post decrement operator - T operator--(int) { + T operator--(int) + { LockGuard lock(_mutex); return _value--; } // conversion operator, used also for <,>,<=,>=,== and != - operator T() const { + operator T() const + { LockGuard lock(_mutex); return _value; } // access to the internal mutex - rtos::Mutex& internal_mutex() { + rtos::Mutex &internal_mutex() + { return _mutex; } diff --git a/TESTS/mbedmicro-rtos-mbed/threads/main.cpp b/TESTS/mbedmicro-rtos-mbed/threads/main.cpp index e58981c0e40..22d7c6f8307 100644 --- a/TESTS/mbedmicro-rtos-mbed/threads/main.cpp +++ b/TESTS/mbedmicro-rtos-mbed/threads/main.cpp @@ -22,11 +22,11 @@ #include "LockGuard.h" #if defined(MBED_RTOS_SINGLE_THREAD) - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #if !DEVICE_USTICKER - #error [NOT_SUPPORTED] test not supported +#error [NOT_SUPPORTED] test not supported #endif #define THREAD_STACK_SIZE 512 @@ -52,28 +52,33 @@ class ParallelThread : public Thread { }; // Tasks with different functions to test on threads -void increment(counter_t* counter) { +void increment(counter_t *counter) +{ (*counter)++; } -void increment_with_yield(counter_t* counter) { +void increment_with_yield(counter_t *counter) +{ Thread::yield(); (*counter)++; } -void increment_with_wait(counter_t* counter) { +void increment_with_wait(counter_t *counter) +{ Thread::wait(100); (*counter)++; } -void increment_with_child(counter_t* counter) { +void increment_with_child(counter_t *counter) +{ Thread *child = new Thread(osPriorityNormal, CHILD_THREAD_STACK_SIZE); child->start(callback(increment, counter)); child->join(); delete child; } -void increment_with_murder(counter_t* counter) { +void increment_with_murder(counter_t *counter) +{ { // take ownership of the counter mutex so it prevent the child to // modify counter. @@ -87,7 +92,8 @@ void increment_with_murder(counter_t* counter) { (*counter)++; } -void self_terminate(Thread *self) { +void self_terminate(Thread *self) +{ self->terminate(); // Code should not get here TEST_ASSERT(0); @@ -126,7 +132,8 @@ void self_terminate(Thread *self) { then the final value of the counter is equal to 1 */ template -void test_single_thread() { +void test_single_thread() +{ counter_t counter(0); Thread thread(osPriorityNormal, THREAD_STACK_SIZE); thread.start(callback(F, &counter)); @@ -165,7 +172,8 @@ void test_single_thread() { then the final value of the counter is equal to number of parallel threads */ template -void test_parallel_threads() { +void test_parallel_threads() +{ counter_t counter(0); ParallelThread threads[N]; @@ -211,7 +219,8 @@ void test_parallel_threads() { then the final value of the counter is equal to number of serial threads */ template -void test_serial_threads() { +void test_serial_threads() +{ counter_t counter(0); for (int i = 0; i < N; i++) { @@ -229,7 +238,8 @@ void test_serial_threads() { when the thread calls @a terminate on its self then the thread terminates execution cleanly */ -void test_self_terminate() { +void test_self_terminate() +{ Thread *thread = new Thread(osPriorityNormal, THREAD_STACK_SIZE); thread->start(callback(self_terminate, thread)); thread->join(); @@ -336,11 +346,13 @@ void test_thread_signal_clr() t_wait.join(); } -void thread_wait_signal() { +void thread_wait_signal() +{ Thread::signal_wait(0x1); } -void stack_info() { +void stack_info() +{ Thread::signal_wait(0x1); thread_wait_signal(); @@ -360,7 +372,8 @@ void stack_info() { and the reported stack size is as requested in the constructor and the sum of free and used stack sizes is equal to the total stack size */ -void test_thread_stack_info() { +void test_thread_stack_info() +{ Thread t(osPriorityNormal, THREAD_STACK_SIZE); t.start(callback(stack_info)); @@ -394,7 +407,8 @@ void test_thread_stack_info() { when the @a wait function is called then the thread sleeps for given amount of time */ -void test_thread_wait() { +void test_thread_wait() +{ Timer timer; timer.start(); @@ -409,7 +423,8 @@ void test_thread_wait() { when the name is queried using @a get_name then the returned name is as set */ -void test_thread_name() { +void test_thread_name() +{ const char tname[] = "Amazing thread"; Thread t(osPriorityNormal, THREAD_STACK_SIZE, NULL, tname); t.start(callback(thread_wait_signal)); @@ -627,7 +642,8 @@ void test_msg_put() } /** Utility function that places some date on the stack */ -void use_some_stack () { +void use_some_stack() +{ volatile uint32_t stack_filler[10] = {0xDEADBEEF}; } @@ -637,18 +653,20 @@ void use_some_stack () { when the thread executes then the supplies buffer is used as a stack */ -void test_thread_ext_stack() { +void test_thread_ext_stack() +{ char stack[512]; - Thread t(osPriorityNormal, sizeof(stack), (unsigned char*)stack); + Thread t(osPriorityNormal, sizeof(stack), (unsigned char *)stack); memset(&stack, 0, sizeof(stack)); t.start(callback(use_some_stack)); t.join(); /* If buffer was used as a stack it was cleared with pattern and some data were placed in it */ - for(unsigned i = 0; i < sizeof(stack); i++) { - if (stack[i] != 0) + for (unsigned i = 0; i < sizeof(stack); i++) { + if (stack[i] != 0) { return; + } } TEST_FAIL_MESSAGE("External stack was not used."); @@ -660,7 +678,8 @@ void test_thread_ext_stack() { when new priority is set using @a set_priority then priority is changed and can be retrieved using @a get_priority */ -void test_thread_prio() { +void test_thread_prio() +{ Thread t(osPriorityNormal, THREAD_STACK_SIZE); t.start(callback(thread_wait_signal)); @@ -674,7 +693,8 @@ void test_thread_prio() { t.join(); } -utest::v1::status_t test_setup(const size_t number_of_cases) { +utest::v1::status_t test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(20, "default_auto"); return verbose_test_setup_handler(number_of_cases); } @@ -685,8 +705,8 @@ utest::v1::status_t test_setup(const size_t number_of_cases) { // macros don't play nicely with the templates (extra comma). static const case_t cases[] = { {"Testing single thread", test_single_thread, DEFAULT_HANDLERS}, - {"Testing parallel threads", test_parallel_threads<3, increment> , DEFAULT_HANDLERS}, - {"Testing serial threads", test_serial_threads<10, increment> , DEFAULT_HANDLERS}, + {"Testing parallel threads", test_parallel_threads<3, increment>, DEFAULT_HANDLERS}, + {"Testing serial threads", test_serial_threads<10, increment>, DEFAULT_HANDLERS}, {"Testing single thread with yield", test_single_thread, DEFAULT_HANDLERS}, {"Testing parallel threads with yield", test_parallel_threads<3, increment_with_yield>, DEFAULT_HANDLERS}, @@ -733,6 +753,7 @@ static const case_t cases[] = { Specification specification(test_setup, cases); -int main() { +int main() +{ return !Harness::run(specification); } diff --git a/TESTS/mbedtls/multi/main.cpp b/TESTS/mbedtls/multi/main.cpp index f89b8444c46..e84ad489efd 100644 --- a/TESTS/mbedtls/multi/main.cpp +++ b/TESTS/mbedtls/multi/main.cpp @@ -34,65 +34,73 @@ using namespace utest::v1; #if defined(MBEDTLS_SHA256_C) /* Tests several call to mbedtls_sha256_update function that are not modulo 64 bytes */ -void test_case_sha256_split() { - const unsigned char test_buf[] = {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"}; - // sha256_output_values for 3*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq - const unsigned char test_sum[] = - { 0x50, 0xEA, 0x82, 0x5D, 0x96, 0x84, 0xF4, 0x22, - 0x9C, 0xA2, 0x9F, 0x1F, 0xEC, 0x51, 0x15, 0x93, - 0xE2, 0x81, 0xE4, 0x6A, 0x14, 0x0D, 0x81, 0xE0, - 0x00, 0x5F, 0x8F, 0x68, 0x86, 0x69, 0xA0, 0x6C}; - unsigned char outsum[32]; - int i; - - mbedtls_sha256_context ctx; - printf("test sha256\n"); - mbedtls_sha256_init( &ctx ); - mbedtls_sha256_starts( &ctx, 0); - #if 0 +void test_case_sha256_split() +{ + const unsigned char test_buf[] = {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"}; + // sha256_output_values for 3*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq + const unsigned char test_sum[] = { + 0x50, 0xEA, 0x82, 0x5D, 0x96, 0x84, 0xF4, 0x22, + 0x9C, 0xA2, 0x9F, 0x1F, 0xEC, 0x51, 0x15, 0x93, + 0xE2, 0x81, 0xE4, 0x6A, 0x14, 0x0D, 0x81, 0xE0, + 0x00, 0x5F, 0x8F, 0x68, 0x86, 0x69, 0xA0, 0x6C + }; + unsigned char outsum[32]; + int i; + + mbedtls_sha256_context ctx; + printf("test sha256\n"); + mbedtls_sha256_init(&ctx); + mbedtls_sha256_starts(&ctx, 0); +#if 0 printf("test not splitted\n"); - mbedtls_sha256_update( &ctx, test_buf, 168 ); - #else + mbedtls_sha256_update(&ctx, test_buf, 168); +#else printf("test splitted into 3 pieces\n"); - mbedtls_sha256_update( &ctx, test_buf, 2 ); - mbedtls_sha256_update( &ctx, test_buf+2, 66 ); - mbedtls_sha256_update( &ctx, test_buf+68, 100 ); - #endif - - mbedtls_sha256_finish( &ctx, outsum ); - mbedtls_sha256_free( &ctx ); - + mbedtls_sha256_update(&ctx, test_buf, 2); + mbedtls_sha256_update(&ctx, test_buf + 2, 66); + mbedtls_sha256_update(&ctx, test_buf + 68, 100); +#endif + + mbedtls_sha256_finish(&ctx, outsum); + mbedtls_sha256_free(&ctx); + printf("\nreceived result : "); - for (i=0;i<32;i++) { printf("%02X",outsum[i]);} + for (i = 0; i < 32; i++) { + printf("%02X", outsum[i]); + } printf("\nawaited result : 50EA825D9684F4229CA29F1FEC511593E281E46A140D81E0005F8F688669A06C\n"); // for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq - + printf("\nend of test sha256\n"); - TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum, test_sum,32); + TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum, test_sum, 32); } /* Tests that treating 2 sha256 objects in // does not impact the result */ -void test_case_sha256_multi() { +void test_case_sha256_multi() +{ const unsigned char test_buf[] = {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"}; const unsigned char test_buf2[] = {"abcdefghijklmnopqrstuvwxyz012345678901234567890123456789"}; // sha256_output_values for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq - const unsigned char test_sum1[] = - { 0x24, 0x8D, 0x6A, 0x61, 0xD2, 0x06, 0x38, 0xB8, - 0xE5, 0xC0, 0x26, 0x93, 0x0C, 0x3E, 0x60, 0x39, - 0xA3, 0x3C, 0xE4, 0x59, 0x64, 0xFF, 0x21, 0x67, - 0xF6, 0xEC, 0xED, 0xD4, 0x19, 0xDB, 0x06, 0xC1 }; + const unsigned char test_sum1[] = { + 0x24, 0x8D, 0x6A, 0x61, 0xD2, 0x06, 0x38, 0xB8, + 0xE5, 0xC0, 0x26, 0x93, 0x0C, 0x3E, 0x60, 0x39, + 0xA3, 0x3C, 0xE4, 0x59, 0x64, 0xFF, 0x21, 0x67, + 0xF6, 0xEC, 0xED, 0xD4, 0x19, 0xDB, 0x06, 0xC1 + }; // sha256_output_values for 3*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq - const unsigned char test_sum2[] = - { 0x50, 0xEA, 0x82, 0x5D, 0x96, 0x84, 0xF4, 0x22, - 0x9C, 0xA2, 0x9F, 0x1F, 0xEC, 0x51, 0x15, 0x93, - 0xE2, 0x81, 0xE4, 0x6A, 0x14, 0x0D, 0x81, 0xE0, - 0x00, 0x5F, 0x8F, 0x68, 0x86, 0x69, 0xA0, 0x6C}; + const unsigned char test_sum2[] = { + 0x50, 0xEA, 0x82, 0x5D, 0x96, 0x84, 0xF4, 0x22, + 0x9C, 0xA2, 0x9F, 0x1F, 0xEC, 0x51, 0x15, 0x93, + 0xE2, 0x81, 0xE4, 0x6A, 0x14, 0x0D, 0x81, 0xE0, + 0x00, 0x5F, 0x8F, 0x68, 0x86, 0x69, 0xA0, 0x6C + }; // sha256_output_values for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdefghijklmnopqrstuvwxyz012345678901234567890123456789 - const unsigned char test_sum3[] = - { 0x6D, 0x5D, 0xDB, 0x5F, 0x4A, 0x94, 0xAB, 0x7E, - 0x5C, 0xF7, 0x9A, 0xD8, 0x3F, 0x58, 0xD3, 0x97, - 0xFE, 0x79, 0xFB, 0x0D, 0x79, 0xB2, 0x0D, 0x22, - 0xFF, 0x95, 0x9F, 0x04, 0xA2, 0xE4, 0x6C, 0x68}; + const unsigned char test_sum3[] = { + 0x6D, 0x5D, 0xDB, 0x5F, 0x4A, 0x94, 0xAB, 0x7E, + 0x5C, 0xF7, 0x9A, 0xD8, 0x3F, 0x58, 0xD3, 0x97, + 0xFE, 0x79, 0xFB, 0x0D, 0x79, 0xB2, 0x0D, 0x22, + 0xFF, 0x95, 0x9F, 0x04, 0xA2, 0xE4, 0x6C, 0x68 + }; unsigned char outsum1[32], outsum2[32], outsum3[32]; int i; @@ -101,55 +109,62 @@ void test_case_sha256_multi() { mbedtls_sha256_context ctx3; printf("test sha256_multi\n"); //Init both contexts - mbedtls_sha256_init( &ctx1); - mbedtls_sha256_init( &ctx2); - mbedtls_sha256_init( &ctx3); + mbedtls_sha256_init(&ctx1); + mbedtls_sha256_init(&ctx2); + mbedtls_sha256_init(&ctx3); //Start both contexts - mbedtls_sha256_starts( &ctx1, 0); - mbedtls_sha256_starts( &ctx2, 0); + mbedtls_sha256_starts(&ctx1, 0); + mbedtls_sha256_starts(&ctx2, 0); printf("upd ctx1\n"); - mbedtls_sha256_update( &ctx1, test_buf, 56 ); + mbedtls_sha256_update(&ctx1, test_buf, 56); printf("upd ctx2\n"); - mbedtls_sha256_update( &ctx2, test_buf, 66 ); + mbedtls_sha256_update(&ctx2, test_buf, 66); printf("finish ctx1\n"); - mbedtls_sha256_finish( &ctx1, outsum1 ); + mbedtls_sha256_finish(&ctx1, outsum1); printf("upd ctx2\n"); - mbedtls_sha256_update( &ctx2, test_buf+66, 46 ); + mbedtls_sha256_update(&ctx2, test_buf + 66, 46); printf("clone ctx2 in ctx3\n"); mbedtls_sha256_clone(&ctx3, (const mbedtls_sha256_context *)&ctx2); printf("free ctx1\n"); - mbedtls_sha256_free( &ctx1 ); + mbedtls_sha256_free(&ctx1); printf("upd ctx2\n"); - mbedtls_sha256_update( &ctx2, test_buf+112, 56 ); + mbedtls_sha256_update(&ctx2, test_buf + 112, 56); printf("upd ctx3 with different values than ctx2\n"); - mbedtls_sha256_update( &ctx3, test_buf2, 56 ); + mbedtls_sha256_update(&ctx3, test_buf2, 56); printf("finish ctx2\n"); - mbedtls_sha256_finish( &ctx2, outsum2 ); + mbedtls_sha256_finish(&ctx2, outsum2); printf("finish ctx3\n"); - mbedtls_sha256_finish( &ctx3, outsum3 ); + mbedtls_sha256_finish(&ctx3, outsum3); printf("free ctx2\n"); - mbedtls_sha256_free( &ctx2 ); + mbedtls_sha256_free(&ctx2); printf("free ctx3\n"); - mbedtls_sha256_free( &ctx3 ); + mbedtls_sha256_free(&ctx3); printf("\nreceived result ctx1 : "); - for (i=0;i<32;i++) { printf("%02X",outsum1[i]);} + for (i = 0; i < 32; i++) { + printf("%02X", outsum1[i]); + } printf("\nawaited result : 248D6A61D20638B8E5C026930C3E6039A33CE45964FF216F6ECEDD19DB06C1\n"); // for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq printf("\nreceived result ctx2 : "); - for (i=0;i<32;i++) { printf("%02X",outsum2[i]);} + for (i = 0; i < 32; i++) { + printf("%02X", outsum2[i]); + } printf("\nawaited result : 50EA825D9684F4229CA29F1FEC511593E281E46A140D81E0005F8F688669A06C\n"); // for 3*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq printf("\nreceived result ctx3 : "); - for (i=0;i<32;i++) { printf("%02X",outsum3[i]);} + for (i = 0; i < 32; i++) { + printf("%02X", outsum3[i]); + } printf("\nawaited result : 6D5DDB5F4A94AB7E5CF79AD83F58D397FE79FB0D79B20D22FF959F04A2E46C68\n"); // for 2*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq+3*0123456789 printf("\nend of test sha256\n"); - TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum1, test_sum1,32); - TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum2, test_sum2,32); - TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum3, test_sum3,32); + TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum1, test_sum1, 32); + TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum2, test_sum2, 32); + TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum3, test_sum3, 32); } #endif //MBEDTLS_SHA256_C -utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) { +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; } @@ -161,19 +176,20 @@ Case cases[] = { #endif }; -utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { +utest::v1::status_t greentea_test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(10, "default_auto"); return greentea_test_setup_handler(number_of_cases); } Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); -int main() { +int main() +{ int ret = 0; #if defined(MBEDTLS_PLATFORM_C) mbedtls_platform_context platform_ctx; - if((ret = mbedtls_platform_setup(&platform_ctx))!= 0) - { + if ((ret = mbedtls_platform_setup(&platform_ctx)) != 0) { mbedtls_printf("Mbed TLS multitest failed! mbedtls_platform_setup returned %d\n", ret); return 1; } diff --git a/TESTS/mbedtls/selftest/main.cpp b/TESTS/mbedtls/selftest/main.cpp index 6635bd0cf22..f2ef3582c22 100644 --- a/TESTS/mbedtls/selftest/main.cpp +++ b/TESTS/mbedtls/selftest/main.cpp @@ -84,19 +84,20 @@ Case cases[] = { #endif /* MBEDTLS_SELF_TEST */ }; -utest::v1::status_t test_setup(const size_t num_cases) { +utest::v1::status_t test_setup(const size_t num_cases) +{ GREENTEA_SETUP(120, "default_auto"); return verbose_test_setup_handler(num_cases); } Specification specification(test_setup, cases); -int main() { +int main() +{ int ret = 0; #if defined(MBEDTLS_PLATFORM_C) mbedtls_platform_context platform_ctx; - if((ret = mbedtls_platform_setup(&platform_ctx))!= 0) - { + if ((ret = mbedtls_platform_setup(&platform_ctx)) != 0) { mbedtls_printf("Mbed TLS selftest failed! mbedtls_platform_setup returned %d\n", ret); return 1; } diff --git a/TESTS/netsocket/tcp/main.cpp b/TESTS/netsocket/tcp/main.cpp index c8f836bef40..70644e4fa79 100644 --- a/TESTS/netsocket/tcp/main.cpp +++ b/TESTS/netsocket/tcp/main.cpp @@ -29,21 +29,21 @@ using namespace utest::v1; -namespace -{ - NetworkInterface* net; - Timer tc_bucket; // Timer to limit a test cases run time +namespace { +NetworkInterface *net; +Timer tc_bucket; // Timer to limit a test cases run time } char tcp_global::rx_buffer[RX_BUFF_SIZE]; char tcp_global::tx_buffer[TX_BUFF_SIZE]; -NetworkInterface* get_interface() +NetworkInterface *get_interface() { return net; } -void drop_bad_packets(TCPSocket& sock, int orig_timeout) { +void drop_bad_packets(TCPSocket &sock, int orig_timeout) +{ nsapi_error_t err; sock.set_timeout(0); while (true) { @@ -55,19 +55,22 @@ void drop_bad_packets(TCPSocket& sock, int orig_timeout) { sock.set_timeout(orig_timeout); } -static void _ifup() { +static void _ifup() +{ net = MBED_CONF_APP_OBJECT_CONSTRUCTION; nsapi_error_t err = MBED_CONF_APP_CONNECT_STATEMENT; TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err); printf("MBED: TCPClient IP address is '%s'\n", net->get_ip_address()); } -static void _ifdown() { +static void _ifdown() +{ net->disconnect(); printf("MBED: ifdown\n"); } -nsapi_error_t tcpsocket_connect_to_echo_srv(TCPSocket& sock) { +nsapi_error_t tcpsocket_connect_to_echo_srv(TCPSocket &sock) +{ SocketAddress tcp_addr; get_interface()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &tcp_addr); @@ -81,7 +84,8 @@ nsapi_error_t tcpsocket_connect_to_echo_srv(TCPSocket& sock) { return sock.connect(tcp_addr); } -nsapi_error_t tcpsocket_connect_to_discard_srv(TCPSocket& sock) { +nsapi_error_t tcpsocket_connect_to_discard_srv(TCPSocket &sock) +{ SocketAddress tcp_addr; get_interface()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &tcp_addr); @@ -97,14 +101,14 @@ nsapi_error_t tcpsocket_connect_to_discard_srv(TCPSocket& sock) { void fill_tx_buffer_ascii(char *buff, size_t len) { - for (size_t i = 0; i= time_allotted) { TEST_FAIL(); @@ -103,10 +104,10 @@ void tcpsocket_echotest_nonblock_receiver(void *receive_bytes) bytes2recv -= recvd; } - TEST_ASSERT_EQUAL(0, memcmp(tcp_global::tx_buffer, tcp_global::rx_buffer, *(int*)receive_bytes)); + TEST_ASSERT_EQUAL(0, memcmp(tcp_global::tx_buffer, tcp_global::rx_buffer, *(int *)receive_bytes)); static int round = 0; - printf("[Recevr#%02d] bytes received: %d\n", round++, *(int*)receive_bytes); + printf("[Recevr#%02d] bytes received: %d\n", round++, *(int *)receive_bytes); tx_sem.release(); @@ -140,10 +141,10 @@ void TCPSOCKET_ECHOTEST_NONBLOCK() bytes2send = pkt_s; while (bytes2send > 0) { - sent = sock.send(&(tcp_global::tx_buffer[pkt_s-bytes2send]), bytes2send); + sent = sock.send(&(tcp_global::tx_buffer[pkt_s - bytes2send]), bytes2send); if (sent == NSAPI_ERROR_WOULD_BLOCK) { if (tc_exec_time.read() >= time_allotted || - osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { + osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { thread->terminate(); delete thread; TEST_FAIL(); diff --git a/TESTS/netsocket/tcp/tcpsocket_echotest_burst.cpp b/TESTS/netsocket/tcp/tcpsocket_echotest_burst.cpp index 2bf623da1d4..2b6d7fa3e54 100644 --- a/TESTS/netsocket/tcp/tcpsocket_echotest_burst.cpp +++ b/TESTS/netsocket/tcp/tcpsocket_echotest_burst.cpp @@ -25,16 +25,16 @@ using namespace utest::v1; -namespace -{ - static const int SIGNAL_SIGIO = 0x1; - static const int SIGIO_TIMEOUT = 5000; //[ms] +namespace { +static const int SIGNAL_SIGIO = 0x1; +static const int SIGIO_TIMEOUT = 5000; //[ms] - static const int BURST_CNT = 100; - static const int BURST_SIZE = 1220; +static const int BURST_CNT = 100; +static const int BURST_SIZE = 1220; } -static void _sigio_handler(osThreadId id) { +static void _sigio_handler(osThreadId id) +{ osSignalSet(id, SIGNAL_SIGIO); } @@ -53,9 +53,9 @@ void TCPSOCKET_ECHOTEST_BURST() for (int i = 0; i < BURST_CNT; i++) { bt_left = BURST_SIZE; while (bt_left > 0) { - sent = sock.send(&(tcp_global::tx_buffer[BURST_SIZE-bt_left]), bt_left); + sent = sock.send(&(tcp_global::tx_buffer[BURST_SIZE - bt_left]), bt_left); if (sent == NSAPI_ERROR_WOULD_BLOCK) { - if(osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { + if (osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { TEST_FAIL(); goto END; } @@ -70,7 +70,7 @@ void TCPSOCKET_ECHOTEST_BURST() bt_left = BURST_SIZE; while (bt_left > 0) { - recvd = sock.recv(&(tcp_global::rx_buffer[BURST_SIZE-bt_left]), BURST_SIZE); + recvd = sock.recv(&(tcp_global::rx_buffer[BURST_SIZE - bt_left]), BURST_SIZE); if (recvd < 0) { printf("[%02d] network error %d\n", i, recvd); break; @@ -106,9 +106,9 @@ void TCPSOCKET_ECHOTEST_BURST_NONBLOCK() for (int i = 0; i < BURST_CNT; i++) { bt_left = BURST_SIZE; while (bt_left > 0) { - sent = sock.send(&(tcp_global::tx_buffer[BURST_SIZE-bt_left]), bt_left); + sent = sock.send(&(tcp_global::tx_buffer[BURST_SIZE - bt_left]), bt_left); if (sent == NSAPI_ERROR_WOULD_BLOCK) { - if(osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { + if (osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { TEST_FAIL(); goto END; } @@ -120,16 +120,16 @@ void TCPSOCKET_ECHOTEST_BURST_NONBLOCK() } bt_left -= sent; } - if (bt_left != 0) { + if (bt_left != 0) { TEST_FAIL(); goto END; - } + } bt_left = BURST_SIZE; while (bt_left > 0) { - recvd = sock.recv(&(tcp_global::rx_buffer[BURST_SIZE-bt_left]), BURST_SIZE); + recvd = sock.recv(&(tcp_global::rx_buffer[BURST_SIZE - bt_left]), BURST_SIZE); if (recvd == NSAPI_ERROR_WOULD_BLOCK) { - if(osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { + if (osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { printf("[bt#%02d] packet timeout...", i); break; } diff --git a/TESTS/netsocket/tcp/tcpsocket_endpoint_close.cpp b/TESTS/netsocket/tcp/tcpsocket_endpoint_close.cpp index a2a68b729f0..ea045109d3f 100644 --- a/TESTS/netsocket/tcp/tcpsocket_endpoint_close.cpp +++ b/TESTS/netsocket/tcp/tcpsocket_endpoint_close.cpp @@ -25,17 +25,18 @@ using namespace utest::v1; -namespace -{ - static const int SIGNAL_SIGIO = 0x1; - static const int SIGIO_TIMEOUT = 5000; //[ms] +namespace { +static const int SIGNAL_SIGIO = 0x1; +static const int SIGIO_TIMEOUT = 5000; //[ms] } -static void _sigio_handler(osThreadId id) { +static void _sigio_handler(osThreadId id) +{ osSignalSet(id, SIGNAL_SIGIO); } -static nsapi_error_t _tcpsocket_connect_to_daytime_srv(TCPSocket& sock) { +static nsapi_error_t _tcpsocket_connect_to_daytime_srv(TCPSocket &sock) +{ SocketAddress tcp_addr; get_interface()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &tcp_addr); @@ -68,22 +69,22 @@ void TCPSOCKET_ENDPOINT_CLOSE() int recvd = 0; int recvd_total = 0; while (true) { - recvd = sock.recv(&(buff[recvd_total]), MORE_THAN_AVAILABLE); - if (recvd_total > 0 && recvd == 0) { - break; // Endpoint closed socket, success - } else if (recvd <= 0) { + recvd = sock.recv(&(buff[recvd_total]), MORE_THAN_AVAILABLE); + if (recvd_total > 0 && recvd == 0) { + break; // Endpoint closed socket, success + } else if (recvd <= 0) { TEST_FAIL(); break; - } else if (recvd == NSAPI_ERROR_WOULD_BLOCK) { - if(tc_exec_time.read() >= time_allotted || - osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { - TEST_FAIL(); - break; - } - continue; - } - recvd_total += recvd; - TEST_ASSERT(recvd_total < MORE_THAN_AVAILABLE); + } else if (recvd == NSAPI_ERROR_WOULD_BLOCK) { + if (tc_exec_time.read() >= time_allotted || + osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { + TEST_FAIL(); + break; + } + continue; + } + recvd_total += recvd; + TEST_ASSERT(recvd_total < MORE_THAN_AVAILABLE); } tc_exec_time.stop(); TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close()); diff --git a/TESTS/netsocket/tcp/tcpsocket_open_limit.cpp b/TESTS/netsocket/tcp/tcpsocket_open_limit.cpp index fcc1ac80bad..f0cd3ac7e3c 100644 --- a/TESTS/netsocket/tcp/tcpsocket_open_limit.cpp +++ b/TESTS/netsocket/tcp/tcpsocket_open_limit.cpp @@ -25,12 +25,11 @@ using namespace utest::v1; -namespace -{ - typedef struct TCPSocketItem { - TCPSocket *sock; - TCPSocketItem *next; - } SocketItem; +namespace { +typedef struct TCPSocketItem { + TCPSocket *sock; + TCPSocketItem *next; +} SocketItem; } void TCPSOCKET_OPEN_LIMIT() @@ -73,7 +72,7 @@ void TCPSOCKET_OPEN_LIMIT() } TCPSocketItem *tmp; - for(TCPSocketItem *it = socket_list_head; it;) { + for (TCPSocketItem *it = socket_list_head; it;) { ++open_sockets[i]; tmp = it; it = it->next; diff --git a/TESTS/netsocket/tcp/tcpsocket_recv_100k.cpp b/TESTS/netsocket/tcp/tcpsocket_recv_100k.cpp index d42755b4f1f..726804c1e63 100644 --- a/TESTS/netsocket/tcp/tcpsocket_recv_100k.cpp +++ b/TESTS/netsocket/tcp/tcpsocket_recv_100k.cpp @@ -25,13 +25,12 @@ using namespace utest::v1; -namespace -{ - static const int SIGNAL_SIGIO = 0x1; - static const int SIGIO_TIMEOUT = 20000; //[ms] +namespace { +static const int SIGNAL_SIGIO = 0x1; +static const int SIGIO_TIMEOUT = 20000; //[ms] } -static nsapi_error_t _tcpsocket_connect_to_chargen_srv(TCPSocket& sock) +static nsapi_error_t _tcpsocket_connect_to_chargen_srv(TCPSocket &sock) { SocketAddress tcp_addr; @@ -63,12 +62,13 @@ static nsapi_error_t _tcpsocket_connect_to_chargen_srv(TCPSocket& sock) static void generate_RFC_864_pattern(size_t offset, uint8_t *buf, size_t len) { while (len--) { - if (offset % 74 == 72) + if (offset % 74 == 72) { *buf++ = '\r'; - else if (offset % 74 == 73) + } else if (offset % 74 == 73) { *buf++ = '\n'; - else - *buf++ = ' ' + (offset%74 + offset/74) % 95 ; + } else { + *buf++ = ' ' + (offset % 74 + offset / 74) % 95 ; + } offset++; } } @@ -78,14 +78,15 @@ static void check_RFC_864_pattern(void *rx_buff, const size_t len, const size_t void *ref_buff = malloc(len); TEST_ASSERT_NOT_NULL(ref_buff); - generate_RFC_864_pattern(offset, (uint8_t*)ref_buff, len); + generate_RFC_864_pattern(offset, (uint8_t *)ref_buff, len); bool match = memcmp(ref_buff, rx_buff, len) == 0; free(ref_buff); TEST_ASSERT(match); } -void rcv_n_chk_against_rfc864_pattern(TCPSocket& sock) { +void rcv_n_chk_against_rfc864_pattern(TCPSocket &sock) +{ static const size_t total_size = 1024 * 100; static const size_t buff_size = 1220; uint8_t buff[buff_size]; @@ -121,7 +122,7 @@ void TCPSOCKET_RECV_100K() TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close()); } -void rcv_n_chk_against_rfc864_pattern_nonblock(TCPSocket& sock) +void rcv_n_chk_against_rfc864_pattern_nonblock(TCPSocket &sock) { static const size_t total_size = 1024 * 100; static const size_t buff_size = 1220; @@ -154,7 +155,8 @@ void rcv_n_chk_against_rfc864_pattern_nonblock(TCPSocket& sock) printf("MBED: Time taken: %fs\n", timer.read()); } -static void _sigio_handler(osThreadId id) { +static void _sigio_handler(osThreadId id) +{ osSignalSet(id, SIGNAL_SIGIO); } diff --git a/TESTS/netsocket/tcp/tcpsocket_recv_timeout.cpp b/TESTS/netsocket/tcp/tcpsocket_recv_timeout.cpp index 080a6c788f0..9f69614bd64 100644 --- a/TESTS/netsocket/tcp/tcpsocket_recv_timeout.cpp +++ b/TESTS/netsocket/tcp/tcpsocket_recv_timeout.cpp @@ -25,13 +25,13 @@ using namespace utest::v1; -namespace -{ - static const int SIGNAL_SIGIO = 0x1; - static const int SIGIO_TIMEOUT = 5000; //[ms] +namespace { +static const int SIGNAL_SIGIO = 0x1; +static const int SIGIO_TIMEOUT = 5000; //[ms] } -static void _sigio_handler(osThreadId id) { +static void _sigio_handler(osThreadId id) +{ osSignalSet(id, SIGNAL_SIGIO); } @@ -58,12 +58,12 @@ void TCPSOCKET_RECV_TIMEOUT() while (pkt_unrecvd) { timer.reset(); timer.start(); - recvd = sock.recv(&(buff[DATA_LEN-pkt_unrecvd]), pkt_unrecvd); + recvd = sock.recv(&(buff[DATA_LEN - pkt_unrecvd]), pkt_unrecvd); timer.stop(); if (recvd == NSAPI_ERROR_WOULD_BLOCK) { if (tc_exec_time.read() >= time_allotted || - (osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout)) { + (osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout)) { TEST_FAIL(); goto CLEANUP; } diff --git a/TESTS/netsocket/tcp/tcpsocket_send_repeat.cpp b/TESTS/netsocket/tcp/tcpsocket_send_repeat.cpp index 54804b7ba39..1c0aa9daccd 100644 --- a/TESTS/netsocket/tcp/tcpsocket_send_repeat.cpp +++ b/TESTS/netsocket/tcp/tcpsocket_send_repeat.cpp @@ -32,7 +32,7 @@ void TCPSOCKET_SEND_REPEAT() int snd; Timer timer; - static const char tx_buffer[] = {'h','e','l','l','o'}; + static const char tx_buffer[] = {'h', 'e', 'l', 'l', 'o'}; for (int i = 0; i < 1000; i++) { snd = sock.send(tx_buffer, sizeof(tx_buffer)); if (snd != sizeof(tx_buffer)) { diff --git a/TESTS/netsocket/tcp/tcpsocket_send_timeout.cpp b/TESTS/netsocket/tcp/tcpsocket_send_timeout.cpp index b6f73df9c82..a302c2cc23a 100644 --- a/TESTS/netsocket/tcp/tcpsocket_send_timeout.cpp +++ b/TESTS/netsocket/tcp/tcpsocket_send_timeout.cpp @@ -35,14 +35,14 @@ void TCPSOCKET_SEND_TIMEOUT() int err; Timer timer; - static const char tx_buffer[] = {'h','e','l','l','o'}; + static const char tx_buffer[] = {'h', 'e', 'l', 'l', 'o'}; for (int i = 0; i < 10; i++) { timer.reset(); timer.start(); err = sock.send(tx_buffer, sizeof(tx_buffer)); timer.stop(); if ((err == sizeof(tx_buffer)) && - (timer.read_ms() <= 800)) { + (timer.read_ms() <= 800)) { continue; } TEST_FAIL(); diff --git a/TESTS/netsocket/tcp/tcpsocket_thread_per_socket_safety.cpp b/TESTS/netsocket/tcp/tcpsocket_thread_per_socket_safety.cpp index 618aed3f139..7a0226e2c0c 100644 --- a/TESTS/netsocket/tcp/tcpsocket_thread_per_socket_safety.cpp +++ b/TESTS/netsocket/tcp/tcpsocket_thread_per_socket_safety.cpp @@ -25,21 +25,22 @@ using namespace utest::v1; -namespace -{ - static const int SIGNAL_SIGIO1 = 0x1; - static const int SIGNAL_SIGIO2 = 0x2; - static const int SIGIO_TIMEOUT = 5000; //[ms] +namespace { +static const int SIGNAL_SIGIO1 = 0x1; +static const int SIGNAL_SIGIO2 = 0x2; +static const int SIGIO_TIMEOUT = 5000; //[ms] - Thread thread; - volatile bool running = true; +Thread thread; +volatile bool running = true; } -static void _sigio_handler1(osThreadId id) { +static void _sigio_handler1(osThreadId id) +{ osSignalSet(id, SIGNAL_SIGIO1); } -static void _sigio_handler2(osThreadId id) { +static void _sigio_handler2(osThreadId id) +{ osSignalSet(id, SIGNAL_SIGIO2); } @@ -61,9 +62,9 @@ static void check_const_len_rand_sequence() fill_tx_buffer_ascii(tx_buff, BUFF_SIZE); bytes2process = BUFF_SIZE; while (bytes2process > 0) { - sent = sock.send(&(tx_buff[BUFF_SIZE-bytes2process]), bytes2process); + sent = sock.send(&(tx_buff[BUFF_SIZE - bytes2process]), bytes2process); if (sent == NSAPI_ERROR_WOULD_BLOCK) { - if(osSignalWait(SIGNAL_SIGIO1, SIGIO_TIMEOUT).status == osEventTimeout) { + if (osSignalWait(SIGNAL_SIGIO1, SIGIO_TIMEOUT).status == osEventTimeout) { TEST_FAIL(); goto END; } @@ -78,7 +79,7 @@ static void check_const_len_rand_sequence() bytes2process = BUFF_SIZE; while (bytes2process > 0) { - recvd = sock.recv(&(rx_buff[BUFF_SIZE-bytes2process]), bytes2process); + recvd = sock.recv(&(rx_buff[BUFF_SIZE - bytes2process]), bytes2process); if (recvd == NSAPI_ERROR_WOULD_BLOCK) { continue; } else if (recvd < 0) { @@ -118,9 +119,9 @@ static void check_var_len_rand_sequence() fill_tx_buffer_ascii(tx_buff, i); bytes2process = i; while (bytes2process > 0) { - sent = sock.send(&(tx_buff[i-bytes2process]), bytes2process); + sent = sock.send(&(tx_buff[i - bytes2process]), bytes2process); if (sent == NSAPI_ERROR_WOULD_BLOCK) { - if(osSignalWait(SIGNAL_SIGIO2, SIGIO_TIMEOUT).status == osEventTimeout) { + if (osSignalWait(SIGNAL_SIGIO2, SIGIO_TIMEOUT).status == osEventTimeout) { TEST_FAIL(); goto END; } @@ -130,12 +131,12 @@ static void check_var_len_rand_sequence() TEST_FAIL(); goto END; } - bytes2process -= sent; + bytes2process -= sent; } bytes2process = i; while (bytes2process > 0) { - recvd = sock.recv(&(rx_buff[i-bytes2process]), bytes2process); + recvd = sock.recv(&(rx_buff[i - bytes2process]), bytes2process); if (recvd == NSAPI_ERROR_WOULD_BLOCK) { continue; } else if (recvd < 0) { diff --git a/TESTS/netsocket/udp/main.cpp b/TESTS/netsocket/udp/main.cpp index 9e171b8a04d..31cb7cfb916 100644 --- a/TESTS/netsocket/udp/main.cpp +++ b/TESTS/netsocket/udp/main.cpp @@ -29,29 +29,31 @@ using namespace utest::v1; -namespace -{ - NetworkInterface* net; +namespace { +NetworkInterface *net; } -NetworkInterface* get_interface() +NetworkInterface *get_interface() { return net; } -static void _ifup() { +static void _ifup() +{ net = MBED_CONF_APP_OBJECT_CONSTRUCTION; nsapi_error_t err = MBED_CONF_APP_CONNECT_STATEMENT; TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err); printf("MBED: UDPClient IP address is '%s'\n", net->get_ip_address()); } -static void _ifdown() { +static void _ifdown() +{ net->disconnect(); printf("MBED: ifdown\n"); } -void drop_bad_packets(UDPSocket& sock, int orig_timeout) { +void drop_bad_packets(UDPSocket &sock, int orig_timeout) +{ nsapi_error_t err; sock.set_timeout(0); while (true) { @@ -65,7 +67,7 @@ void drop_bad_packets(UDPSocket& sock, int orig_timeout) { void fill_tx_buffer_ascii(char *buff, size_t len) { - for (size_t i = 0; i RECV_TIMEOUT ? recv_timeout/2 : RECV_TIMEOUT; + recv_timeout = recv_timeout > RECV_TIMEOUT ? recv_timeout / 2 : RECV_TIMEOUT; // Packets might arrive unordered for (int k = 0; k < BURST_PKTS; k++) { if (tx_buffers[k].len == recvd && - (memcmp(tx_buffers[k].payload, rx_buffer, recvd) == 0)) { + (memcmp(tx_buffers[k].payload, rx_buffer, recvd) == 0)) { bt_total += recvd; } } @@ -135,13 +137,13 @@ void UDPSOCKET_ECHOTEST_BURST() free_tx_buffers(); - double loss_ratio = 1 - ((double)(BURST_CNT*BURST_PKTS-pkg_fail) / (double)(BURST_CNT*BURST_PKTS)); + double loss_ratio = 1 - ((double)(BURST_CNT * BURST_PKTS - pkg_fail) / (double)(BURST_CNT * BURST_PKTS)); printf("Packets sent: %d, packets received %d, loss ratio %.2lf\r\n", - BURST_CNT*BURST_PKTS, BURST_CNT*BURST_PKTS-pkg_fail, loss_ratio); + BURST_CNT * BURST_PKTS, BURST_CNT * BURST_PKTS - pkg_fail, loss_ratio); // Packet loss up to 30% tolerated TEST_ASSERT_DOUBLE_WITHIN(TOLERATED_LOSS_RATIO, EXPECTED_LOSS_RATIO, loss_ratio); // 70% of the bursts need to be successful - TEST_ASSERT_INT_WITHIN(3*(BURST_CNT/10), BURST_CNT, ok_bursts); + TEST_ASSERT_INT_WITHIN(3 * (BURST_CNT / 10), BURST_CNT, ok_bursts); TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close()); } @@ -175,8 +177,8 @@ void UDPSOCKET_ECHOTEST_BURST_NONBLOCK() for (int j = 0; j < BURST_PKTS; j++) { recvd = sock.recvfrom(&temp_addr, rx_buffer, 500); if (recvd == NSAPI_ERROR_WOULD_BLOCK) { - if(osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { - pkg_fail += BURST_PKTS-j; + if (osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) { + pkg_fail += BURST_PKTS - j; break; } --j; @@ -191,7 +193,7 @@ void UDPSOCKET_ECHOTEST_BURST_NONBLOCK() // Packets might arrive unordered for (int k = 0; k < BURST_PKTS; k++) { if (tx_buffers[k].len == recvd && - (memcmp(tx_buffers[k].payload, rx_buffer, recvd) == 0)) { + (memcmp(tx_buffers[k].payload, rx_buffer, recvd) == 0)) { bt_total += recvd; goto PKT_OK; } @@ -213,13 +215,13 @@ void UDPSOCKET_ECHOTEST_BURST_NONBLOCK() free_tx_buffers(); - double loss_ratio = 1 - ((double)(BURST_CNT*BURST_PKTS-pkg_fail) / (double)(BURST_CNT*BURST_PKTS)); + double loss_ratio = 1 - ((double)(BURST_CNT * BURST_PKTS - pkg_fail) / (double)(BURST_CNT * BURST_PKTS)); printf("Packets sent: %d, packets received %d, loss ratio %.2lf\r\n", - BURST_CNT*BURST_PKTS, BURST_CNT*BURST_PKTS-pkg_fail, loss_ratio); + BURST_CNT * BURST_PKTS, BURST_CNT * BURST_PKTS - pkg_fail, loss_ratio); // Packet loss up to 30% tolerated TEST_ASSERT_DOUBLE_WITHIN(TOLERATED_LOSS_RATIO, EXPECTED_LOSS_RATIO, loss_ratio); // 70% of the bursts need to be successful - TEST_ASSERT_INT_WITHIN(3*(BURST_CNT/10), BURST_CNT, ok_bursts); + TEST_ASSERT_INT_WITHIN(3 * (BURST_CNT / 10), BURST_CNT, ok_bursts); TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close()); } diff --git a/TESTS/netsocket/udp/udpsocket_open_limit.cpp b/TESTS/netsocket/udp/udpsocket_open_limit.cpp index 3766ee49b26..4d4fcf57216 100644 --- a/TESTS/netsocket/udp/udpsocket_open_limit.cpp +++ b/TESTS/netsocket/udp/udpsocket_open_limit.cpp @@ -25,12 +25,11 @@ using namespace utest::v1; -namespace -{ - typedef struct UDPSocketItem { - UDPSocket *sock; - UDPSocketItem *next; - } SocketItem; +namespace { +typedef struct UDPSocketItem { + UDPSocket *sock; + UDPSocketItem *next; +} SocketItem; } void UDPSOCKET_OPEN_LIMIT() @@ -73,7 +72,7 @@ void UDPSOCKET_OPEN_LIMIT() } UDPSocketItem *tmp; - for(UDPSocketItem *it = socket_list_head; it;) { + for (UDPSocketItem *it = socket_list_head; it;) { ++open_sockets[i]; tmp = it; it = it->next; diff --git a/TESTS/netsocket/udp/udpsocket_recv_timeout.cpp b/TESTS/netsocket/udp/udpsocket_recv_timeout.cpp index 3c00c183998..ea0b9be829b 100644 --- a/TESTS/netsocket/udp/udpsocket_recv_timeout.cpp +++ b/TESTS/netsocket/udp/udpsocket_recv_timeout.cpp @@ -25,13 +25,13 @@ using namespace utest::v1; -namespace -{ - static const int SIGNAL_SIGIO = 0x1; - static const int SIGIO_TIMEOUT = 5000; //[ms] +namespace { +static const int SIGNAL_SIGIO = 0x1; +static const int SIGIO_TIMEOUT = 5000; //[ms] } -static void _sigio_handler(osThreadId id) { +static void _sigio_handler(osThreadId id) +{ osSignalSet(id, SIGNAL_SIGIO); } diff --git a/TESTS/netsocket/udp/udpsocket_sendto_repeat.cpp b/TESTS/netsocket/udp/udpsocket_sendto_repeat.cpp index 4b78f9592a7..db7a1d8297b 100644 --- a/TESTS/netsocket/udp/udpsocket_sendto_repeat.cpp +++ b/TESTS/netsocket/udp/udpsocket_sendto_repeat.cpp @@ -37,7 +37,7 @@ void UDPSOCKET_SENDTO_REPEAT() int sent; Timer timer; int i; - static const char tx_buffer[] = {'h','e','l','l','o'}; + static const char tx_buffer[] = {'h', 'e', 'l', 'l', 'o'}; bool oom_earlier = false; // 2 times in a row -> time to give up for (i = 0; i < 100; i++) { sent = sock.sendto(udp_addr, tx_buffer, sizeof(tx_buffer)); diff --git a/TESTS/network/emac/emac_TestMemoryManager.cpp b/TESTS/network/emac/emac_TestMemoryManager.cpp index 05a0a62663e..c37dc2068a7 100644 --- a/TESTS/network/emac/emac_TestMemoryManager.cpp +++ b/TESTS/network/emac/emac_TestMemoryManager.cpp @@ -203,7 +203,7 @@ emac_mem_buf_t *EmacTestMemoryManager::alloc_pool(uint32_t size, uint32_t align, if (size_left > pool_buffer_max_size) { size_left = size_left - pool_buffer_max_size; alloc_size = pool_buffer_max_size; - // New smaller than alloc size buffer needed + // New smaller than alloc size buffer needed } else { alloc_size = size_left; size_left = 0; @@ -550,7 +550,8 @@ void EmacTestMemoryManager::validate_list() const m_mem_mutex.unlock(); } -EmacTestMemoryManager &EmacTestMemoryManager::get_instance() { +EmacTestMemoryManager &EmacTestMemoryManager::get_instance() +{ static EmacTestMemoryManager test_memory_manager; return test_memory_manager; } diff --git a/TESTS/network/emac/emac_TestNetworkStack.h b/TESTS/network/emac/emac_TestNetworkStack.h index d781d15190b..9b128b53a28 100644 --- a/TESTS/network/emac/emac_TestNetworkStack.h +++ b/TESTS/network/emac/emac_TestNetworkStack.h @@ -56,7 +56,7 @@ class EmacTestNetworkStack : public OnboardNetworkStack, private mbed::NonCopyab const char *netmask, const char *gw, nsapi_ip_stack_t stack = DEFAULT_STACK, bool blocking = true - ); + ); /** Disconnect interface from the network * @@ -148,7 +148,7 @@ class EmacTestNetworkStack : public OnboardNetworkStack, private mbed::NonCopyab * @return 0 on success, negative error code on failure */ virtual nsapi_error_t gethostbyname(const char *host, - SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC); + SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC); /** Add a domain name server to list of servers to query * @@ -236,7 +236,7 @@ class EmacTestNetworkStack : public OnboardNetworkStack, private mbed::NonCopyab * @return 0 on success, negative error code on failure */ virtual nsapi_error_t socket_accept(nsapi_socket_t server, - nsapi_socket_t *handle, SocketAddress *address=0); + nsapi_socket_t *handle, SocketAddress *address = 0); /** Send data over a TCP socket * diff --git a/TESTS/network/emac/emac_ctp.cpp b/TESTS/network/emac/emac_ctp.cpp index dde3b82ca09..71b5d22a93c 100644 --- a/TESTS/network/emac/emac_ctp.cpp +++ b/TESTS/network/emac/emac_ctp.cpp @@ -90,7 +90,7 @@ ctp_function emac_if_ctp_header_handle(unsigned char *eth_input_frame, unsigned // Copy own address to origin memcpy(ð_output_frame[6], origin_addr, 6); return CTP_FORWARD; - // reply + // reply } else if (function == 0x0001) { *receipt_number = ethernet_ptr[1] << 8 | ethernet_ptr[0]; return CTP_REPLY; diff --git a/TESTS/network/emac/emac_test_initialize.cpp b/TESTS/network/emac/emac_test_initialize.cpp index 568cc577d60..7d663802881 100644 --- a/TESTS/network/emac/emac_test_initialize.cpp +++ b/TESTS/network/emac/emac_test_initialize.cpp @@ -83,7 +83,7 @@ void test_emac_initialize() int size = network_interface->scan(ap, 30); - for (int i=0; i(ð_mac_addr[0])); emac->get_hwaddr(eth_mac_addr); emac->set_hwaddr(eth_mac_addr); - printf("emac hwaddr %x:%x:%x:%x:%x:%x\r\n\r\n", eth_mac_addr[0],eth_mac_addr[1],eth_mac_addr[2],eth_mac_addr[3],eth_mac_addr[4],eth_mac_addr[5]); + printf("emac hwaddr %x:%x:%x:%x:%x:%x\r\n\r\n", eth_mac_addr[0], eth_mac_addr[1], eth_mac_addr[2], eth_mac_addr[3], eth_mac_addr[4], eth_mac_addr[5]); int mtu_size = emac->get_mtu_size(); printf("emac mtu %i\r\n\r\n", mtu_size); diff --git a/TESTS/network/emac/emac_test_memory.cpp b/TESTS/network/emac/emac_test_memory.cpp index 4c358af6e41..2bb781850ff 100644 --- a/TESTS/network/emac/emac_test_memory.cpp +++ b/TESTS/network/emac/emac_test_memory.cpp @@ -86,19 +86,19 @@ void test_emac_memory_cb(int opt) break; case 6: - printf("STEP 6: memory available\r\n\r\n"); - emac_if_set_output_memory(true); - emac_if_set_input_memory(true); - memory = true; - break; + printf("STEP 6: memory available\r\n\r\n"); + emac_if_set_output_memory(true); + emac_if_set_input_memory(true); + memory = true; + break; case 7: - printf("STEP 7: memory available, alloc from heap\r\n\r\n"); - emac_if_set_output_memory(true); - emac_if_set_input_memory(true); - options |= CTP_OPT_HEAP; - memory = true; - break; + printf("STEP 7: memory available, alloc from heap\r\n\r\n"); + emac_if_set_output_memory(true); + emac_if_set_input_memory(true); + options |= CTP_OPT_HEAP; + memory = true; + break; case 8: // Test ended @@ -121,7 +121,7 @@ void test_emac_memory_cb(int opt) printf("too many retries\r\n\r\n"); SET_ERROR_FLAGS(TEST_FAILED); END_TEST_LOOP; - // Otherwise continues test + // Otherwise continues test } else { RESET_OUTGOING_MSG_DATA; next_len = true; diff --git a/TESTS/network/emac/emac_test_unicast.cpp b/TESTS/network/emac/emac_test_unicast.cpp index 53b258d33e1..fc20b0771b5 100644 --- a/TESTS/network/emac/emac_test_unicast.cpp +++ b/TESTS/network/emac/emac_test_unicast.cpp @@ -58,8 +58,8 @@ void test_emac_unicast_cb(int opt) if (++test_step == 3) { END_TEST_LOOP; } else { - retries = 0; - send_request = true; + retries = 0; + send_request = true; } } } diff --git a/TESTS/network/emac/emac_util.cpp b/TESTS/network/emac/emac_util.cpp index ede4925e13d..f812adc2e4e 100644 --- a/TESTS/network/emac/emac_util.cpp +++ b/TESTS/network/emac/emac_util.cpp @@ -81,7 +81,7 @@ typedef struct { extern struct netif *netif_list; // Broadcast address -const unsigned char eth_mac_broadcast_addr[ETH_MAC_ADDR_LEN] = {0xff,0xff,0xff,0xff,0xff,0xff}; +const unsigned char eth_mac_broadcast_addr[ETH_MAC_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; // MTU size static int eth_mtu_size = 0; @@ -213,9 +213,9 @@ void emac_if_validate_outgoing_msg(void) if (!(outgoing_msgs[i].flags & PRINTED)) { if ((trace_level & TRACE_SUCCESS) || ((trace_level & TRACE_FAILURE) && failure)) { printf("response: receipt number %i %s %s %s\r\n\r\n", outgoing_msgs[i].receipt_number, - outgoing_msgs[i].flags & INVALID_LENGHT ? "LENGTH INVALID" : "LENGTH OK", - outgoing_msgs[i].flags & INVALID_DATA ? "DATA INVALID" : "DATA OK", - outgoing_msgs[i].flags & BROADCAST ? "BROADCAST" : "UNICAST"); + outgoing_msgs[i].flags & INVALID_LENGHT ? "LENGTH INVALID" : "LENGTH OK", + outgoing_msgs[i].flags & INVALID_DATA ? "DATA INVALID" : "DATA OK", + outgoing_msgs[i].flags & BROADCAST ? "BROADCAST" : "UNICAST"); outgoing_msgs[i].flags |= PRINTED; } } @@ -338,22 +338,22 @@ void emac_if_reset_all_error_flags(void) void emac_if_print_error_flags(void) { - int error_flags_value = emac_if_get_error_flags(); + int error_flags_value = emac_if_get_error_flags(); - char no_resp_message[50]; - if (error_flags_value & NO_RESPONSE) { - snprintf(no_resp_message, 50, "no response from echo server, counter: %i", no_response_cnt); - } else if (no_response_cnt > 0) { - printf("no response from echo server, counter: %i\r\n\r\n", no_response_cnt); - } + char no_resp_message[50]; + if (error_flags_value & NO_RESPONSE) { + snprintf(no_resp_message, 50, "no response from echo server, counter: %i", no_response_cnt); + } else if (no_response_cnt > 0) { + printf("no response from echo server, counter: %i\r\n\r\n", no_response_cnt); + } - printf("test result: %s%s%s%s%s%s\r\n\r\n", - error_flags_value ? "Test FAILED, reason: ": "PASS", - error_flags_value & TEST_FAILED ? "test failed ": "", - error_flags_value & MSG_VALID_ERROR ? "message content validation error ": "", - error_flags_value & OUT_OF_MSG_DATA ? "out of message validation data storage ": "", - error_flags_value & NO_FREE_MEM_BUF ? "no free memory buffers ": "", - error_flags_value & NO_RESPONSE ? no_resp_message: ""); + printf("test result: %s%s%s%s%s%s\r\n\r\n", + error_flags_value ? "Test FAILED, reason: " : "PASS", + error_flags_value & TEST_FAILED ? "test failed " : "", + error_flags_value & MSG_VALID_ERROR ? "message content validation error " : "", + error_flags_value & OUT_OF_MSG_DATA ? "out of message validation data storage " : "", + error_flags_value & NO_FREE_MEM_BUF ? "no free memory buffers " : "", + error_flags_value & NO_RESPONSE ? no_resp_message : ""); } void emac_if_set_trace_level(char trace_level_value) @@ -371,14 +371,14 @@ void emac_if_trace_to_ascii_hex_dump(const char *prefix, int len, unsigned char int line_len = 0; for (int i = 0; i < len; i++) { - if ((line_len % 14) == 0) { - if (line_len != 0) { - printf("\r\n"); - } - printf("%s %06x", prefix, line_len); - } - line_len++; - printf(" %02x", data[i]); + if ((line_len % 14) == 0) { + if (line_len != 0) { + printf("\r\n"); + } + printf("%s %06x", prefix, line_len); + } + line_len++; + printf(" %02x", data[i]); } printf("\r\n\r\n"); } @@ -417,7 +417,7 @@ void emac_if_check_memory(bool output) void emac_if_set_memory(bool memory) { static bool memory_value = true; - if (memory_value != memory ) { + if (memory_value != memory) { memory_value = memory; EmacTestMemoryManager *mem_mngr = emac_m_mngr_get(); mem_mngr->set_memory_available(memory); @@ -468,7 +468,7 @@ static void link_input_event_cb(void *buf) worker_loop_event_queue.call(current_test_step_cb_fnc, INPUT); } #if MBED_CONF_APP_ECHO_SERVER - // Echoes only if configured as echo server + // Echoes only if configured as echo server } else if (function == CTP_FORWARD) { emac_if_memory_buffer_write(buf, eth_output_frame_data, false); emac_if_get()->link_out(buf); @@ -479,9 +479,9 @@ static void link_input_event_cb(void *buf) emac_if_add_echo_server_addr(ð_input_frame_data[6]); if (trace_level & TRACE_ETH_FRAMES) { - printf("INP> LEN %i\r\n\r\n", length); - const char trace_type[] = "INP>"; - emac_if_trace_to_ascii_hex_dump(trace_type, ETH_FRAME_HEADER_LEN, eth_input_frame_data); + printf("INP> LEN %i\r\n\r\n", length); + const char trace_type[] = "INP>"; + emac_if_trace_to_ascii_hex_dump(trace_type, ETH_FRAME_HEADER_LEN, eth_input_frame_data); } } } diff --git a/TESTS/network/emac/main.cpp b/TESTS/network/emac/main.cpp index c9aba478ef6..9d8dcff25ff 100644 --- a/TESTS/network/emac/main.cpp +++ b/TESTS/network/emac/main.cpp @@ -53,7 +53,8 @@ using namespace utest::v1; // Test setup -utest::v1::status_t test_setup(const size_t number_of_cases) { +utest::v1::status_t test_setup(const size_t number_of_cases) +{ #if !MBED_CONF_APP_ECHO_SERVER GREENTEA_SETUP(600, "default_auto"); #endif diff --git a/TESTS/network/wifi/get_interface.cpp b/TESTS/network/wifi/get_interface.cpp index a3ffcf0b53f..9a4759e1bdf 100644 --- a/TESTS/network/wifi/get_interface.cpp +++ b/TESTS/network/wifi/get_interface.cpp @@ -16,11 +16,11 @@ */ #ifndef MBED_CONF_APP_OBJECT_CONSTRUCTION - #error [NOT_SUPPORTED] No network interface found for this target. +#error [NOT_SUPPORTED] No network interface found for this target. #endif #if !defined(MBED_CONF_APP_WIFI_SECURE_SSID) && !defined(MBED_CONF_APP_WIFI_UNSECURE_SSID) - #error [NOT_SUPPORTED] Requires parameters from mbed_app.json +#error [NOT_SUPPORTED] Requires parameters from mbed_app.json #endif #include "mbed.h" diff --git a/TESTS/network/wifi/main.cpp b/TESTS/network/wifi/main.cpp index 7cd699e33b3..703ff0406e3 100644 --- a/TESTS/network/wifi/main.cpp +++ b/TESTS/network/wifi/main.cpp @@ -16,7 +16,7 @@ */ #ifndef MBED_CONF_APP_OBJECT_CONSTRUCTION - #error [NOT_SUPPORTED] No network interface found for this target. +#error [NOT_SUPPORTED] No network interface found for this target. #endif #include "mbed.h" @@ -48,7 +48,8 @@ using namespace utest::v1; -utest::v1::status_t test_setup(const size_t number_of_cases) { +utest::v1::status_t test_setup(const size_t number_of_cases) +{ GREENTEA_SETUP(240, "default_auto"); return verbose_test_setup_handler(number_of_cases); } @@ -90,6 +91,7 @@ Case cases[] = { Specification specification(test_setup, cases); // Entry point into the tests -int main() { +int main() +{ return !Harness::run(specification); } diff --git a/TESTS/network/wifi/wifi-constructor.cpp b/TESTS/network/wifi/wifi-constructor.cpp index 3fa80ff5cbb..d97d3a3fde2 100644 --- a/TESTS/network/wifi/wifi-constructor.cpp +++ b/TESTS/network/wifi/wifi-constructor.cpp @@ -23,7 +23,8 @@ using namespace utest::v1; -void wifi_constructor() { +void wifi_constructor() +{ WiFiInterface *wifi = get_interface(); TEST_ASSERT(wifi); } diff --git a/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp b/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp index 90f4c5994bd..e23980e18af 100644 --- a/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp +++ b/TESTS/network/wifi/wifi_connect_disconnect_repeat.cpp @@ -33,7 +33,7 @@ void wifi_connect_disconnect_repeat(void) error = wifi->set_credentials(MBED_CONF_APP_WIFI_UNSECURE_SSID, NULL); TEST_ASSERT(error == NSAPI_ERROR_OK); - for(int i=0; i<10; i++) { + for (int i = 0; i < 10; i++) { error = wifi->connect(); TEST_ASSERT(error == NSAPI_ERROR_OK); error = wifi->disconnect(); diff --git a/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp b/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp index a3c531fd103..d365ed77d84 100644 --- a/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp +++ b/TESTS/network/wifi/wifi_connect_params_channel_fail.cpp @@ -35,7 +35,7 @@ void wifi_connect_params_channel_fail(void) } nsapi_error_t error = wifi->connect(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, get_security(), MBED_CONF_APP_WIFI_CH_UNSECURE); - TEST_ASSERT(error==NSAPI_ERROR_CONNECTION_TIMEOUT || error==NSAPI_ERROR_NO_CONNECTION); + TEST_ASSERT(error == NSAPI_ERROR_CONNECTION_TIMEOUT || error == NSAPI_ERROR_NO_CONNECTION); } #endif // defined(MBED_CONF_APP_WIFI_SECURE_SSID) diff --git a/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp b/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp index 112a4af389c..eca57ef2023 100644 --- a/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp +++ b/TESTS/network/wifi/wifi_connect_params_valid_secure.cpp @@ -29,7 +29,7 @@ void wifi_connect_params_valid_secure(void) { WiFiInterface *wifi = get_interface(); - if(wifi->connect(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, get_security()) == NSAPI_ERROR_OK) { + if (wifi->connect(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, get_security()) == NSAPI_ERROR_OK) { return; } diff --git a/TESTS/network/wifi/wifi_scan.cpp b/TESTS/network/wifi/wifi_scan.cpp index 6986d64d1ef..ab74e5deb99 100644 --- a/TESTS/network/wifi/wifi_scan.cpp +++ b/TESTS/network/wifi/wifi_scan.cpp @@ -44,7 +44,7 @@ void wifi_scan(void) TEST_ASSERT_EQUAL_INT_MESSAGE(6, sscanf(MBED_CONF_APP_AP_MAC_SECURE, coversion_string, &secure_bssid[0], &secure_bssid[1], &secure_bssid[2], &secure_bssid[3], &secure_bssid[4], &secure_bssid[5]), "Failed to convert ap-mac-secure from mbed_app.json"); TEST_ASSERT_EQUAL_INT_MESSAGE(6, sscanf(MBED_CONF_APP_AP_MAC_UNSECURE, coversion_string, &unsecure_bssid[0], &unsecure_bssid[1], &unsecure_bssid[2], &unsecure_bssid[3], &unsecure_bssid[4], &unsecure_bssid[5]), "Failed to convert ap-mac-unsecure from mbed_app.json"); - for (int i=0; i Date: Fri, 3 Aug 2018 10:21:11 +0100 Subject: [PATCH 2/2] crc test: manual fix cases Leave as it is for readability --- TESTS/mbed_hal/crc/main.cpp | 130 ++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 64 deletions(-) diff --git a/TESTS/mbed_hal/crc/main.cpp b/TESTS/mbed_hal/crc/main.cpp index 51ecdcc962f..c233c120d60 100644 --- a/TESTS/mbed_hal/crc/main.cpp +++ b/TESTS/mbed_hal/crc/main.cpp @@ -205,73 +205,75 @@ Specification specification(greentea_test_setup, cases, greentea_test_teardown_h int main() { + // *INDENT-OFF* TEST_CASE local_test_cases[] = { /* Predefined polynomials. */ - /* 00 */{ {POLY_7BIT_SD, 7, 0x00000000, 0x00000000, false, false}, 0xEA }, - /* 01 */{ {POLY_7BIT_SD, 7, 0x0000007F, 0x00000000, false, false}, 0xA0 }, - /* 02 */{ {POLY_7BIT_SD, 7, 0x0000002B, 0x00000000, false, false}, 0x74 }, - /* 03 */{ {POLY_7BIT_SD, 7, 0x00000000, 0x0000007F, false, false}, 0x95 }, - /* 04 */{ {POLY_7BIT_SD, 7, 0x00000000, 0x0000002B, false, false}, 0xC1 }, - /* 05 */{ {POLY_7BIT_SD, 7, 0x00000000, 0x00000000, true, false}, 0xA4 }, - /* 06 */{ {POLY_7BIT_SD, 7, 0x00000000, 0x00000000, false, true }, 0x57 }, - - /* 07 */{ {POLY_8BIT_CCITT, 8, 0x00000000, 0x00000000, false, false}, 0xF4 }, - /* 08 */{ {POLY_8BIT_CCITT, 8, 0x000000FF, 0x00000000, false, false}, 0xFB }, - /* 09 */{ {POLY_8BIT_CCITT, 8, 0x000000AB, 0x00000000, false, false}, 0x87 }, - /* 10 */{ {POLY_8BIT_CCITT, 8, 0x00000000, 0x000000FF, false, false}, 0x0B }, - /* 11 */{ {POLY_8BIT_CCITT, 8, 0x00000000, 0x000000AB, false, false}, 0x5F }, - /* 12 */{ {POLY_8BIT_CCITT, 8, 0x00000000, 0x00000000, true, false}, 0x04 }, - /* 13 */{ {POLY_8BIT_CCITT, 8, 0x00000000, 0x00000000, false, true }, 0x2F }, - - /* 14 */{ {POLY_16BIT_CCITT, 16, 0x00000000, 0x00000000, false, false}, 0x31C3 }, - /* 15 */{ {POLY_16BIT_CCITT, 16, 0x0000FFFF, 0x00000000, false, false}, 0x29B1 }, - /* 16 */{ {POLY_16BIT_CCITT, 16, 0x0000ABAB, 0x00000000, false, false}, 0x7D70 }, - /* 17 */{ {POLY_16BIT_CCITT, 16, 0x00000000, 0x0000FFFF, false, false}, 0xCE3C }, - /* 18 */{ {POLY_16BIT_CCITT, 16, 0x00000000, 0x0000ABAB, false, false}, 0x9A68 }, - /* 19 */{ {POLY_16BIT_CCITT, 16, 0x00000000, 0x00000000, true, false}, 0x9184 }, - /* 20 */{ {POLY_16BIT_CCITT, 16, 0x00000000, 0x00000000, false, true }, 0xC38C }, - - /* 21 */{ {POLY_16BIT_IBM, 16, 0x00000000, 0x00000000, false, false}, 0xFEE8 }, - /* 22 */{ {POLY_16BIT_IBM, 16, 0x0000FFFF, 0x00000000, false, false}, 0xAEE7 }, - /* 23 */{ {POLY_16BIT_IBM, 16, 0x0000ABAB, 0x00000000, false, false}, 0x0887 }, - /* 24 */{ {POLY_16BIT_IBM, 16, 0x00000000, 0x0000FFFF, false, false}, 0x0117 }, - /* 25 */{ {POLY_16BIT_IBM, 16, 0x00000000, 0x0000ABAB, false, false}, 0x5543 }, - /* 26 */{ {POLY_16BIT_IBM, 16, 0x00000000, 0x00000000, true, false}, 0xBCDD }, - /* 27 */{ {POLY_16BIT_IBM, 16, 0x00000000, 0x00000000, false, true }, 0x177F }, - - /* 28 */{ {POLY_32BIT_ANSI, 32, 0x00000000, 0x00000000, false, false}, 0x89A1897F }, - /* 29 */{ {POLY_32BIT_ANSI, 32, 0xFFFFFFFF, 0x00000000, false, false}, 0x0376E6E7 }, - /* 30 */{ {POLY_32BIT_ANSI, 32, 0xABABABAB, 0x00000000, false, false}, 0x871A2FAA }, - /* 31 */{ {POLY_32BIT_ANSI, 32, 0x00000000, 0xFFFFFFFF, false, false}, 0x765E7680 }, - /* 32 */{ {POLY_32BIT_ANSI, 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4 }, - /* 33 */{ {POLY_32BIT_ANSI, 32, 0x00000000, 0x00000000, true, false}, 0x11B4BFB4 }, - /* 34 */{ {POLY_32BIT_ANSI, 32, 0x00000000, 0x00000000, false, true }, 0xFE918591 }, - - /* Not-predefined polynomials. */ - /* 35 */{ {POLY_8BIT_MAXIM, 8, 0x00000000, 0x00000000, false, false}, 0xA2 }, - /* 36 */{ {POLY_8BIT_MAXIM, 8, 0x000000FF, 0x00000000, false, false}, 0xF7 }, - /* 37 */{ {POLY_8BIT_MAXIM, 8, 0x000000AB, 0x00000000, false, false}, 0x71 }, - /* 38 */{ {POLY_8BIT_MAXIM, 8, 0x00000000, 0x000000FF, false, false}, 0x5D }, - /* 39 */{ {POLY_8BIT_MAXIM, 8, 0x00000000, 0x000000AB, false, false}, 0x09 }, - /* 40 */{ {POLY_8BIT_MAXIM, 8, 0x00000000, 0x00000000, true, false}, 0x85 }, - /* 41 */{ {POLY_8BIT_MAXIM, 8, 0x00000000, 0x00000000, false, true }, 0x45 }, - - /* 42 */{ {POLY_16BIT_MAXIM, 16, 0x00000000, 0x00000000, false, false}, 0xFEE8 }, - /* 43 */{ {POLY_16BIT_MAXIM, 16, 0x0000FFFF, 0x00000000, false, false}, 0xAEE7 }, - /* 44 */{ {POLY_16BIT_MAXIM, 16, 0x0000ABAB, 0x00000000, false, false}, 0x0887 }, - /* 45 */{ {POLY_16BIT_MAXIM, 16, 0x00000000, 0x0000FFFF, false, false}, 0x0117 }, - /* 46 */{ {POLY_16BIT_MAXIM, 16, 0x00000000, 0x0000ABAB, false, false}, 0x5543 }, - /* 47 */{ {POLY_16BIT_MAXIM, 16, 0x00000000, 0x00000000, true, false}, 0xBCDD }, - /* 48 */{ {POLY_16BIT_MAXIM, 16, 0x00000000, 0x00000000, false, true }, 0x177F }, - - /* 49 */{ {POLY_32BIT_POSIX, 32, 0x00000000, 0x00000000, false, false}, 0x89A1897F }, - /* 50 */{ {POLY_32BIT_POSIX, 32, 0xFFFFFFFF, 0x00000000, false, false}, 0x0376E6E7 }, - /* 51 */{ {POLY_32BIT_POSIX, 32, 0xABABABAB, 0x00000000, false, false}, 0x871A2FAA }, - /* 52 */{ {POLY_32BIT_POSIX, 32, 0x00000000, 0xFFFFFFFF, false, false}, 0x765E7680 }, - /* 53 */{ {POLY_32BIT_POSIX, 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4 }, - /* 54 */{ {POLY_32BIT_POSIX, 32, 0x00000000, 0x00000000, true, false}, 0x11B4BFB4 }, - /* 55 */{ {POLY_32BIT_POSIX, 32, 0x00000000, 0x00000000, false, true }, 0xFE918591 }, + /* 00 */{ {POLY_7BIT_SD , 7, 0x00000000, 0x00000000, false, false}, 0xEA }, + /* 01 */{ {POLY_7BIT_SD , 7, 0x0000007F, 0x00000000, false, false}, 0xA0 }, + /* 02 */{ {POLY_7BIT_SD , 7, 0x0000002B, 0x00000000, false, false}, 0x74 }, + /* 03 */{ {POLY_7BIT_SD , 7, 0x00000000, 0x0000007F, false, false}, 0x95 }, + /* 04 */{ {POLY_7BIT_SD , 7, 0x00000000, 0x0000002B, false, false}, 0xC1 }, + /* 05 */{ {POLY_7BIT_SD , 7, 0x00000000, 0x00000000, true , false}, 0xA4 }, + /* 06 */{ {POLY_7BIT_SD , 7, 0x00000000, 0x00000000, false, true }, 0x57 }, + + /* 07 */{ {POLY_8BIT_CCITT , 8, 0x00000000, 0x00000000, false, false}, 0xF4 }, + /* 08 */{ {POLY_8BIT_CCITT , 8, 0x000000FF, 0x00000000, false, false}, 0xFB }, + /* 09 */{ {POLY_8BIT_CCITT , 8, 0x000000AB, 0x00000000, false, false}, 0x87 }, + /* 10 */{ {POLY_8BIT_CCITT , 8, 0x00000000, 0x000000FF, false, false}, 0x0B }, + /* 11 */{ {POLY_8BIT_CCITT , 8, 0x00000000, 0x000000AB, false, false}, 0x5F }, + /* 12 */{ {POLY_8BIT_CCITT , 8, 0x00000000, 0x00000000, true , false}, 0x04 }, + /* 13 */{ {POLY_8BIT_CCITT , 8, 0x00000000, 0x00000000, false, true }, 0x2F }, + + /* 14 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x00000000, false, false}, 0x31C3 }, + /* 15 */{ {POLY_16BIT_CCITT , 16, 0x0000FFFF, 0x00000000, false, false}, 0x29B1 }, + /* 16 */{ {POLY_16BIT_CCITT , 16, 0x0000ABAB, 0x00000000, false, false}, 0x7D70 }, + /* 17 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x0000FFFF, false, false}, 0xCE3C }, + /* 18 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x0000ABAB, false, false}, 0x9A68 }, + /* 19 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x00000000, true , false}, 0x9184 }, + /* 20 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x00000000, false, true }, 0xC38C }, + + /* 21 */{ {POLY_16BIT_IBM , 16, 0x00000000, 0x00000000, false, false}, 0xFEE8 }, + /* 22 */{ {POLY_16BIT_IBM , 16, 0x0000FFFF, 0x00000000, false, false}, 0xAEE7 }, + /* 23 */{ {POLY_16BIT_IBM , 16, 0x0000ABAB, 0x00000000, false, false}, 0x0887 }, + /* 24 */{ {POLY_16BIT_IBM , 16, 0x00000000, 0x0000FFFF, false, false}, 0x0117 }, + /* 25 */{ {POLY_16BIT_IBM , 16, 0x00000000, 0x0000ABAB, false, false}, 0x5543 }, + /* 26 */{ {POLY_16BIT_IBM , 16, 0x00000000, 0x00000000, true , false}, 0xBCDD }, + /* 27 */{ {POLY_16BIT_IBM , 16, 0x00000000, 0x00000000, false, true }, 0x177F }, + + /* 28 */{ {POLY_32BIT_ANSI , 32, 0x00000000, 0x00000000, false, false}, 0x89A1897F }, + /* 29 */{ {POLY_32BIT_ANSI , 32, 0xFFFFFFFF, 0x00000000, false, false}, 0x0376E6E7 }, + /* 30 */{ {POLY_32BIT_ANSI , 32, 0xABABABAB, 0x00000000, false, false}, 0x871A2FAA }, + /* 31 */{ {POLY_32BIT_ANSI , 32, 0x00000000, 0xFFFFFFFF, false, false}, 0x765E7680 }, + /* 32 */{ {POLY_32BIT_ANSI , 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4 }, + /* 33 */{ {POLY_32BIT_ANSI , 32, 0x00000000, 0x00000000, true , false}, 0x11B4BFB4 }, + /* 34 */{ {POLY_32BIT_ANSI , 32, 0x00000000, 0x00000000, false, true }, 0xFE918591 }, + + /* Not-predefined polynomials. */ + /* 35 */{ {POLY_8BIT_MAXIM , 8, 0x00000000, 0x00000000, false, false}, 0xA2 }, + /* 36 */{ {POLY_8BIT_MAXIM , 8, 0x000000FF, 0x00000000, false, false}, 0xF7 }, + /* 37 */{ {POLY_8BIT_MAXIM , 8, 0x000000AB, 0x00000000, false, false}, 0x71 }, + /* 38 */{ {POLY_8BIT_MAXIM , 8, 0x00000000, 0x000000FF, false, false}, 0x5D }, + /* 39 */{ {POLY_8BIT_MAXIM , 8, 0x00000000, 0x000000AB, false, false}, 0x09 }, + /* 40 */{ {POLY_8BIT_MAXIM , 8, 0x00000000, 0x00000000, true , false}, 0x85 }, + /* 41 */{ {POLY_8BIT_MAXIM , 8, 0x00000000, 0x00000000, false, true }, 0x45 }, + + /* 42 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x00000000, false, false}, 0xFEE8 }, + /* 43 */{ {POLY_16BIT_MAXIM , 16, 0x0000FFFF, 0x00000000, false, false}, 0xAEE7 }, + /* 44 */{ {POLY_16BIT_MAXIM , 16, 0x0000ABAB, 0x00000000, false, false}, 0x0887 }, + /* 45 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x0000FFFF, false, false}, 0x0117 }, + /* 46 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x0000ABAB, false, false}, 0x5543 }, + /* 47 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x00000000, true , false}, 0xBCDD }, + /* 48 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x00000000, false, true }, 0x177F }, + + /* 49 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0x00000000, false, false}, 0x89A1897F }, + /* 50 */{ {POLY_32BIT_POSIX , 32, 0xFFFFFFFF, 0x00000000, false, false}, 0x0376E6E7 }, + /* 51 */{ {POLY_32BIT_POSIX , 32, 0xABABABAB, 0x00000000, false, false}, 0x871A2FAA }, + /* 52 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0xFFFFFFFF, false, false}, 0x765E7680 }, + /* 53 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4 }, + /* 54 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0x00000000, true , false}, 0x11B4BFB4 }, + /* 55 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0x00000000, false, true }, 0xFE918591 }, }; + // *INDENT-ON* test_cases = local_test_cases; test_cases_size = sizeof(local_test_cases);