summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt3
-rw-r--r--tests/dlt-test-preregister-context.c32
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c40e681..6cc1006 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -13,8 +13,11 @@ add_executable(gtest_dlt_user gtest_dlt_user.cpp)
add_executable(gtest_dlt_daemon_common gtest_dlt_daemon_common.cpp ../src/daemon/dlt_daemon_common.c)
add_executable(dlt_test_receiver dlt_test_receiver.c)
add_executable(dlt_env_ll_unit_test dlt_env_ll_unit_test.cpp)
+add_executable(dlt-test-preregister-context dlt-test-preregister-context.c)
target_link_libraries(gtest_dlt_common gtest gtest_main dlt)
target_link_libraries(gtest_dlt_user gtest gtest_main dlt)
target_link_libraries(gtest_dlt_daemon_common gtest gtest_main dlt)
target_link_libraries(dlt_test_receiver dlt)
target_link_libraries(dlt_env_ll_unit_test gtest gtest_main dlt)
+target_link_libraries(dlt-test-preregister-context gtest gtest_main dlt)
+
diff --git a/tests/dlt-test-preregister-context.c b/tests/dlt-test-preregister-context.c
new file mode 100644
index 0000000..ad10d6f
--- /dev/null
+++ b/tests/dlt-test-preregister-context.c
@@ -0,0 +1,32 @@
+/**
+ * Copyright (C) 2015 Intel Corporation
+ *
+ */
+
+#include <unistd.h> /* for fork() */
+
+#include "dlt.h"
+
+/**
+ * @brief sample code for using pre-registered contexts
+ */
+int main()
+{
+ DltContext mainContext;
+ DLT_REGISTER_CONTEXT(mainContext, "CTXP", "main context");
+
+ DLT_LOG(mainContext, DLT_LOG_WARN, DLT_STRING("First message before app registered"));
+ usleep(200000);
+
+ DLT_LOG(mainContext, DLT_LOG_WARN, DLT_STRING("Second message before app registered"));
+ usleep(200000);
+
+ DLT_REGISTER_APP("PRNT", "Sample pre-register application");
+
+ DLT_LOG(mainContext, DLT_LOG_WARN, DLT_STRING("First message after app registered"));
+ usleep(200000);
+
+ DLT_UNREGISTER_APP();
+
+ return 0;
+}