summaryrefslogtreecommitdiff
path: root/tests/gtest_dlt_user.cpp
diff options
context:
space:
mode:
authorMartin Willers <M.Willers@gmx.net>2021-05-17 02:51:06 +0200
committerGitHub <noreply@github.com>2021-05-17 09:51:06 +0900
commit49ef927f7d3e6c9be4e6a0b81ee3bea28960db11 (patch)
treee4444b9605a3e1f7d4f5b9833a897a00f639295a /tests/gtest_dlt_user.cpp
parentf5344f8cf036e6dcb899522e8e679639dd23e1a4 (diff)
downloadDLT-daemon-49ef927f7d3e6c9be4e6a0b81ee3bea28960db11.tar.gz
Make nonverbose mode non exclusive (#300)
* Make Non-Verbose mode non-exclusive Switching to global Non-Verbose mode now does not force Verbose messages to also be sent as Non-Verbose ones anymore. That would not make any sense, because Verbose messages don't have a MessageId and thus are all getting the same MessageId of 65535. Instead, setting global "Non-Verbose" mode will allow both Verbose and Non-Verbose messages to be sent in a single session. The "Verbose-APIs" (e.g. dlt_user_log_write_start()) will then only write Verbose messages, whereas the "Non-Verbose APIs" (e.g. dlt_user_log_write_start_id()) will then only write Non-Verbose messages. Signed-off-by: Martin Willers <M.Willers@gmx.net>
Diffstat (limited to 'tests/gtest_dlt_user.cpp')
-rw-r--r--tests/gtest_dlt_user.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/gtest_dlt_user.cpp b/tests/gtest_dlt_user.cpp
index ca5117c..a66f7a4 100644
--- a/tests/gtest_dlt_user.cpp
+++ b/tests/gtest_dlt_user.cpp
@@ -3647,6 +3647,45 @@ TEST(t_dlt_user_log_write_raw_formatted_attr, normal)
/*/////////////////////////////////////// */
/*
+ * Test sending Verbose and Non-Verbose messages in the same session.
+ */
+
+/*/////////////////////////////////////// */
+/* t_dlt_user_nonverbose*/
+TEST(t_dlt_user_nonverbose, nonverbosemode)
+{
+ dlt_nonverbose_mode();
+ dlt_use_extended_header_for_non_verbose(false);
+
+ DltContext context;
+ DltContextData contextData;
+
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_message_modes"));
+
+ // Send a Verbose message
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start(&context, &contextData, DLT_LOG_DEFAULT));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_constant_string_attr(&contextData, "hello", "msg"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_attr(&contextData, 0x01020304, "val1", "unit1"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_attr(&contextData, 0x04030201, "val2", "unit2"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+
+ // Send a Non-Verbose message
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_start_id(&context, &contextData, DLT_LOG_DEFAULT, 42));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_constant_string_attr(&contextData, "hello", "msg"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_attr(&contextData, 0x01020304, "val1", "unit1"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_uint32_attr(&contextData, 0x04030201, "val2", "unit2"));
+ EXPECT_LE(DLT_RETURN_OK, dlt_user_log_write_finish(&contextData));
+
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_context(&context));
+ EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app());
+
+ dlt_use_extended_header_for_non_verbose(true);
+ dlt_verbose_mode();
+}
+
+/*/////////////////////////////////////// */
+/*
* int dlt_log_string(DltContext *handle,DltLogLevelType loglevel, const char *text);
* int dlt_log_string_int(DltContext *handle,DltLogLevelType loglevel, const char *text, int data);
* int dlt_log_string_uint(DltContext *handle,DltLogLevelType loglevel, const char *text, unsigned int data);