diff --git a/.astyleignore b/.astyleignore deleted file mode 100644 index 89620f3105..0000000000 --- a/.astyleignore +++ /dev/null @@ -1 +0,0 @@ -BUILD diff --git a/.astylerc b/.astylerc deleted file mode 100644 index 7e0bc337f3..0000000000 --- a/.astylerc +++ /dev/null @@ -1,37 +0,0 @@ -# Mbed OS code style definition file for astyle - -# Don't create backup files, let git handle it -suffix=none - -# K&R style -style=kr - -# 1 TBS addition to k&r, add braces to one liners -# Use -j as it was changed in astyle from brackets to braces, this way it is compatible with older astyle versions --j - -# 4 spaces, convert tabs to spaces -indent=spaces=4 -convert-tabs - -# Indent switches and cases -indent-switches - -# Remove spaces in and around parentheses -unpad-paren - -# Insert a space after if, while, for, and around operators -pad-header -pad-oper - -# Pointer/reference operators go next to the name (on the right) -align-pointer=name -align-reference=name - -# Attach { for classes and namespaces -attach-namespaces -attach-classes - -# Extend longer lines, define maximum 120 value. This results in aligned code, -# otherwise the lines are broken and not consistent -max-continuation-indent=120 diff --git a/.yotta_ignore b/.yotta_ignore deleted file mode 100644 index cc6371fe0c..0000000000 --- a/.yotta_ignore +++ /dev/null @@ -1 +0,0 @@ -/*CMakeLists.txt diff --git a/example/linux/Makefile b/example/linux/Makefile deleted file mode 100644 index 1d2420ce60..0000000000 --- a/example/linux/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -all: - gcc main.c -g -I ../.. ../../source/mbed_trace.c -DYOTTA_CFG -DMBED_CONF_MBED_TRACE_FEA_IPV6=0 -o app diff --git a/example/linux/README.md b/example/linux/README.md deleted file mode 100644 index fd333c8083..0000000000 --- a/example/linux/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# linux example application using mbed-trace library - -## build - -``` -make -``` - -## run - -``` -./app -``` diff --git a/example/linux/main.c b/example/linux/main.c deleted file mode 100644 index adefc0dce5..0000000000 --- a/example/linux/main.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2018 ARM Limited. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include - - -#include "mbed-trace/mbed_trace.h" -#define TRACE_GROUP "main" - - -int main(void) -{ - mbed_trace_init(); - tr_debug("debug print"); - tr_info("info print"); - tr_warn("warning print"); - tr_error("error print"); - mbed_trace_free(); - return 0; -} diff --git a/example/linux/memtest.sh b/example/linux/memtest.sh deleted file mode 100755 index 133aa39d51..0000000000 --- a/example/linux/memtest.sh +++ /dev/null @@ -1 +0,0 @@ -valgrind --leak-check=yes --error-exitcode=1 ./app diff --git a/example/mbed-os-5/README.md b/example/mbed-os-5/README.md deleted file mode 100644 index 5eba8102ea..0000000000 --- a/example/mbed-os-5/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# mbed-os 5 example application using mbed-trace library - -## define mbed-os.lib - -``` -echo https://github.com/armmbed/mbed-os/#6a0a86538c0b9b2bfcc4583b1e2b7fea8f4e71e9 > mbed-os.lib -``` - -## build - -``` -mbed deploy -mbed compile -t GCC_ARM -m K64F -``` - - -## Usage - -When you flash a target with this application and open a terminal you should see the following traces: - -``` -[INFO][main] Hello tracers -[DBG ][main] Infinite loop.. -[DBG ][main] Infinite loop.. -[DBG ][main] Infinite loop.. -... -``` diff --git a/example/mbed-os-5/main.cpp b/example/mbed-os-5/main.cpp deleted file mode 100644 index 45522abb79..0000000000 --- a/example/mbed-os-5/main.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2018 ARM Limited. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include - -#include "mbed.h" -#include "mbed_trace.h" - -#define TRACE_GROUP "main" - -int main(void) -{ - // Initialize trace library - mbed_trace_init(); - // trace Something - tr_info("Hello tracers"); - while(1) { - tr_debug("Infinite loop.."); - } -} diff --git a/example/mbed-os-5/mbed_app.json b/example/mbed-os-5/mbed_app.json deleted file mode 100644 index 645c992f50..0000000000 --- a/example/mbed-os-5/mbed_app.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "macros": [ - "MEM_ALLOC=malloc", - "MEM_FREE=free" - ], - "target_overrides": { - "*": { - "platform.stdio-baud-rate": 115200, - "platform.stdio-convert-newlines": true, - "platform.stdio-buffered-serial": true, - "target.features_add": ["COMMON_PAL"], - "mbed-trace.enable": 1 - } - } -} diff --git a/module.json b/module.json deleted file mode 100644 index 9c3be8dee9..0000000000 --- a/module.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "mbed-trace", - "version": "1.3.0", - "description": "Trace library for mbed devices", - "keywords": [ - "trace", - "debug", - "library", - "client", - "mbedOS", - "mbed" - ], - "author": "Jussi Vatjus-Anttila", - "repository": { - "url": "https://github.com/ARMmbed/mbed-trace.git", - "type": "git" - }, - "homepage": "https://github.com/ARMmbed/mbed-trace", - "licenses": [ - { - "url": "https://spdx.org/licenses/Apache-2.0", - "type": "Apache-2.0" - } - ], - "testTargetDependencies": { - "x86-linux-native": { - "cpputest": "ARMmbed/cpputest", - "nanostack-libservice": "^3.6.0" - }, - "x86-osx-native": { - "cpputest": "ARMmbed/cpputest", - "nanostack-libservice": "^3.6.0" - }, - "x86-windows-native": { - "cpputest": "ARMmbed/cpputest", - "nanostack-libservice": "^3.6.0" - } - }, - "dependencies": { - "nanostack-libservice": "^3.6.0" - } -} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index efdd53b9cf..0000000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# only build tests on targets that declare they are like posix -if(DEFINED TARGET_LIKE_X86_WINDOWS_NATIVE OR DEFINED TARGET_LIKE_X86_LINUX_NATIVE OR DEFINED TARGET_LIKE_X86_OSX_NATIVE) - - # describe the test executable - add_executable(mbed_trace_test EXCLUDE_FROM_ALL Test.cpp stubs/ip6tos_stub.c) - - include_directories("../yotta_modules/cpputest" "./stubs") - - # describe what the test executable needs to link with - target_link_libraries(mbed_trace_test "mbed-trace" cpputest) - - # describe what is actual test binary - if(DEFINED TARGET_LIKE_X86_WINDOWS_NATIVE) - add_test(mbed_trace_test "build/x86-windows-native/test/mbed_trace_test") - add_dependencies(all_tests mbed_trace_test) - elseif(DEFINED TARGET_LIKE_X86_LINUX_NATIVE) - SET(TEST_EXECUTABLE "../../../build/x86-linux-native/test/mbed_trace_test") - add_test(mbed_trace_test ${TEST_EXECUTABLE}) - add_dependencies(all_tests mbed_trace_test) - elseif(DEFINED TARGET_LIKE_X86_OSX_NATIVE) - SET(TEST_EXECUTABLE "../../../build/x86-osx-native/test/mbed_trace_test") - add_test(mbed_trace_test ${TEST_EXECUTABLE}) - add_dependencies(all_tests mbed_trace_test) - endif() -endif() diff --git a/test/Test.cpp b/test/Test.cpp deleted file mode 100644 index 4261d8172e..0000000000 --- a/test/Test.cpp +++ /dev/null @@ -1,501 +0,0 @@ -/* - * Copyright (c) 2014 ARM. All rights reserved. - */ -/** - * \file \test_libTrace\Test.c - * - * \brief Unit tests for mbed_trace - */ -#include -#include -#include - -#include "mbed-cpputest/CppUTest/TestHarness.h" -#include "mbed-cpputest/CppUTest/SimpleString.h" -#include "mbed-cpputest/CppUTest/CommandLineTestRunner.h" - -#define MBED_CONF_MBED_TRACE_ENABLE 1 -#define MBED_CONF_MBED_TRACE_FEA_IPV6 1 - -#include "mbed-trace/mbed_trace.h" -#include "ip6tos_stub.h" - -int main(int ac, char **av) -{ - return CommandLineTestRunner::RunAllTests(ac, av); -} - -static int mutex_wait_count = 0; -static int mutex_release_count = 0; -static bool check_mutex_lock_status = true; -void my_mutex_wait() -{ - mutex_wait_count++; -} -void my_mutex_release() -{ - mutex_release_count++; -} - -char buf[1024]; -#include -void myprint(const char *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(); - } -}; - -/* 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; - - 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); - - 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)); -} - -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); -} - -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); -} - -TEST(trace, TooLong) -{ -#define TOO_LONG_SIZE 9400 -#define TRACE_LINE_SIZE 1024 - char longStr[TOO_LONG_SIZE] = {0}; - for (int i = 0; i < TOO_LONG_SIZE; i++) { - longStr[i] = 0x36; - } - - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", longStr); - - char shouldStr[TRACE_LINE_SIZE] = "[DBG ][mygr]: "; - for (int i = 14; i < TRACE_LINE_SIZE; i++) { - shouldStr[i] = 0x36; - } - shouldStr[TRACE_LINE_SIZE - 1] = 0; - STRCMP_EQUAL(shouldStr, buf); -} - -TEST(trace, BufferResize) -{ - uint8_t arr[20] = {0}; - memset(arr, '0', 20); - - mbed_trace_buffer_sizes(0, 10); - STRCMP_EQUAL("30:30:30*", mbed_trace_array(arr, 20)); - mbed_trace_buffer_sizes(0, 15); - STRCMP_EQUAL("30:30:30:30*", mbed_trace_array(arr, 20)); - mbed_trace_buffer_sizes(0, 15); - STRCMP_EQUAL("30:30:30:30", mbed_trace_array(arr, 4)); - - const char *expectedStr = "0123456789"; - mbed_trace_buffer_sizes(11, 0); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "01234567890123456789"); - STRCMP_EQUAL(expectedStr, buf); - expectedStr = "012345678901234"; - mbed_trace_buffer_sizes(16, 0); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "01234567890123456789"); - STRCMP_EQUAL(expectedStr, buf); - expectedStr = "012345678901234"; - mbed_trace_buffer_sizes(16, 0); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "012345678901234"); - STRCMP_EQUAL(expectedStr, buf); -} - -TEST(trace, PreInitConfiguration) -{ - uint8_t arr[20] = {0}; - memset(arr, '0', 20); - - mbed_trace_free(); - mbed_trace_config_set(TRACE_MODE_PLAIN | TRACE_ACTIVE_LEVEL_ALL); - mbed_trace_print_function_set(myprint); - mbed_trace_buffer_sizes(11, 10); - mbed_trace_mutex_wait_function_set(my_mutex_wait); - mbed_trace_mutex_release_function_set(my_mutex_release); - mbed_trace_init(); - - STRCMP_EQUAL("30:30:30*", mbed_trace_array(arr, 20)); - - const char *expectedStr = "0123456789"; - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "01234567890123456789"); - STRCMP_EQUAL(expectedStr, buf); -} - -#if YOTTA_CFG_MBED_TRACE_FEA_IPV6 == 1 -ip6tos_stub_def_t ip6tos_stub; // extern variable - -TEST(trace, ipv6) -{ - uint8_t prefix[] = { 0x14, 0x6e, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00 }; - int prefix_len = 64; - - char expected_str1[] = "146e:a00::/64"; - ip6tos_stub.output_string = "146e:a00::/64"; - char *str = mbed_trace_ipv6_prefix(prefix, prefix_len); - CHECK(memcmp(ip6tos_stub.input_array, prefix, 8) == 0); - STRCMP_EQUAL(expected_str1, str); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "flush buffers and locks"); - - char expected_str2[] = "::/0"; - ip6tos_stub.output_string = "::/0"; - str = mbed_trace_ipv6_prefix(NULL, 0); - STRCMP_EQUAL(expected_str2, str); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "flush buffers and locks"); - - char expected_str3[] = ""; - str = mbed_trace_ipv6_prefix(NULL, 1); - STRCMP_EQUAL(expected_str3, str); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "flush buffers and locks"); - - char expected_str4[] = ""; - str = mbed_trace_ipv6_prefix(prefix, 200); - STRCMP_EQUAL(expected_str4, str); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "flush buffers and locks"); - - char expected_str5[] = ""; - ip6tos_stub.output_string = "0123456789012345678901234567890123456789"; - str = mbed_trace_ipv6_prefix(prefix, 64); // Fill the tmp_data buffer - str = mbed_trace_ipv6_prefix(prefix, 64); - str = mbed_trace_ipv6_prefix(prefix, 64); - str = mbed_trace_ipv6_prefix(prefix, 64); - STRCMP_EQUAL(expected_str5, str); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "flush buffers and locks"); -} - -TEST(trace, active_level_all_ipv6) -{ - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL); - - uint8_t arr[] = { 0x20, 0x01, 0xd, 0xb8, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }; - ip6tos_stub.output_string = "2001:db8::1:0:0:1"; - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "my addr: %s", mbed_trace_ipv6(arr)); - CHECK(memcmp(ip6tos_stub.input_array, arr, 16) == 0); - STRCMP_EQUAL("[DBG ][mygr]: my addr: 2001:db8::1:0:0:1", buf); -} -#endif //YOTTA_CFG_MBED_TRACE_FEA_IPV6 - -TEST(trace, config_change) -{ - mbed_trace_config_set(TRACE_MODE_COLOR | TRACE_ACTIVE_LEVEL_ALL); - CHECK(mbed_trace_config_get() == TRACE_MODE_COLOR | TRACE_ACTIVE_LEVEL_ALL); - mbed_trace_config_set(TRACE_MODE_PLAIN | TRACE_ACTIVE_LEVEL_NONE); - CHECK(mbed_trace_config_get() == TRACE_MODE_PLAIN | TRACE_ACTIVE_LEVEL_NONE); - mbed_trace_config_set(TRACE_MODE_PLAIN | TRACE_ACTIVE_LEVEL_ALL); - CHECK(mbed_trace_config_get() == TRACE_MODE_PLAIN | TRACE_ACTIVE_LEVEL_ALL); -} - -TEST(trace, active_level_all_color) -{ - mbed_trace_config_set(TRACE_MODE_COLOR | TRACE_ACTIVE_LEVEL_ALL); - // unknown debug level - mbed_tracef(TRACE_LEVEL_DEBUG + 1, "mygr", "hep"); - STRCMP_EQUAL(" hep", buf); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "hello"); - STRCMP_EQUAL("\x1b[90m[DBG ][mygr]: hello\x1b[0m", buf); - mbed_tracef(TRACE_LEVEL_INFO, "mygr", "to one"); - STRCMP_EQUAL("\x1b[39m[INFO][mygr]: to one\x1b[0m", buf); - mbed_tracef(TRACE_LEVEL_WARN, "mygr", "and all"); - STRCMP_EQUAL("\x1b[33m[WARN][mygr]: and all\x1b[0m", buf); - mbed_tracef(TRACE_LEVEL_ERROR, "mygr", "even you"); - STRCMP_EQUAL("\x1b[31m[ERR ][mygr]: even you\x1b[0m", buf); -} - -TEST(trace, change_levels) -{ - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_DEBUG); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "hep"); - STRCMP_EQUAL("[DBG ][mygr]: hep", buf); - - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_DEBUG | TRACE_MODE_PLAIN); - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "hep"); - STRCMP_EQUAL("hep", buf); - - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_DEBUG | TRACE_MODE_COLOR); - mbed_tracef(TRACE_LEVEL_ERROR, "mygr", "hep"); - STRCMP_EQUAL("\x1b[31m[ERR ][mygr]: hep\x1b[0m", buf); - -} - -TEST(trace, active_level_debug) -{ - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_DEBUG); - - // unknown debug level - mbed_tracef(TRACE_LEVEL_DEBUG + 1, "mygr", "hep"); - STRCMP_EQUAL(" hep", buf); - - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "hep"); - STRCMP_EQUAL("[DBG ][mygr]: hep", buf); - - mbed_tracef(TRACE_LEVEL_INFO, "mygr", "test"); - STRCMP_EQUAL("[INFO][mygr]: test", buf); - - mbed_tracef(TRACE_LEVEL_WARN, "mygr", "hups"); - STRCMP_EQUAL("[WARN][mygr]: hups", buf); - - mbed_tracef(TRACE_LEVEL_ERROR, "mygr", "o'ou"); - STRCMP_EQUAL("[ERR ][mygr]: o'ou", buf); -} - -TEST(trace, active_level_info) -{ - buf[0] = 0; - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_INFO); - - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "hep"); - STRCMP_EQUAL("", mbed_trace_last()); - - mbed_tracef(TRACE_LEVEL_INFO, "mygr", "test"); - STRCMP_EQUAL("[INFO][mygr]: test", buf); - - mbed_tracef(TRACE_LEVEL_WARN, "mygr", "hups"); - STRCMP_EQUAL("[WARN][mygr]: hups", buf); - - mbed_tracef(TRACE_LEVEL_ERROR, "mygr", "o'ou"); - STRCMP_EQUAL("[ERR ][mygr]: o'ou", buf); -} - -TEST(trace, active_level_warn) -{ - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_WARN); - - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "hep"); - STRCMP_EQUAL("", mbed_trace_last()); - - mbed_tracef(TRACE_LEVEL_INFO, "mygr", "test"); - STRCMP_EQUAL("", mbed_trace_last()); - - mbed_tracef(TRACE_LEVEL_WARN, "mygr", "hups"); - STRCMP_EQUAL("[WARN][mygr]: hups", buf); - - mbed_tracef(TRACE_LEVEL_ERROR, "mygr", "o'ou"); - STRCMP_EQUAL("[ERR ][mygr]: o'ou", buf); -} - -TEST(trace, active_level_error) -{ - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ERROR); - - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "hep"); - STRCMP_EQUAL("", mbed_trace_last()); - - mbed_tracef(TRACE_LEVEL_INFO, "mygr", "test"); - STRCMP_EQUAL("", mbed_trace_last()); - - mbed_tracef(TRACE_LEVEL_WARN, "mygr", "hups"); - STRCMP_EQUAL("", mbed_trace_last()); - - mbed_tracef(TRACE_LEVEL_ERROR, "mygr", "o'ou"); - STRCMP_EQUAL("[ERR ][mygr]: o'ou", buf); -} -TEST(trace, active_level_none) -{ - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_NONE); - - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "hep"); - STRCMP_EQUAL("", mbed_trace_last()); - - mbed_tracef(TRACE_LEVEL_INFO, "mygr", "test"); - STRCMP_EQUAL("", mbed_trace_last()); - - mbed_tracef(TRACE_LEVEL_WARN, "mygr", "hups"); - STRCMP_EQUAL("", mbed_trace_last()); - - mbed_tracef(TRACE_LEVEL_ERROR, "mygr", "o'ou"); - STRCMP_EQUAL("", mbed_trace_last()); -} - -TEST(trace, active_level_all_1) -{ - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL); - mbed_trace_exclude_filters_set((char *)"mygr"); - - mbed_tracef(TRACE_LEVEL_DEBUG, "mygu", "hep"); - STRCMP_EQUAL("[DBG ][mygu]: hep", buf); - - mbed_tracef(TRACE_LEVEL_INFO, "mygr", "test"); - STRCMP_EQUAL("", mbed_trace_last()); -} -TEST(trace, active_level_all_2) -{ - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL); - mbed_trace_exclude_filters_set((char *)"mygr,mygu"); - - mbed_tracef(TRACE_LEVEL_DEBUG, "mygu", "hep"); - STRCMP_EQUAL("", mbed_trace_last()); - - mbed_tracef(TRACE_LEVEL_INFO, "mygr", "test"); - STRCMP_EQUAL("", mbed_trace_last()); -} -TEST(trace, active_level_all_3) -{ - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL); - mbed_trace_include_filters_set((char *)"mygr"); - - mbed_tracef(TRACE_LEVEL_DEBUG, "mygu", "hep"); - STRCMP_EQUAL("", mbed_trace_last()); - - mbed_tracef(TRACE_LEVEL_INFO, "mygr", "test"); - STRCMP_EQUAL("[INFO][mygr]: test", buf); -} - -TEST(trace, active_level_all_array) -{ - mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL); - - uint8_t arr[] = {0x01, 0x02, 0x03}; - mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "my addr: %s", mbed_trace_array(arr, 3)); - STRCMP_EQUAL("[DBG ][mygr]: my addr: 01:02:03", buf); -} - - -size_t time_length; -char trace_prefix_str[] = "[