diff --git a/features/frameworks/mbed-client-randlib/.yotta_ignore b/features/frameworks/mbed-client-randlib/.yotta_ignore new file mode 100644 index 00000000000..ab1cfb4ef2c --- /dev/null +++ b/features/frameworks/mbed-client-randlib/.yotta_ignore @@ -0,0 +1 @@ +test/* diff --git a/features/frameworks/mbed-client-randlib/source/randLIB.c b/features/frameworks/mbed-client-randlib/source/randLIB.c index b75d7edae8d..274e9bc39b8 100644 --- a/features/frameworks/mbed-client-randlib/source/randLIB.c +++ b/features/frameworks/mbed-client-randlib/source/randLIB.c @@ -98,7 +98,7 @@ void randLIB_seed_random(void) /* Spell out expressions so we get known ordering of 4 seed calls */ uint64_t s = (uint64_t) arm_random_seed_get() << 32; - state[0] ^= ( s | arm_random_seed_get()); + state[0] ^= (s | arm_random_seed_get()); s = (uint64_t) arm_random_seed_get() << 32; state[1] ^= s | arm_random_seed_get(); @@ -129,19 +129,19 @@ void randLIB_add_seed(uint64_t seed) uint8_t randLIB_get_8bit(void) { uint64_t r = randLIB_get_64bit(); - return (uint8_t) (r >> 56); + return (uint8_t)(r >> 56); } uint16_t randLIB_get_16bit(void) { uint64_t r = randLIB_get_64bit(); - return (uint16_t) (r >> 48); + return (uint16_t)(r >> 48); } uint32_t randLIB_get_32bit(void) { uint64_t r = randLIB_get_64bit(); - return (uint32_t) (r >> 32); + return (uint32_t)(r >> 32); } diff --git a/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/makefile_defines.txt b/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/makefile_defines.txt index 18691ee5431..0a350ee9221 100644 --- a/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/makefile_defines.txt +++ b/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/makefile_defines.txt @@ -11,6 +11,7 @@ INCLUDE_DIRS =\ ../../../..\ ../../../../source\ ../../../../mbed-client-randlib\ + ../../../../../../../libService/libService\ /usr/include\ $(CPPUTEST_HOME)/include\ diff --git a/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/main.cpp b/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/main.cpp index d76b2f9173a..becceb65ca9 100644 --- a/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/main.cpp +++ b/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/main.cpp @@ -6,7 +6,7 @@ #include "CppUTest/TestPlugin.h" #include "CppUTest/TestRegistry.h" #include "CppUTestExt/MockSupportPlugin.h" -int main(int ac, char** av) +int main(int ac, char **av) { return CommandLineTestRunner::RunAllTests(ac, av); } diff --git a/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/randlibtest.cpp b/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/randlibtest.cpp index 67b3cb59a01..309896d81d4 100644 --- a/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/randlibtest.cpp +++ b/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/randlibtest.cpp @@ -6,12 +6,10 @@ TEST_GROUP(randLIB) { - void setup() - { + void setup() { } - void teardown() - { + void teardown() { } }; diff --git a/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/test_randlib.c b/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/test_randlib.c index d918d591083..3a9639f7b7d 100644 --- a/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/test_randlib.c +++ b/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/test_randlib.c @@ -18,9 +18,9 @@ bool test_randLIB_get_8bit() randLIB_reset(); randLIB_seed_random(); uint8_t test = randLIB_get_8bit(); - if( test == 0 ) { + if (test == 0) { test = randLIB_get_8bit(); - if( test == 0 ) { + if (test == 0) { return false; } } @@ -32,9 +32,9 @@ bool test_randLIB_get_16bit() randLIB_reset(); randLIB_seed_random(); uint16_t test = randLIB_get_16bit(); - if( test == 0 ) { + if (test == 0) { test = randLIB_get_16bit(); - if( test == 0 ) { + if (test == 0) { return false; } } @@ -46,9 +46,9 @@ bool test_randLIB_get_32bit() randLIB_reset(); randLIB_seed_random(); uint32_t test = randLIB_get_32bit(); - if( test == 0 ) { + if (test == 0) { test = randLIB_get_32bit(); - if( test == 0 ) { + if (test == 0) { return false; } } @@ -145,7 +145,7 @@ bool test_randLIB_get_n_bytes_random() uint8_t dat[5]; void *ret = randLIB_get_n_bytes_random(dat, 5); - if(ret != dat){ + if (ret != dat) { return false; } @@ -164,12 +164,12 @@ bool test_randLIB_get_random_in_range() randLIB_seed_random(); uint16_t ret = randLIB_get_random_in_range(2, 2); - if( ret != 2 ){ + if (ret != 2) { return false; } ret = randLIB_get_random_in_range(2, 3); - if( ret != 2 && ret != 3){ + if (ret != 2 && ret != 3) { return false; } @@ -183,12 +183,12 @@ bool test_randLIB_randomise_base() randLIB_reset(); randLIB_seed_random(); - uint32_t ret = randLIB_randomise_base(0,0,0); - if( ret ){ + uint32_t ret = randLIB_randomise_base(0, 0, 0); + if (ret) { return false; } - ret = randLIB_randomise_base(0xffff0000,0x8888,0x8888); - if( ret != 0xffffffff ){ + ret = randLIB_randomise_base(0xffff0000, 0x8888, 0x8888); + if (ret != 0xffffffff) { return false; } return true; diff --git a/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/stubs/open_stub.c b/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/stubs/open_stub.c index 588c12096e7..6fda589546a 100644 --- a/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/stubs/open_stub.c +++ b/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/stubs/open_stub.c @@ -8,17 +8,17 @@ bool allow_open = true; int __real_open(const char *path, int flags, ...); int __wrap_open(const char *path, int flags, ...) { - if (allow_open) { - if (flags & O_CREAT) { - va_list vl; - va_start(vl,flags); - mode_t mode = va_arg(vl, mode_t); - va_end(vl); - return __real_open(path, flags, mode); - } else { - return __real_open(path, flags); - } - } else { - return -1; - } + if (allow_open) { + if (flags & O_CREAT) { + va_list vl; + va_start(vl, flags); + mode_t mode = va_arg(vl, mode_t); + va_end(vl); + return __real_open(path, flags, mode); + } else { + return __real_open(path, flags); + } + } else { + return -1; + } } diff --git a/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/stubs/random_stub.c b/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/stubs/random_stub.c index f480385da88..c271839a6b8 100644 --- a/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/stubs/random_stub.c +++ b/features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/stubs/random_stub.c @@ -1,7 +1,8 @@ /* * Copyright (c) 2016, ARM Limited, All Rights Reserved */ -#include "random_stub.h" + +#include "ns_types.h" static uint32_t seed_value = 4; static bool seed_inc = false; diff --git a/features/frameworks/mbed-trace/README.md b/features/frameworks/mbed-trace/README.md index dd322e53982..ddc266382fa 100644 --- a/features/frameworks/mbed-trace/README.md +++ b/features/frameworks/mbed-trace/README.md @@ -107,6 +107,43 @@ Set the output function, `printf` by default: mbed_trace_print_function_set(printf) ``` +### Tracing level + +Run time tracing level is set using `mbed_trace_set_config()` function. Possible levels and examples how to set them is presented below. + +```c +//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL); +//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_DEBUG); // (same as ALL) +mbed_trace_config_set(TRACE_ACTIVE_LEVEL_INFO); +//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_WARN); +//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ERROR); +//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_CMD); +//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_NONE); +``` + +Build time optimization can be done with `MBED_TRACE_MAX_LEVEL` definition. Setting max level to `TRACE_LEVEL_DEBUG` includes all traces to the build. Setting max level to `TRACE_LEVEL_INFO` includes all but `tr_debug()` traces to the build. Other maximum tracing levels follow the same behavior and no messages above the selected level are included in the build. + +```c +#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_DEBUG +#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_INFO +#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_WARN +#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_ERROR +#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_CMD +``` + +In Mbed OS, the build time maximum tracing level can be set through `mbed_app.json` as shown below. + +``` +{ + "target_overrides":{ + "*":{ + "mbed-trace.enable": true, + "mbed-trace.max-level": "TRACE_LEVEL_INFO" + } + } +} +``` + ### Helping functions The purpose of the helping functions is to provide simple conversions, for example from an array to C string, so that you can print everything to single trace line. They must be called inside the actual trace calls, for example: diff --git a/features/frameworks/mbed-trace/mbed-trace/mbed_trace.h b/features/frameworks/mbed-trace/mbed-trace/mbed_trace.h index eb4055b0c01..0562e4a898a 100644 --- a/features/frameworks/mbed-trace/mbed-trace/mbed_trace.h +++ b/features/frameworks/mbed-trace/mbed-trace/mbed_trace.h @@ -180,11 +180,11 @@ extern "C" { * Initialize trace functionality * @return 0 when all success, otherwise non zero */ -int mbed_trace_init( void ); +int mbed_trace_init(void); /** * Free trace memory */ -void mbed_trace_free( void ); +void mbed_trace_free(void); /** * Resize buffers (line / tmp ) sizes * @param lineLength new maximum length for trace line (0 = do no resize) @@ -226,7 +226,7 @@ uint8_t mbed_trace_config_get(void); * char* trace_time(){ return "rtc-time-in-string"; } * mbed_trace_prefix_function_set( &trace_time ); */ -void mbed_trace_prefix_function_set( char* (*pref_f)(size_t) ); +void mbed_trace_prefix_function_set(char *(*pref_f)(size_t)); /** * Set trace suffix function * suffix -function return string with null terminated @@ -235,18 +235,18 @@ void mbed_trace_prefix_function_set( char* (*pref_f)(size_t) ); * char* trace_suffix(){ return " END"; } * mbed_trace_suffix_function_set( &trace_suffix ); */ -void mbed_trace_suffix_function_set(char* (*suffix_f)(void) ); +void mbed_trace_suffix_function_set(char *(*suffix_f)(void)); /** * Set trace print function * By default, trace module print using printf() function, * but with this you can write own print function, * for e.g. to other IO device. */ -void mbed_trace_print_function_set( void (*print_f)(const char*) ); +void mbed_trace_print_function_set(void (*print_f)(const char *)); /** * Set trace print function for tr_cmdline() */ -void mbed_trace_cmdprint_function_set( void (*printf)(const char*) ); +void mbed_trace_cmdprint_function_set(void (*printf)(const char *)); /** * Set trace mutex wait function * By default, trace calls are not thread safe. @@ -270,10 +270,10 @@ void mbed_trace_mutex_release_function_set(void (*mutex_release_f)(void)); * mbed_trace_exclude_filters_set("mygr"); * mbed_tracef(TRACE_ACTIVE_LEVEL_DEBUG, "ougr", "This is not printed"); */ -void mbed_trace_exclude_filters_set(char* filters); +void mbed_trace_exclude_filters_set(char *filters); /** get trace exclude filters */ -const char* mbed_trace_exclude_filters_get(void); +const char *mbed_trace_exclude_filters_get(void); /** * When trace group contains text in filter, * trace will be printed. @@ -282,10 +282,10 @@ const char* mbed_trace_exclude_filters_get(void); * mbed_tracef(TRACE_ACTIVE_LEVEL_DEBUG, "mygr", "Hi There"); * mbed_tracef(TRACE_ACTIVE_LEVEL_DEBUG, "grp2", "This is not printed"); */ -void mbed_trace_include_filters_set(char* filters); +void mbed_trace_include_filters_set(char *filters); /** get trace include filters */ -const char* mbed_trace_include_filters_get(void); +const char *mbed_trace_include_filters_get(void); /** * General trace function * This should be used every time when user want to print out something important thing @@ -298,9 +298,9 @@ const char* mbed_trace_include_filters_get(void); * @param ... variable arguments related to fmt */ #if defined(__GNUC__) || defined(__CC_ARM) -void mbed_tracef(uint8_t dlevel, const char* grp, const char *fmt, ...) __attribute__ ((__format__(__printf__, 3, 4))); +void mbed_tracef(uint8_t dlevel, const char *grp, const char *fmt, ...) __attribute__((__format__(__printf__, 3, 4))); #else -void mbed_tracef(uint8_t dlevel, const char* grp, const char *fmt, ...); +void mbed_tracef(uint8_t dlevel, const char *grp, const char *fmt, ...); #endif /** * General trace function @@ -318,16 +318,16 @@ void mbed_tracef(uint8_t dlevel, const char* grp, const char *fmt, ...); * @param ap variable arguments list (like vprintf) */ #if defined(__GNUC__) || defined(__CC_ARM) -void mbed_vtracef(uint8_t dlevel, const char* grp, const char *fmt, va_list ap) __attribute__ ((__format__(__printf__, 3, 0))); +void mbed_vtracef(uint8_t dlevel, const char *grp, const char *fmt, va_list ap) __attribute__((__format__(__printf__, 3, 0))); #else -void mbed_vtracef(uint8_t dlevel, const char* grp, const char *fmt, va_list ap); +void mbed_vtracef(uint8_t dlevel, const char *grp, const char *fmt, va_list ap); #endif /** * Get last trace from buffer */ -const char* mbed_trace_last(void); +const char *mbed_trace_last(void); #if MBED_CONF_MBED_TRACE_FEA_IPV6 == 1 /** * mbed_tracef helping function for convert ipv6 @@ -339,7 +339,7 @@ const char* mbed_trace_last(void); * @param add_ptr IPv6 Address pointer * @return temporary buffer where ipv6 is in string format */ -char* mbed_trace_ipv6(const void *addr_ptr); +char *mbed_trace_ipv6(const void *addr_ptr); /** * mbed_tracef helping function for print ipv6 prefix * usage e.g. @@ -350,7 +350,7 @@ char* mbed_trace_ipv6(const void *addr_ptr); * @param prefix_len prefix length * @return temporary buffer where ipv6 is in string format */ -char* mbed_trace_ipv6_prefix(const uint8_t *prefix, uint8_t prefix_len); +char *mbed_trace_ipv6_prefix(const uint8_t *prefix, uint8_t prefix_len); #endif /** * mbed_tracef helping function for convert hex-array to string. @@ -364,7 +364,7 @@ char* mbed_trace_ipv6_prefix(const uint8_t *prefix, uint8_t prefix_len); * if array as string not fit to temp buffer, this function write '*' as last character, * which indicate that buffer is too small for array. */ -char* mbed_trace_array(const uint8_t* buf, uint16_t len); +char *mbed_trace_array(const uint8_t *buf, uint16_t len); #ifdef __cplusplus } diff --git a/features/frameworks/mbed-trace/mbed_lib.json b/features/frameworks/mbed-trace/mbed_lib.json index 9a2b49d7d57..f58ccb2ac16 100644 --- a/features/frameworks/mbed-trace/mbed_lib.json +++ b/features/frameworks/mbed-trace/mbed_lib.json @@ -5,6 +5,12 @@ "help": "Used to globally enable traces.", "value": null }, + "max-level": { + "help": "This flag is used to optimize the code size. For example, setting trace optimization level to TRACE_LEVEL_INFO will define all tr_debug() macros empty, which reduces the binary size. The possible optimization levels are TRACE_LEVEL_DEBUG, TRACE_LEVEL_INFO, TRACE_LEVEL_WARN, TRACE_LEVEL_ERROR and TRACE_LEVEL_CMD. To set the output tracing level, please use mbed_trace_config_set(TRACE_ACTIVE_LEVEL_INFO). The possible tracing levels for mbed_trace_config_set() are TRACE_ACTIVE_LEVEL_ALL, TRACE_ACTIVE_LEVEL_DEBUG (same as ALL), TRACE_ACTIVE_LEVEL_INFO, TRACE_ACTIVE_LEVEL_WARN, TRACE_ACTIVE_LEVEL_ERROR, TRACE_ACTIVE_LEVEL_CMD and TRACE_LEVEL_NONE.", + "value": null, + "macro_name": "MBED_TRACE_MAX_LEVEL" + + }, "fea-ipv6": { "help": "Used to globally disable ipv6 tracing features.", "value": null diff --git a/features/frameworks/mbed-trace/source/mbed_trace.c b/features/frameworks/mbed-trace/source/mbed_trace.c index 5fdffd52c30..04dacbfaafc 100644 --- a/features/frameworks/mbed-trace/source/mbed_trace.c +++ b/features/frameworks/mbed-trace/source/mbed_trace.c @@ -93,7 +93,7 @@ #endif /** default print function, just redirect str to printf */ -static void mbed_trace_realloc( char **buffer, int *length_ptr, int new_length); +static void mbed_trace_realloc(char **buffer, int *length_ptr, int new_length); static void mbed_trace_default_print(const char *str); static void mbed_trace_reset_tmp(void); @@ -209,7 +209,7 @@ void mbed_trace_free(void) m_trace.mutex_release_f = 0; m_trace.mutex_lock_count = 0; } -static void mbed_trace_realloc( char **buffer, int *length_ptr, int new_length) +static void mbed_trace_realloc(char **buffer, int *length_ptr, int new_length) { MBED_TRACE_MEM_FREE(*buffer); *buffer = MBED_TRACE_MEM_ALLOC(new_length); @@ -217,11 +217,11 @@ static void mbed_trace_realloc( char **buffer, int *length_ptr, int new_length) } void mbed_trace_buffer_sizes(int lineLength, int tmpLength) { - if( lineLength > 0 ) { - mbed_trace_realloc( &(m_trace.line), &m_trace.line_length, lineLength ); + if (lineLength > 0) { + mbed_trace_realloc(&(m_trace.line), &m_trace.line_length, lineLength); } - if( tmpLength > 0 ) { - mbed_trace_realloc( &(m_trace.tmp_data), &m_trace.tmp_data_length, tmpLength); + if (tmpLength > 0) { + mbed_trace_realloc(&(m_trace.tmp_data), &m_trace.tmp_data_length, tmpLength); mbed_trace_reset_tmp(); } } @@ -311,9 +311,9 @@ void mbed_tracef(uint8_t dlevel, const char *grp, const char *fmt, ...) mbed_vtracef(dlevel, grp, fmt, ap); va_end(ap); } -void mbed_vtracef(uint8_t dlevel, const char* grp, const char *fmt, va_list ap) +void mbed_vtracef(uint8_t dlevel, const char *grp, const char *fmt, va_list ap) { - if ( m_trace.mutex_wait_f ) { + if (m_trace.mutex_wait_f) { m_trace.mutex_wait_f(); m_trace.mutex_lock_count++; } @@ -476,7 +476,7 @@ void mbed_vtracef(uint8_t dlevel, const char* grp, const char *fmt, va_list ap) } end: - if ( m_trace.mutex_release_f ) { + if (m_trace.mutex_release_f) { // Store the mutex lock count to temp variable so that it won't get // clobbered during last loop iteration when mutex gets released int count = m_trace.mutex_lock_count; @@ -507,7 +507,7 @@ const char *mbed_trace_last(void) char *mbed_trace_ipv6(const void *addr_ptr) { /** Acquire mutex. It is released before returning from mbed_vtracef. */ - if ( m_trace.mutex_wait_f ) { + if (m_trace.mutex_wait_f) { m_trace.mutex_wait_f(); m_trace.mutex_lock_count++; } @@ -528,7 +528,7 @@ char *mbed_trace_ipv6(const void *addr_ptr) char *mbed_trace_ipv6_prefix(const uint8_t *prefix, uint8_t prefix_len) { /** Acquire mutex. It is released before returning from mbed_vtracef. */ - if ( m_trace.mutex_wait_f ) { + if (m_trace.mutex_wait_f) { m_trace.mutex_wait_f(); m_trace.mutex_lock_count++; } @@ -551,7 +551,7 @@ char *mbed_trace_ipv6_prefix(const uint8_t *prefix, uint8_t prefix_len) char *mbed_trace_array(const uint8_t *buf, uint16_t len) { /** Acquire mutex. It is released before returning from mbed_vtracef. */ - if ( m_trace.mutex_wait_f ) { + if (m_trace.mutex_wait_f) { m_trace.mutex_wait_f(); m_trace.mutex_lock_count++; } @@ -581,7 +581,7 @@ char *mbed_trace_array(const uint8_t *buf, uint16_t len) wptr += retval; } if (wptr > str) { - if( overflow ) { + if (overflow) { // replace last character as 'star', // which indicate buffer len is not enough *(wptr - 1) = '*'; diff --git a/features/frameworks/mbed-trace/test/Test.cpp b/features/frameworks/mbed-trace/test/Test.cpp index bd0426130ee..4261d8172ea 100644 --- a/features/frameworks/mbed-trace/test/Test.cpp +++ b/features/frameworks/mbed-trace/test/Test.cpp @@ -30,101 +30,107 @@ static int mutex_release_count = 0; static bool check_mutex_lock_status = true; void my_mutex_wait() { - mutex_wait_count++; + mutex_wait_count++; } void my_mutex_release() { - mutex_release_count++; + mutex_release_count++; } char buf[1024]; #include -void myprint(const char* str) +void myprint(const char *str) { - if ( check_mutex_lock_status ) { - CHECK( (mutex_wait_count - mutex_release_count) > 0 ); - } - strcpy(buf, str); + if (check_mutex_lock_status) { + CHECK((mutex_wait_count - mutex_release_count) > 0); + } + strcpy(buf, str); } TEST_GROUP(trace) { - void setup() - { - - mbed_trace_init(); - mbed_trace_config_set(TRACE_MODE_PLAIN|TRACE_ACTIVE_LEVEL_ALL); - mbed_trace_print_function_set( myprint ); - mbed_trace_mutex_wait_function_set( my_mutex_wait ); - mbed_trace_mutex_release_function_set( my_mutex_release ); - } - void teardown() - { - CHECK(mutex_wait_count == mutex_release_count); // Check the mutex count with every test - mbed_trace_free(); - } + void setup() { + + mbed_trace_init(); + mbed_trace_config_set(TRACE_MODE_PLAIN | TRACE_ACTIVE_LEVEL_ALL); + mbed_trace_print_function_set(myprint); + mbed_trace_mutex_wait_function_set(my_mutex_wait); + mbed_trace_mutex_release_function_set(my_mutex_release); + } + void teardown() { + CHECK(mutex_wait_count == mutex_release_count); // Check the mutex count with every test + mbed_trace_free(); + } }; /* Unity test code starts */ TEST(trace, MutexNotSet) { - mbed_trace_mutex_wait_function_set( 0 ); - mbed_trace_mutex_release_function_set( 0 ); - int mutex_call_count_at_entry = mutex_wait_count; - check_mutex_lock_status = false; + mbed_trace_mutex_wait_function_set(0); + mbed_trace_mutex_release_function_set(0); + int mutex_call_count_at_entry = mutex_wait_count; + check_mutex_lock_status = false; - char expectedStr[] = "Hello hello!"; - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "Hello hello!"); - STRCMP_EQUAL(expectedStr, buf); + char expectedStr[] = "Hello hello!"; + mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "Hello hello!"); + STRCMP_EQUAL(expectedStr, buf); - CHECK( mutex_call_count_at_entry == mutex_wait_count ); - CHECK( mutex_call_count_at_entry == mutex_release_count ); + CHECK(mutex_call_count_at_entry == mutex_wait_count); + CHECK(mutex_call_count_at_entry == mutex_release_count); - mbed_trace_mutex_wait_function_set( my_mutex_wait ); - mbed_trace_mutex_release_function_set( my_mutex_release ); - check_mutex_lock_status = true; + mbed_trace_mutex_wait_function_set(my_mutex_wait); + mbed_trace_mutex_release_function_set(my_mutex_release); + check_mutex_lock_status = true; } TEST(trace, Array) { - unsigned char longStr[200] = {0x66}; - for(int i=0;i<200;i++) {longStr[i] = 0x66; } - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(longStr, 200) ); + unsigned char longStr[200] = {0x66}; + for (int i = 0; i < 200; i++) { + longStr[i] = 0x66; + } + mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(longStr, 200)); } TEST(trace, Null0Array) { - static const unsigned char array[2] = { 0x23, 0x45 }; - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(array, 2)); - STRCMP_EQUAL("23:45", buf); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(array, 0)); - STRCMP_EQUAL("", buf); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(NULL, 0)); - STRCMP_EQUAL("", buf); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(NULL, 2)); - STRCMP_EQUAL("", buf); + static const unsigned char array[2] = { 0x23, 0x45 }; + mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(array, 2)); + STRCMP_EQUAL("23:45", buf); + mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(array, 0)); + STRCMP_EQUAL("", buf); + mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(NULL, 0)); + STRCMP_EQUAL("", buf); + mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(NULL, 2)); + STRCMP_EQUAL("", buf); } TEST(trace, LongString) { - char longStr[1000] = {0x36}; - for(int i=0;i<999;i++) {longStr[i] = 0x36; } - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", longStr ); + char longStr[1000] = {0x36}; + for (int i = 0; i < 999; i++) { + longStr[i] = 0x36; + } + mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", longStr); } TEST(trace, TooLong) { - #define TOO_LONG_SIZE 9400 - #define TRACE_LINE_SIZE 1024 - char longStr[TOO_LONG_SIZE] = {0}; - for(int i=0;i][DBG ][mygr]: test 1 2", buf); - //TEST_ASSERT_EQUAL_INT(4, time_length); - - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL|TRACE_MODE_PLAIN); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "test"); - STRCMP_EQUAL("test", buf); - - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL|TRACE_MODE_COLOR); - mbed_tracef(TRACE_LEVEL_ERROR, "mygr", "test"); - STRCMP_EQUAL("\x1b[31m[