From 49ef927f7d3e6c9be4e6a0b81ee3bea28960db11 Mon Sep 17 00:00:00 2001 From: Martin Willers Date: Mon, 17 May 2021 02:51:06 +0200 Subject: 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 --- tests/gtest_dlt_user.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests') 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 @@ -3645,6 +3645,45 @@ TEST(t_dlt_user_log_write_raw_formatted_attr, normal) EXPECT_LE(DLT_RETURN_OK, dlt_unregister_app()); } +/*/////////////////////////////////////// */ +/* + * 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); -- cgit v1.2.1