From 453136f8f5b21b560bd5542e8f0b0a403c87c1eb Mon Sep 17 00:00:00 2001 From: rahulsutariya Date: Tue, 17 Feb 2026 07:23:46 +0100 Subject: [PATCH 01/12] logging: copybara rules updates GIT_ORIGIN_SPP_REV_ID: dbd744b4b707c9279c12b2717f4e80be456938fc --- score/datarouter/BUILD | 7 +- .../session_handle_interface.h | 6 +- .../session_handle_mock.h | 6 +- .../filetransfer_message.h | 6 +- .../filetransfer_message_trace.h | 6 +- .../include/file_transfer.h | 6 +- .../include/ifile_transfer.h | 6 +- .../mock/filetransfer_mock.h | 6 +- score/datarouter/error/error.h | 6 +- .../applications/datarouter_feature_config.h | 6 +- .../include/daemon/configurator_commands.h | 6 +- .../include/daemon/diagnostic_job_handler.h | 6 +- .../include/daemon/diagnostic_job_parser.h | 6 +- .../include/daemon/i_diagnostic_job_handler.h | 6 +- .../include/daemon/i_diagnostic_job_parser.h | 18 +---- .../include/daemon/i_dlt_log_server.h | 6 +- score/datarouter/include/daemon/i_udp_send.h | 6 +- .../log_entry_deserialization_visitor.h | 6 +- .../include/daemon/message_passing_server.h | 6 +- score/datarouter/include/daemon/utility.h | 6 +- score/datarouter/include/dlt/dltid.h | 6 +- score/datarouter/include/logger/logger.h | 6 +- .../lib/synchronized/synchronized.h | 6 +- score/datarouter/network/vlan.h | 6 +- score/datarouter/network/vlan_local.h | 6 +- .../dynamic_config/dynamic_config_impl/BUILD | 69 ------------------- .../dynamic_config_session.h | 59 ---------------- .../dynamic_config_session_factory.h | 42 ----------- .../dlt/nonverbose_dlt_impl/nonverbose_dlt.h | 6 +- .../src/persistency/i_persistent_dictionary.h | 6 +- .../persistency/mock_persistent_dictionary.h | 6 +- .../persistent_dictionary_factory.hpp | 6 +- .../stub_persistent_dictionary.h | 6 +- .../stub_persistent_dictionary_factory.h | 6 +- .../src/persistent_logging/isysedr_handler.h | 6 +- .../stub_sysedr_factory.h | 6 +- .../stub_sysedr_handler.h | 6 +- .../src/persistent_logging/sysedr_factory.hpp | 6 +- .../test/ut/ut_logging/tracingTest.cpp | 6 +- .../test/utils/data_router_test_utils.h | 6 +- score/mw/log/custom_recorder_example/BUILD | 12 ---- 41 files changed, 113 insertions(+), 304 deletions(-) delete mode 100644 score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/BUILD delete mode 100644 score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/dynamic_config_session.h delete mode 100644 score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/dynamic_config_session_factory.h diff --git a/score/datarouter/BUILD b/score/datarouter/BUILD index 4ddc53b..2445357 100644 --- a/score/datarouter/BUILD +++ b/score/datarouter/BUILD @@ -337,7 +337,7 @@ filegroup( visibility = [ "//platform/aas/tools/itf:__subpackages__", "//platform/aas/tools/sctf:__subpackages__", - "//pqr/abc/abc-lmn/config/iproject/corepas/datarouter:__pkg__", + "//pqr/abc/abc-lmn/config/project/cpu/pas/datarouter:__pkg__", "//score/datarouter/test:__subpackages__", ], ) @@ -591,6 +591,7 @@ cc_library( ":log_entry_deserialization", ":log_sender", ":logchannel_utility", + ":udp_stream_output", ":unixdomain_server", "//score/datarouter/network:vlan", "//score/datarouter/src/persistent_logging/persistent_logging_stub:sysedr_stub", @@ -753,6 +754,7 @@ cc_library( hdrs = [ "include/daemon/socketserver.h", ], + # Configuration block updated during migration features = COMPILER_WARNING_FEATURES, local_defines = select({ "//score/datarouter/build_configuration_flags:config_persistent_logging": ["PERSISTENT_LOGGING"], @@ -787,6 +789,7 @@ cc_library( hdrs = [ "include/daemon/socketserver.h", ], + # Configuration block updated during migration features = COMPILER_WARNING_FEATURES, local_defines = select({ "//score/datarouter/build_configuration_flags:config_persistent_logging": ["PERSISTENT_LOGGING"], @@ -797,7 +800,7 @@ cc_library( deps = [ ":datarouter_feature_config_testing", ":datarouter_lib", - ":dltserver_testing", + ":dltserver", ":persistentlogconfig", ":socketserver_config_lib_testing", "@score_baselibs//score/mw/log/configuration:nvconfigfactory", diff --git a/score/datarouter/daemon_communication/session_handle_interface.h b/score/datarouter/daemon_communication/session_handle_interface.h index b5a1691..abe8f38 100644 --- a/score/datarouter/daemon_communication/session_handle_interface.h +++ b/score/datarouter/daemon_communication/session_handle_interface.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_DAEMON_COMMUNICATION_SESION_HANDLE_INTERFACE_H_ -#define SCORE_PAS_LOGGING_DAEMON_COMMUNICATION_SESION_HANDLE_INTERFACE_H_ +#ifndef SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_INTERFACE_H_ +#define SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_INTERFACE_H_ namespace score { @@ -35,4 +35,4 @@ class ISessionHandle } // namespace platform } // namespace score -#endif // SCORE_PAS_LOGGING_DAEMON_COMMUNICATION_SESION_HANDLE_INTERFACE_H_ +#endif // SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_INTERFACE_H_ diff --git a/score/datarouter/daemon_communication/session_handle_mock.h b/score/datarouter/daemon_communication/session_handle_mock.h index 79df25c..0303892 100644 --- a/score/datarouter/daemon_communication/session_handle_mock.h +++ b/score/datarouter/daemon_communication/session_handle_mock.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_DAEMON_COMMUNICATION_SESION_HANDLE_MOCK_H_ -#define SCORE_PAS_LOGGING_DAEMON_COMMUNICATION_SESION_HANDLE_MOCK_H_ +#ifndef SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_MOCK_H_ +#define SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_MOCK_H_ #include "score/datarouter/daemon_communication/session_handle_interface.h" @@ -29,4 +29,4 @@ class SessionHandleMock : public score::platform::internal::daemon::ISessionHand } // namespace score::platform::internal::daemon::mock -#endif // SCORE_PAS_LOGGING_DAEMON_COMMUNICATION_SESION_HANDLE_MOCK_H_ +#endif // SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_MOCK_H_ diff --git a/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message.h b/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message.h index 4f2a998..c96f988 100644 --- a/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message.h +++ b/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_FILETRANSFER_MESSAGE_H -#define SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_FILETRANSFER_MESSAGE_H +#ifndef SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_FILETRANSFER_MESSAGE_H +#define SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_FILETRANSFER_MESSAGE_H #include "score/datarouter/include/dlt/dltid.h" @@ -37,4 +37,4 @@ struct FileTransferEntry } // namespace score::logging -#endif // SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_FILETRANSFER_MESSAGE_H +#endif // SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_FILETRANSFER_MESSAGE_H diff --git a/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message_trace.h b/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message_trace.h index 2e18a95..c6f9d0e 100644 --- a/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message_trace.h +++ b/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message_trace.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_FILETRANSFER_MESSAGE_TRACE_H -#define SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_FILETRANSFER_MESSAGE_TRACE_H +#ifndef SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_FILETRANSFER_MESSAGE_TRACE_H +#define SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_FILETRANSFER_MESSAGE_TRACE_H #include "filetransfer_message.h" @@ -36,4 +36,4 @@ STRUCT_TRACEABLE(FileTransferEntry, appid, ctxid, file_name, delete_file) } // namespace score::logging -#endif // SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_FILETRANSFER_MESSAGE_TRACE_H +#endif // SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_FILETRANSFER_MESSAGE_TRACE_H diff --git a/score/datarouter/dlt_filetransfer_trigger_lib/include/file_transfer.h b/score/datarouter/dlt_filetransfer_trigger_lib/include/file_transfer.h index 5989082..629c22b 100644 --- a/score/datarouter/dlt_filetransfer_trigger_lib/include/file_transfer.h +++ b/score/datarouter/dlt_filetransfer_trigger_lib/include/file_transfer.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_INCLUDE_FILE_TRANSFER_H -#define SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_INCLUDE_FILE_TRANSFER_H +#ifndef SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_INCLUDE_FILE_TRANSFER_H +#define SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_INCLUDE_FILE_TRANSFER_H #include "ifile_transfer.h" @@ -32,4 +32,4 @@ class FileTransfer final : public IFileTransfer } // namespace score::logging -#endif // SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_INCLUDE_FILE_TRANSFER_H +#endif // SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_INCLUDE_FILE_TRANSFER_H diff --git a/score/datarouter/dlt_filetransfer_trigger_lib/include/ifile_transfer.h b/score/datarouter/dlt_filetransfer_trigger_lib/include/ifile_transfer.h index 373bc6c..99f5498 100644 --- a/score/datarouter/dlt_filetransfer_trigger_lib/include/ifile_transfer.h +++ b/score/datarouter/dlt_filetransfer_trigger_lib/include/ifile_transfer.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_INCLUDE_IFILE_TRANSFER_H -#define SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_INCLUDE_IFILE_TRANSFER_H +#ifndef SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_INCLUDE_IFILE_TRANSFER_H +#define SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_INCLUDE_IFILE_TRANSFER_H #include #include @@ -44,4 +44,4 @@ using IFileTransferPtr = std::unique_ptr; } // namespace score::logging -#endif // SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_INCLUDE_IFILE_TRANSFER_H +#endif // SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_INCLUDE_IFILE_TRANSFER_H diff --git a/score/datarouter/dlt_filetransfer_trigger_lib/mock/filetransfer_mock.h b/score/datarouter/dlt_filetransfer_trigger_lib/mock/filetransfer_mock.h index b1fdc1d..93f9bbe 100644 --- a/score/datarouter/dlt_filetransfer_trigger_lib/mock/filetransfer_mock.h +++ b/score/datarouter/dlt_filetransfer_trigger_lib/mock/filetransfer_mock.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_MOCK_FILETRANSFER_MOCK_H -#define SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_MOCK_FILETRANSFER_MOCK_H +#ifndef SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_MOCK_FILETRANSFER_MOCK_H +#define SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_MOCK_FILETRANSFER_MOCK_H #include "score/datarouter/dlt_filetransfer_trigger_lib/include/ifile_transfer.h" @@ -32,4 +32,4 @@ class MockFileTransfer : public IFileTransfer } // namespace logging } // namespace score -#endif // SCORE_PAS_LOGGING_DLT_FILETRANSFER_TRIGGER_LIB_MOCK_FILETRANSFER_MOCK_H +#endif // SCORE_DATAROUTER_DLT_FILETRANSFER_TRIGGER_LIB_MOCK_FILETRANSFER_MOCK_H diff --git a/score/datarouter/error/error.h b/score/datarouter/error/error.h index 5685b74..d977072 100644 --- a/score/datarouter/error/error.h +++ b/score/datarouter/error/error.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_ERROR_ERROR_H -#define SCORE_PAS_LOGGING_ERROR_ERROR_H +#ifndef SCORE_DATAROUTER_ERROR_ERROR_H +#define SCORE_DATAROUTER_ERROR_ERROR_H #include "score/result/error.h" @@ -43,4 +43,4 @@ score::result::Error MakeError(const LoggingErrorCode code, const std::string_vi } // namespace logging } // namespace score -#endif // SCORE_PAS_LOGGING_ERROR_ERROR_H +#endif // SCORE_DATAROUTER_ERROR_ERROR_H diff --git a/score/datarouter/include/applications/datarouter_feature_config.h b/score/datarouter/include/applications/datarouter_feature_config.h index d968285..dc9036d 100644 --- a/score/datarouter/include/applications/datarouter_feature_config.h +++ b/score/datarouter/include/applications/datarouter_feature_config.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_DATAROUTER_FEATURE_CONFIG_H -#define SCORE_PAS_LOGGING_DATAROUTER_FEATURE_CONFIG_H +#ifndef SCORE_DATAROUTER_DATAROUTER_FEATURE_CONFIG_H +#define SCORE_DATAROUTER_DATAROUTER_FEATURE_CONFIG_H // --- Conditional Compilation Feature Switch --- #if defined(PERSISTENT_CONFIG_FEATURE_ENABLED) @@ -104,4 +104,4 @@ using FileTransferStreamHandlerType = score::logging::dltserver::StubFileTransfe } // namespace platform } // namespace score -#endif // SCORE_PAS_LOGGING_DATAROUTER_FEATURE_CONFIG_H +#endif // SCORE_DATAROUTER_DATAROUTER_FEATURE_CONFIG_H diff --git a/score/datarouter/include/daemon/configurator_commands.h b/score/datarouter/include/daemon/configurator_commands.h index 36c4c16..1a0e1ce 100644 --- a/score/datarouter/include/daemon/configurator_commands.h +++ b/score/datarouter/include/daemon/configurator_commands.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_INCLUDE_DAEMON_CONFIGURATOR_COMMANDS_H -#define SCORE_PAS_LOGGING_INCLUDE_DAEMON_CONFIGURATOR_COMMANDS_H +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_CONFIGURATOR_COMMANDS_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_CONFIGURATOR_COMMANDS_H #include @@ -49,4 +49,4 @@ static constexpr std::uint8_t DISABLE = 0; } // namespace logging } // namespace score -#endif // SCORE_PAS_LOGGING_INCLUDE_DAEMON_CONFIGURATOR_COMMANDS_H +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_CONFIGURATOR_COMMANDS_H diff --git a/score/datarouter/include/daemon/diagnostic_job_handler.h b/score/datarouter/include/daemon/diagnostic_job_handler.h index 9acd082..0ce3902 100644 --- a/score/datarouter/include/daemon/diagnostic_job_handler.h +++ b/score/datarouter/include/daemon/diagnostic_job_handler.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_INCLUDE_DAEMON_DIAGNOSTIC_JOB_HANDLER_H -#define SCORE_PAS_LOGGING_INCLUDE_DAEMON_DIAGNOSTIC_JOB_HANDLER_H +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_DIAGNOSTIC_JOB_HANDLER_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_DIAGNOSTIC_JOB_HANDLER_H #include "i_diagnostic_job_handler.h" #include "score/mw/log/log_level.h" @@ -179,4 +179,4 @@ class SetDltOutputEnableHandler final : public IDiagnosticJobHandler } // namespace logging } // namespace score -#endif // SCORE_PAS_LOGGING_INCLUDE_DAEMON_DIAGNOSTIC_JOB_HANDLER_H +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_DIAGNOSTIC_JOB_HANDLER_H diff --git a/score/datarouter/include/daemon/diagnostic_job_parser.h b/score/datarouter/include/daemon/diagnostic_job_parser.h index 039ad10..c36b2e3 100644 --- a/score/datarouter/include/daemon/diagnostic_job_parser.h +++ b/score/datarouter/include/daemon/diagnostic_job_parser.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_INCLUDE_DAEMON_DIAGNOSTIC_JOB_PARSER_H -#define SCORE_PAS_LOGGING_INCLUDE_DAEMON_DIAGNOSTIC_JOB_PARSER_H +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_DIAGNOSTIC_JOB_PARSER_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_DIAGNOSTIC_JOB_PARSER_H #include #include @@ -51,4 +51,4 @@ class DiagnosticJobParser : public IDiagnosticJobParser } // namespace logging } // namespace score -#endif // SCORE_PAS_LOGGING_INCLUDE_DAEMON_DIAGNOSTIC_JOB_PARSER_H +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_DIAGNOSTIC_JOB_PARSER_H diff --git a/score/datarouter/include/daemon/i_diagnostic_job_handler.h b/score/datarouter/include/daemon/i_diagnostic_job_handler.h index c8af91d..5a79c84 100644 --- a/score/datarouter/include/daemon/i_diagnostic_job_handler.h +++ b/score/datarouter/include/daemon/i_diagnostic_job_handler.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_INCLUDE_DAEMON_I_DIAGNOSTIC_JOB_HANDLER_H -#define SCORE_PAS_LOGGING_INCLUDE_DAEMON_I_DIAGNOSTIC_JOB_HANDLER_H +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_I_DIAGNOSTIC_JOB_HANDLER_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_I_DIAGNOSTIC_JOB_HANDLER_H #include #include @@ -37,4 +37,4 @@ class IDiagnosticJobHandler } // namespace logging } // namespace score -#endif // SCORE_PAS_LOGGING_INCLUDE_DAEMON_I_DIAGNOSTIC_JOB_HANDLER_H +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_I_DIAGNOSTIC_JOB_HANDLER_H diff --git a/score/datarouter/include/daemon/i_diagnostic_job_parser.h b/score/datarouter/include/daemon/i_diagnostic_job_parser.h index 9fd0158..a3f1d23 100644 --- a/score/datarouter/include/daemon/i_diagnostic_job_parser.h +++ b/score/datarouter/include/daemon/i_diagnostic_job_parser.h @@ -1,15 +1,3 @@ -/******************************************************************************** - * Copyright (c) 2026 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ /******************************************************************************** * Copyright (c) 2025 Contributors to the Eclipse Foundation @@ -24,8 +12,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_INCLUDE_DAEMON_I_DIAGNOSTIC_JOB_PARSER_H -#define SCORE_PAS_LOGGING_INCLUDE_DAEMON_I_DIAGNOSTIC_JOB_PARSER_H +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_I_DIAGNOSTIC_JOB_PARSER_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_I_DIAGNOSTIC_JOB_PARSER_H #include #include @@ -53,4 +41,4 @@ class IDiagnosticJobParser } // namespace logging } // namespace score -#endif // SCORE_PAS_LOGGING_INCLUDE_DAEMON_I_DIAGNOSTIC_JOB_PARSER_H +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_I_DIAGNOSTIC_JOB_PARSER_H diff --git a/score/datarouter/include/daemon/i_dlt_log_server.h b/score/datarouter/include/daemon/i_dlt_log_server.h index cfaeee6..2012b41 100644 --- a/score/datarouter/include/daemon/i_dlt_log_server.h +++ b/score/datarouter/include/daemon/i_dlt_log_server.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_INCLUDE_DAEMON_I_DLT_LOG_SERVER_H -#define SCORE_PAS_LOGGING_INCLUDE_DAEMON_I_DLT_LOG_SERVER_H +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_I_DLT_LOG_SERVER_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_I_DLT_LOG_SERVER_H #include "score/mw/log/log_level.h" #include "score/datarouter/include/daemon/configurator_commands.h" @@ -67,4 +67,4 @@ class IDltLogServer } // namespace logging } // namespace score -#endif // SCORE_PAS_LOGGING_INCLUDE_DAEMON_I_DLT_LOG_SERVER_H +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_I_DLT_LOG_SERVER_H diff --git a/score/datarouter/include/daemon/i_udp_send.h b/score/datarouter/include/daemon/i_udp_send.h index 80495b3..7afa079 100644 --- a/score/datarouter/include/daemon/i_udp_send.h +++ b/score/datarouter/include/daemon/i_udp_send.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_INCLUDE_DAEMON_I_UDP_SEND_H -#define SCORE_PAS_LOGGING_INCLUDE_DAEMON_I_UDP_SEND_H +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_I_UDP_SEND_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_I_UDP_SEND_H #include "score/os/errno.h" #include @@ -35,4 +35,4 @@ class IUdpSend } // namespace dltserver } // namespace logging } // namespace score -#endif // SCORE_PAS_LOGGING_INCLUDE_DAEMON_I_UDP_SEND_H +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_I_UDP_SEND_H diff --git a/score/datarouter/include/daemon/log_entry_deserialization_visitor.h b/score/datarouter/include/daemon/log_entry_deserialization_visitor.h index 96bc227..a4c5582 100644 --- a/score/datarouter/include/daemon/log_entry_deserialization_visitor.h +++ b/score/datarouter/include/daemon/log_entry_deserialization_visitor.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_INCLUDE_DAEMON_LOG_ENTRY_DESERIALIZATION_VISITOR_H_ -#define SCORE_PAS_LOGGING_INCLUDE_DAEMON_LOG_ENTRY_DESERIALIZATION_VISITOR_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_LOG_ENTRY_DESERIALIZATION_VISITOR_H_ +#define SCORE_DATAROUTER_INCLUDE_DAEMON_LOG_ENTRY_DESERIALIZATION_VISITOR_H_ #include "score/mw/log/detail/common/log_entry_deserialize.h" #include "static_reflection_with_serialization/serialization/for_logging.h" @@ -89,4 +89,4 @@ inline auto visit_as(serialized_visitor& /*unused*/, const T& /*unused*/) } // namespace common } // namespace score -#endif // SCORE_PAS_LOGGING_INCLUDE_DAEMON_LOG_ENTRY_DESERIALIZATION_VISITOR_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_LOG_ENTRY_DESERIALIZATION_VISITOR_H_ diff --git a/score/datarouter/include/daemon/message_passing_server.h b/score/datarouter/include/daemon/message_passing_server.h index 3836534..6693cf1 100644 --- a/score/datarouter/include/daemon/message_passing_server.h +++ b/score/datarouter/include/daemon/message_passing_server.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_INCLUDE_DAEMON_MESSAGE_PASSING_SERVER_H -#define SCORE_PAS_LOGGING_INCLUDE_DAEMON_MESSAGE_PASSING_SERVER_H +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_MESSAGE_PASSING_SERVER_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_MESSAGE_PASSING_SERVER_H #include "score/mw/log/detail/data_router/data_router_messages.h" @@ -198,4 +198,4 @@ class MessagePassingServer : public IMessagePassingServerSessionWrapper } // namespace platform } // namespace score -#endif // SCORE_PAS_LOGGING_INCLUDE_DAEMON_MESSAGE_PASSING_SERVER_H +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_MESSAGE_PASSING_SERVER_H diff --git a/score/datarouter/include/daemon/utility.h b/score/datarouter/include/daemon/utility.h index 5a230af..0329bb7 100644 --- a/score/datarouter/include/daemon/utility.h +++ b/score/datarouter/include/daemon/utility.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_INCLUDE_DAEMON_UTILITY_H -#define SCORE_PAS_LOGGING_INCLUDE_DAEMON_UTILITY_H +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_UTILITY_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_UTILITY_H #include "score/mw/log/log_level.h" #include @@ -37,4 +37,4 @@ inline std::string GetStringFromLogLevel(score::mw::log::LogLevel level) namespace logchannel_operations = logging_daemon::logchannel_utility; -#endif // SCORE_PAS_LOGGING_INCLUDE_DAEMON_UTILITY_H +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_UTILITY_H diff --git a/score/datarouter/include/dlt/dltid.h b/score/datarouter/include/dlt/dltid.h index dcbec2b..03cef5c 100644 --- a/score/datarouter/include/dlt/dltid.h +++ b/score/datarouter/include/dlt/dltid.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_INCLUDE_DLT_DLTID_H -#define SCORE_PAS_LOGGING_INCLUDE_DLT_DLTID_H +#ifndef SCORE_DATAROUTER_INCLUDE_DLT_DLTID_H +#define SCORE_DATAROUTER_INCLUDE_DLT_DLTID_H #include "score/mw/log/detail/logging_identifier.h" #include @@ -105,4 +105,4 @@ struct hash } // namespace std -#endif // SCORE_PAS_LOGGING_INCLUDE_DLT_DLTID_H +#endif // SCORE_DATAROUTER_INCLUDE_DLT_DLTID_H diff --git a/score/datarouter/include/logger/logger.h b/score/datarouter/include/logger/logger.h index b0dac59..b240091 100644 --- a/score/datarouter/include/logger/logger.h +++ b/score/datarouter/include/logger/logger.h @@ -11,11 +11,11 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef AAS_PAS_LOGGING_LOGGER_H_ -#define AAS_PAS_LOGGING_LOGGER_H_ +#ifndef AAS_DATAROUTER_LOGGER_H_ +#define AAS_DATAROUTER_LOGGER_H_ /// \file This file shall be replaced by the mw::log package. #include "score/mw/log/legacy_non_verbose_api/tracing.h" -#endif // AAS_PAS_LOGGING_LOGGER_H_ +#endif // AAS_DATAROUTER_LOGGER_H_ diff --git a/score/datarouter/lib/synchronized/synchronized.h b/score/datarouter/lib/synchronized/synchronized.h index 789f649..cb08412 100644 --- a/score/datarouter/lib/synchronized/synchronized.h +++ b/score/datarouter/lib/synchronized/synchronized.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_LIB_SYNCHRONIZED_SYNCHRONIZED_H -#define SCORE_PAS_LOGGING_LIB_SYNCHRONIZED_SYNCHRONIZED_H +#ifndef SCORE_DATAROUTER_LIB_SYNCHRONIZED_SYNCHRONIZED_H +#define SCORE_DATAROUTER_LIB_SYNCHRONIZED_SYNCHRONIZED_H #include #include @@ -93,4 +93,4 @@ class Synchronized } // namespace platform } // namespace score -#endif // SCORE_PAS_LOGGING_LIB_SYNCHRONIZED_SYNCHRONIZED_H +#endif // SCORE_DATAROUTER_LIB_SYNCHRONIZED_SYNCHRONIZED_H diff --git a/score/datarouter/network/vlan.h b/score/datarouter/network/vlan.h index 340b937..17b2e05 100644 --- a/score/datarouter/network/vlan.h +++ b/score/datarouter/network/vlan.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_NETWORK_VLAN_H -#define SCORE_PAS_LOGGING_NETWORK_VLAN_H +#ifndef SCORE_DATAROUTER_NETWORK_VLAN_H +#define SCORE_DATAROUTER_NETWORK_VLAN_H #if defined(USE_LOCAL_VLAN) #include "score/datarouter/network/vlan_local.h" @@ -20,4 +20,4 @@ #include "score/network/vlan.h" #endif -#endif // SCORE_PAS_LOGGING_NETWORK_VLAN_H +#endif // SCORE_DATAROUTER_NETWORK_VLAN_H diff --git a/score/datarouter/network/vlan_local.h b/score/datarouter/network/vlan_local.h index a805db2..57d6cd1 100644 --- a/score/datarouter/network/vlan_local.h +++ b/score/datarouter/network/vlan_local.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_NETWORK_VLAN_LOCAL_H -#define SCORE_PAS_LOGGING_NETWORK_VLAN_LOCAL_H +#ifndef SCORE_DATAROUTER_NETWORK_VLAN_LOCAL_H +#define SCORE_DATAROUTER_NETWORK_VLAN_LOCAL_H #include "score/os/ObjectSeam.h" #include "score/os/errno.h" @@ -47,4 +47,4 @@ class Vlan : public ObjectSeam } // namespace os } // namespace score -#endif // SCORE_PAS_LOGGING_NETWORK_VLAN_LOCAL_H +#endif // SCORE_DATAROUTER_NETWORK_VLAN_LOCAL_H diff --git a/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/BUILD b/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/BUILD deleted file mode 100644 index 6bedaba..0000000 --- a/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/BUILD +++ /dev/null @@ -1,69 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2025 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License Version 2.0 which is available at -# https://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -# ******************************************************************************* - -load("@score_baselibs//score/language/safecpp:toolchain_features.bzl", "COMPILER_WARNING_FEATURES") -load("@score_baselibs//score/quality/clang_tidy:extra_checks.bzl", "clang_tidy_extra_checks") - -clang_tidy_extra_checks( - name = "clang_tidy_extra_checks", - extra_features = [ - "spp_code_style_check_header_guards", - "spp_code_style_check_method_names", - "spp_code_style_check_readability", - "spp_code_style_check_type_names", - "spp_code_style_check_variable_names", - ], -) - -[ - cc_library( - name = "dynamic_config_session" + name, - testonly = test_only, - hdrs = [ - "dynamic_config_session.h", - "dynamic_config_session_factory.h", - ], - features = COMPILER_WARNING_FEATURES, - strip_include_prefix = ".", - visibility = visibility, - deps = deps + [ - "//score/datarouter/src/configuration/dynamic_config:i_session", - ], - ) - for name, test_only, visibility, deps in [ - ( - "", - False, - [ - "@score_logging//score/datarouter:__pkg__", - "@score_logging//score/datarouter:__subpackages__", - ], - [ - "@score_logging//score/datarouter:unixdomain_server", - "//score/datarouter/src/configuration/dynamic_config:config_session_factory", - ], - ), - ( - "_testing", - True, - [ - "@score_logging//score/datarouter:__pkg__", - "//score/datarouter/test:__subpackages__", - ], - [ - "@score_logging//score/datarouter:unixdomain_mock", - "//score/datarouter/src/configuration/dynamic_config:config_session_factory_testing", - ], - ), - ] -] diff --git a/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/dynamic_config_session.h b/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/dynamic_config_session.h deleted file mode 100644 index 8354e9f..0000000 --- a/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/dynamic_config_session.h +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -#ifndef DYNAMIC_CONFIG_SESSION_H -#define DYNAMIC_CONFIG_SESSION_H - -#include "unix_domain/unix_domain_server.h" -#include -namespace score -{ -namespace logging -{ -namespace daemon -{ - -class ConfigSession final : public score::platform::internal::UnixDomainServer::ISession -{ - public: - template - ConfigSession(score::platform::internal::UnixDomainServer::SessionHandle handle, Handler&& handler) - : handle_(std::move(handle)), handler_(std::forward(handler)) - { - } - - ~ConfigSession() override = default; - - private: - // Not called from production code. - // LCOV_EXCL_START - bool tick() override - { - return false; - } - // LCOV_EXCL_STOP - void on_command(const std::string& command) override final - { - auto response = handler_(command); - handle_.pass_message(response); - } - - score::platform::internal::UnixDomainServer::SessionHandle handle_; - std::function handler_; -}; - -} // namespace daemon -} // namespace logging -} // namespace score - -#endif // DYNAMIC_CONFIG_SESSION_H diff --git a/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/dynamic_config_session_factory.h b/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/dynamic_config_session_factory.h deleted file mode 100644 index 261b1c5..0000000 --- a/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/dynamic_config_session_factory.h +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -#ifndef DYNAMIC_CONFIG_SESSION_FACTORY_H -#define DYNAMIC_CONFIG_SESSION_FACTORY_H - -#include "config_session_factory.hpp" -#include "dynamic_config_session.h" - -namespace score -{ -namespace logging -{ -namespace daemon -{ - -class DynamicConfigSessionFactory : public ConfigSessionFactory -{ - public: - template - std::unique_ptr CreateConcreteSession(score::platform::internal::UnixDomainServer::SessionHandle handle, - Handler&& handler) - { - return std::make_unique(std::move(handle), std::forward(handler)); - } -}; - -} // namespace daemon -} // namespace logging -} // namespace score - -#endif // DYNAMIC_CONFIG_SESSION_FACTORY_H diff --git a/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h b/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h index e6772b0..e4c0104 100644 --- a/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h +++ b/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_NONVERBOSE_DLT_NONVERBOSE_DLT_H -#define SCORE_PAS_LOGGING_NONVERBOSE_DLT_NONVERBOSE_DLT_H +#ifndef SCORE_DATAROUTER_NONVERBOSE_DLT_NONVERBOSE_DLT_H +#define SCORE_DATAROUTER_NONVERBOSE_DLT_NONVERBOSE_DLT_H #include "logparser/logparser.h" #include "score/mw/log/configuration/nvconfig.h" @@ -56,4 +56,4 @@ class DltNonverboseHandler : public LogParser::AnyHandler } // namespace logging } // namespace score -#endif // SCORE_PAS_LOGGING_NONVERBOSE_DLT_NONVERBOSE_DLT_H +#endif // SCORE_DATAROUTER_NONVERBOSE_DLT_NONVERBOSE_DLT_H diff --git a/score/datarouter/src/persistency/i_persistent_dictionary.h b/score/datarouter/src/persistency/i_persistent_dictionary.h index 2a83876..3d06a2a 100644 --- a/score/datarouter/src/persistency/i_persistent_dictionary.h +++ b/score/datarouter/src/persistency/i_persistent_dictionary.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_SRC_PERSISTENCY_I_PERSISTENT_DICTIONARY_H -#define SCORE_PAS_LOGGING_SRC_PERSISTENCY_I_PERSISTENT_DICTIONARY_H +#ifndef SCORE_DATAROUTER_SRC_PERSISTENCY_I_PERSISTENT_DICTIONARY_H +#define SCORE_DATAROUTER_SRC_PERSISTENCY_I_PERSISTENT_DICTIONARY_H #include @@ -45,4 +45,4 @@ class IPersistentDictionary } // namespace platform } // namespace score -#endif // SCORE_PAS_LOGGING_SRC_PERSISTENCY_I_PERSISTENT_DICTIONARY_H +#endif // SCORE_DATAROUTER_SRC_PERSISTENCY_I_PERSISTENT_DICTIONARY_H diff --git a/score/datarouter/src/persistency/mock_persistent_dictionary.h b/score/datarouter/src/persistency/mock_persistent_dictionary.h index 38f1313..d87affa 100644 --- a/score/datarouter/src/persistency/mock_persistent_dictionary.h +++ b/score/datarouter/src/persistency/mock_persistent_dictionary.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_SRC_PERSISTENCY_MOCK_PERSISTENT_DICTIONARY_H -#define SCORE_PAS_LOGGING_SRC_PERSISTENCY_MOCK_PERSISTENT_DICTIONARY_H +#ifndef SCORE_DATAROUTER_SRC_PERSISTENCY_MOCK_PERSISTENT_DICTIONARY_H +#define SCORE_DATAROUTER_SRC_PERSISTENCY_MOCK_PERSISTENT_DICTIONARY_H #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -43,4 +43,4 @@ class MockPersistentDictionary : public ::score::platform::datarouter::IPersiste } // namespace platform } // namespace score -#endif // SCORE_PAS_LOGGING_SRC_PERSISTENCY_MOCK_PERSISTENT_DICTIONARY_H +#endif // SCORE_DATAROUTER_SRC_PERSISTENCY_MOCK_PERSISTENT_DICTIONARY_H diff --git a/score/datarouter/src/persistency/persistent_dictionary_factory.hpp b/score/datarouter/src/persistency/persistent_dictionary_factory.hpp index 4b31576..5725acb 100644 --- a/score/datarouter/src/persistency/persistent_dictionary_factory.hpp +++ b/score/datarouter/src/persistency/persistent_dictionary_factory.hpp @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_SRC_PERSISTENCY_PERSISTENT_DICTIONARY_FACTORY_HPP -#define SCORE_PAS_LOGGING_SRC_PERSISTENCY_PERSISTENT_DICTIONARY_FACTORY_HPP +#ifndef SCORE_DATAROUTER_SRC_PERSISTENCY_PERSISTENT_DICTIONARY_FACTORY_HPP +#define SCORE_DATAROUTER_SRC_PERSISTENCY_PERSISTENT_DICTIONARY_FACTORY_HPP #include "i_persistent_dictionary.h" #include @@ -60,4 +60,4 @@ class PersistentDictionaryFactory } // namespace platform } // namespace score -#endif // SCORE_PAS_LOGGING_SRC_PERSISTENCY_PERSISTENT_DICTIONARY_FACTORY_HPP +#endif // SCORE_DATAROUTER_SRC_PERSISTENCY_PERSISTENT_DICTIONARY_FACTORY_HPP diff --git a/score/datarouter/src/persistency/stub_persistent_dictionary/stub_persistent_dictionary.h b/score/datarouter/src/persistency/stub_persistent_dictionary/stub_persistent_dictionary.h index 2e2ceb6..9b823ef 100644 --- a/score/datarouter/src/persistency/stub_persistent_dictionary/stub_persistent_dictionary.h +++ b/score/datarouter/src/persistency/stub_persistent_dictionary/stub_persistent_dictionary.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_SRC_PERSISTENCY_STUB_PERSISTENT_DICTIONARY_STUB_PERSISTENT_DICTIONARY_H -#define SCORE_PAS_LOGGING_SRC_PERSISTENCY_STUB_PERSISTENT_DICTIONARY_STUB_PERSISTENT_DICTIONARY_H +#ifndef SCORE_DATAROUTER_SRC_PERSISTENCY_STUB_PERSISTENT_DICTIONARY_STUB_PERSISTENT_DICTIONARY_H +#define SCORE_DATAROUTER_SRC_PERSISTENCY_STUB_PERSISTENT_DICTIONARY_STUB_PERSISTENT_DICTIONARY_H #include "score/datarouter/src/persistency/i_persistent_dictionary.h" @@ -37,4 +37,4 @@ class StubPersistentDictionary final : public IPersistentDictionary } // namespace platform } // namespace score -#endif // SCORE_PAS_LOGGING_SRC_PERSISTENCY_STUB_PERSISTENT_DICTIONARY_STUB_PERSISTENT_DICTIONARY_H +#endif // SCORE_DATAROUTER_SRC_PERSISTENCY_STUB_PERSISTENT_DICTIONARY_STUB_PERSISTENT_DICTIONARY_H diff --git a/score/datarouter/src/persistency/stub_persistent_dictionary/stub_persistent_dictionary_factory.h b/score/datarouter/src/persistency/stub_persistent_dictionary/stub_persistent_dictionary_factory.h index 28bd88e..67bce46 100644 --- a/score/datarouter/src/persistency/stub_persistent_dictionary/stub_persistent_dictionary_factory.h +++ b/score/datarouter/src/persistency/stub_persistent_dictionary/stub_persistent_dictionary_factory.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_SRC_PERSISTENCY_STUB_PERSISTENT_DICTIONARY_STUB_PERSISTENT_DICTIONARY_FACTORY_H -#define SCORE_PAS_LOGGING_SRC_PERSISTENCY_STUB_PERSISTENT_DICTIONARY_STUB_PERSISTENT_DICTIONARY_FACTORY_H +#ifndef SCORE_DATAROUTER_SRC_PERSISTENCY_STUB_PERSISTENT_DICTIONARY_STUB_PERSISTENT_DICTIONARY_FACTORY_H +#define SCORE_DATAROUTER_SRC_PERSISTENCY_STUB_PERSISTENT_DICTIONARY_STUB_PERSISTENT_DICTIONARY_FACTORY_H #include "score/datarouter/src/persistency/persistent_dictionary_factory.hpp" #include @@ -34,4 +34,4 @@ class StubPersistentDictionaryFactory : public PersistentDictionaryFactory } // namespace platform } // namespace score -#endif // SCORE_PAS_LOGGING_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_FACTORY_H +#endif // SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_FACTORY_H diff --git a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h b/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h index e23be0e..c88fecf 100644 --- a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h +++ b/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_HANDLER_H -#define SCORE_PAS_LOGGING_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_HANDLER_H +#ifndef SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_HANDLER_H +#define SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_HANDLER_H #include "score/datarouter/src/persistent_logging/isysedr_handler.h" @@ -38,4 +38,4 @@ class StubSysedrHandler final : public ISysedrHandler } // namespace platform } // namespace score -#endif // SCORE_PAS_LOGGING_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_HANDLER_H +#endif // SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_PERSISTENT_LOGGING_STUB_STUB_SYSEDR_HANDLER_H diff --git a/score/datarouter/src/persistent_logging/sysedr_factory.hpp b/score/datarouter/src/persistent_logging/sysedr_factory.hpp index fad6fee..4036974 100644 --- a/score/datarouter/src/persistent_logging/sysedr_factory.hpp +++ b/score/datarouter/src/persistent_logging/sysedr_factory.hpp @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_SRC_PERSISTENT_LOGGING_SYSEDR_FACTORY_HPP -#define SCORE_PAS_LOGGING_SRC_PERSISTENT_LOGGING_SYSEDR_FACTORY_HPP +#ifndef SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_SYSEDR_FACTORY_HPP +#define SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_SYSEDR_FACTORY_HPP #include "score/datarouter/src/persistent_logging/isysedr_handler.h" #include @@ -54,4 +54,4 @@ class SysedrFactory } // namespace platform } // namespace score -#endif // SCORE_PAS_LOGGING_SRC_PERSISTENT_LOGGING_SYSEDR_FACTORY_HPP +#endif // SCORE_DATAROUTER_SRC_PERSISTENT_LOGGING_SYSEDR_FACTORY_HPP diff --git a/score/datarouter/test/ut/ut_logging/tracingTest.cpp b/score/datarouter/test/ut/ut_logging/tracingTest.cpp index c731a30..7a9629e 100644 --- a/score/datarouter/test/ut/ut_logging/tracingTest.cpp +++ b/score/datarouter/test/ut/ut_logging/tracingTest.cpp @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef AAS_PAS_LOGGING_TRACING_TEST_H -#define AAS_PAS_LOGGING_TRACING_TEST_H +#ifndef AAS_DATAROUTER_TRACING_TEST_H +#define AAS_DATAROUTER_TRACING_TEST_H #include "gtest/gtest.h" #include @@ -43,4 +43,4 @@ TEST_F(TracingTest, TracingLifeCycleStart) } // namespace logging } // namespace score -#endif // AAS_PAS_LOGGING_TRACING_TEST_H +#endif // AAS_DATAROUTER_TRACING_TEST_H diff --git a/score/datarouter/test/utils/data_router_test_utils.h b/score/datarouter/test/utils/data_router_test_utils.h index e4aa637..a491c8d 100644 --- a/score/datarouter/test/utils/data_router_test_utils.h +++ b/score/datarouter/test/utils/data_router_test_utils.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_PAS_LOGGING_TEST_UTILS_DATA_ROUTER_TEST_UTILS_H -#define SCORE_PAS_LOGGING_TEST_UTILS_DATA_ROUTER_TEST_UTILS_H +#ifndef SCORE_DATAROUTER_TEST_UTILS_DATA_ROUTER_TEST_UTILS_H +#define SCORE_DATAROUTER_TEST_UTILS_DATA_ROUTER_TEST_UTILS_H #include "score/datarouter/datarouter/data_router.h" @@ -56,4 +56,4 @@ TestTypeInfo CreateTypeInfo() } // namespace } // namespace test::utils -#endif // SCORE_PAS_LOGGING_TEST_UTILS_DATA_ROUTER_TEST_UTILS_H +#endif // SCORE_DATAROUTER_TEST_UTILS_DATA_ROUTER_TEST_UTILS_H diff --git a/score/mw/log/custom_recorder_example/BUILD b/score/mw/log/custom_recorder_example/BUILD index 2060072..f846650 100644 --- a/score/mw/log/custom_recorder_example/BUILD +++ b/score/mw/log/custom_recorder_example/BUILD @@ -1,15 +1,3 @@ -# ******************************************************************************* -# Copyright (c) 2026 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License Version 2.0 which is available at -# https://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -# ******************************************************************************* load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") # ******************************************************************************* From fde47361c6bbdfe118b428937a3a17a569c59ec3 Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Sun, 8 Feb 2026 13:36:59 +0100 Subject: [PATCH 02/12] Convert uxf diagrams under mw/log to plantuml part1 GIT_ORIGIN_SPP_REV_ID: 6fd59fac1193f07b682bf5dd008ac6e2c9d03203 --- score/mw/log/design/configuration_static.puml | 249 +++++++++++++++++ .../log/design/datarouter_backend/README.md | 3 +- ...ssage_client_impl_connecttodatarouter.puml | 35 +++ score/mw/log/design/error_domain.puml | 13 + .../design/mw_log_datarouter_recorder.puml | 60 ++++ score/mw/log/design/mw_log_file_backend.puml | 263 ++++++++++++++++++ score/mw/log/design/mw_log_recorders.puml | 172 ++++++++++++ .../design/mw_log_shared_memory_reader.puml | 81 ++++++ 8 files changed, 874 insertions(+), 2 deletions(-) create mode 100644 score/mw/log/design/configuration_static.puml create mode 100644 score/mw/log/design/datarouter_message_client_impl_connecttodatarouter.puml create mode 100644 score/mw/log/design/error_domain.puml create mode 100644 score/mw/log/design/mw_log_datarouter_recorder.puml create mode 100644 score/mw/log/design/mw_log_file_backend.puml create mode 100644 score/mw/log/design/mw_log_recorders.puml create mode 100644 score/mw/log/design/mw_log_shared_memory_reader.puml diff --git a/score/mw/log/design/configuration_static.puml b/score/mw/log/design/configuration_static.puml new file mode 100644 index 0000000..3bc1766 --- /dev/null +++ b/score/mw/log/design/configuration_static.puml @@ -0,0 +1,249 @@ +@startuml configuration_static + +interface "bmw:mw::log::Recorder" as Recorder { +} + +class "TextRecorder" as TextRecorder { +} + +class "DataRouterRecorder" as DataRouterRecorder { + - configuration: score::mw::log::Configuration +} + +class "FileRecorder" as FileRecorder { +} + +class "Empty" as Empty { +} + +class "CompositeRecorder" as CompositeRecorder { + - config_: score::mw::log::detail::Configuration +} + +class "RecorderComposite" as RecorderComposite { + + RecorderComposite(recorders: vector) + __ + - recorders_: vector +} + +class "score::mw::log::Configuration" as Configuration { + - ecu_id_: LoggingIdentifier + - app_id_: LoggingIdentifier + - app_description_: std::string + - log_mode_: std::unordered_set + - log_file_path_: std::string + - default_log_level_: LogLevel + - default_console_log_level_: LogLevel + - context_log_level_: ContextLogLevelMap + - stack_buffer_size_: std::size_t + - ring_buffer_size_: std::size_t + - ring_buffer_overwrite_on_full_: bool + - number_of_slots_: std::size_t + - slot_size_bytes_: std::size_t + - data_router_uid_: std::size_t + - dynamic_datarouter_identifiers_: bool + __ + + Configuration() + + GetEcuId(): std::string_view + + SetEcuId(const std::string_view): void + + GetAppId(): std::string_view + + SetAppId(const std::string_view): void + + GetAppDescription(): std::string_view + + SetAppDescription(const std::string_view): void + + GetLogMode(): const std::unordered_set& + + SetLogMode(const std::unordered_set&): void + + GetLogFilePath(): std::string_view + + SetLogFilePath(const std::string_view): void + + GetDefaultLogLevel(): LogLevel + + SetDefaultLogLevel(const LogLevel): void + + GetDefaultConsoleLogLevel(): LogLevel + + SetDefaultConsoleLogLevel(const LogLevel): void + + GetContextLogLevel(): ContextLogLevelMap& + + SetContextLogLevel(const ContextLogLevelMap&): void + + GetStackBufferSize(): std::size_t + + SetStackBufferSize(const std::size_t stack_buffer_size) + + GetRingBufferSize(): std::size_t + + SetRingBufferSize(const std::size_t ring_buffer_size): void + + GetRingBufferOverwriteOnFull(): bool + + SetRingBufferOverwriteOnFull(const bool): void + + GetNumberOfSlots(): std::size_t + + SetNumberOfSlots(const std::size_t number_of_slots): void + + GetSlotSizeInBytes(): std::size_t + + SetSlotSizeInBytes(const std::size_t slot_size_bytes): void + + SetDataRouterUid(const std::size_t uid): void + + GetDataRouterUid(): std::size_t + + GetDynamicDatarouterIdentifiers(): bool + + SetDynamicDatarouterIdentifiers(const bool enable_dynamic_identifier): void + + IsLogLevelEnabled(const LogLevel& log_level,\n const std::string_view context,\n const bool check_for_console = false): bool +} + +class "TargetConfigReader" as TargetConfigReader { + - discoverer_: unique_ptr + __ + + TargetConfigReader(discoverer: IConfigurationFileDiscoverer) + + ReadConfig(): score::Result +} + +interface "ITargetConfigReader" as ITargetConfigReader { + + {abstract} ReadConfig(): score::Result +} + +class "TargetConfigReaderMock" as TargetConfigReaderMock { +} + +class "RecorderFactory" as RecorderFactory { + - GetRemoteRecorder(const Configuration&):\n std::unique_ptr + - GetFileRecorder(const Configuration& config\n const std::unique_ptr&):\n std::unique_ptr + - GetConsoleRecorder(const Configuration&):\n std::unique_ptr + __ + + CreateFromConfiguration(): std::unique_ptr + + CreateFromConfiguration(\n const std::unique_ptr):\n std::unique_ptr + + CreateWithConsoleLoggingOnly(): std::unique_ptr + + CreateStub(): std::unique_ptr + + CreateRecorderFromLogMode(\n const LogMode&,\n const Configuration&,\n const std::unique_ptr) +} + +interface "IRecorderFactory" as IRecorderFactory { + + CreateFromConfiguration: std::unique_ptr + + CreateWithConsoleLoggingOnly(): std::unique_ptr + + CreateStub(): std::unique_ptr +} + +class "score::mw::log::detail::Runtime" as Runtime { +} + +interface "IConfigurationFileDiscoverer" as IConfigurationFileDiscoverer { + + {abstract} FindConfigurationFiles(): vector +} + +class "ConfigurationFileDiscoverer" as ConfigurationFileDiscoverer { + - path_: std::unique_ptr + - stdlib_: std::unique_ptr + - unistd_: std::unique_ptr + __ + + ConfigurationFileDiscoverer(\n std::unique_ptr&&,\n std::unique_ptr&&,\n std::unique_ptr&&) + + FindConfigurationFiles(): std::vector +} + +class "ConfigurationFileDiscovererMock" as ConfigurationFileDiscovererMock { +} + +class "LoggingIdentifier" as LoggingIdentifier { + + LoggingIdentifier(const std::string_view) + + GetStringView(): std::string_view + + friend operator==(const LoggingIdentifier&, const LoggingIdentifier&): bool + + friend operator!=(const LoggingIdentifier&, const LoggingIdentifier&): bool + + kMaxLength: std::size_t + + data_: std::array +} + +package "score::json" { + class JsonUtils { + + FromFile(path): Result + } +} + +package "score::os" { + class "utils/path" as Path { + + {static} get_exec_path(): Result + + {static} get_parent_dir(): string + } + + class "Unistd" as Unistd { + + access() + } + + class "Stdlib" as Stdlib { + + getenv() + } +} + +' Inheritance relationships +Recorder <|-- DataRouterRecorder +Recorder <|-- TextRecorder +Recorder <|-- FileRecorder +Recorder <|-- Empty +Recorder <|-- CompositeRecorder +Recorder <|.. RecorderComposite + +ITargetConfigReader <|.. TargetConfigReader +ITargetConfigReader <|.. TargetConfigReaderMock + +IConfigurationFileDiscoverer <|-- ConfigurationFileDiscoverer +IConfigurationFileDiscoverer <|-- ConfigurationFileDiscovererMock + +' Composition and aggregation relationships +DataRouterRecorder *-- Configuration +CompositeRecorder *-- Configuration +RecorderComposite *-- DataRouterRecorder +RecorderComposite *-- TextRecorder +Configuration *-- LoggingIdentifier + +' Usage relationships +RecorderFactory ..> RecorderComposite : creates +RecorderFactory ..> TargetConfigReader : uses +RecorderFactory ..> IRecorderFactory : uses +Runtime ..> Recorder : owns instance of +TargetConfigReader ..> Configuration : creates +TargetConfigReader *-- IConfigurationFileDiscoverer +TargetConfigReader ..> JsonUtils : uses +ConfigurationFileDiscoverer ..> Path : uses +ConfigurationFileDiscoverer ..> Unistd : uses +ConfigurationFileDiscoverer ..> Stdlib : uses + +note right of RecorderComposite + Forwards the logs to all recorders in the list + passed in the constructor. +end note + +note right of RecorderFactory + CreateForTarget(): Loads the configuration + and instantiates the requested + recorder types. + + CreateForUnitTests(): Prepares a recorder + that puts logs in standard output stream + for unit testing. + + CreateStub(): Returns Empty recorder that + discards all the logs. +end note + +note right of TargetConfigReader + Reads config from + /opt//etc/logging.json + and /ecu/logging.json and creates the + Configuration object. +end note + +note bottom of TargetConfigReaderMock + Used for unit testing the RecorderFactory. +end note + +note top of TargetConfigReader + Dependency injection for unit testing. +end note + +note right of DataRouterRecorder + Configuration passed + the constructor by value. +end note + +note right of ConfigurationFileDiscoverer + Finds the file paths to the global, environmental and + application configuration files and returns all that exists. + + Global configuration: + 1. /etc/ecu_logging_config.json if it exists. + + Environmental configuration: + 1. path under the MW_LOG_CONFIG_FILE environmental + variable if it defined + + Application configuration: + 1. /etc/logging.json + 2. /logging.json + 3. /../etc/logging.json +end note + +@enduml diff --git a/score/mw/log/design/datarouter_backend/README.md b/score/mw/log/design/datarouter_backend/README.md index a8c4e23..7534adf 100644 --- a/score/mw/log/design/datarouter_backend/README.md +++ b/score/mw/log/design/datarouter_backend/README.md @@ -201,7 +201,7 @@ readable without synchronization. Only after reading the remaining data from the ring buffer, should Datarouter unmap the shared memory page. Then the OS should free up the used resources. -![SharedMemoryReader Class diagram](https://www.plantuml.com/plantuml/proxy?src=https://raw.githubusercontent.com/swh/ddad_score/mw/log/design/mw_log_shared_memory_reader.uxf?ref=a294e8aeb6453344591cfb1780d719f4a5ea1daa) +![SharedMemoryReader Class diagram](https://www.plantuml.com/plantuml/proxy?src=https://raw.githubusercontent.com/swh/ddad_score/mw/log/design/mw_log_shared_memory_reader.puml) ## Limited impact of incoming messages in the logging client @@ -308,4 +308,3 @@ Message ID: `kAcquireResponse` Message type: `MediumMessage` Payload: `struct ReadAcquireResult` - diff --git a/score/mw/log/design/datarouter_message_client_impl_connecttodatarouter.puml b/score/mw/log/design/datarouter_message_client_impl_connecttodatarouter.puml new file mode 100644 index 0000000..9bc688b --- /dev/null +++ b/score/mw/log/design/datarouter_message_client_impl_connecttodatarouter.puml @@ -0,0 +1,35 @@ +@startuml +!theme plain +title DatarouterMessageClientImpl::ConnectToDatarouter + +partition "DatarouterMessageClientImpl::ConnectToDatarouter" { + start + + :Block termination Signal; + note right + **Note:** + The logger thread (owned by adaptive application) + should not react to the Terminate Signal. Instead + the Terminate Signal should be handled by + mw::lifecycle for Adaptive applications. + end note + + :Create sender; + + :Start receiver; + + if (Receiver started?) then (Yes) + if (Is exit requsted?) then (No) + :Send connect message; + else (Yes) + endif + else (No) + :Unlink shared memory file; + :Request stop for connection; + :Shutdown thread pool; + endif + + stop +} + +@enduml diff --git a/score/mw/log/design/error_domain.puml b/score/mw/log/design/error_domain.puml new file mode 100644 index 0000000..3f3509c --- /dev/null +++ b/score/mw/log/design/error_domain.puml @@ -0,0 +1,13 @@ +@startuml error_domain + +interface "score::result::ErrorDomain" as ErrorDomainInterface { + {abstract} +MessageFor(const score::result::ErrorCode&): std::string_view +} + +class "score::mw::log::detail::ErrorDomain" as ErrorDomain { + +MessageFor(const score::result::ErrorCode&): std::string_view +} + +ErrorDomainInterface <|.. ErrorDomain + +@enduml diff --git a/score/mw/log/design/mw_log_datarouter_recorder.puml b/score/mw/log/design/mw_log_datarouter_recorder.puml new file mode 100644 index 0000000..0a0e2b9 --- /dev/null +++ b/score/mw/log/design/mw_log_datarouter_recorder.puml @@ -0,0 +1,60 @@ +@startuml mw_log_datarouter_recorder + +class "DataRouterRecorder" as DataRouterRecorder { + - backend_: std::unique_ptr + - config_: Configuration + - statistics_reporter_: StatisticsReporter + __ + + DataRouterRecorder(std::unique_ptr&&, const Configuration&) + + StartRecord(const std::string_view, const LogLevel): score::cpp::optional + + StopRecord(const SlotHandle&): void + + Log(const SlotHandle&, const T) - family of functions + + IsLogEnabled(const LogLevel&, const std::string_view) : bool + __ + - LogData(const SlotHandle&, const T data): void + - SetApplicationId(LogRecord&): void +} + +class "StatisticsReporter" as StatisticsReporter { + - recorder_: Recorder& + - report_interval_: std::chrono::seconds + - number_of_slots_: std::size_t + - slot_size_bytes_: std::size_t + - no_slot_available_counter_: std::atomic + - message_too_long_counter_: std::atomic + - last_report_time_point_nanoseconds_: std::atomic + - currently_reporting_: std::atomic_bool + __ + + StatisticsReporter(Recorder&, const std::chrono::seconds,\n const std::size_t, const std::size_t) + + IncrementNoSlotAvailable(): void + + IncrementMessageTooLong(): void + + Update(const std::chrono::steady_clock::time_point&): void +} + +interface "IStatisticsReporter" as IStatisticsReporter { + + IncrementNoSlotAvailable(): void + + IncrementMessageTooLong(): void + + Update(const std::chrono::steady_clock::time_point&): void +} + +class "Configuration" as Configuration { +} + +class "DataRouterBackend" as DataRouterBackend { +} + +class "Recorder" as Recorder { +} + +class "mw::log::Runtime" as Runtime <> { +} + +' Relationships +Runtime --> DataRouterRecorder : is owned by +DataRouterRecorder *-- StatisticsReporter +DataRouterRecorder *-- Configuration +DataRouterRecorder *-- DataRouterBackend +StatisticsReporter ..|> IStatisticsReporter +StatisticsReporter --> Recorder : uses + +@enduml diff --git a/score/mw/log/design/mw_log_file_backend.puml b/score/mw/log/design/mw_log_file_backend.puml new file mode 100644 index 0000000..6e0e85d --- /dev/null +++ b/score/mw/log/design/mw_log_file_backend.puml @@ -0,0 +1,263 @@ +@startuml mw_log_file_backend + +' Classes +class "mw::log::Recorder" as Recorder { + + StartRecord(ctx:std::string_view, ll:LogLevel): score::cpp::optional + + StopRecord(slot:SlotHandle&) + + Log( T data ) - family of functions + __ + - backend:unique_ptr + __ + Responsibilities: + -- Opens and closes file. + Uses formatters to serialize + user data and header. +} + +interface "mw::log::detail::Backend" as Backend { + + ReserveSlot(): score::cpp::optional + + FlushSlot(const SlotHandle&) + + GetLogRecord(const SlotHandle&): LogRecord& +} + +class "mw::log::detail::FileOutputBackend" as FileOutputBackend { + - buffer_allocator_: std::unique_ptr> + - slot_drainer_:SlotDrainer + __ + + FileOutputBackend(std::unique_ptr,\n const std::int32_t,\n std::unique_ptr>,\n std::unique_ptr) + + ReserveSlot():score::cpp::optional + + FlushSlot(const SlotHandle&):void + + GetLogRecord(const SlotHandle&): LogRecord& + __ + Responsibilities + -- keeps statistics of dropped messages +} + +class "mw::log::detail::SlotDrainer" as SlotDrainer { + - allocator_: std::unique_ptr>& + - message_builder_:std::unique_ptr + - context_mutex_:std::mutex + - circular_buffer_:score::cpp::circular_buffer + - current_slot_:score::cpp::optional> + - non_blocking_writer_: NonBlockingWriter + - limit_slots_in_one_cycle_: const std::size_t + __ + + SlotDrainer(std::unique_ptr,\n std::unique_ptr>&,\n const std::int32_t,\n const std::size_t,\n std::unique_ptr) + + PushBack(const SlotHandle&):void + + Flush():void + __ + - TryFlushSlots(): score::cpp::expected + - TryFlushSpans(): score::cpp::expected + - MoreSlotsAvailableAndLoaded():bool + - MoreSpansAvailableAndLoaded():bool + __ + Responsibilities + -- Drains slots - empties circular_buffer + when subsequent data has been flushed + -- Returns status if data was flushed or stalled +} + +class "mw::log::detail::NonBlockingWriter" as NonBlockingWriter { + - unistd_: std::unique_ptr + - file_handle_: std::int32_t + - number_of_flushed_bytes_: uint64_t + - buffer_: score::cpp::span + - buffer_flushed_: Result + - max_chunk_size_: std::size_t + __ + + NonBlockingWriter(const std::int32_t, std::size_t, std::unique_ptr) + + FlushIntoFile(): score::cpp::expected + + SetSpan(const score::cpp::span&): void + + GetMaxChunkSize(): std::size_t + __ + - InternalFlush(const uint64_t): score::cpp::expected + __ + Responsibilities + -- Write logs into file +} + +interface "mw::log::detail::IMessageBuilder" as IMessageBuilder { + + GetNextSpan() : score::cpp::optional> + + SetNextMessage(LogRecord&): void + __ + Responsibility: + iterates over spans of data to be + serialized into output stream. +} + +class "mw::log::detail::DltMessageBuilder" as DltMessageBuilder { + + DltMessageBuilder(ecu_id) + + GetNextSpan() : score::cpp::optional> + + SetNextMessage(LogRecord&): void +} + +class "mw::log::detail::TextMessageBuilder" as TextMessageBuilder { + + TextMessageBuilder(app_id, ecu_id, ) + + GetNextSpan() : score::cpp::optional> + + SetNextMessage(log_record:LogRecord&): void +} + +class "mw::log::detail::CircularAllocator" as CircularAllocator { + - claimed_sequence_:std::atomic + - buffer_:std::vector> + __ + + CircularAllocator(std::size_t, const T&) + + AcquireSlotToWrite(): score::cpp::optional + + GetUnderlyingBufferFor(std::size_t): T& + + ReleaseSlot(std::size_t):void + + GetUsedCount():size_t +} + +class "score::cpp::circular_buffer" as CircularBuffer { + Responsibilities + -- stores elements of static size + -- overwrites data when full + -- realizes FIFO pattern +} + +class "mw::log::detail::Slot" as Slot { + + data: T + + in_use: std::atomic +} + +class "mw::log::detail::LogRecord" as LogRecord #Orange { + - logEntry_:LogEntry + - verbosePayload_:VerbosePayload + __ + LogRecord(const std::size_t) + getLogEntry(): LogEntry& + getLogEntry(): const LogEntry& + getVerbosePayload(): VerbosePayload& + getVerbosePayload(): const VerbosePayload& +} + +class "VerbosePayload" as VerbosePayload { +} + +class "LoggingIdentifier" as LoggingIdentifier { +} + +class "mw::log::detail::BackendLogMock" as BackendLogMock #Pink { + + ReserveSlot(): score::cpp::optional + + FlushSlot(const SlotHandle&) + + GetLogRecord(const SlotHandle&): LogRecord& +} + +class "OSAL::Unistd" as OsalUnistd1 { +} + +class "OSAL::Unistd" as OsalUnistd2 { +} + +class "OSAL::fcntl" as Fcntl { +} + +' Relationships +Recorder *-- Backend +Backend <|.. FileOutputBackend +Backend <|.. BackendLogMock + +FileOutputBackend *-- SlotDrainer +FileOutputBackend *-- CircularAllocator + +SlotDrainer *-- NonBlockingWriter +SlotDrainer *-- CircularBuffer +SlotDrainer *-- CircularAllocator +SlotDrainer *-- IMessageBuilder + +NonBlockingWriter *-- OsalUnistd1 +NonBlockingWriter ..> OsalUnistd1 : write + +IMessageBuilder <|-- DltMessageBuilder +IMessageBuilder <|-- TextMessageBuilder + +CircularAllocator "0..n" *-- Slot +CircularAllocator ..> CircularAllocator : GetUnderlyingBufferFor()\nReleaseSlot() + +FileOutputBackend ..> CircularAllocator : AcquireSlotToWrite()\nGetUnderlyingBufferFor() +SlotDrainer ..> CircularAllocator : GetUnderlyingBufferFor()\nReleaseSlot() + +CircularBuffer ..> CircularAllocator : Created based on CircularAllocatorSize + +DltMessageBuilder *-- LoggingIdentifier +DltMessageBuilder *-- VerbosePayload +TextMessageBuilder *-- LoggingIdentifier +TextMessageBuilder *-- VerbosePayload + +Recorder ..> Fcntl : open\nSetNonBlocking / fctrl call +Recorder ..> OsalUnistd2 : close + +' Notes +note right of NonBlockingWriter + Test strategy: + Inject OSAL mock + by constructor argument + with default value +end note + +note right of FileOutputBackend + Test strategy: + Inject NonBlocking Writer + and using OSAL mock + Configure circular buffer size + Use MessageBuilderMock +end note + +note right of IMessageBuilder + Test strategy: + Insert the data, verify outcome +end note + +note top of CircularBuffer + Test strategy: + using score::cpp::circular_buffer + not tested here +end note + +note bottom of CircularBuffer + By design we exclude possibility of dropped + messages in CircularBuffer because the + size of SlotAllocator is smaller or less + than CircularBuffer size. + + Size of score::cpp::CircularBuffer +end note + +note right of LogRecord + Test strategy: + Tested in data_router +end note + +note bottom of FileOutputBackend + Test strategy: + Test just a glue code and + not underlying classes + Inject SlotDrainer with + mocked OSAL + Use MessageBuilderMock + + Only place that messages + may be dropped for the + reason of failure to get buffer + from SlotAllocator +end note + +note bottom of BackendLogMock + Mock +end note + +note bottom of LogRecord + Note.. + + Used for data types + that differ from message to message +end note + +note as SyncNote + Synchronised access only: guarded by SlotDrainer context mutex. +end note + +SyncNote .. IMessageBuilder +SyncNote .. NonBlockingWriter + +@enduml diff --git a/score/mw/log/design/mw_log_recorders.puml b/score/mw/log/design/mw_log_recorders.puml new file mode 100644 index 0000000..995deff --- /dev/null +++ b/score/mw/log/design/mw_log_recorders.puml @@ -0,0 +1,172 @@ +@startuml mw_log_recorders + +' Interface +interface "mw::log::Recorder" as Recorder { + + StartRecord(ctx:std::string_view, log_level:LogLevel) : score::cpp::optional + + StopRecord(slot:SlotHandle&): void + + Log(const SlotHandle&, const T data) - family of functions + + IsLogEnabled(const LogLevel&, const std::string_view): bool +} + +' Interface +interface "mw::log::detail::Backend" as Backend { + +ReserveSlot() : score::cpp::optional + +FlushSlot(slot : const SlotHandle&) + +GetLogRecord(slot : const SlotHandle&): LogRecord& +} + +' Recorder implementations +class "mw::log::detail::FileRecorder" as FileRecorder { + - backend_ : std::unique_ptr + - config_ : Configuration + __ + + FileRecorder(const detail::Configuration&,\n std::unique_ptr) + + StartRecord(ctx:std::string_view, const LogLevel): score::cpp::optional + + StopRecord(const SlotHandle&): void + + IsLogEnabled(const LogLevel&, const std::string_view): bool + + Log(const SlotHandle&, T data) - family of functions +} + +class "mw::log::detail::TextRecorder" as TextRecorder { + - backend_ : std::unique_ptr + - config_ : Configuration + - check_log_level_for_console_: bool + __ + + TextRecorder(const detail::Configuration&,\n std::unique_ptr,\n const bool) + + StartRecord(ctx:std::string_view, const LogLevel): score::cpp::optional + + StopRecord(const SlotHandle&): void + + IsLogEnabled(const LogLevel&, const std::string_view): bool + + Log(const SlotHandle&, T data) - family of functions +} + +class "mw::log::detail::DataRouterRecorder" as DataRouterRecorder { +} + +class "mw::log::detail::CompositeRecorder" as CompositeRecorder { + - recorders_ : std::vector> + __ + + CompositeRecorder(std::vector> recorders) + + StartRecord(const std::string_view, const LogLevel): score::cpp::optional + + StopRecord(slot:SlotHandle&): void + + GetRecorders(): std::vector>& + + IsLogEnabled(const LogLevel&, const std::string_view): bool + + Log(const SlotHandle&, const T) - family of functions +} + +class "mw::log::detail::EmptyRecorder" as EmptyRecorder { + + StartRecord(const std::string_view, const LogLevel):\n score::cpp::optional + + StopRecord(const SlotHandle&): void + + IsLogEnabled(const LogLevel&, const std::string_view): bool + + Log(const SlotHandle&, T data) - family of functions +} + +class "mw::log::detail::RecorderMock" as RecorderMock #pink { +} + +' Backend implementations +class "mw::log::detail::FileOutputBackend" as FileOutputBackend { +} + +class "mw::log::detail::SlogBackend" as SlogBackend { + - app_id_: std::string + - buffer_: CircularAllocator + - slog_buffer_: slog2_buffer_t + - slog_buffer_config_: slog2_buffer_set_config_t + - slog2_instance_: std::unique_ptr + __ + + SlogBackend(const std::size_t,\n const LogRecord&,\n const std::string_view,\n std::unique_ptr) + + ReserveSlot(): score::cpp::optional + + FlushSlot(const SlotHandle&): void + + GetLogRecord(const SlotHandle&): LogRecord& + __ + - Init(verbosity: std::uint8_t) : void +} + +class "mw::log::detail::DataRouterBackend" as DataRouterBackend { +} + +class "mw::log::detail::BackendMock" as BackendMock #pink { +} + +' Helper classes +class "DltArgumentCounter" as DltArgumentCounter { + - counter_ : std::uint8_t& + __ + DltArgumentCounter(std::uint8_t&) + __ + + TryAddArgument(add_argument_callback) : AddArgumentResult +} + +class "mw::log::detail::TextFormat" as TextFormat { + {static} + PutFormattedTime(VerbosePayload&) : void + {static} + TerminateLog(VerbosePayload&) : void + {static} + Log(VerbosePayload&, const T, const IntegerRepresentation) : void\n - family of functions + {static} + Log(VerbosePayload&, const T) : void\n - family of functions +} + +class "mw::log::detail::DLTFormat" as DLTFormat { + + Log(VerbosePayload&, const bool): AddArgumentResult + + Log(VerbosePayload&, T, const IntegerRepresentation):\n AddArgumentResult - family of functions +} + +class "mw::log::detail::CircularAllocator" as CircularAllocator { +} + +class "mw::log::detail::LogRecord" as LogRecord { +} + +' External dependencies +class "OSAL::fcntl" as fcntl { +} + +class "OSAL::Unistd" as Unistd { +} + +' Relationships - Recorder interface +FileRecorder .up.|> Recorder +TextRecorder .up.|> Recorder +DataRouterRecorder .up.|> Recorder +CompositeRecorder .up.|> Recorder +EmptyRecorder .up.|> Recorder +RecorderMock .up.|> Recorder + +' Relationships - Backend interface +FileOutputBackend .up.|> Backend +SlogBackend .up.|> Backend +DataRouterBackend .up.|> Backend +BackendMock .up.|> Backend + +' Composition relationships +FileRecorder *-- Backend +FileRecorder *-- DltArgumentCounter +TextRecorder *-- Backend +TextRecorder *-- DltArgumentCounter +DataRouterRecorder *-- Backend + +' Dependencies +FileRecorder ..> TextFormat : Log +FileRecorder ..> DLTFormat : uses +TextRecorder ..> TextFormat : Log +DataRouterRecorder ..> DLTFormat : uses +TextRecorder ..> DLTFormat : uses + +' Backend composition +SlogBackend *-- CircularAllocator +SlogBackend --> LogRecord : uses + +' External dependencies +FileRecorder ..> fcntl : open\nSetNonBlocking / fctrl call +FileRecorder ..> Unistd : close + +' Notes +note bottom of Recorder + Refer Recorder.h for all the Log(const SlotHandle&, const T data) + - family of functions +end note + +note top of TextFormat + Refer text_format.h for all the Log(...) + - family of functions +end note + +@enduml diff --git a/score/mw/log/design/mw_log_shared_memory_reader.puml b/score/mw/log/design/mw_log_shared_memory_reader.puml new file mode 100644 index 0000000..0ee176e --- /dev/null +++ b/score/mw/log/design/mw_log_shared_memory_reader.puml @@ -0,0 +1,81 @@ +@startuml mw_log_shared_memory_reader + +package "mw::log" { + interface "ReaderFactory" as ReaderFactory { + + Create(const std::int32_t, const pid_t): score::cpp::optional + + Default(): std::unique_ptr + } + + class "ReaderFactoryImpl" as ReaderFactoryImpl { + - mman_: score::cpp::pmr::unique_ptr + - stat_: score::cpp::pmr::unique_ptr + __ + + Create(const std::int32_t, const pid_t): score::cpp::optional + } + + class "SharedMemoryReader" as SharedMemoryReader { + - shared_data_: SharedData& + - unmap_callback_: UnmapCallback + - linear_reader_: std::optional + - acquired_data_: std::optional + - number_of_acquired_bytes_: Length + - finished_reading_after_detach_: bool + - buffer_expected_to_read_next_: std::uint32_t + - is_writer_detached_: bool + - alternating_read_only_reader_: AlternatingReadOnlyReader + - DetachWriter(): void + - IsWriterDetached(): bool + __ + + SharedMemoryReader(const SharedData&, const score::cpp::span,\n const score::cpp::span, UnmapCallback) + + Read(const TypeRegistrationCallback&, const NewRecordCallback&): std::optional + + PeekNumberOfBytesAcquiredInBuffer(const std::uint32_t): std::optional + + ReadDetached(const TypeRegistrationCallback&, const NewRecordCallback&): std::optional + + GetNumberOfDropsWithBufferFull(): Length + + GetSizeOfDropsWithBufferFull(): Length + + GetNumberOfDropsWithInvalidSize(): Length + + GetRingBufferSizeBytes(): Length + + GetNumberOfAcquiredBytes(): Length + + IsBlockReleasedByWriters(): bool + + NotifyAcquisitionSetReader(const ReadAcquireResult&): std::optional + } + + class "SharedData" as SharedData <> { + } + + class "LinearReader" as LinearReader { + - data_: score::cpp::span + - read_index_: Length + __ + + LinearReader(const score::cpp::span&) + + Read(): score::cpp::optional> + } + + class "score::os::Mman" as Mman { + } + + class "score::os::Stat" as Stat { + } + + ' Relationships + ReaderFactory <|.. ReaderFactoryImpl + ReaderFactoryImpl ..> SharedMemoryReader : <> + ReaderFactoryImpl ..> Mman : <> + ReaderFactoryImpl ..> Stat : <> + SharedMemoryReader ..> SharedData : <> + SharedMemoryReader ..> LinearReader : <> +} + +package "score::platform::datarouter" { + class "DataRouter" as DataRouter { + - subscriberDatabase_: SubscriberDatabase + - databaseCallback_ : WriteSubscriberDatabaseCallback + __ + + new_source_session(): SessionPtr + + new_subscriber_session(): SessionPtr + } + + ' Relationship + DataRouter ..> ReaderFactory : <> +} + +@enduml From b9c8402b8976b4484d3f39b682bfca8bb485e211 Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Tue, 3 Feb 2026 12:01:33 +0100 Subject: [PATCH 03/12] Enable extra clang_tidy checks for all datarouter files GIT_ORIGIN_SPP_REV_ID: b04d180da1a9375664c128050fc70943b93aba3e --- score/datarouter/BUILD | 12 + .../session_handle_interface.h | 6 +- .../session_handle_mock.h | 6 +- score/datarouter/datarouter/data_router.cpp | 128 +++---- score/datarouter/datarouter/data_router.h | 68 ++-- .../filetransfer_message.h | 4 +- .../filetransfer_message_trace.h | 2 +- score/datarouter/include/Tracing | 6 +- .../include/daemon/configurator_commands.h | 34 +- .../include/daemon/data_router_cfg.h | 10 +- .../include/daemon/diagnostic_job_handler.h | 60 ++-- .../include/daemon/diagnostic_job_parser.h | 8 +- .../include/daemon/dlt_log_channel.h | 112 +++--- .../include/daemon/dlt_log_server.h | 220 ++++++------ .../include/daemon/dlt_log_server_config.h | 48 +-- .../include/daemon/dltserver_common.h | 12 +- .../include/daemon/i_diagnostic_job_handler.h | 2 +- .../include/daemon/i_diagnostic_job_parser.h | 2 +- .../include/daemon/i_dlt_log_server.h | 42 +-- .../datarouter/include/daemon/i_log_sender.h | 10 +- .../log_entry_deserialization_visitor.h | 19 +- score/datarouter/include/daemon/log_sender.h | 16 +- .../include/daemon/message_passing_server.h | 74 ++-- .../include/daemon/persistentlogging_config.h | 26 +- .../datarouter/include/daemon/socketserver.h | 6 +- .../include/daemon/socketserver_config.h | 16 +- .../daemon/socketserver_filter_factory.h | 8 +- .../daemon/socketserver_json_helpers.h | 14 +- .../include/daemon/udp_stream_output.h | 18 +- score/datarouter/include/daemon/utility.h | 2 +- score/datarouter/include/daemon/verbose_dlt.h | 10 +- score/datarouter/include/dlt/dlt_common.h | 6 +- score/datarouter/include/dlt/dlt_headers.h | 44 +-- score/datarouter/include/dlt/dlt_protocol.h | 74 ++-- score/datarouter/include/dlt/dlt_types.h | 114 +++--- score/datarouter/include/dlt/dltid.h | 24 +- .../datarouter/include/dlt/dltid_converter.h | 8 +- score/datarouter/include/dlt/logentry_trace.h | 12 +- score/datarouter/include/dlt/plogfilterdesc.h | 14 +- .../include/logparser/i_logparser.h | 44 +-- .../datarouter/include/logparser/logparser.h | 48 +-- .../include/router/data_router_types.h | 12 +- .../include/unix_domain/unix_domain_client.h | 44 +-- .../include/unix_domain/unix_domain_common.h | 30 +- .../include/unix_domain/unix_domain_server.h | 66 ++-- .../mocks/daemon/diagnostic_job_parser_mock.h | 8 +- .../mocks/daemon/dlt_log_server_mock.h | 33 +- .../datarouter/mocks/daemon/log_sender_mock.h | 10 +- .../mocks/daemon/udp_stream_output.h | 38 +- score/datarouter/mocks/logparser_mock.h | 26 +- .../mocks/unix_domain/unix_domain_server.h | 16 +- .../src/applications/datarouter_app.cpp | 22 +- .../src/applications/datarouter_app.h | 12 +- .../src/applications/main_nonadaptive.cpp | 16 +- score/datarouter/src/applications/options.cpp | 22 +- score/datarouter/src/applications/options.h | 18 +- .../configuration/dynamic_config/i_session.h | 12 +- .../src/daemon/diagnostic_job_handler.cpp | 26 +- .../src/daemon/diagnostic_job_parser.cpp | 66 ++-- .../datarouter/src/daemon/dlt_log_channel.cpp | 55 ++- .../datarouter/src/daemon/dlt_log_server.cpp | 335 +++++++++--------- .../src/daemon/message_passing_server.cpp | 114 +++--- .../src/daemon/persistentlogging_config.cpp | 48 +-- score/datarouter/src/daemon/socketserver.cpp | 71 ++-- .../src/daemon/socketserver_config.cpp | 175 ++++----- .../daemon/socketserver_filter_factory.cpp | 40 +-- .../src/daemon/udp_stream_output.cpp | 54 +-- score/datarouter/src/daemon/utility.cpp | 16 +- score/datarouter/src/daemon/verbose_dlt.cpp | 12 +- score/datarouter/src/dlt/dltid_converter.cpp | 4 +- .../nonverbose_dlt_impl/nonverbose_dlt.cpp | 6 +- .../dlt/nonverbose_dlt_impl/nonverbose_dlt.h | 2 +- .../nonverbose_dlt_stub/stub_nonverbose_dlt.h | 2 +- .../file_transfer_handler_factory.hpp | 4 +- .../file_transfer_handler_factory_stub.h | 4 +- .../file_transfer_stream_handler_stub.h | 6 +- score/datarouter/src/logparser/logparser.cpp | 143 ++++---- .../persistency/mock_persistent_dictionary.h | 4 +- .../src/persistent_logging/isysedr_handler.h | 9 +- .../stub_sysedr_handler.cpp | 4 +- .../stub_sysedr_handler.h | 4 +- .../src/unix_domain/unix_domain_client.cpp | 32 +- .../src/unix_domain/unix_domain_common.cpp | 64 ++-- .../src/unix_domain/unix_domain_server.cpp | 111 +++--- .../test_config_session_factory.cpp | 14 +- .../ut/ut_logging/test_datarouter_app.cpp | 18 +- .../test_diagnostic_job_handler.cpp | 44 +-- .../ut_logging/test_diagnostic_job_parser.cpp | 108 +++--- .../test/ut/ut_logging/test_dltchannel.cpp | 220 ++++++------ .../test/ut/ut_logging/test_dltprotocol.cpp | 48 +-- .../test/ut/ut_logging/test_dltserver.cpp | 312 ++++++++-------- .../test_file_transfer_handler_factory.cpp | 2 +- .../ut_logging/test_filetransfer_stream.cpp | 20 +- .../test/ut/ut_logging/test_logparser.cpp | 136 +++---- .../test_message_passing_server.cpp | 56 +-- .../test/ut/ut_logging/test_nonverbosedlt.cpp | 30 +- .../test/ut/ut_logging/test_options.cpp | 90 ++--- .../ut_logging/test_persistentlog_config.cpp | 56 +-- .../ut_logging/test_socketserver_config.cpp | 98 ++--- .../ut/ut_logging/test_udp_stream_output.cpp | 14 +- .../ut/ut_logging/test_unix_domain_server.cpp | 168 ++++----- .../test/ut/ut_logging/test_verbose_dlt.cpp | 10 +- .../test/utils/data_router_test_utils.h | 2 +- 103 files changed, 2322 insertions(+), 2309 deletions(-) diff --git a/score/datarouter/BUILD b/score/datarouter/BUILD index 2445357..94c7ad9 100644 --- a/score/datarouter/BUILD +++ b/score/datarouter/BUILD @@ -13,6 +13,18 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") load("@score_baselibs//score/language/safecpp:toolchain_features.bzl", "COMPILER_WARNING_FEATURES") +load("@score_baselibs//score/quality/clang_tidy:extra_checks.bzl", "clang_tidy_extra_checks") + +clang_tidy_extra_checks( + name = "clang_tidy_extra_checks", + extra_features = [ + "spp_code_style_check_header_guards", + "spp_code_style_check_method_names", + "spp_code_style_check_readability", + "spp_code_style_check_type_names", + "spp_code_style_check_variable_names", + ], +) ## =========================================================================== ## dltprotocol diff --git a/score/datarouter/daemon_communication/session_handle_interface.h b/score/datarouter/daemon_communication/session_handle_interface.h index abe8f38..d26fe3d 100644 --- a/score/datarouter/daemon_communication/session_handle_interface.h +++ b/score/datarouter/daemon_communication/session_handle_interface.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_INTERFACE_H_ -#define SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_INTERFACE_H_ +#ifndef SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESSION_HANDLE_INTERFACE_H +#define SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESSION_HANDLE_INTERFACE_H namespace score { @@ -35,4 +35,4 @@ class ISessionHandle } // namespace platform } // namespace score -#endif // SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_INTERFACE_H_ +#endif // SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESSION_HANDLE_INTERFACE_H diff --git a/score/datarouter/daemon_communication/session_handle_mock.h b/score/datarouter/daemon_communication/session_handle_mock.h index 0303892..a3e6583 100644 --- a/score/datarouter/daemon_communication/session_handle_mock.h +++ b/score/datarouter/daemon_communication/session_handle_mock.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_MOCK_H_ -#define SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_MOCK_H_ +#ifndef SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_MOCK_H +#define SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_MOCK_H #include "score/datarouter/daemon_communication/session_handle_interface.h" @@ -29,4 +29,4 @@ class SessionHandleMock : public score::platform::internal::daemon::ISessionHand } // namespace score::platform::internal::daemon::mock -#endif // SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_MOCK_H_ +#endif // SCORE_DATAROUTER_DAEMON_COMMUNICATION_SESION_HANDLE_MOCK_H diff --git a/score/datarouter/datarouter/data_router.cpp b/score/datarouter/datarouter/data_router.cpp index de8ec25..4145ffd 100644 --- a/score/datarouter/datarouter/data_router.cpp +++ b/score/datarouter/datarouter/data_router.cpp @@ -74,12 +74,12 @@ std::string QuotaValueAsString(double quota) noexcept return ss.str(); } -DataRouter::DataRouter(score::mw::log::Logger& logger, SourceSetupCallback sourceCallback) - : stats_logger_(logger), sourceCallback_(sourceCallback) +DataRouter::DataRouter(score::mw::log::Logger& logger, SourceSetupCallback source_callback) + : stats_logger_(logger), source_callback_(source_callback) { } -DataRouter::MessagingSessionPtr DataRouter::new_source_session( +DataRouter::MessagingSessionPtr DataRouter::NewSourceSession( int fd, const std::string name, const bool is_dlt_enabled, @@ -87,7 +87,7 @@ DataRouter::MessagingSessionPtr DataRouter::new_source_session( const double quota, bool quota_enforcement_enabled, const pid_t client_pid, - const score::mw::log::NvConfig& nvConfig, + const score::mw::log::NvConfig& nv_config, score::mw::log::detail::ReaderFactoryPtr reader_factory) { // It shall be safe to create shared memory reader as only single process - Datarouter daemon, shall be running @@ -99,30 +99,30 @@ DataRouter::MessagingSessionPtr DataRouter::new_source_session( return nullptr; } - return new_source_session_impl( - name, is_dlt_enabled, std::move(handle), quota, quota_enforcement_enabled, std::move(reader), nvConfig); + return NewSourceSessionImpl( + name, is_dlt_enabled, std::move(handle), quota, quota_enforcement_enabled, std::move(reader), nv_config); } -void DataRouter::show_source_statistics(uint16_t series_num) +void DataRouter::ShowSourceStatistics(uint16_t series_num) { std::lock_guard lock(subscriber_mutex_); stats_logger_.LogInfo() << "log stat #" << series_num; - for (auto& sourceSession : sources_) + for (const auto& source_session : sources_) { - sourceSession->show_stats(); + source_session->ShowStats(); } } -std::unique_ptr DataRouter::new_source_session_impl( +std::unique_ptr DataRouter::NewSourceSessionImpl( const std::string name, const bool is_dlt_enabled, SessionHandleVariant handle, const double quota, bool quota_enforcement_enabled, std::unique_ptr reader, - const score::mw::log::NvConfig& nvConfig) + const score::mw::log::NvConfig& nv_config) { - auto sourceSession = + auto source_session = std::make_unique(*this, std::move(reader), name, @@ -131,9 +131,9 @@ std::unique_ptr DataRouter::new_source_session_impl( quota, quota_enforcement_enabled, stats_logger_, - std::make_unique(nvConfig)); + std::make_unique(nv_config)); - if (!sourceSession) + if (!source_session) { return nullptr; } @@ -143,17 +143,17 @@ std::unique_ptr DataRouter::new_source_session_impl( // Insert is protected by subscriber_mutex_ held by caller (new_source_session_impl). // This relies on the calling convention that SourceSession is only constructed // from new_source_session_impl() which acquires the lock before construction. - std::ignore = sources_.insert(sourceSession.get()); + std::ignore = sources_.insert(source_session.get()); - if (sourceCallback_) + if (source_callback_) { - sourceCallback_(std::move(sourceSession->get_parser())); + source_callback_(std::move(source_session->GetParser())); } // persistent subscribers - return sourceSession; + return source_session; } -bool DataRouter::SourceSession::tick() +bool DataRouter::SourceSession::Tick() { if (local_subscriber_data_.lock()->detach_on_closed_processed) { @@ -162,38 +162,38 @@ bool DataRouter::SourceSession::tick() // Phase 1: finalize a pending acquire if possible bool needs_fast_reschedule{false}; - const bool acquire_finalized = tryFinalizeAcquisition(needs_fast_reschedule); + const bool acquire_finalized = TryFinalizeAcquisition(needs_fast_reschedule); uint64_t message_count_local = 0; uint64_t number_of_bytes_in_buffer = 0; std::chrono::microseconds transport_delay_local = std::chrono::microseconds::zero(); auto start = score::os::HighResolutionSteadyClock::now(); - processAndRouteLogMessages(message_count_local, + ProcessAndRouteLogMessages(message_count_local, transport_delay_local, number_of_bytes_in_buffer, acquire_finalized, needs_fast_reschedule); - update_and_log_stats(message_count_local, number_of_bytes_in_buffer, transport_delay_local, start); + UpdateAndLogStats(message_count_local, number_of_bytes_in_buffer, transport_delay_local, start); // NOTE: keep historical external API: tick() returns false. // Scheduler/tests rely on this; internal reschedule hint is tracked via needs_fast_reschedule. return false; } -bool DataRouter::SourceSession::tryFinalizeAcquisition(bool& needs_fast_reschedule) +bool DataRouter::SourceSession::TryFinalizeAcquisition(bool& needs_fast_reschedule) { std::optional data_acquired_local; - data_acquired_local = command_data_.lock()->data_acquired_; + data_acquired_local = command_data_.lock()->data_acquired; if (data_acquired_local.has_value()) { if (reader_->IsBlockReleasedByWriters(data_acquired_local.value().acquired_buffer)) { std::ignore = reader_->NotifyAcquisitionSetReader(data_acquired_local.value()); - command_data_.lock()->data_acquired_ = std::nullopt; + command_data_.lock()->data_acquired = std::nullopt; return true; } @@ -206,7 +206,7 @@ bool DataRouter::SourceSession::tryFinalizeAcquisition(bool& needs_fast_reschedu return false; } -void DataRouter::SourceSession::processAndRouteLogMessages(uint64_t& message_count_local, +void DataRouter::SourceSession::ProcessAndRouteLogMessages(uint64_t& message_count_local, std::chrono::microseconds& transport_delay_local, uint64_t& number_of_bytes_in_buffer, bool acquire_finalized_in_this_tick, @@ -257,10 +257,10 @@ void DataRouter::SourceSession::processAndRouteLogMessages(uint64_t& message_cou if (detach_needed) { local_subscriber_data_.lock()->detach_on_closed_processed = true; - process_detached_logs(number_of_bytes_in_buffer); + ProcessDetachedLogs(number_of_bytes_in_buffer); } - bool enabled_logging = local_subscriber_data_.lock()->enabled_logging_at_server_; + bool enabled_logging = local_subscriber_data_.lock()->enabled_logging_at_server; { auto cmd = command_data_.lock(); @@ -279,7 +279,7 @@ void DataRouter::SourceSession::processAndRouteLogMessages(uint64_t& message_cou if ((peek_bytes.has_value() && peek_bytes.value() > 0) || (cmd->ticks_without_write > kTicksWithoutAcquireWhileNoWrites)) { - cmd->acquire_requested = request_acquire(); + cmd->acquire_requested = RequestAcquire(); needs_fast_reschedule = cmd->acquire_requested; } else @@ -290,7 +290,7 @@ void DataRouter::SourceSession::processAndRouteLogMessages(uint64_t& message_cou } else { - cmd->acquire_requested = request_acquire(); + cmd->acquire_requested = RequestAcquire(); needs_fast_reschedule = cmd->acquire_requested; } } @@ -300,7 +300,7 @@ void DataRouter::SourceSession::processAndRouteLogMessages(uint64_t& message_cou std::chrono::duration_cast(std::chrono::steady_clock::now() - current_timestamp); } -void DataRouter::SourceSession::process_detached_logs(uint64_t& number_of_bytes_in_buffer) +void DataRouter::SourceSession::ProcessDetachedLogs(uint64_t& number_of_bytes_in_buffer) { const auto number_of_bytes_in_buffer_result_detached = reader_->ReadDetached( [this](const auto& registration) noexcept { @@ -319,10 +319,10 @@ void DataRouter::SourceSession::process_detached_logs(uint64_t& number_of_bytes_ stats_logger_.LogError() << name << ": detached logs processed: " << number_of_bytes_in_buffer_result_detached; } -void DataRouter::SourceSession::update_and_log_stats(uint64_t message_count_local, - uint64_t number_of_bytes_in_buffer, - std::chrono::microseconds transport_delay_local, - score::os::HighResolutionSteadyClock::time_point start) +void DataRouter::SourceSession::UpdateAndLogStats(uint64_t message_count_local, + uint64_t number_of_bytes_in_buffer, + std::chrono::microseconds transport_delay_local, + score::os::HighResolutionSteadyClock::time_point start) { { auto stats = stats_data_.lock(); @@ -353,10 +353,10 @@ void DataRouter::SourceSession::update_and_log_stats(uint64_t message_count_loca stats->max_bytes_in_buffer = std::max(stats->max_bytes_in_buffer, number_of_bytes_in_buffer); stats->transport_delay = std::max(stats->transport_delay, transport_delay_local); stats->time_spent_reading += - std::chrono::duration_cast(score::platform::timestamp_t::clock::now() - start); + std::chrono::duration_cast(score::platform::TimestampT::clock::now() - start); } - checkAndSetQuotaEnforcement(); + CheckAndSetQuotaEnforcement(); } DataRouter::SourceSession::SourceSession(DataRouter& router, @@ -379,10 +379,10 @@ DataRouter::SourceSession::SourceSession(DataRouter& router, handle_(std::move(handle)), stats_logger_(stats_logger) { - local_subscriber_data_.lock()->enabled_logging_at_server_ = is_dlt_enabled; + local_subscriber_data_.lock()->enabled_logging_at_server = is_dlt_enabled; { auto stats = stats_data_.lock(); - stats->quota_KBps = quota; + stats->quota_k_bps = quota; stats->quota_enforcement_enabled = quota_enforcement_enabled; stats->name = name; } @@ -391,11 +391,11 @@ DataRouter::SourceSession::SourceSession(DataRouter& router, auto stats = stats_data_.lock(); if (stats->name == "DR") { - constexpr double newQuotaValue = std::numeric_limits::max(); + constexpr double kNewQuotaValue = std::numeric_limits::max(); stats_logger_.LogInfo() << "Override quota value for Datarouter (to be unlimited). Old value: " - << QuotaValueAsString(stats->quota_KBps) - << ", new value: " << QuotaValueAsString(newQuotaValue); - stats->quota_KBps = newQuotaValue; + << QuotaValueAsString(stats->quota_k_bps) + << ", new value: " << QuotaValueAsString(kNewQuotaValue); + stats->quota_k_bps = kNewQuotaValue; } } } @@ -410,7 +410,7 @@ DataRouter::SourceSession::~SourceSession() stats_logger_.LogInfo() << "Cleaning up source session for " << stats_data_.lock()->name; } -void DataRouter::SourceSession::checkAndSetQuotaEnforcement() +void DataRouter::SourceSession::CheckAndSetQuotaEnforcement() { auto stats = stats_data_.lock(); if (!stats->quota_overlimit_detected && stats->quota_enforcement_enabled) @@ -427,28 +427,28 @@ void DataRouter::SourceSession::checkAndSetQuotaEnforcement() return; } - const auto rate_KBps = + const auto rate_k_bps = static_cast(stats->totalsize) * 1000. / 1024. / static_cast(tstat_in_msec); - stats_logger_.LogInfo() << stats->name << "quota status. rate: " << rate_KBps - << ", quota_KBps_: " << QuotaValueAsString(stats->quota_KBps) + stats_logger_.LogInfo() << stats->name << "quota status. rate: " << rate_k_bps + << ", quota_KBps_: " << QuotaValueAsString(stats->quota_k_bps) << ", totalsize_: " << stats->totalsize << ", tstat_in_msec: " << tstat_in_msec; - if (rate_KBps > stats->quota_KBps) + if (rate_k_bps > stats->quota_k_bps) { stats_logger_.LogError() << stats->name - << ": exceeded the quota. quota enforcement set. rate: " << rate_KBps - << ", quota_KBps: " << QuotaValueAsString(stats->quota_KBps); + << ": exceeded the quota. quota enforcement set. rate: " << rate_k_bps + << ", quota_KBps: " << QuotaValueAsString(stats->quota_k_bps); stats->quota_overlimit_detected = true; } } } -void DataRouter::SourceSession::show_stats() +void DataRouter::SourceSession::ShowStats() { uint64_t message_count{0}; uint64_t totalsize{0}; - double quota_KBps{0.0}; + double quota_k_bps{0.0}; bool quota_enforcement_enabled{false}; bool quota_overlimit_detected{false}; std::chrono::microseconds time_spent_reading{}; @@ -462,7 +462,7 @@ void DataRouter::SourceSession::show_stats() auto stats = stats_data_.lock(); message_count = stats->message_count; totalsize = stats->totalsize; - quota_KBps = stats->quota_KBps; + quota_k_bps = stats->quota_k_bps; quota_enforcement_enabled = stats->quota_enforcement_enabled; quota_overlimit_detected = stats->quota_overlimit_detected; time_spent_reading = stats->time_spent_reading; @@ -501,7 +501,7 @@ void DataRouter::SourceSession::show_stats() } auto tstat_in_msec = std::chrono::duration_cast(current_time - last_start); - auto rate_KBps = static_cast(totalsize) * 1000. / 1024. / static_cast(tstat_in_msec.count()); + auto rate_k_bps = static_cast(totalsize) * 1000. / 1024. / static_cast(tstat_in_msec.count()); auto [time_between_calls, time_to_process] = [this]() noexcept { auto subs_data = local_subscriber_data_.lock(); @@ -509,8 +509,8 @@ void DataRouter::SourceSession::show_stats() }(); stats_logger_.LogInfo() << name << ": count " << message_count << ", size " << totalsize - << " B, rate: " << rate_KBps << " KBps" - << ", quota rate: " << QuotaValueAsString(quota_KBps) + << " B, rate: " << rate_k_bps << " KBps" + << ", quota rate: " << QuotaValueAsString(quota_k_bps) << ", quota enforcement: " << quota_overlimit_detected << ", read_time:" << time_spent_reading.count() << " us" << ", transp_delay:" << transport_delay.count() << " us" @@ -521,10 +521,10 @@ void DataRouter::SourceSession::show_stats() << ", messages dropped: " << message_count_dropped << " (accumulated)" << ", IPC count: " << count_acquire_requests; - if (rate_KBps > quota_KBps && quota_enforcement_enabled) + if (rate_k_bps > quota_k_bps && quota_enforcement_enabled) { - stats_logger_.LogError() << name << ": exceeded the quota of " << QuotaValueAsString(quota_KBps) - << "KBps, rate " << rate_KBps << " KBps"; + stats_logger_.LogError() << name << ": exceeded the quota of " << QuotaValueAsString(quota_k_bps) + << "KBps, rate " << rate_k_bps << " KBps"; } if (quota_overlimit_detected) { @@ -532,12 +532,12 @@ void DataRouter::SourceSession::show_stats() } } -bool DataRouter::SourceSession::request_acquire() +bool DataRouter::SourceSession::RequestAcquire() { const bool acquire_result = score::cpp::visit(score::cpp::overload( [](UnixDomainServer::SessionHandle& handle) { - handle.pass_message("<"); + handle.PassMessage("<"); return true; }, [](score::cpp::pmr::unique_ptr& handle) { @@ -556,14 +556,14 @@ bool DataRouter::SourceSession::request_acquire() return acquire_result; } -void DataRouter::SourceSession::on_acquire_response(const score::mw::log::detail::ReadAcquireResult& acq) +void DataRouter::SourceSession::OnAcquireResponse(const score::mw::log::detail::ReadAcquireResult& acq) { auto cmd = command_data_.lock(); - cmd->data_acquired_ = acq; + cmd->data_acquired = acq; cmd->block_expected_to_be_next = GetExpectedNextAcquiredBlockId(acq); } -void DataRouter::SourceSession::on_closed_by_peer() +void DataRouter::SourceSession::OnClosedByPeer() { command_data_.lock()->command_detach_on_closed = true; } diff --git a/score/datarouter/datarouter/data_router.h b/score/datarouter/datarouter/data_router.h index 0f86428..b0bf107 100644 --- a/score/datarouter/datarouter/data_router.h +++ b/score/datarouter/datarouter/data_router.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef DATA_ROUTER_H_ -#define DATA_ROUTER_H_ +#ifndef SCORE_DATAROUTER_DATAROUTER_DATA_ROUTER_H +#define SCORE_DATAROUTER_DATAROUTER_DATA_ROUTER_H #include "daemon/message_passing_server.h" #include "logparser/logparser.h" @@ -51,7 +51,7 @@ struct LocalSubscriberData std::chrono::microseconds time_to_process_records{std::chrono::microseconds::zero()}; std::chrono::steady_clock::time_point last_call_timestamp{std::chrono::steady_clock::now()}; bool detach_on_closed_processed{false}; - bool enabled_logging_at_server_{false}; + bool enabled_logging_at_server{false}; }; struct CommandData @@ -60,7 +60,7 @@ struct CommandData bool acquire_requested{false}; uint8_t ticks_without_write{0}; std::optional block_expected_to_be_next{std::nullopt}; - std::optional data_acquired_{std::nullopt}; + std::optional data_acquired{std::nullopt}; }; struct StatsData @@ -71,7 +71,7 @@ struct StatsData uint64_t message_count_dropped_invalid_size{0}; uint64_t max_bytes_in_buffer{0}; uint64_t totalsize{0}; - double quota_KBps{0.0}; + double quota_k_bps{0.0}; bool quota_enforcement_enabled{false}; bool quota_overlimit_detected{false}; std::chrono::microseconds time_spent_reading{std::chrono::microseconds::zero()}; @@ -91,9 +91,9 @@ class DataRouter using SessionHandleVariant = score::cpp::variant>; - explicit DataRouter(score::mw::log::Logger& logger, SourceSetupCallback sourceCallback = SourceSetupCallback()); + explicit DataRouter(score::mw::log::Logger& logger, SourceSetupCallback source_callback = SourceSetupCallback()); - MessagingSessionPtr new_source_session( + MessagingSessionPtr NewSourceSession( int fd, const std::string name, const bool is_dlt_enabled, @@ -101,24 +101,24 @@ class DataRouter const double quota, bool quota_enforcement_enabled, const pid_t client_pid, - const score::mw::log::NvConfig& nvConfig, + const score::mw::log::NvConfig& nv_config, score::mw::log::detail::ReaderFactoryPtr reader_factory = score::mw::log::detail::ReaderFactory::Default(score::cpp::pmr::get_default_resource())); template - void for_each_source_parser(E e, F f, bool enable_logging_client) + void ForEachSourceParser(E e, F f, bool enable_logging_client) { std::lock_guard lock(subscriber_mutex_); - for (auto& sourceSession : sources_) + for (const auto& source_session : sources_) { // No need for the extra lock - synchronization is handled by the Synchronized wrapper - sourceSession->SetLoggingClientEnabled(enable_logging_client); - e(sourceSession->get_parser()); + source_session->SetLoggingClientEnabled(enable_logging_client); + e(source_session->GetParser()); } f(); } - void show_source_statistics(uint16_t series_num); + void ShowSourceStatistics(uint16_t series_num); // for unit test only. to keep rest of functions in private class DataRouterForTest; @@ -150,7 +150,7 @@ class DataRouter void SetLoggingClientEnabled(bool enable) { - local_subscriber_data_.lock()->enabled_logging_at_server_ = enable; + local_subscriber_data_.lock()->enabled_logging_at_server = enable; } ~SourceSession(); @@ -158,31 +158,31 @@ class DataRouter class SourceSessionForTest; private: - bool is_source_closed() override + bool IsSourceClosed() override { return local_subscriber_data_.lock()->detach_on_closed_processed; } - bool tick() override; + bool Tick() override; - bool tryFinalizeAcquisition(bool& needs_fast_reschedule); - void processAndRouteLogMessages(uint64_t& message_count_local, + bool TryFinalizeAcquisition(bool& needs_fast_reschedule); + void ProcessAndRouteLogMessages(uint64_t& message_count_local, std::chrono::microseconds& transport_delay_local, uint64_t& number_of_bytes_in_buffer, bool acquire_finalized_in_this_tick, bool& needs_fast_reschedule); - void update_and_log_stats(uint64_t message_count_local, - uint64_t number_of_bytes_in_buffer, - std::chrono::microseconds transport_delay_local, - score::os::HighResolutionSteadyClock::time_point start); - void process_detached_logs(uint64_t& number_of_bytes_in_buffer); + void UpdateAndLogStats(uint64_t message_count_local, + uint64_t number_of_bytes_in_buffer, + std::chrono::microseconds transport_delay_local, + score::os::HighResolutionSteadyClock::time_point start); + void ProcessDetachedLogs(uint64_t& number_of_bytes_in_buffer); - void on_acquire_response(const score::mw::log::detail::ReadAcquireResult& acq) override; + void OnAcquireResponse(const score::mw::log::detail::ReadAcquireResult& acq) override; - void on_closed_by_peer() override; + void OnClosedByPeer() override; - void checkAndSetQuotaEnforcement(); - bool request_acquire(); + void CheckAndSetQuotaEnforcement(); + bool RequestAcquire(); Synchronized local_subscriber_data_; Synchronized command_data_; @@ -195,26 +195,26 @@ class DataRouter score::mw::log::Logger& stats_logger_; public: - void show_stats(); - ILogParser& get_parser() + void ShowStats(); + ILogParser& GetParser() { - return *(parser_.get()); + return *(parser_); } }; - std::unique_ptr new_source_session_impl( + std::unique_ptr NewSourceSessionImpl( const std::string name, const bool is_dlt_enabled, SessionHandleVariant handle, const double quota, bool quota_enforcement_enabled, std::unique_ptr reader, - const score::mw::log::NvConfig& nvConfig); + const score::mw::log::NvConfig& nv_config); score::mw::log::Logger& stats_logger_; std::unordered_set sources_; - SourceSetupCallback sourceCallback_; + SourceSetupCallback source_callback_; std::mutex subscriber_mutex_; }; @@ -223,4 +223,4 @@ class DataRouter } // namespace platform } // namespace score -#endif // DATA_ROUTER_H_ +#endif // SCORE_DATAROUTER_DATAROUTER_DATA_ROUTER_H diff --git a/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message.h b/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message.h index c96f988..7f7433b 100644 --- a/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message.h +++ b/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message.h @@ -26,11 +26,11 @@ struct FileTransferEntry // Suppress "AUTOSAR C++14 A9-5-1", The rule states: "Unions shall not be used." // Unavoidable use of of union type, in future dltit_t with LoggingIdentifier. // coverity[autosar_cpp14_a9_5_1_violation] see above - score::platform::dltid_t appid{}; + score::platform::DltidT appid{}; // Suppress "AUTOSAR C++14 A9-5-1", The rule states: "Unions shall not be used." // Unavoidable use of of union type, in future dltit_t with LoggingIdentifier. // coverity[autosar_cpp14_a9_5_1_violation] see above - score::platform::dltid_t ctxid{}; + score::platform::DltidT ctxid{}; std::string file_name{}; uint8_t delete_file = 0; }; diff --git a/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message_trace.h b/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message_trace.h index c6f9d0e..d2aa911 100644 --- a/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message_trace.h +++ b/score/datarouter/dlt_filetransfer_trigger_lib/filetransfer_message_trace.h @@ -24,7 +24,7 @@ namespace score::logging { -MEMCPY_SERIALIZABLE(score::common::visitor::payload_tags::text, score::platform::dltid_t) +MEMCPY_SERIALIZABLE(score::common::visitor::payload_tags::text, score::platform::DltidT) // Suppress "AUTOSAR C++14 A18-9-4". The rule states: An argument to std::forward shall not be subsequently used. // Rationale: STRUCT_TRACEABLE is a macro, std::forward is from the macro definition // Suppress "AUTOSAR C++14 M3-2-3". The rule states: "A type, object or function that is used in diff --git a/score/datarouter/include/Tracing b/score/datarouter/include/Tracing index 5a29655..155e766 100644 --- a/score/datarouter/include/Tracing +++ b/score/datarouter/include/Tracing @@ -11,10 +11,10 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef AAS_PAS_LOGGING_TRACING_ -#define AAS_PAS_LOGGING_TRACING_ +#ifndef PLATFORM_AAS_PAS_LOGGING_INCLUDE_TRACING +#define PLATFORM_AAS_PAS_LOGGING_INCLUDE_TRACING /// \file This file shall be replaced by the mw::log package. #include "score/mw/log/legacy_non_verbose_api/tracing.h" -#endif // AAS_PAS_LOGGING_TRACING_ +#endif // PLATFORM_AAS_PAS_LOGGING_INCLUDE_TRACING diff --git a/score/datarouter/include/daemon/configurator_commands.h b/score/datarouter/include/daemon/configurator_commands.h index 1a0e1ce..2f6d121 100644 --- a/score/datarouter/include/daemon/configurator_commands.h +++ b/score/datarouter/include/daemon/configurator_commands.h @@ -24,26 +24,26 @@ namespace dltserver { namespace config { -static constexpr std::uint8_t READ_LOG_CHANNEL_NAMES = 8; -static constexpr std::uint8_t SET_LOG_LEVEL = 0; -static constexpr std::uint8_t RESET_TO_DEFAULT = 1; -static constexpr std::uint8_t SET_MESSAGING_FILTERING_STATE = 2; -static constexpr std::uint8_t SET_LOG_CHANNEL_THRESHOLD = 3; -static constexpr std::uint8_t STORE_DLT_CONFIG = 4; -static constexpr std::uint8_t SET_TRACE_STATE = 5; -static constexpr std::uint8_t SET_DEFAULT_LOG_LEVEL = 6; -static constexpr std::uint8_t SET_DEFAULT_TRACE_STATE = 7; -static constexpr std::uint8_t SET_LOG_CHANNEL_ASSIGNMENT = 9; -static constexpr std::uint8_t SET_DLT_OUTPUT_ENABLE = 10; +static constexpr std::uint8_t kReadLogChannelNames = 8; +static constexpr std::uint8_t kSetLogLevel = 0; +static constexpr std::uint8_t kResetToDefault = 1; +static constexpr std::uint8_t kSetMessagingFilteringState = 2; +static constexpr std::uint8_t kSetLogChannelThreshold = 3; +static constexpr std::uint8_t kStoreDltConfig = 4; +static constexpr std::uint8_t kSetTraceState = 5; +static constexpr std::uint8_t kSetDefaultLogLevel = 6; +static constexpr std::uint8_t kSetDefaultTraceState = 7; +static constexpr std::uint8_t kSetLogChannelAssignment = 9; +static constexpr std::uint8_t kSetDltOutputEnable = 10; -static constexpr std::uint8_t DLT_ASSIGN_ADD = 1; +static constexpr std::uint8_t kDltAssignAdd = 1; -static constexpr char RET_OK = static_cast(0); -static constexpr char RET_UNKNOWN = static_cast(-1); -static constexpr char RET_ERROR = static_cast(-2); +static constexpr char kRetOk = static_cast(0); +static constexpr char kRetUnknown = static_cast(-1); +static constexpr char kRetError = static_cast(-2); -static constexpr std::uint8_t ENABLE = 1; -static constexpr std::uint8_t DISABLE = 0; +static constexpr std::uint8_t kEnable = 1; +static constexpr std::uint8_t kDisable = 0; } // namespace config } // namespace dltserver } // namespace logging diff --git a/score/datarouter/include/daemon/data_router_cfg.h b/score/datarouter/include/daemon/data_router_cfg.h index 42836c0..2fa3061 100644 --- a/score/datarouter/include/daemon/data_router_cfg.h +++ b/score/datarouter/include/daemon/data_router_cfg.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef DATAROUTER_ETC_H_ -#define DATAROUTER_ETC_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_DATA_ROUTER_CFG_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_DATA_ROUTER_CFG_H #include @@ -22,10 +22,10 @@ namespace logging { namespace config { -static const std::string socket_address{"datarouter_socket"}; -static constexpr const score::cpp::string_view dlt_config_client_name{"_dlt_config"}; +static const std::string kSocketAddress{"datarouter_socket"}; +static constexpr const score::cpp::string_view kDltConfigClientName{"_dlt_config"}; } // namespace config } // namespace logging } // namespace score -#endif // DATAROUTER_ETC_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_DATA_ROUTER_CFG_H diff --git a/score/datarouter/include/daemon/diagnostic_job_handler.h b/score/datarouter/include/daemon/diagnostic_job_handler.h index 0ce3902..dbec07f 100644 --- a/score/datarouter/include/daemon/diagnostic_job_handler.h +++ b/score/datarouter/include/daemon/diagnostic_job_handler.h @@ -29,45 +29,45 @@ class ReadLogChannelNamesHandler final : public IDiagnosticJobHandler { public: ReadLogChannelNamesHandler() = default; - const std::string execute(IDltLogServer& srv) override; + std::string Execute(IDltLogServer& srv) override; }; class ResetToDefaultHandler final : public IDiagnosticJobHandler { public: ResetToDefaultHandler() = default; - const std::string execute(IDltLogServer& srv) override; + std::string Execute(IDltLogServer& srv) override; }; class StoreDltConfigHandler final : public IDiagnosticJobHandler { public: StoreDltConfigHandler() = default; - const std::string execute(IDltLogServer& srv) override; + std::string Execute(IDltLogServer& srv) override; }; class SetTraceStateHandler final : public IDiagnosticJobHandler { public: SetTraceStateHandler() = default; - const std::string execute(IDltLogServer& srv) override; + std::string Execute(IDltLogServer& srv) override; }; class SetDefaultTraceStateHandler final : public IDiagnosticJobHandler { public: SetDefaultTraceStateHandler() = default; - const std::string execute(IDltLogServer& srv) override; + std::string Execute(IDltLogServer& srv) override; }; class SetLogChannelThresholdHandler final : public IDiagnosticJobHandler { private: - score::platform::dltid_t channel_; - loglevel_t threshold_; + score::platform::DltidT channel_; + LoglevelT threshold_; public: - SetLogChannelThresholdHandler(score::platform::dltid_t channel, loglevel_t threshold) + SetLogChannelThresholdHandler(score::platform::DltidT channel, LoglevelT threshold) : channel_(channel), threshold_(threshold) { } @@ -77,28 +77,28 @@ class SetLogChannelThresholdHandler final : public IDiagnosticJobHandler return channel_ == rhs.channel_ && threshold_ == rhs.threshold_; } - const std::string execute(IDltLogServer& srv) override; + std::string Execute(IDltLogServer& srv) override; }; class SetLogLevelHandler final : public IDiagnosticJobHandler { private: - score::platform::dltid_t appId_; - score::platform::dltid_t ctxId_; - threshold_t threshold_; + score::platform::DltidT app_id_; + score::platform::DltidT ctx_id_; + ThresholdT threshold_; public: - SetLogLevelHandler(score::platform::dltid_t appId, score::platform::dltid_t ctxId, threshold_t threshold) - : appId_(appId), ctxId_(ctxId), threshold_(threshold) + SetLogLevelHandler(score::platform::DltidT app_id, score::platform::DltidT ctx_id, ThresholdT threshold) + : app_id_(app_id), ctx_id_(ctx_id), threshold_(threshold) { } bool operator==(const SetLogLevelHandler& rhs) const noexcept { - return appId_ == rhs.appId_ && ctxId_ == rhs.ctxId_ && threshold_ == rhs.threshold_; + return app_id_ == rhs.app_id_ && ctx_id_ == rhs.ctx_id_ && threshold_ == rhs.threshold_; } - const std::string execute(IDltLogServer& srv) override; + std::string Execute(IDltLogServer& srv) override; }; class SetMessagingFilteringStateHandler final : public IDiagnosticJobHandler @@ -114,49 +114,49 @@ class SetMessagingFilteringStateHandler final : public IDiagnosticJobHandler return enabled_ == rhs.enabled_; } - const std::string execute(IDltLogServer& srv) override; + std::string Execute(IDltLogServer& srv) override; }; class SetDefaultLogLevelHandler final : public IDiagnosticJobHandler { private: - loglevel_t level_; + LoglevelT level_; public: - explicit SetDefaultLogLevelHandler(loglevel_t level) : level_(level) {} + explicit SetDefaultLogLevelHandler(LoglevelT level) : level_(level) {} bool operator==(const SetDefaultLogLevelHandler& rhs) const noexcept { return level_ == rhs.level_; } - const std::string execute(IDltLogServer& srv) override; + std::string Execute(IDltLogServer& srv) override; }; class SetLogChannelAssignmentHandler final : public IDiagnosticJobHandler { private: - score::platform::dltid_t appId_; - score::platform::dltid_t ctxId_; - score::platform::dltid_t channel_; + score::platform::DltidT app_id_; + score::platform::DltidT ctx_id_; + score::platform::DltidT channel_; AssignmentAction assignment_flag_; public: - SetLogChannelAssignmentHandler(score::platform::dltid_t appId, - score::platform::dltid_t ctxId, - score::platform::dltid_t channel, + SetLogChannelAssignmentHandler(score::platform::DltidT app_id, + score::platform::DltidT ctx_id, + score::platform::DltidT channel, AssignmentAction assignment_flag) - : appId_(appId), ctxId_(ctxId), channel_(channel), assignment_flag_(assignment_flag) + : app_id_(app_id), ctx_id_(ctx_id), channel_(channel), assignment_flag_(assignment_flag) { } bool operator==(const SetLogChannelAssignmentHandler& rhs) const noexcept { - return appId_ == rhs.appId_ && ctxId_ == rhs.ctxId_ && channel_ == rhs.channel_ && + return app_id_ == rhs.app_id_ && ctx_id_ == rhs.ctx_id_ && channel_ == rhs.channel_ && assignment_flag_ == rhs.assignment_flag_; } - const std::string execute(IDltLogServer& srv) override; + std::string Execute(IDltLogServer& srv) override; }; class SetDltOutputEnableHandler final : public IDiagnosticJobHandler @@ -172,7 +172,7 @@ class SetDltOutputEnableHandler final : public IDiagnosticJobHandler return enable_ == rhs.enable_; } - const std::string execute(IDltLogServer& srv) override; + std::string Execute(IDltLogServer& srv) override; }; } // namespace dltserver diff --git a/score/datarouter/include/daemon/diagnostic_job_parser.h b/score/datarouter/include/daemon/diagnostic_job_parser.h index c36b2e3..abcee06 100644 --- a/score/datarouter/include/daemon/diagnostic_job_parser.h +++ b/score/datarouter/include/daemon/diagnostic_job_parser.h @@ -28,9 +28,9 @@ namespace logging namespace dltserver { -score::platform::dltid_t extractId(const std::string& message, const size_t offset); +score::platform::DltidT ExtractId(const std::string& message, const size_t offset); -void appendId(score::platform::dltid_t name, std::string& message); +void AppendId(score::platform::DltidT name, std::string& message); // This class is responsible for converting a raw byte string into a clean // IDiagnosticJob object. @@ -41,10 +41,10 @@ class DiagnosticJobParser : public IDiagnosticJobParser // Returns a unique pointer of type IDiagnosticJobHandler (Not an instance because it's abstract) // pointing to a derived class of the diagnostic job on success. // Returns nullptr if parsing fails (e.g., wrong size, unknown command). - std::unique_ptr parse(const std::string& command) override; + std::unique_ptr Parse(const std::string& command) override; private: - [[nodiscard]] std::optional getAssignmentAction(std::uint8_t value) noexcept; + [[nodiscard]] std::optional GetAssignmentAction(std::uint8_t value) noexcept; }; } // namespace dltserver diff --git a/score/datarouter/include/daemon/dlt_log_channel.h b/score/datarouter/include/daemon/dlt_log_channel.h index bbb4957..8c26ed2 100644 --- a/score/datarouter/include/daemon/dlt_log_channel.h +++ b/score/datarouter/include/daemon/dlt_log_channel.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef DLT_LOG_CHANNEL_H_ -#define DLT_LOG_CHANNEL_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_DLT_LOG_CHANNEL_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_DLT_LOG_CHANNEL_H #include "daemon/dltserver_common.h" #include "daemon/udp_stream_output.h" @@ -38,19 +38,19 @@ namespace dltserver class DltLogChannel { public: - DltLogChannel(const dltid_t channelName, + DltLogChannel(const DltidT channel_id, const mw::log::LogLevel threshold, - const dltid_t ecu, - const char* srcAddr, - const uint16_t srcPort, - const char* dstAddr, - const uint16_t dstPort, - const char* multicastInterface) - : channelName_(channelName), - ecu_(ecu), - channelThreshold_(threshold), + const DltidT ecu_id, + const char* src_addr, + const uint16_t src_port, + const char* dst_addr, + const uint16_t dst_port, + const char* multicast_interface) + : channel_name(channel_id), + ecu(ecu_id), + channel_threshold(threshold), mutex_{}, - out_(dstAddr, dstPort, multicastInterface), + out_(dst_addr, dst_port, multicast_interface), mcnt_(0), count_verbose_messages_in_buffer_(0), count_nonverbose_messages_in_buffer_(0), @@ -59,27 +59,27 @@ class DltLogChannel mmsg_hdr_array_{}, prebuf_size_(0), prebuf_is_verbose_(false), - srcport_(srcPort), + srcport_(src_port), bind_result_{}, verbose_(), non_verbose_() { - bind_result_ = out_.bind(srcAddr, srcPort); + bind_result_ = out_.Bind(src_addr, src_port); } - DltLogChannel(const std::string& channelName, + DltLogChannel(const std::string& channel_id, const mw::log::LogLevel threshold, - const std::string& ecu, - const char* srcAddr, - const uint16_t srcPort, - const char* dstAddr, - const uint16_t dstPort, - const char* multicastInterface) - : channelName_(dltid_t(channelName)), - ecu_(dltid_t(ecu)), - channelThreshold_(threshold), + const std::string& ecu_id, + const char* src_addr, + const uint16_t src_port, + const char* dst_addr, + const uint16_t dst_port, + const char* multicast_interface) + : channel_name(DltidT(channel_id)), + ecu(DltidT(ecu_id)), + channel_threshold(threshold), mutex_{}, - out_(dstAddr, dstPort, multicastInterface), + out_(dst_addr, dst_port, multicast_interface), mcnt_(0), count_verbose_messages_in_buffer_(0), count_nonverbose_messages_in_buffer_(0), @@ -88,20 +88,20 @@ class DltLogChannel mmsg_hdr_array_{}, prebuf_size_(0), prebuf_is_verbose_(false), - srcport_(srcPort), + srcport_(src_port), bind_result_{}, verbose_(), non_verbose_() { - bind_result_ = out_.bind(srcAddr, srcPort); + bind_result_ = out_.Bind(src_addr, src_port); } ~DltLogChannel() = default; DltLogChannel(const DltLogChannel&) = delete; DltLogChannel(DltLogChannel&& from) noexcept - : channelName_(from.channelName_), - ecu_(from.ecu_), - channelThreshold_(from.channelThreshold_.load()), + : channel_name(from.channel_name), + ecu(from.ecu), + channel_threshold(from.channel_threshold.load()), mutex_{}, out_(std::move(from.out_)), mcnt_(0), @@ -119,41 +119,41 @@ class DltLogChannel { } - void sendNonVerbose(const score::mw::log::config::NvMsgDescriptor& desc, + void SendNonVerbose(const score::mw::log::config::NvMsgDescriptor& desc, uint32_t tmsp, const void* data, size_t size); - void sendVerbose(const uint32_t tmsp, + void SendVerbose(const uint32_t tmsp, const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection& entry); // FT stands for 'file transfer' - void sendFTVerbose(score::cpp::span data, + void SendFtVerbose(score::cpp::span data, const mw::log::LogLevel loglevel, - dltid_t appId, - dltid_t ctxId, + DltidT app_id, + DltidT ctx_id, uint8_t nor, uint32_t tmsp); template - void show_stats(Logger& stat_logger) + void ShowStats(Logger& stat_logger) { std::lock_guard lock(mutex_); - ShowAndClearStatsDlt(verbose_, stat_logger, channelName_); - ShowAndClearStatsNonVerbose(non_verbose_, stat_logger, channelName_); + ShowAndClearStatsDlt(verbose_, stat_logger, channel_name); + ShowAndClearStatsNonVerbose(non_verbose_, stat_logger, channel_name); } - void flush(); + void Flush(); - const dltid_t channelName_; - const dltid_t ecu_; + const DltidT channel_name; + const DltidT ecu; - std::atomic channelThreshold_; + std::atomic channel_threshold; private: static constexpr uint32_t kIpv4HeaderWithoutOptions = 20UL; static constexpr uint32_t kUdpHeader = 8UL; static constexpr uint32_t kMtu = 1500UL; - static constexpr uint32_t UDP_MAX_PAYLOAD = kMtu - (kIpv4HeaderWithoutOptions + kUdpHeader); - static constexpr uint16_t bandwidth_denominator_ = 10 /* show_stats() cycle_time */ * 1024 /* KiBytes */; + static constexpr uint32_t kUdpMaxPayload = kMtu - (kIpv4HeaderWithoutOptions + kUdpHeader); + static constexpr uint16_t kBandwidthDenominator = 10 /* show_stats() cycle_time */ * 1024 /* KiBytes */; std::mutex mutex_; UdpStreamOutput out_; @@ -162,7 +162,7 @@ class DltLogChannel uint8_t count_nonverbose_messages_in_buffer_; static constexpr auto kVectorCount = 4UL; uint32_t vector_index_ = 0UL; - std::array, kVectorCount> prebuf_data_; + std::array, kVectorCount> prebuf_data_; std::array io_vec_; std::array mmsg_hdr_array_; size_t prebuf_size_; @@ -203,7 +203,7 @@ class DltLogChannel if ((flush && vector_index_ > 0) || vector_index_ >= kVectorCount) { score::cpp::span mmsg_span(mmsg_hdr_array_.data(), vector_index_); - const auto send_result = out_.send(mmsg_span); + const auto send_result = out_.Send(mmsg_span); if (send_result.has_value() == false) { if (count_verbose_messages_in_buffer_ > 0) @@ -242,14 +242,14 @@ class DltLogChannel template void ShowAndClearStatsDlt(DltLogChannelStatistics& statistics, Logger& stat_logger, - dltid_t channel_name, + DltidT channel_id, const score::cpp::string_view statistics_type = "verbose") { auto log_stream{stat_logger.LogInfo()}; log_stream << std::string(statistics_type.data(), statistics_type.size()) - << " messages in the channel:" << std::string{channel_name.data(), channel_name.size()} << ": count " + << " messages in the channel:" << std::string{channel_id.Data(), channel_id.size()} << ": count " << statistics.stats_msgcnt << ", size " << statistics.stats_totalsize << " bytes (" - << statistics.stats_totalsize / bandwidth_denominator_ << " kiB/s)" + << statistics.stats_totalsize / kBandwidthDenominator << " kiB/s)" << "failed to send: total count " << statistics.send_failures_count; if (statistics.send_failures_count > 0) @@ -275,9 +275,9 @@ class DltLogChannel template void ShowAndClearStatsNonVerbose(DltLogChannelNonVerboseStatistics& statistics, Logger& stat_logger, - dltid_t channel_name) + DltidT channel_id) { - ShowAndClearStatsDlt(statistics, stat_logger, channel_name, "non-verbose"); + ShowAndClearStatsDlt(statistics, stat_logger, channel_id, "non-verbose"); std::vector> dlt_non_verbose_diagnostics(begin(statistics.message_id_data_stats), end(statistics.message_id_data_stats)); @@ -288,12 +288,12 @@ class DltLogChannel }); auto&& log_stream = stat_logger.LogInfo(); - log_stream << "dlt stats: non-verbose messages in channel:" - << std::string{channel_name.data(), channel_name.size()} << " sent data by message id."; + log_stream << "dlt stats: non-verbose messages in channel:" << std::string{channel_id.Data(), channel_id.size()} + << " sent data by message id."; std::for_each( begin(dlt_non_verbose_diagnostics), end(dlt_non_verbose_diagnostics), [&log_stream](const auto& elem) { log_stream << "Msgid:" << elem.first << " bytes:" << elem.second << " (" - << elem.second / bandwidth_denominator_ << "kiB/s) |"; + << elem.second / kBandwidthDenominator << "kiB/s) |"; }); // Cleanup: @@ -306,4 +306,4 @@ class DltLogChannel } // namespace logging } // namespace score -#endif // DLT_LOG_CHANNEL_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_DLT_LOG_CHANNEL_H diff --git a/score/datarouter/include/daemon/dlt_log_server.h b/score/datarouter/include/daemon/dlt_log_server.h index c7958f2..fbfa3a6 100644 --- a/score/datarouter/include/daemon/dlt_log_server.h +++ b/score/datarouter/include/daemon/dlt_log_server.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef DLT_LOG_SERVER_H_ -#define DLT_LOG_SERVER_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_DLT_LOG_SERVER_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_DLT_LOG_SERVER_H #include "applications/datarouter_feature_config.h" #include "daemon/diagnostic_job_handler.h" @@ -47,9 +47,9 @@ namespace logging namespace dltserver { -const std::string LOG_ENTRY_TYPE_NAME{"score::mw::log::detail::LogEntry"}; -const std::string PERSISTENT_REQUEST_TYPE_NAME{"score::logging::internal::PersistentLoggingRequestStructure"}; -const std::string FILE_TRANSFER_TYPE_NAME{"score::logging::FileTransferEntry"}; +const std::string kLogEntryTypeName{"score::mw::log::detail::LogEntry"}; +const std::string kPersistentRequestTypeName{"score::logging::internal::PersistentLoggingRequestStructure"}; +const std::string kFileTransferTypeName{"score::logging::FileTransferEntry"}; class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOutput, DltVerboseHandler::IOutput, FileTransferStreamHandlerType::IOutput, @@ -62,7 +62,7 @@ class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOut using ConfigWriteCallback = std::function; using ConfigCommandHandler = std::function; - DltLogServer(StaticConfig staticConfig, + DltLogServer(StaticConfig static_config, ConfigReadCallback reader, ConfigWriteCallback writer, bool enabled, @@ -71,28 +71,28 @@ class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOut : score::platform::datarouter::DltNonverboseHandlerType::IOutput(), DltVerboseHandler::IOutput(), FileTransferStreamHandlerType::IOutput(), - configMutex_{}, - filteringEnabled_{}, - dltOutputEnabled_{enabled}, - defaultThreshold_{}, - messageThresholds_{}, - channelAssignments_{}, + config_mutex_{}, + filtering_enabled_{}, + dlt_output_enabled_{enabled}, + default_threshold_{}, + message_thresholds_{}, + channel_assignments_{}, throughput_overall_{0}, throughput_apps_{}, - staticConfig_{std::move(staticConfig)}, + static_config_{std::move(static_config)}, channels_{}, - defaultChannel_{}, - coredumpChannel_{std::nullopt}, - channelNums_{}, + default_channel_{}, + coredump_channel_{std::nullopt}, + channel_nums_{}, nvhandler_{*this}, vhandler_{*this}, - fthandler{*this}, - readerCallback_{reader}, - writerCallback_{writer}, + fthandler_{*this}, + reader_callback_{reader}, + writer_callback_{writer}, log_sender_(log_sender ? std::move(log_sender) : std::make_unique()), parser_(parser ? std::move(parser) : std::make_unique()) { - init_log_channels(); + InitLogChannels(); SysedrFactoryType sysedr_factory; sysedr_handler_ = sysedr_factory.CreateSysedrHandler(); } @@ -100,122 +100,122 @@ class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOut virtual ~DltLogServer() = default; // Not possible to mock LogParser currently. // LCOV_EXCL_START - void add_handlers(ILogParser& parser) + void AddHandlers(ILogParser& parser) { - parser.add_global_handler(*sysedr_handler_); - parser.add_type_handler(PERSISTENT_REQUEST_TYPE_NAME, *sysedr_handler_); + parser.AddGlobalHandler(*sysedr_handler_); + parser.AddTypeHandler(kPersistentRequestTypeName, *sysedr_handler_); - if (dltOutputEnabled_) + if (dlt_output_enabled_) { // XXX only add handler for those which are accepted - parser.add_global_handler(nvhandler_); - parser.add_type_handler(LOG_ENTRY_TYPE_NAME, vhandler_); - parser.add_type_handler(FILE_TRANSFER_TYPE_NAME, fthandler); + parser.AddGlobalHandler(nvhandler_); + parser.AddTypeHandler(kLogEntryTypeName, vhandler_); + parser.AddTypeHandler(kFileTransferTypeName, fthandler_); } } - void update_handlers(ILogParser& parser, bool enabled) + void UpdateHandlers(ILogParser& parser, bool enabled) { // protected by external mutex if (enabled) { - parser.add_global_handler(nvhandler_); - parser.add_type_handler(LOG_ENTRY_TYPE_NAME, vhandler_); - parser.add_type_handler(FILE_TRANSFER_TYPE_NAME, fthandler); + parser.AddGlobalHandler(nvhandler_); + parser.AddTypeHandler(kLogEntryTypeName, vhandler_); + parser.AddTypeHandler(kFileTransferTypeName, fthandler_); } else { - parser.remove_global_handler(nvhandler_); - parser.remove_type_handler(LOG_ENTRY_TYPE_NAME, vhandler_); - parser.remove_type_handler(FILE_TRANSFER_TYPE_NAME, fthandler); + parser.RemoveGlobalHandler(nvhandler_); + parser.RemoveTypeHandler(kLogEntryTypeName, vhandler_); + parser.RemoveTypeHandler(kFileTransferTypeName, fthandler_); } } // LCOV_EXCL_STOP - void set_enabled_callback(EnabledCallback enabledCallback = EnabledCallback()) + void SetEnabledCallback(EnabledCallback enabled_callback = EnabledCallback()) { - enabledCallback_ = enabledCallback; + enabled_callback_ = enabled_callback; } - void update_handlers_final(bool enabled) + void UpdateHandlersFinal(bool enabled) { // protected by external mutex - dltOutputEnabled_ = enabled; + dlt_output_enabled_ = enabled; } - void flush() + void Flush() { for (auto& channel : channels_) { - channel.flush(); + channel.Flush(); } } - double get_quota(std::string name) + double GetQuota(std::string name) { - auto quota = throughput_apps_.find(dltid_t(name)); + auto quota = throughput_apps_.find(DltidT(name)); return quota == throughput_apps_.end() ? 1.0 : quota->second; } - bool getQuotaEnforcementEnabled() const + bool GetQuotaEnforcementEnabled() const { - return staticConfig_.quotaEnforcementEnabled; + return static_config_.quota_enforcement_enabled; } - SessionPtr new_config_session(score::platform::datarouter::ConfigSessionHandleType handle) + SessionPtr NewConfigSession(score::platform::datarouter::ConfigSessionHandleType handle) { return score::platform::datarouter::DynamicConfigurationHandlerFactoryType().CreateConfigSession( - std::move(handle), make_config_command_handler()); + std::move(handle), MakeConfigCommandHandler()); } // Provide a delegate to handle config commands without exposing private methods - ConfigCommandHandler make_config_command_handler() + ConfigCommandHandler MakeConfigCommandHandler() { return [this](const std::string& command) { - return on_config_command(command); + return OnConfigCommand(command); }; } // LCOV_EXCL_START : not possible to test log info output template - void show_channel_statistics(uint16_t series_num, Logger& stats_logger_) + void ShowChannelStatistics(uint16_t series_num, Logger& stats_logger) { - stats_logger_.LogInfo() << "log stat for the channels #" << series_num; + stats_logger.LogInfo() << "log stat for the channels #" << series_num; for (auto& dltlogchannel : channels_) { - dltlogchannel.show_stats(stats_logger_); + dltlogchannel.ShowStats(stats_logger); } } // LCOV_EXCL_STOP bool GetDltEnabled() const noexcept; - const std::string ReadLogChannelNames() override; - const std::string ResetToDefault() override; - const std::string StoreDltConfig() override; - const std::string SetTraceState() override; - const std::string SetDefaultTraceState() override; - const std::string SetLogChannelThreshold(dltid_t channel, loglevel_t threshold) override; - const std::string SetLogLevel(dltid_t appId, dltid_t ctxId, threshold_t threshold) override; - const std::string SetMessagingFilteringState(bool enabled) override; - const std::string SetDefaultLogLevel(loglevel_t level) override; - const std::string SetLogChannelAssignment(dltid_t appId, - dltid_t ctxId, - dltid_t channel, - AssignmentAction assignment_flag) override; - const std::string SetDltOutputEnable(bool enable) override; + std::string ReadLogChannelNames() override; + std::string ResetToDefault() override; + std::string StoreDltConfig() override; + std::string SetTraceState() override; + std::string SetDefaultTraceState() override; + std::string SetLogChannelThreshold(DltidT channel, LoglevelT threshold) override; + std::string SetLogLevel(DltidT app_id, DltidT ctx_id, ThresholdT threshold) override; + std::string SetMessagingFilteringState(bool enabled) override; + std::string SetDefaultLogLevel(LoglevelT level) override; + std::string SetLogChannelAssignment(DltidT app_id, + DltidT ctx_id, + DltidT channel, + AssignmentAction assignment_flag) override; + std::string SetDltOutputEnable(bool enable) override; // This is used for test purpose only in google tests, to have an access to the private members. // Do not use this calls in implementation except unit tests. class DltLogServerTest; private: - using key_t = std::pair; + using KeyT = std::pair; - struct key_hash + struct KeyHash { public: - std::size_t operator()(const key_t& k) const + std::size_t operator()(const KeyT& k) const { auto low = static_cast(k.first.value); auto high = static_cast(k.second.value) << 32; @@ -223,23 +223,23 @@ class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOut } }; - using channelmask_t = std::bitset<32>; + using ChannelmaskT = std::bitset<32>; template - void filterAndCall(dltid_t appId, dltid_t ctxId, mw::log::LogLevel logLevel, F f) + void FilterAndCall(DltidT app_id, DltidT ctx_id, mw::log::LogLevel log_level, F f) { - channelmask_t assigned; + ChannelmaskT assigned; { - std::lock_guard lock(configMutex_); - if (!isAcceptedByFiltering(appId, ctxId, logLevel)) + std::lock_guard lock(config_mutex_); + if (!IsAcceptedByFiltering(app_id, ctx_id, log_level)) { return; } - assigned = assignedToChannels(appId, ctxId); + assigned = AssignedToChannels(app_id, ctx_id); } if (assigned.none()) { - f(channels_[defaultChannel_]); + f(channels_[default_channel_]); } else { @@ -254,15 +254,15 @@ class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOut } template - static std::optional findInKeyMap(const KeyMap& m, dltid_t appId, dltid_t ctxId) + static std::optional FindInKeyMap(const KeyMap& m, DltidT app_id, DltidT ctx_id) { - auto p = m.find({appId, ctxId}); + auto p = m.find({app_id, ctx_id}); if (p == m.end()) { - p = m.find({dltid_t{}, ctxId}); + p = m.find({DltidT{}, ctx_id}); if (p == m.end()) { - p = m.find({appId, dltid_t{}}); + p = m.find({app_id, DltidT{}}); } } if (p == m.end()) @@ -276,47 +276,47 @@ class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOut } // should be called under the mutex - bool isAcceptedByFiltering(const dltid_t appId, const dltid_t ctxId, const mw::log::LogLevel logLevel) + bool IsAcceptedByFiltering(const DltidT app_id, const DltidT ctx_id, const mw::log::LogLevel log_level) { - if (!filteringEnabled_) + if (!filtering_enabled_) { return true; } - const auto threshold = findInKeyMap(messageThresholds_, appId, ctxId).value_or(defaultThreshold_); - return logLevel <= threshold; + const auto threshold = FindInKeyMap(message_thresholds_, app_id, ctx_id).value_or(default_threshold_); + return log_level <= threshold; } // should be called under the mutex - channelmask_t assignedToChannels(dltid_t appId, dltid_t ctxId) + ChannelmaskT AssignedToChannels(DltidT app_id, DltidT ctx_id) { - return findInKeyMap(channelAssignments_, appId, ctxId).value_or(channelmask_t{}); + return FindInKeyMap(channel_assignments_, app_id, ctx_id).value_or(ChannelmaskT{}); } - std::mutex configMutex_; + std::mutex config_mutex_; - bool filteringEnabled_; - bool dltOutputEnabled_; + bool filtering_enabled_; + bool dlt_output_enabled_; - loglevel_t defaultThreshold_; - std::unordered_map messageThresholds_; - std::unordered_map channelAssignments_; + LoglevelT default_threshold_; + std::unordered_map message_thresholds_; + std::unordered_map channel_assignments_; double throughput_overall_; - std::unordered_map throughput_apps_; + std::unordered_map throughput_apps_; - StaticConfig staticConfig_; + StaticConfig static_config_; std::vector channels_; - size_t defaultChannel_; - std::optional coredumpChannel_; - std::unordered_map channelNums_; + size_t default_channel_; + std::optional coredump_channel_; + std::unordered_map channel_nums_; score::platform::datarouter::DltNonverboseHandlerType nvhandler_; DltVerboseHandler vhandler_; - FileTransferStreamHandlerType fthandler; - EnabledCallback enabledCallback_; - ConfigReadCallback readerCallback_; - ConfigWriteCallback writerCallback_; + FileTransferStreamHandlerType fthandler_; + EnabledCallback enabled_callback_; + ConfigReadCallback reader_callback_; + ConfigWriteCallback writer_callback_; std::unique_ptr log_sender_; std::unique_ptr parser_; @@ -326,29 +326,29 @@ class DltLogServer : score::platform::datarouter::DltNonverboseHandlerType::IOut uint32_t tmsp, const void* data, size_t size) override final; - void sendVerbose( + void SendVerbose( uint32_t tmsp, const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection& entry) override final; void SendFtVerbose(score::cpp::span data, mw::log::LogLevel loglevel, - dltid_t appId, - dltid_t ctxId, + DltidT app_id, + DltidT ctx_id, uint8_t nor, uint32_t tmsp) override final; - void init_log_channels(const bool reloading = false); - void init_log_channels_default(const bool reloading = false); + void InitLogChannels(const bool reloading = false); + void InitLogChannelsDefault(const bool reloading = false); - void save_database(); - void clear_database(); + void SaveDatabase(); + void ClearDatabase(); - void set_output_enabled(const bool enabled); + void SetOutputEnabled(const bool enabled); - const std::string on_config_command(const std::string& command); + std::string OnConfigCommand(const std::string& command); }; } // namespace dltserver } // namespace logging } // namespace score -#endif // DLT_LOG_SERVER_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_DLT_LOG_SERVER_H diff --git a/score/datarouter/include/daemon/dlt_log_server_config.h b/score/datarouter/include/daemon/dlt_log_server_config.h index e2b2238..73481c8 100644 --- a/score/datarouter/include/daemon/dlt_log_server_config.h +++ b/score/datarouter/include/daemon/dlt_log_server_config.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef DLT_LOG_SERVER_CONFIG_H_ -#define DLT_LOG_SERVER_CONFIG_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_DLT_LOG_SERVER_CONFIG_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_DLT_LOG_SERVER_CONFIG_H #include "daemon/dltserver_common.h" #include "score/mw/log/log_level.h" @@ -27,57 +27,57 @@ namespace logging namespace dltserver { -using loglevel_t = mw::log::LogLevel; +using LoglevelT = mw::log::LogLevel; struct StaticConfig { struct ChannelDescription { - dltid_t ecu; + DltidT ecu; std::string address; uint16_t port = 0U; - std::string dstAddress; - uint16_t dstPort = 0U; + std::string dst_address; + uint16_t dst_port = 0U; - loglevel_t channelThreshold = loglevel_t::kOff; - std::string multicastInterface; + LoglevelT channel_threshold = LoglevelT::kOff; + std::string multicast_interface; }; struct ThroughputQuotas { - double overallMbps; - std::unordered_map applicationsKbps; + double overall_mbps; + std::unordered_map applications_kbps; }; - dltid_t coredumpChannel; - dltid_t defaultChannel; - std::unordered_map channels; + DltidT coredump_channel; + DltidT default_channel; + std::unordered_map channels; - bool filteringEnabled = false; - loglevel_t defaultThreshold = loglevel_t::kOff; - std::unordered_map>> channelAssignments; - std::unordered_map> messageThresholds; + bool filtering_enabled = false; + LoglevelT default_threshold = LoglevelT::kOff; + std::unordered_map>> channel_assignments; + std::unordered_map> message_thresholds; ThroughputQuotas throughput; - bool quotaEnforcementEnabled; + bool quota_enforcement_enabled; }; struct PersistentConfig { struct ChannelDescription { - loglevel_t channelThreshold = loglevel_t::kOff; + LoglevelT channel_threshold = LoglevelT::kOff; }; std::unordered_map channels; - bool filteringEnabled = false; - loglevel_t defaultThreshold = loglevel_t::kOff; - std::unordered_map>> channelAssignments; - std::unordered_map> messageThresholds; + bool filtering_enabled = false; + LoglevelT default_threshold = LoglevelT::kOff; + std::unordered_map>> channel_assignments; + std::unordered_map> message_thresholds; }; } // namespace dltserver } // namespace logging } // namespace score -#endif // DLT_LOG_SERVER_CONFIG_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_DLT_LOG_SERVER_CONFIG_H diff --git a/score/datarouter/include/daemon/dltserver_common.h b/score/datarouter/include/daemon/dltserver_common.h index fd6db6d..85f7781 100644 --- a/score/datarouter/include/daemon/dltserver_common.h +++ b/score/datarouter/include/daemon/dltserver_common.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef DLTSERVER_COMMON_H -#define DLTSERVER_COMMON_H +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_DLTSERVER_COMMON_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_DLTSERVER_COMMON_H #include "dlt/dltid.h" #include "logparser/logparser.h" @@ -24,9 +24,9 @@ namespace logging namespace dltserver { -using score::platform::bufsize_t; -using score::platform::dltid_t; -using score::platform::timestamp_t; +using score::platform::BufsizeT; +using score::platform::DltidT; +using score::platform::TimestampT; using score::platform::TypeInfo; using score::platform::internal::LogParser; @@ -34,4 +34,4 @@ using score::platform::internal::LogParser; } // namespace logging } // namespace score -#endif // DLTSERVER_COMMON_H +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_DLTSERVER_COMMON_H diff --git a/score/datarouter/include/daemon/i_diagnostic_job_handler.h b/score/datarouter/include/daemon/i_diagnostic_job_handler.h index 5a79c84..ef18755 100644 --- a/score/datarouter/include/daemon/i_diagnostic_job_handler.h +++ b/score/datarouter/include/daemon/i_diagnostic_job_handler.h @@ -29,7 +29,7 @@ namespace dltserver class IDiagnosticJobHandler { public: - virtual const std::string execute(IDltLogServer& srv) = 0; + virtual std::string Execute(IDltLogServer& srv) = 0; virtual ~IDiagnosticJobHandler() = default; }; diff --git a/score/datarouter/include/daemon/i_diagnostic_job_parser.h b/score/datarouter/include/daemon/i_diagnostic_job_parser.h index a3f1d23..900b5b2 100644 --- a/score/datarouter/include/daemon/i_diagnostic_job_parser.h +++ b/score/datarouter/include/daemon/i_diagnostic_job_parser.h @@ -32,7 +32,7 @@ class IDiagnosticJobHandler; // Forward Declaration class IDiagnosticJobParser { public: - virtual std::unique_ptr parse(const std::string& command) = 0; + virtual std::unique_ptr Parse(const std::string& command) = 0; virtual ~IDiagnosticJobParser() = default; }; diff --git a/score/datarouter/include/daemon/i_dlt_log_server.h b/score/datarouter/include/daemon/i_dlt_log_server.h index 2012b41..c4ea642 100644 --- a/score/datarouter/include/daemon/i_dlt_log_server.h +++ b/score/datarouter/include/daemon/i_dlt_log_server.h @@ -26,39 +26,39 @@ namespace logging namespace dltserver { -using loglevel_t = mw::log::LogLevel; +using LoglevelT = mw::log::LogLevel; enum class ThresholdCmd : std::uint8_t { - UseDefault = 0xFF + kUseDefault = 0xFF }; -using threshold_t = std::variant; +using ThresholdT = std::variant; enum class AssignmentAction : std::uint8_t { - Remove = 0, - Add = config::DLT_ASSIGN_ADD + kRemove = 0, + kAdd = config::kDltAssignAdd }; // This class is responsible for providing an interface for diagnostic job handling class IDltLogServer { public: - virtual const std::string ReadLogChannelNames() = 0; - virtual const std::string ResetToDefault() = 0; - virtual const std::string StoreDltConfig() = 0; - virtual const std::string SetTraceState() = 0; - virtual const std::string SetDefaultTraceState() = 0; - virtual const std::string SetLogChannelThreshold(score::platform::dltid_t channel, loglevel_t threshold) = 0; - virtual const std::string SetLogLevel(score::platform::dltid_t appId, - score::platform::dltid_t ctxId, - threshold_t threshold) = 0; - virtual const std::string SetMessagingFilteringState(bool enabled) = 0; - virtual const std::string SetDefaultLogLevel(loglevel_t level) = 0; - virtual const std::string SetLogChannelAssignment(score::platform::dltid_t appId, - score::platform::dltid_t ctxId, - score::platform::dltid_t channel, - AssignmentAction assignment_flag) = 0; - virtual const std::string SetDltOutputEnable(bool enable) = 0; + virtual std::string ReadLogChannelNames() = 0; + virtual std::string ResetToDefault() = 0; + virtual std::string StoreDltConfig() = 0; + virtual std::string SetTraceState() = 0; + virtual std::string SetDefaultTraceState() = 0; + virtual std::string SetLogChannelThreshold(score::platform::DltidT channel, LoglevelT threshold) = 0; + virtual std::string SetLogLevel(score::platform::DltidT app_id, + score::platform::DltidT ctx_id, + ThresholdT threshold) = 0; + virtual std::string SetMessagingFilteringState(bool enabled) = 0; + virtual std::string SetDefaultLogLevel(LoglevelT level) = 0; + virtual std::string SetLogChannelAssignment(score::platform::DltidT app_id, + score::platform::DltidT ctx_id, + score::platform::DltidT channel, + AssignmentAction assignment_flag) = 0; + virtual std::string SetDltOutputEnable(bool enable) = 0; virtual ~IDltLogServer() = default; }; diff --git a/score/datarouter/include/daemon/i_log_sender.h b/score/datarouter/include/daemon/i_log_sender.h index 216ed9c..0a42839 100644 --- a/score/datarouter/include/daemon/i_log_sender.h +++ b/score/datarouter/include/daemon/i_log_sender.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef I_LOG_SENDER_H_ -#define I_LOG_SENDER_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_I_LOG_SENDER_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_I_LOG_SENDER_H #include "score/mw/log/log_level.h" #include "score/datarouter/include/daemon/dlt_log_channel.h" @@ -42,8 +42,8 @@ class ILogSender DltLogChannel& c) = 0; virtual void SendFTVerbose(score::cpp::span data, mw::log::LogLevel loglevel, - dltid_t appId, - dltid_t ctxId, + DltidT app_id, + DltidT ctx_id, uint8_t nor, uint32_t tmsp, DltLogChannel& c) = 0; @@ -54,4 +54,4 @@ class ILogSender } // namespace logging } // namespace score -#endif // I_LOG_SENDER_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_I_LOG_SENDER_H diff --git a/score/datarouter/include/daemon/log_entry_deserialization_visitor.h b/score/datarouter/include/daemon/log_entry_deserialization_visitor.h index a4c5582..9d667ac 100644 --- a/score/datarouter/include/daemon/log_entry_deserialization_visitor.h +++ b/score/datarouter/include/daemon/log_entry_deserialization_visitor.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_LOG_ENTRY_DESERIALIZATION_VISITOR_H_ -#define SCORE_DATAROUTER_INCLUDE_DAEMON_LOG_ENTRY_DESERIALIZATION_VISITOR_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_LOG_ENTRY_DESERIALIZATION_VISITOR_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_LOG_ENTRY_DESERIALIZATION_VISITOR_H #include "score/mw/log/detail/common/log_entry_deserialize.h" #include "static_reflection_with_serialization/serialization/for_logging.h" @@ -26,6 +26,9 @@ namespace visitor namespace dlt_server_logging = ::score::mw::log::detail::log_entry_deserialization; +// NOLINTBEGIN(readability-identifier-naming): follow naming convention in visit.h and for_logging.h under the +// score::common::visitor namespace + // Design rationale: It was decided to provide overload of the custom type i.e. SerializedVectorData instead of generic // solution due to simplicity of implementation. The goal of the change is to optimize passing data as pointer to // shared memory data instead of allocating and passing it through std::vector which happens when using default @@ -37,7 +40,7 @@ inline void deserialize(const vector_serialized& serial, deserializer_helper& a, dlt_server_logging::SerializedVectorData& t) { - using subsize_s_t = const subsize_serialized; + using SubsizeST = const subsize_serialized; typename A::offset_t offset; deserialize(serial.offset, a, offset); if (offset == 0) @@ -46,7 +49,7 @@ inline void deserialize(const vector_serialized& serial, detail::clear(t); return; } - const auto vector_size_location = a.template address(offset); + const auto vector_size_location = a.template address(offset); if (vector_size_location == nullptr) { // error condition already set by a.address() @@ -57,7 +60,7 @@ inline void deserialize(const vector_serialized& serial, deserialize(*vector_size_location, a, subsize); const std::size_t n = subsize / sizeof(S); - const auto vector_contents_offset = static_cast(offset + sizeof(subsize_s_t)); + const auto vector_contents_offset = static_cast(offset + sizeof(SubsizeST)); const S* const vector_contents_address = a.template address(vector_contents_offset, n); if (vector_contents_address == nullptr) { @@ -68,7 +71,7 @@ inline void deserialize(const vector_serialized& serial, // data from series of bytes to C++ structures. This is the crucial place where it is done. // It is safe because the serialization method encodes the length of the payload. // Serialized payload in this case is just a series of elements which have the size of one byte. - const auto vector_data_address = + const auto* const vector_data_address = // coverity[autosar_cpp14_m5_2_8_violation] static_cast(static_cast(vector_contents_address)); t.data = score::cpp::span{vector_data_address, static_cast(n)}; @@ -85,8 +88,10 @@ inline auto visit_as(serialized_visitor& /*unused*/, const T& /*unused*/) return vector_serialized_descriptor(); } +// NOLINTEND(readability-identifier-naming) + } // namespace visitor } // namespace common } // namespace score -#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_LOG_ENTRY_DESERIALIZATION_VISITOR_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_LOG_ENTRY_DESERIALIZATION_VISITOR_H diff --git a/score/datarouter/include/daemon/log_sender.h b/score/datarouter/include/daemon/log_sender.h index 1d6d9af..c144fa4 100644 --- a/score/datarouter/include/daemon/log_sender.h +++ b/score/datarouter/include/daemon/log_sender.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef LOG_SENDER_H_ -#define LOG_SENDER_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_LOG_SENDER_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_LOG_SENDER_H #include "score/datarouter/include/daemon/i_log_sender.h" @@ -36,23 +36,23 @@ class LogSender : public ILogSender size_t size, DltLogChannel& c) override { - c.sendNonVerbose(desc, tmsp, data, size); + c.SendNonVerbose(desc, tmsp, data, size); } void SendVerbose(uint32_t tmsp, const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection& entry, DltLogChannel& c) override { - c.sendVerbose(tmsp, entry); + c.SendVerbose(tmsp, entry); } void SendFTVerbose(score::cpp::span data, mw::log::LogLevel loglevel, - dltid_t appId, - dltid_t ctxId, + DltidT app_id, + DltidT ctx_id, uint8_t nor, uint32_t tmsp, DltLogChannel& c) override { - c.sendFTVerbose(data, loglevel, appId, ctxId, nor, tmsp); + c.SendFtVerbose(data, loglevel, app_id, ctx_id, nor, tmsp); } }; // LCOV_EXCL_STOP @@ -60,4 +60,4 @@ class LogSender : public ILogSender } // namespace logging } // namespace score -#endif // LOG_SENDER_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_LOG_SENDER_H diff --git a/score/datarouter/include/daemon/message_passing_server.h b/score/datarouter/include/daemon/message_passing_server.h index 6693cf1..3cbf55d 100644 --- a/score/datarouter/include/daemon/message_passing_server.h +++ b/score/datarouter/include/daemon/message_passing_server.h @@ -90,10 +90,10 @@ class MessagePassingServer : public IMessagePassingServerSessionWrapper class ISession { public: - virtual bool tick() = 0; - virtual void on_acquire_response(const score::mw::log::detail::ReadAcquireResult&) = 0; - virtual void on_closed_by_peer() = 0; - virtual bool is_source_closed() = 0; + virtual bool Tick() = 0; + virtual void OnAcquireResponse(const score::mw::log::detail::ReadAcquireResult&) = 0; + virtual void OnClosedByPeer() = 0; + virtual bool IsSourceClosed() = 0; virtual ~ISession() = default; }; @@ -117,57 +117,59 @@ class MessagePassingServer : public IMessagePassingServerSessionWrapper void OnConnectRequest(const score::cpp::span message, const pid_t pid); void OnAcquireResponse(const score::cpp::span message, const pid_t pid); - using timestamp_t = std::chrono::steady_clock::time_point; + using TimestampT = std::chrono::steady_clock::time_point; struct SessionWrapper { - SessionWrapper(IMessagePassingServerSessionWrapper* server, pid_t pid, std::unique_ptr session) - : server_(server), - pid_(pid), - session_(std::move(session)), - enqueued_(false), - running_(false), - to_delete_(false), - closed_by_peer_(false), - to_force_finish_(false) + SessionWrapper(IMessagePassingServerSessionWrapper* server_instance, + pid_t process_id, + std::unique_ptr session_instance) + : server(server_instance), + pid(process_id), + session(std::move(session_instance)), + enqueued(false), + running(false), + to_delete(false), + closed_by_peer(false), + to_force_finish(false) { } - void enqueue_for_delete_while_locked(bool by_peer = false); - bool is_marked_for_delete() + void EnqueueForDeleteWhileLocked(bool by_peer = false); + bool IsMarkedForDelete() const { - return to_delete_; + return to_delete; } - bool get_reset_closed_by_peer() + bool GetResetClosedByPeer() { - bool by_peer = closed_by_peer_; - closed_by_peer_ = false; + bool by_peer = closed_by_peer; + closed_by_peer = false; return by_peer; } - bool tick_at_worker_thread(); - void notify_closed_by_peer(); + bool TickAtWorkerThread() const; + void NotifyClosedByPeer() const; - void set_running_while_locked(); - bool reset_running_while_locked(bool requeue); + void SetRunningWhileLocked(); + bool ResetRunningWhileLocked(bool requeue); - void enqueue_tick_while_locked(); + void EnqueueTickWhileLocked(); - inline bool GetIsSourceClosed() + inline bool GetIsSourceClosed() const { - return session_->is_source_closed(); + return session->IsSourceClosed(); } - IMessagePassingServerSessionWrapper* server_; - pid_t pid_; - std::unique_ptr session_; + IMessagePassingServerSessionWrapper* server; + pid_t pid; + std::unique_ptr session; - bool enqueued_; - bool running_; - bool to_delete_; - bool closed_by_peer_; - bool to_force_finish_; + bool enqueued; + bool running; + bool to_delete; + bool closed_by_peer; + bool to_force_finish; }; void FinishPreviousSessionWhileLocked(std::unordered_map::iterator it, @@ -181,7 +183,7 @@ class MessagePassingServer : public IMessagePassingServerSessionWrapper std::mutex mutex_; score::cpp::stop_source stop_source_; - timestamp_t connection_timeout_; + TimestampT connection_timeout_; score::cpp::jthread worker_thread_; std::condition_variable worker_cond_; // to wake up worker thread std::unordered_map pid_session_map_; diff --git a/score/datarouter/include/daemon/persistentlogging_config.h b/score/datarouter/include/daemon/persistentlogging_config.h index 1710712..c63243d 100644 --- a/score/datarouter/include/daemon/persistentlogging_config.h +++ b/score/datarouter/include/daemon/persistentlogging_config.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef PERSISTENTLOGGING_CONFIG_H_ -#define PERSISTENTLOGGING_CONFIG_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_PERSISTENTLOGGING_CONFIG_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_PERSISTENTLOGGING_CONFIG_H #include "dlt/plogfilterdesc.h" @@ -31,24 +31,24 @@ struct PersistentLoggingConfig { enum class ReadResult { - OK, - ERROR_OPEN, - ERROR_PARSE, - ERROR_CONTENT + kOk, + kErrorOpen, + kErrorParse, + kErrorContent }; - ReadResult readResult_ = ReadResult::ERROR_OPEN; - std::vector verboseFilters_; - std::vector nonVerboseFilters_; + ReadResult read_result = ReadResult::kErrorOpen; + std::vector verbose_filters; + std::vector non_verbose_filters; }; -extern const std::string DEFAULT_PERSISTENT_LOGGING_JSON_FILEPATH; +extern const std::string kDefaultPersistentLoggingJsonFilepath; -PersistentLoggingConfig readPersistentLoggingConfig( - const std::string& filePath = DEFAULT_PERSISTENT_LOGGING_JSON_FILEPATH); +PersistentLoggingConfig ReadPersistentLoggingConfig( + const std::string& file_path = kDefaultPersistentLoggingJsonFilepath); } // namespace internal } // namespace platform } // namespace score -#endif // PERSISTENTLOGGING_CONFIG_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_PERSISTENTLOGGING_CONFIG_H diff --git a/score/datarouter/include/daemon/socketserver.h b/score/datarouter/include/daemon/socketserver.h index 23a6e3a..bd73ef0 100644 --- a/score/datarouter/include/daemon/socketserver.h +++ b/score/datarouter/include/daemon/socketserver.h @@ -75,10 +75,10 @@ class SocketServer bool is_dlt_enabled; }; - static void run(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime) + static void Run(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime) { static SocketServer server; - server.doWork(exit_requested, no_adaptive_runtime); + server.DoWork(exit_requested, no_adaptive_runtime); } // static void run(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime); @@ -133,7 +133,7 @@ class SocketServer const std::string& appid); private: - void doWork(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime); + void DoWork(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime); }; } // namespace datarouter diff --git a/score/datarouter/include/daemon/socketserver_config.h b/score/datarouter/include/daemon/socketserver_config.h index 43433f3..e26d6ad 100644 --- a/score/datarouter/include/daemon/socketserver_config.h +++ b/score/datarouter/include/daemon/socketserver_config.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SOCKETSERVER_CONFIG_H_ -#define SOCKETSERVER_CONFIG_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_SOCKETSERVER_CONFIG_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_SOCKETSERVER_CONFIG_H #include "daemon/dlt_log_server_config.h" #include "score/datarouter/src/persistency/i_persistent_dictionary.h" @@ -26,15 +26,15 @@ namespace platform namespace datarouter { -score::Result readStaticDlt(const char* path); -score::logging::dltserver::PersistentConfig readDlt(IPersistentDictionary& pd); -void writeDlt(const score::logging::dltserver::PersistentConfig& config, IPersistentDictionary& pd); +score::Result ReadStaticDlt(const char* path); +score::logging::dltserver::PersistentConfig ReadDlt(IPersistentDictionary& pd); +void WriteDlt(const score::logging::dltserver::PersistentConfig& config, IPersistentDictionary& pd); -bool readDltEnabled(IPersistentDictionary& pd); -void writeDltEnabled(bool enabled, IPersistentDictionary& pd); +bool ReadDltEnabled(IPersistentDictionary& pd); +void WriteDltEnabled(bool enabled, IPersistentDictionary& pd); } // namespace datarouter } // namespace platform } // namespace score -#endif // SOCKETSERVER_CONFIG_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_SOCKETSERVER_CONFIG_H diff --git a/score/datarouter/include/daemon/socketserver_filter_factory.h b/score/datarouter/include/daemon/socketserver_filter_factory.h index 2894547..5350908 100644 --- a/score/datarouter/include/daemon/socketserver_filter_factory.h +++ b/score/datarouter/include/daemon/socketserver_filter_factory.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SOCKETSERVER_FILTER_FACTORY_H_ -#define SOCKETSERVER_FILTER_FACTORY_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_SOCKETSERVER_FILTER_FACTORY_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_SOCKETSERVER_FILTER_FACTORY_H #include "logparser/logparser.h" @@ -23,10 +23,10 @@ namespace platform namespace datarouter { -internal::LogParser::FilterFunctionFactory getFilterFactory(); +internal::LogParser::FilterFunctionFactory GetFilterFactory(); } // namespace datarouter } // namespace platform } // namespace score -#endif // SOCKETSERVER_FILTER_FACTORY_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_SOCKETSERVER_FILTER_FACTORY_H diff --git a/score/datarouter/include/daemon/socketserver_json_helpers.h b/score/datarouter/include/daemon/socketserver_json_helpers.h index 37391b3..bc831ff 100644 --- a/score/datarouter/include/daemon/socketserver_json_helpers.h +++ b/score/datarouter/include/daemon/socketserver_json_helpers.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SOCKETSERVER_JSON_HELPERS_H_ -#define SOCKETSERVER_JSON_HELPERS_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_SOCKETSERVER_JSON_HELPERS_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_SOCKETSERVER_JSON_HELPERS_H #include @@ -23,7 +23,7 @@ namespace platform namespace datarouter { -inline rapidjson::Document createRJDocument() +inline rapidjson::Document CreateRjDocument() { // This value is equal to rapidjson::Document::kDefaultStackCapacity, but cannot be referenced // directly because it is declared as private. It is needed because the constructor for @@ -32,15 +32,15 @@ inline rapidjson::Document createRJDocument() // the stackCapacity is the middle parameter, so we cannot rely on its default value if we // specify the third argument as nullptr. As a result, we need to supply a value for // stackCapacity, even though the default value is okay for our use. - constexpr size_t RAPIDJSON_DEFAULT_STACK_CAPACITY = 1024U; + constexpr size_t kRapidjsonDefaultStackCapacity = 1024U; - return rapidjson::Document(nullptr, RAPIDJSON_DEFAULT_STACK_CAPACITY, nullptr); + return rapidjson::Document(nullptr, kRapidjsonDefaultStackCapacity, nullptr); } -constexpr size_t JSON_READ_BUFFER_SIZE = 65536U; +constexpr size_t kJsonReadBufferSize = 65536U; } // namespace datarouter } // namespace platform } // namespace score -#endif // SOCKETSERVER_JSON_HELPERS_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_SOCKETSERVER_JSON_HELPERS_H diff --git a/score/datarouter/include/daemon/udp_stream_output.h b/score/datarouter/include/daemon/udp_stream_output.h index 7af761f..585a1bc 100644 --- a/score/datarouter/include/daemon/udp_stream_output.h +++ b/score/datarouter/include/daemon/udp_stream_output.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef UDP_STREAM_OUTPUT_H_ -#define UDP_STREAM_OUTPUT_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_UDP_STREAM_OUTPUT_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_UDP_STREAM_OUTPUT_H #include "score/os/pthread.h" #include "score/os/socket_impl.h" @@ -39,9 +39,9 @@ namespace dltserver class UdpStreamOutput { public: - UdpStreamOutput(const char* dstAddr, - uint16_t dstPort, - const char* multicastInterface, + UdpStreamOutput(const char* dst_addr, + uint16_t dst_port, + const char* multicast_interface, std::unique_ptr socket_instance = std::make_unique(), score::os::Vlan& vlan = score::os::Vlan::instance()); @@ -49,12 +49,12 @@ class UdpStreamOutput UdpStreamOutput(const UdpStreamOutput&) = delete; UdpStreamOutput(UdpStreamOutput&& from) noexcept; - score::cpp::expected_blank bind(const char* srcAddr = nullptr, uint16_t srcPort = 0) noexcept; + score::cpp::expected_blank Bind(const char* src_addr = nullptr, uint16_t src_port = 0) noexcept; - score::cpp::expected send(score::cpp::span mmsg) noexcept; + score::cpp::expected Send(score::cpp::span mmsg) noexcept; // Used to send single big message: - score::cpp::expected send(const iovec* iovec_tab, const size_t size) noexcept; + score::cpp::expected Send(const iovec* iovec_tab, const size_t size) noexcept; private: int socket_; @@ -67,4 +67,4 @@ class UdpStreamOutput } // namespace logging } // namespace score -#endif // UDP_STREAM_OUTPUT_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_UDP_STREAM_OUTPUT_H diff --git a/score/datarouter/include/daemon/utility.h b/score/datarouter/include/daemon/utility.h index 0329bb7..a5ba7e1 100644 --- a/score/datarouter/include/daemon/utility.h +++ b/score/datarouter/include/daemon/utility.h @@ -23,7 +23,7 @@ namespace logging_daemon namespace logchannel_utility { -score::mw::log::LogLevel ToLogLevel(const std::string& logLevel); +score::mw::log::LogLevel ToLogLevel(const std::string& log_level); std::string ToString(const score::mw::log::LogLevel level); diff --git a/score/datarouter/include/daemon/verbose_dlt.h b/score/datarouter/include/daemon/verbose_dlt.h index 5255313..c053035 100644 --- a/score/datarouter/include/daemon/verbose_dlt.h +++ b/score/datarouter/include/daemon/verbose_dlt.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef VERBOSE_DLT_H_ -#define VERBOSE_DLT_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DAEMON_VERBOSE_DLT_H +#define SCORE_DATAROUTER_INCLUDE_DAEMON_VERBOSE_DLT_H #include "dlt/logentry_trace.h" #include "logparser/logparser.h" @@ -35,7 +35,7 @@ class DltVerboseHandler : public LogParser::TypeHandler class IOutput { public: - virtual void sendVerbose( + virtual void SendVerbose( uint32_t tmsp, const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection& entry) = 0; @@ -46,7 +46,7 @@ class DltVerboseHandler : public LogParser::TypeHandler : LogParser::TypeHandler(), logger_(score::mw::log::CreateLogger("vL", "Verbose logging")), output_(output) { } - virtual void handle(timestamp_t timestamp, const char* data, bufsize_t size) override; + virtual void Handle(TimestampT timestamp, const char* data, BufsizeT size) override; private: score::mw::log::Logger& logger_; @@ -57,4 +57,4 @@ class DltVerboseHandler : public LogParser::TypeHandler } // namespace logging } // namespace score -#endif // VERBOSE_DLT_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DAEMON_VERBOSE_DLT_H diff --git a/score/datarouter/include/dlt/dlt_common.h b/score/datarouter/include/dlt/dlt_common.h index 93a67ee..f800402 100644 --- a/score/datarouter/include/dlt/dlt_common.h +++ b/score/datarouter/include/dlt/dlt_common.h @@ -26,8 +26,8 @@ Initials Date Comment aw 13.01.2010 initial */ -#ifndef DLT_COMMON_H -#define DLT_COMMON_H +#ifndef SCORE_DATAROUTER_INCLUDE_DLT_DLT_COMMON_H +#define SCORE_DATAROUTER_INCLUDE_DLT_DLT_COMMON_H /** \defgroup commonapi DLT Common API @@ -173,4 +173,4 @@ typedef struct #endif // NOLINTEND(score-banned-preprocessor-directives) -#endif /* DLT_COMMON_H */ +#endif // SCORE_DATAROUTER_INCLUDE_DLT_DLT_COMMON_H diff --git a/score/datarouter/include/dlt/dlt_headers.h b/score/datarouter/include/dlt/dlt_headers.h index 3368ba9..91f31d4 100644 --- a/score/datarouter/include/dlt/dlt_headers.h +++ b/score/datarouter/include/dlt/dlt_headers.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef DLT_HEADERS_H_ -#define DLT_HEADERS_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DLT_DLT_HEADERS_H +#define SCORE_DATAROUTER_INCLUDE_DLT_DLT_HEADERS_H #include "dlt/dlt_common.h" #include "score/mw/log/detail/common/log_entry_deserialize.h" @@ -26,7 +26,7 @@ namespace platform namespace internal { -static constexpr uint32_t DLT_MESSAGE_SIZE = 65536UL; +static constexpr uint32_t kDltMessageSize = 65536UL; // NOLINTBEGIN(score-banned-preprocessor-directives) see below /** @@ -99,28 +99,28 @@ inline void ConstructDltStandardHeader(DltStandardHeader& std, size_t msg_size, std.mcnt = mcnt; std.len = DLT_HTOBE_16(msg_size); } -inline void ConstructDltStandardHeaderExtra(DltStandardHeaderExtra& stde, dltid_t ecu, uint32_t tmsp) +inline void ConstructDltStandardHeaderExtra(DltStandardHeaderExtra& stde, DltidT ecu, uint32_t tmsp) { - std::copy_n(ecu.data(), std::min(ecu.size(), sizeof(stde.ecu)), static_cast(stde.ecu)); + std::copy_n(ecu.Data(), std::min(ecu.size(), sizeof(stde.ecu)), static_cast(stde.ecu)); stde.tmsp = DLT_HTOBE_32(tmsp); } inline void ConstructDltExtendedHeader(DltExtendedHeader& ext, const mw::log::LogLevel loglevel, uint8_t nor, - dltid_t appId, - dltid_t ctxId) + DltidT app_id, + DltidT ctx_id) { ext.msin = static_cast((DLT_TYPE_LOG << DLT_MSIN_MSTP_SHIFT) | (static_cast(loglevel) << DLT_MSIN_MTIN_SHIFT) | (DLT_MSIN_VERB)); ext.noar = nor; - std::copy_n(appId.data(), sizeof(ext.apid), static_cast(ext.apid)); - std::copy_n(ctxId.data(), sizeof(ext.ctid), static_cast(ext.ctid)); + std::copy_n(app_id.Data(), sizeof(ext.apid), static_cast(ext.apid)); + std::copy_n(ctx_id.Data(), sizeof(ext.ctid), static_cast(ext.ctid)); } inline void ConstructStorageVerbosePacket(uint8_t* dlt_message, const score::mw::log::detail::LogEntry& entry, - dltid_t ecu, + DltidT ecu, uint8_t mcnt, uint32_t tmsp, uint32_t secs, @@ -128,7 +128,7 @@ inline void ConstructStorageVerbosePacket(uint8_t* dlt_message, { // truncate the message to max size if the msg size is exceeding the available buffer size size_t size = - std::min(entry.payload.size(), DLT_MESSAGE_SIZE - (sizeof(DltStorageHeader) + sizeof(DltVerboseHeader))); + std::min(entry.payload.size(), kDltMessageSize - (sizeof(DltStorageHeader) + sizeof(DltVerboseHeader))); auto& storagehdr = *static_cast(static_cast(dlt_message)); ConstructDltStorageHeader(storagehdr, secs, microsecs); auto& hdr = *static_cast(static_cast(std::next( @@ -139,8 +139,8 @@ inline void ConstructStorageVerbosePacket(uint8_t* dlt_message, ConstructDltExtendedHeader(hdr.ext, entry.log_level, static_cast(entry.num_of_args), - platform::convertToDltId(entry.app_id), - platform::convertToDltId(entry.ctx_id)); + platform::ConvertToDltId(entry.app_id), + platform::ConvertToDltId(entry.ctx_id)); // avoid signed/unsigned comparison warning in std::next const auto offset = static_cast::difference_type>( sizeof(DltStorageHeader) + sizeof(DltVerboseHeader)); @@ -150,32 +150,32 @@ inline void ConstructStorageVerbosePacket(uint8_t* dlt_message, inline uint32_t ConstructVerboseHeader( DltVerboseHeader& header, const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection& entry, - dltid_t ecu, + DltidT ecu, uint8_t mcnt, uint32_t tmsp) { size_t payload_size = std::min(static_cast(entry.GetPayload().size()), - static_cast(DLT_MESSAGE_SIZE - sizeof(DltVerboseHeader))); + static_cast(kDltMessageSize - sizeof(DltVerboseHeader))); ConstructDltStandardHeader(header.std, (sizeof(DltVerboseHeader) + payload_size), mcnt, true); ConstructDltStandardHeaderExtra(header.stde, ecu, tmsp); ConstructDltExtendedHeader(header.ext, entry.log_level, static_cast(entry.num_of_args), - platform::convertToDltId(entry.app_id), - platform::convertToDltId(entry.ctx_id)); + platform::ConvertToDltId(entry.app_id), + platform::ConvertToDltId(entry.ctx_id)); return sizeof(DltVerboseHeader); } inline void ConstructVerbosePacket( char* dlt_message, const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection& entry, - dltid_t ecu, + DltidT ecu, uint8_t mcnt, uint32_t tmsp) { // truncate the message to max size if the msg size is exceeding the available buffer size const auto data_size = static_cast(entry.GetPayload().size()); - std::size_t size = std::min(data_size, DLT_MESSAGE_SIZE - sizeof(DltVerboseHeader)); + std::size_t size = std::min(data_size, kDltMessageSize - sizeof(DltVerboseHeader)); // autosar_cpp14_m5_2_8_violation : No harm from casting void pointer // coverity[autosar_cpp14_m5_2_8_violation] auto& hdr = *static_cast(static_cast(dlt_message)); @@ -191,7 +191,7 @@ inline void ConstructVerbosePacket( inline uint32_t ConstructNonVerboseHeader(DltNvHeaderWithMsgid& hdr, size_t size, uint32_t msgid, - dltid_t ecu, + DltidT ecu, uint8_t mcnt, uint32_t tmsp) { @@ -205,7 +205,7 @@ inline void ConstructNonVerbosePacket(char* dlt_message, const void* data, size_t size, uint32_t msgid, - dltid_t ecu, + DltidT ecu, uint8_t mcnt, uint32_t tmsp) { @@ -223,4 +223,4 @@ inline void ConstructNonVerbosePacket(char* dlt_message, } // namespace platform } // namespace score -#endif // DLT_HEADERS_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DLT_DLT_HEADERS_H diff --git a/score/datarouter/include/dlt/dlt_protocol.h b/score/datarouter/include/dlt/dlt_protocol.h index 0d2409b..85189bc 100644 --- a/score/datarouter/include/dlt/dlt_protocol.h +++ b/score/datarouter/include/dlt/dlt_protocol.h @@ -26,8 +26,8 @@ Initials Date Comment aw 13.01.2010 initial */ -#ifndef DLT_PROTOCOL_H -#define DLT_PROTOCOL_H +#ifndef SCORE_DATAROUTER_INCLUDE_DLT_DLT_PROTOCOL_H +#define SCORE_DATAROUTER_INCLUDE_DLT_DLT_PROTOCOL_H #include "dlt/dlt_common.h" /** \defgroup protocolapi DLT Protocol API @@ -193,42 +193,42 @@ /** \} */ -static constexpr uint8_t FLST_NOR = 8; -static constexpr uint8_t FLDA_NOR = 5; -static constexpr uint8_t FLFI_NOR = 3; -static constexpr uint8_t FLIF_NOR = 7; -static constexpr uint8_t FLER_FILE_NOR = 9; -static constexpr uint8_t FLER_NO_FILE_NOR = 5; +static constexpr uint8_t kFlstNor = 8; +static constexpr uint8_t kFldaNor = 5; +static constexpr uint8_t kFlfiNor = 3; +static constexpr uint8_t kFlifNor = 7; +static constexpr uint8_t kFlerFileNor = 9; +static constexpr uint8_t kFlerNoFileNor = 5; //! Defines the buffer size of a single file package which will be logged to dlt -static constexpr uint16_t BUFFER_SIZE = 1024; +static constexpr uint16_t kBufferSize = 1024; //! Defines the data package size which will be logged to dlt -static constexpr uint16_t PKG_FLAG_BYTES = 2 + 5 + 4; -static constexpr uint16_t PKG_SERIALNO_BYTES = 4 + 4; -static constexpr uint16_t PKG_PKGNO_BYTES = 4 + 4; -static constexpr uint16_t PKG_RAWDATA_BYTES = 4 + 2 + BUFFER_SIZE; -static constexpr uint16_t DATAPKGSIZE = - PKG_FLAG_BYTES + PKG_SERIALNO_BYTES + PKG_PKGNO_BYTES + PKG_RAWDATA_BYTES + PKG_FLAG_BYTES; +static constexpr uint16_t kPkgFlagBytes = 2 + 5 + 4; +static constexpr uint16_t kPkgSerialnoBytes = 4 + 4; +static constexpr uint16_t kPkgPkgnoBytes = 4 + 4; +static constexpr uint16_t kPkgRawdataBytes = 4 + 2 + kBufferSize; +static constexpr uint16_t kDatapkgsize = + kPkgFlagBytes + kPkgSerialnoBytes + kPkgPkgnoBytes + kPkgRawdataBytes + kPkgFlagBytes; /* ! Error code for dlt_user_log_file_complete */ -static constexpr int16_t DLT_FILETRANSFER_ERROR_FILE_COMPLETE = -300; +static constexpr int16_t kDltFiletransferErrorFileComplete = -300; /* ! Error code for dlt_user_log_file_complete */ -static constexpr int16_t DLT_FILETRANSFER_ERROR_FILE_COMPLETE1 = -301; +static constexpr int16_t kDltFiletransferErrorFileCompletE1 = -301; /* ! Error code for dlt_user_log_file_complete */ -static constexpr int16_t DLT_FILETRANSFER_ERROR_FILE_COMPLETE2 = -302; +static constexpr int16_t kDltFiletransferErrorFileCompletE2 = -302; /* ! Error code for dlt_user_log_file_complete */ -static constexpr int16_t DLT_FILETRANSFER_ERROR_FILE_COMPLETE3 = -303; +static constexpr int16_t kDltFiletransferErrorFileCompletE3 = -303; /* ! Error code for dlt_user_log_file_head */ -static constexpr int16_t DLT_FILETRANSFER_ERROR_FILE_HEAD = -400; +static constexpr int16_t kDltFiletransferErrorFileHead = -400; /* ! Error code for dlt_user_log_file_data */ -static constexpr int16_t DLT_FILETRANSFER_ERROR_FILE_DATA = -500; +static constexpr int16_t kDltFiletransferErrorFileData = -500; /* ! Error code for dlt_user_log_file_data */ -static constexpr int16_t DLT_FILETRANSFER_ERROR_FILE_DATA_USER_BUFFER_FAILED = -501; +static constexpr int16_t kDltFiletransferErrorFileDataUserBufferFailed = -501; /* ! Error code for dlt_user_log_file_end */ -static constexpr int16_t DLT_FILETRANSFER_ERROR_FILE_END = -600; +static constexpr int16_t kDltFiletransferErrorFileEnd = -600; /* ! Error code for dlt_user_log_file_infoAbout */ -static constexpr int16_t DLT_FILETRANSFER_ERROR_INFO_ABOUT = -700; +static constexpr int16_t kDltFiletransferErrorInfoAbout = -700; /* ! Error code for dlt_user_log_file_packagesCount */ -static constexpr int16_t DLT_FILETRANSFER_ERROR_PACKAGE_COUNT = -800; +static constexpr int16_t kDltFiletransferErrorPackageCount = -800; inline std::optional /*buffer*/, uint8_t /*args count*/>> PackageFileHeader( score::cpp::span data_span, @@ -321,7 +321,7 @@ inline std::optional /*buffer*/, uint8_t /*arg type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_16BIT; std::memcpy(std::next(buffer, buffersize), &(type_info), sizeof(type_info)); buffersize += static_cast(sizeof(type_info)); - std::memcpy(std::next(buffer, buffersize), &BUFFER_SIZE, sizeof(uint16_t)); + std::memcpy(std::next(buffer, buffersize), &kBufferSize, sizeof(uint16_t)); buffersize += static_cast(sizeof(uint16_t)); // package flag "FLST" @@ -334,7 +334,7 @@ inline std::optional /*buffer*/, uint8_t /*arg buffersize += static_cast(sizeof(transfer_type)); // NOLINTEND(score-banned-function) - return std::tuple{data_span.subspan(0, buffersize), FLST_NOR}; + return std::tuple{data_span.subspan(0, buffersize), kFlstNor}; } inline std::optional /*buffer*/, uint8_t /*args count*/>> @@ -352,7 +352,7 @@ PackageFileData(score::cpp::span buffer_in, FILE* file, const uint32_t ser // - Work with already closed file. A unit test already implemented but it sporadically raises a memory leak. // - Providing a value for the whence argument that is not SEEK_SET, SEEK_CUR, or SEEK_END(it's fixed to SEEK_SET). // So, safer to suppress it. - if (0 != fseek(file, (pkgno - 1) * BUFFER_SIZE, SEEK_SET)) // LCOV_EXCL_BR_LINE + if (0 != fseek(file, (pkgno - 1) * kBufferSize, SEEK_SET)) // LCOV_EXCL_BR_LINE { // File access error: return std::nullopt; // LCOV_EXCL_LINE @@ -363,7 +363,7 @@ PackageFileData(score::cpp::span buffer_in, FILE* file, const uint32_t ser static_cast(sizeof(transfer_type)) + static_cast(sizeof(type_info)) + static_cast(sizeof(serialno)) + static_cast(sizeof(type_info)) + static_cast(sizeof(pkgno)) + static_cast(sizeof(type_info)) + - static_cast(sizeof(uint16_t)) + BUFFER_SIZE + static_cast(sizeof(type_info)) + + static_cast(sizeof(uint16_t)) + kBufferSize + static_cast(sizeof(type_info)) + static_cast(sizeof(string_length_data_1)) + static_cast(sizeof(transfer_type)); buffersize_max > buffer_in.size()) { @@ -402,7 +402,7 @@ PackageFileData(score::cpp::span buffer_in, FILE* file, const uint32_t ser std::memcpy(std::next(buffer, buffersize), &(type_info), sizeof(type_info)); buffersize += static_cast(sizeof(type_info)); readbytes = static_cast(fread( - std::next(buffer, buffersize + static_cast(sizeof(uint16_t))), sizeof(char), BUFFER_SIZE, file)); + std::next(buffer, buffersize + static_cast(sizeof(uint16_t))), sizeof(char), kBufferSize, file)); std::memcpy(std::next(buffer, buffersize), &readbytes, sizeof(uint16_t)); buffersize += static_cast(sizeof(uint16_t)); buffersize += readbytes; @@ -418,7 +418,7 @@ PackageFileData(score::cpp::span buffer_in, FILE* file, const uint32_t ser buffersize += static_cast(sizeof(transfer_type)); // NOLINTEND(score-banned-function) - return std::tuple{buffer_in.subspan(0, buffersize), FLDA_NOR}; + return std::tuple{buffer_in.subspan(0, buffersize), kFldaNor}; } inline std::optional /*buffersize*/, uint8_t /*args count*/>> PackageFileEnd( @@ -475,7 +475,7 @@ inline std::optional /*buffersize*/, uint8_t / buffersize += static_cast(sizeof(transfer_type)); // NOLINTEND(score-banned-function) - return std::tuple(data_buffer.first(buffersize), FLFI_NOR); + return std::tuple(data_buffer.first(buffersize), kFlfiNor); } inline std::optional /*buffer*/, uint8_t /*args count*/>> PackageFileError( @@ -496,7 +496,7 @@ inline std::optional /*buffer*/, uint8_t /*arg const auto alias_string_length = static_cast(alias.size() + 1); uint32_t buffersize = 0; char* buffer = data_span.data(); - uint8_t nor = FLER_FILE_NOR; + uint8_t nor = kFlerFileNor; // NOLINTBEGIN(score-banned-function) see below // memcpy used to copy construct FileEnd packet in raw memory @@ -566,7 +566,7 @@ inline std::optional /*buffer*/, uint8_t /*arg std::memcpy(std::next(buffer, buffersize), &packagecount, sizeof(packagecount)); buffersize += static_cast(sizeof(packagecount)); - if (error_msg != "") + if (!error_msg.empty()) { type_info = DLT_TYPE_INFO_STRG | DLT_SCOD_UTF8; const auto string_length_err = static_cast(error_msg.size() + 1); @@ -630,7 +630,7 @@ inline std::optional /*buffer*/, uint8_t /*arg std::memcpy(std::next(buffer, buffersize), &transfer_type, sizeof(transfer_type)); buffersize += static_cast(sizeof(transfer_type)); - nor = FLER_NO_FILE_NOR; + nor = kFlerNoFileNor; } // NOLINTEND(score-banned-function) return std::tuple{data_span.subspan(0, buffersize), nor}; @@ -734,7 +734,7 @@ inline std::optional /*buffer*/, uint8_t /*arg buffersize += static_cast(sizeof(transfer_type)); // NOLINTEND(score-banned-function) - return std::tuple{data_span.subspan(0, buffersize), FLIF_NOR}; + return std::tuple{data_span.subspan(0, buffersize), kFlifNor}; } -#endif /* DLT_PROTOCOL_H */ +#endif // SCORE_DATAROUTER_INCLUDE_DLT_DLT_PROTOCOL_H diff --git a/score/datarouter/include/dlt/dlt_types.h b/score/datarouter/include/dlt/dlt_types.h index 7902579..dbb97f0 100644 --- a/score/datarouter/include/dlt/dlt_types.h +++ b/score/datarouter/include/dlt/dlt_types.h @@ -15,8 +15,8 @@ * @licence end@ */ -#ifndef DLT_TYPES_H -#define DLT_TYPES_H +#ifndef SCORE_DATAROUTER_INCLUDE_DLT_DLT_TYPES_H +#define SCORE_DATAROUTER_INCLUDE_DLT_DLT_TYPES_H #ifdef _MSC_VER typedef __int64 int64_t; @@ -44,15 +44,15 @@ typedef unsigned int speed_t; */ typedef enum { - DLT_RETURN_LOGGING_DISABLED = -7, - DLT_RETURN_USER_BUFFER_FULL = -6, - DLT_RETURN_WRONG_PARAMETER = -5, - DLT_RETURN_BUFFER_FULL = -4, - DLT_RETURN_PIPE_FULL = -3, - DLT_RETURN_PIPE_ERROR = -2, - DLT_RETURN_ERROR = -1, - DLT_RETURN_OK = 0, - DLT_RETURN_TRUE = 1 + kDltReturnLoggingDisabled = -7, + kDltReturnUserBufferFull = -6, + kDltReturnWrongParameter = -5, + kDltReturnBufferFull = -4, + kDltReturnPipeFull = -3, + kDltReturnPipeError = -2, + kDltReturnError = -1, + kDltReturnOk = 0, + kDltReturnTrue = 1 } DltReturnValue; /** @@ -60,15 +60,15 @@ typedef enum */ typedef enum { - DLT_LOG_DEFAULT = -1, /**< Default log level */ - DLT_LOG_OFF = 0x00, /**< Log level off */ - DLT_LOG_FATAL = 0x01, /**< fatal system error */ - DLT_LOG_ERROR = 0x02, /**< error with impact to correct functionality */ - DLT_LOG_WARN = 0x03, /**< warning, correct behaviour could not be ensured */ - DLT_LOG_INFO = 0x04, /**< informational */ - DLT_LOG_DEBUG = 0x05, /**< debug */ - DLT_LOG_VERBOSE = 0x06, /**< highest grade of information */ - DLT_LOG_MAX /**< maximum value, used for range check */ + kDltLogDefault = -1, /**< Default log level */ + kDltLogOff = 0x00, /**< Log level off */ + kDltLogFatal = 0x01, /**< fatal system error */ + kDltLogError = 0x02, /**< error with impact to correct functionality */ + kDltLogWarn = 0x03, /**< warning, correct behaviour could not be ensured */ + kDltLogInfo = 0x04, /**< informational */ + kDltLogDebug = 0x05, /**< debug */ + kDltLogVerbose = 0x06, /**< highest grade of information */ + kDltLogMax = 7 /**< maximum value, used for range check */ } DltLogLevelType; /** @@ -76,14 +76,14 @@ typedef enum */ typedef enum { - DLT_FORMAT_DEFAULT = 0x00, /**< no sepecial format */ - DLT_FORMAT_HEX8 = 0x01, /**< Hex 8 */ - DLT_FORMAT_HEX16 = 0x02, /**< Hex 16 */ - DLT_FORMAT_HEX32 = 0x03, /**< Hex 32 */ - DLT_FORMAT_HEX64 = 0x04, /**< Hex 64 */ - DLT_FORMAT_BIN8 = 0x05, /**< Binary 8 */ - DLT_FORMAT_BIN16 = 0x06, /**< Binary 16 */ - DLT_FORMAT_MAX /**< maximum value, used for range check */ + kDltFormatDefault = 0x00, /**< no sepecial format */ + kDltFormatHeX8 = 0x01, /**< Hex 8 */ + kDltFormatHeX16 = 0x02, /**< Hex 16 */ + kDltFormatHeX32 = 0x03, /**< Hex 32 */ + kDltFormatHeX64 = 0x04, /**< Hex 64 */ + kDltFormatBiN8 = 0x05, /**< Binary 8 */ + kDltFormatBiN16 = 0x06, /**< Binary 16 */ + kDltFormatMax = 7 /**< maximum value, used for range check */ } DltFormatType; /** @@ -91,10 +91,10 @@ typedef enum */ typedef enum { - DLT_TRACE_STATUS_DEFAULT = -1, /**< Default trace status */ - DLT_TRACE_STATUS_OFF = 0x00, /**< Trace status: Off */ - DLT_TRACE_STATUS_ON = 0x01, /**< Trace status: On */ - DLT_TRACE_STATUS_MAX /**< maximum value, used for range check */ + kDltTraceStatusDefault = -1, /**< Default trace status */ + kDltTraceStatusOff = 0x00, /**< Trace status: Off */ + kDltTraceStatusOn = 0x01, /**< Trace status: On */ + kDltTraceStatusMax = 2 /**< maximum value, used for range check */ } DltTraceStatusType; /** @@ -103,22 +103,22 @@ typedef enum */ typedef enum { - DLT_NW_TRACE_IPC = 0x01, /**< Interprocess communication */ - DLT_NW_TRACE_CAN = 0x02, /**< Controller Area Network Bus */ - DLT_NW_TRACE_FLEXRAY = 0x03, /**< Flexray Bus */ - DLT_NW_TRACE_MOST = 0x04, /**< Media Oriented System Transport Bus */ - DLT_NW_TRACE_RESERVED0 = 0x05, - DLT_NW_TRACE_RESERVED1 = 0x06, - DLT_NW_TRACE_RESERVED2 = 0x07, - DLT_NW_TRACE_USER_DEFINED0 = 0x08, - DLT_NW_TRACE_USER_DEFINED1 = 0x09, - DLT_NW_TRACE_USER_DEFINED2 = 0x0A, - DLT_NW_TRACE_USER_DEFINED3 = 0x0B, - DLT_NW_TRACE_USER_DEFINED4 = 0x0C, - DLT_NW_TRACE_USER_DEFINED5 = 0x0D, - DLT_NW_TRACE_USER_DEFINED6 = 0x0E, - DLT_NW_TRACE_USER_DEFINED7 = 0x0F, - DLT_NW_TRACE_MAX /**< maximum value, used for range check */ + kDltNwTraceIpc = 0x01, /**< Interprocess communication */ + kDltNwTraceCan = 0x02, /**< Controller Area Network Bus */ + kDltNwTraceFlexray = 0x03, /**< Flexray Bus */ + kDltNwTraceMost = 0x04, /**< Media Oriented System Transport Bus */ + kDltNwTraceReserveD0 = 0x05, + kDltNwTraceReserveD1 = 0x06, + kDltNwTraceReserveD2 = 0x07, + kDltNwTraceUserDefineD0 = 0x08, + kDltNwTraceUserDefineD1 = 0x09, + kDltNwTraceUserDefineD2 = 0x0A, + kDltNwTraceUserDefineD3 = 0x0B, + kDltNwTraceUserDefineD4 = 0x0C, + kDltNwTraceUserDefineD5 = 0x0D, + kDltNwTraceUserDefineD6 = 0x0E, + kDltNwTraceUserDefineD7 = 0x0F, + kDltNwTraceMax = 16 /**< maximum value, used for range check */ } DltNetworkTraceType; /** @@ -126,15 +126,15 @@ typedef enum */ typedef enum { - DLT_USER_MODE_UNDEFINED = -1, - DLT_USER_MODE_OFF = 0, - DLT_USER_MODE_EXTERNAL, - DLT_USER_MODE_INTERNAL, - DLT_USER_MODE_BOTH, - DLT_USER_MODE_MAX /**< maximum value, used for range check */ + kDltUserModeUndefined = -1, + kDltUserModeOff = 0, + kDltUserModeExternal = 1, + kDltUserModeInternal = 2, + kDltUserModeBoth = 3, + kDltUserModeMax = 4 /**< maximum value, used for range check */ } DltUserLogMode; -typedef float float32_t; -typedef double float64_t; +typedef float Float32T; +typedef double Float64T; -#endif /* DLT_TYPES_H */ +#endif // SCORE_DATAROUTER_INCLUDE_DLT_DLT_TYPES_H diff --git a/score/datarouter/include/dlt/dltid.h b/score/datarouter/include/dlt/dltid.h index 03cef5c..008aa26 100644 --- a/score/datarouter/include/dlt/dltid.h +++ b/score/datarouter/include/dlt/dltid.h @@ -30,24 +30,24 @@ namespace platform // multiple translation units shall be declared in one and only one file. // false positive : dltid_t is only declared once in this file. // coverity[autosar_cpp14_m3_2_3_violation] -struct dltid_t +struct DltidT { constexpr static size_t kSize{4U}; score::mw::log::detail::LoggingIdentifier bytes; std::int32_t value; - dltid_t() noexcept : value() {} - explicit dltid_t(const char* str) noexcept : dltid_t(std::string_view{str}) {} - explicit dltid_t(const std::string_view str) noexcept : bytes{str}, value{} + DltidT() noexcept : value() {} + explicit DltidT(const char* str) noexcept : DltidT(std::string_view{str}) {} + explicit DltidT(const std::string_view str) noexcept : bytes{str}, value{} { value = static_cast(score::mw::log::detail::LoggingIdentifier::HashFunction{}(bytes)); } - explicit dltid_t(const std::string& str) noexcept : dltid_t(std::string_view{str.data(), str.size()}) {} - explicit dltid_t(const score::cpp::string_view& str) noexcept : dltid_t(std::string_view{str.data(), str.size()}) {}; + explicit DltidT(const std::string& str) noexcept : DltidT(std::string_view{str.data(), str.size()}) {} + explicit DltidT(const score::cpp::string_view& str) noexcept : DltidT(std::string_view{str.data(), str.size()}) {}; - dltid_t& operator=(const std::string& str) + DltidT& operator=(const std::string& str) { bytes = score::mw::log::detail::LoggingIdentifier(std::string_view(str)); value = static_cast(score::mw::log::detail::LoggingIdentifier::HashFunction{}(bytes)); @@ -62,17 +62,17 @@ struct dltid_t return std::string(bytes.data_.data(), bytes.data_.size()); } - bool operator==(const dltid_t& id) const + bool operator==(const DltidT& id) const { return this->value == id.value; } - char* data() + char* Data() { return bytes.data_.data(); } - const char* data() const + const char* Data() const { return bytes.data_.data(); } @@ -95,9 +95,9 @@ template <> // multiple translation units shall be declared in one and only one file. // false positive : template specialization for hash. // coverity[autosar_cpp14_m3_2_3_violation] -struct hash +struct hash { - std::size_t operator()(const score::platform::dltid_t& d) const noexcept + std::size_t operator()(const score::platform::DltidT& d) const noexcept { return static_cast(d.value); } diff --git a/score/datarouter/include/dlt/dltid_converter.h b/score/datarouter/include/dlt/dltid_converter.h index 587a40a..585bf6c 100644 --- a/score/datarouter/include/dlt/dltid_converter.h +++ b/score/datarouter/include/dlt/dltid_converter.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef DLTID_CONVERTER_H_ -#define DLTID_CONVERTER_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DLT_DLTID_CONVERTER_H +#define SCORE_DATAROUTER_INCLUDE_DLT_DLTID_CONVERTER_H #include "score/mw/log/detail/logging_identifier.h" #include "score/datarouter/include/dlt/dltid.h" @@ -22,9 +22,9 @@ namespace score namespace platform { -dltid_t convertToDltId(const score::mw::log::detail::LoggingIdentifier& logging_identifier); +DltidT ConvertToDltId(const score::mw::log::detail::LoggingIdentifier& logging_identifier); } // namespace platform } // namespace score -#endif // DLTID_CONVERTER_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DLT_DLTID_CONVERTER_H diff --git a/score/datarouter/include/dlt/logentry_trace.h b/score/datarouter/include/dlt/logentry_trace.h index c642af8..df03149 100644 --- a/score/datarouter/include/dlt/logentry_trace.h +++ b/score/datarouter/include/dlt/logentry_trace.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef LOGENTRY_TRACE_H_ -#define LOGENTRY_TRACE_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DLT_LOGENTRY_TRACE_H +#define SCORE_DATAROUTER_INCLUDE_DLT_LOGENTRY_TRACE_H #include "dlt/dltid.h" #include "score/mw/log/detail/logging_identifier.h" @@ -29,7 +29,7 @@ namespace platform // LCOV_EXCL_START : See above // MEMCPY_SERIALIZABLE won't cause data loss. // coverity[autosar_cpp14_a4_7_1_violation] -MEMCPY_SERIALIZABLE(score::common::visitor::payload_tags::text, dltid_t) +MEMCPY_SERIALIZABLE(score::common::visitor::payload_tags::text, DltidT) // LCOV_EXCL_STOP namespace internal @@ -45,7 +45,7 @@ struct LogEntryFilter // coverity[autosar_cpp14_m11_0_1_violation] score::mw::log::detail::LoggingIdentifier ctx_id{""}; // coverity[autosar_cpp14_m11_0_1_violation] - uint8_t logLevelThreshold = 0U; + uint8_t log_level_threshold = 0U; }; // The STRUCT_TRACEABLE macro is part of the Tracing infrastructure and is tested independently. @@ -58,11 +58,11 @@ struct LogEntryFilter // translation units shall be declared in one and only one file.". // coverity[autosar_cpp14_a18_9_4_violation] // coverity[autosar_cpp14_m3_2_3_violation] -STRUCT_TRACEABLE(LogEntryFilter, app_id, ctx_id, logLevelThreshold) +STRUCT_TRACEABLE(LogEntryFilter, app_id, ctx_id, log_level_threshold) // LCOV_EXCL_STOP } // namespace internal } // namespace platform } // namespace score -#endif // LOGENTRY_TRACE_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DLT_LOGENTRY_TRACE_H diff --git a/score/datarouter/include/dlt/plogfilterdesc.h b/score/datarouter/include/dlt/plogfilterdesc.h index c8e3c84..7c621dc 100644 --- a/score/datarouter/include/dlt/plogfilterdesc.h +++ b/score/datarouter/include/dlt/plogfilterdesc.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef PLOGFILTERDESC_H_ -#define PLOGFILTERDESC_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_DLT_PLOGFILTERDESC_H +#define SCORE_DATAROUTER_INCLUDE_DLT_PLOGFILTERDESC_H #include "score/mw/log/detail/log_entry.h" @@ -23,15 +23,15 @@ namespace platform namespace internal { -struct plogfilterdesc +struct Plogfilterdesc { - score::mw::log::detail::LoggingIdentifier appid_; - score::mw::log::detail::LoggingIdentifier ctxid_; - uint8_t logLevel_{}; + score::mw::log::detail::LoggingIdentifier appid; + score::mw::log::detail::LoggingIdentifier ctxid; + uint8_t log_level{}; }; } // namespace internal } // namespace platform } // namespace score -#endif // PLOGFILTERDESC_H_ +#endif // SCORE_DATAROUTER_INCLUDE_DLT_PLOGFILTERDESC_H diff --git a/score/datarouter/include/logparser/i_logparser.h b/score/datarouter/include/logparser/i_logparser.h index 6adf300..f7f05e1 100644 --- a/score/datarouter/include/logparser/i_logparser.h +++ b/score/datarouter/include/logparser/i_logparser.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef PAS_LOGGING_ILOGPARSER_H_ -#define PAS_LOGGING_ILOGPARSER_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_LOGPARSER_I_LOGPARSER_H +#define SCORE_DATAROUTER_INCLUDE_LOGPARSER_I_LOGPARSER_H #include "dlt/dltid.h" #include "router/data_router_types.h" @@ -35,16 +35,16 @@ class INvConfig; namespace platform { -using timestamp_t = score::os::HighResolutionSteadyClock::time_point; +using TimestampT = score::os::HighResolutionSteadyClock::time_point; struct TypeInfo { - const score::mw::log::config::NvMsgDescriptor* nvMsgDesc; - bufsize_t id; + const score::mw::log::config::NvMsgDescriptor* nv_msg_desc; + BufsizeT id; std::string params; - std::string typeName; - dltid_t ecuId; - dltid_t appId; + std::string type_name; + DltidT ecu_id; + DltidT app_id; }; namespace internal @@ -56,14 +56,14 @@ class ILogParser class TypeHandler { public: - virtual void handle(timestamp_t timestamp, const char* data, bufsize_t size) = 0; + virtual void Handle(TimestampT timestamp, const char* data, BufsizeT size) = 0; virtual ~TypeHandler() = default; }; class AnyHandler { public: - virtual void handle(const TypeInfo& TypeInfo, timestamp_t timestamp, const char* data, bufsize_t size) = 0; + virtual void Handle(const TypeInfo& type_info, TimestampT timestamp, const char* data, BufsizeT size) = 0; virtual ~AnyHandler() = default; }; @@ -72,29 +72,29 @@ class ILogParser // a function object to return whether the message parameter passes some encapsulted filter // (in order to support content-based forwarding) - using FilterFunction = std::function; + using FilterFunction = std::function; // a function to create such function objects based on the type of the message, // the type of the filter object, and the serialized payload of the filter object // (called on the request data provided by add_data_forwarder()) using FilterFunctionFactory = std::function; - virtual void set_filter_factory(FilterFunctionFactory factory) = 0; + virtual void SetFilterFactory(FilterFunctionFactory factory) = 0; - virtual void add_incoming_type(const bufsize_t map_index, const std::string& params) = 0; + virtual void AddIncomingType(const BufsizeT map_index, const std::string& params) = 0; virtual void AddIncomingType(const score::mw::log::detail::TypeRegistration&) = 0; - virtual void add_type_handler(const std::string& typeName, TypeHandler& handler) = 0; - virtual void add_global_handler(AnyHandler& handler) = 0; + virtual void AddTypeHandler(const std::string& type_name, TypeHandler& handler) = 0; + virtual void AddGlobalHandler(AnyHandler& handler) = 0; - virtual void remove_type_handler(const std::string& typeName, TypeHandler& handler) = 0; - virtual void remove_global_handler(AnyHandler& handler) = 0; + virtual void RemoveTypeHandler(const std::string& type_name, TypeHandler& handler) = 0; + virtual void RemoveGlobalHandler(AnyHandler& handler) = 0; - virtual bool is_type_hndl_registered(const std::string& typeName, const TypeHandler& handler) = 0; - virtual bool is_glb_hndl_registered(const AnyHandler& handler) = 0; + virtual bool IsTypeHndlRegistered(const std::string& type_name, const TypeHandler& handler) = 0; + virtual bool IsGlbHndlRegistered(const AnyHandler& handler) = 0; - virtual void reset_internal_mapping() = 0; - virtual void parse(timestamp_t timestamp, const char* data, bufsize_t size) = 0; + virtual void ResetInternalMapping() = 0; + virtual void Parse(TimestampT timestamp, const char* data, BufsizeT size) = 0; virtual void Parse(const score::mw::log::detail::SharedMemoryRecord& record) = 0; }; @@ -102,4 +102,4 @@ class ILogParser } // namespace platform } // namespace score -#endif // PAS_LOGGING_ILOGPARSER_H_ +#endif // SCORE_DATAROUTER_INCLUDE_LOGPARSER_I_LOGPARSER_H diff --git a/score/datarouter/include/logparser/logparser.h b/score/datarouter/include/logparser/logparser.h index 15eeb85..0a9802d 100644 --- a/score/datarouter/include/logparser/logparser.h +++ b/score/datarouter/include/logparser/logparser.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef PAS_LOGGING_LOGPARSER_H_ -#define PAS_LOGGING_LOGPARSER_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_LOGPARSER_LOGPARSER_H +#define SCORE_DATAROUTER_INCLUDE_LOGPARSER_LOGPARSER_H #include "logparser/i_logparser.h" @@ -45,26 +45,26 @@ class LogParser : public ILogParser explicit LogParser(const score::mw::log::INvConfig& nv_config); ~LogParser() = default; - void set_filter_factory(FilterFunctionFactory factory) override + void SetFilterFactory(FilterFunctionFactory factory) override { - filter_factory = factory; + filter_factory_ = factory; } - void add_incoming_type(const bufsize_t map_index, const std::string& params) override; + void AddIncomingType(const BufsizeT map_index, const std::string& params) override; void AddIncomingType(const score::mw::log::detail::TypeRegistration&) override; - void add_type_handler(const std::string& typeName, TypeHandler& handler) override; - void add_global_handler(AnyHandler& handler) override; + void AddTypeHandler(const std::string& type_name, TypeHandler& handler) override; + void AddGlobalHandler(AnyHandler& handler) override; - void remove_type_handler(const std::string& typeName, TypeHandler& handler) override; - void remove_global_handler(AnyHandler& handler) override; + void RemoveTypeHandler(const std::string& type_name, TypeHandler& handler) override; + void RemoveGlobalHandler(AnyHandler& handler) override; - bool is_type_hndl_registered(const std::string& typeName, const TypeHandler& handler) override; - bool is_glb_hndl_registered(const AnyHandler& handler) override; + bool IsTypeHndlRegistered(const std::string& type_name, const TypeHandler& handler) override; + bool IsGlbHndlRegistered(const AnyHandler& handler) override; - void reset_internal_mapping() override; + void ResetInternalMapping() override; - void parse(timestamp_t timestamp, const char* data, bufsize_t size) override; + void Parse(TimestampT timestamp, const char* data, BufsizeT size) override; void Parse(const score::mw::log::detail::SharedMemoryRecord& record) override; private: @@ -87,14 +87,14 @@ class LogParser : public ILogParser class IndexParser { public: - TypeInfo info_; + TypeInfo info; - explicit IndexParser(TypeInfo info) : info_{info}, handlers_() {} + explicit IndexParser(TypeInfo type_info) : info{type_info}, handlers_{} {} - void add_handler(const HandleRequestMap::value_type& request); - void remove_handler(const HandleRequestMap::value_type& request); + void AddHandler(const HandleRequestMap::value_type& request); + void RemoveHandler(const HandleRequestMap::value_type& request); - void parse(const timestamp_t timestamp, const char* const data, const bufsize_t size); + void Parse(const TimestampT timestamp, const char* const data, const BufsizeT size); private: struct Handler @@ -115,14 +115,14 @@ class LogParser : public ILogParser std::vector handlers_; }; - FilterFunctionFactory filter_factory; + FilterFunctionFactory filter_factory_; - HandleRequestMap handle_request_map; + HandleRequestMap handle_request_map_; - std::unordered_multimap typename_to_index; - std::unordered_map index_parser_map; + std::unordered_multimap typename_to_index_; + std::unordered_map index_parser_map_; - std::vector global_handlers; + std::vector global_handlers_; const score::mw::log::INvConfig& nv_config_; }; @@ -130,4 +130,4 @@ class LogParser : public ILogParser } // namespace platform } // namespace score -#endif // PAS_LOGGING_LOGPARSER_H_ +#endif // SCORE_DATAROUTER_INCLUDE_LOGPARSER_LOGPARSER_H diff --git a/score/datarouter/include/router/data_router_types.h b/score/datarouter/include/router/data_router_types.h index ecf127c..8e0d5d0 100644 --- a/score/datarouter/include/router/data_router_types.h +++ b/score/datarouter/include/router/data_router_types.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef DATA_ROUTER_TYPES_H_ -#define DATA_ROUTER_TYPES_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_ROUTER_DATA_ROUTER_TYPES_H +#define SCORE_DATAROUTER_INCLUDE_ROUTER_DATA_ROUTER_TYPES_H #include #include @@ -22,15 +22,15 @@ namespace score namespace platform { -using bufsize_t = std::uint32_t; +using BufsizeT = std::uint32_t; struct DataFilter { - std::string filterType; - std::string filterData; + std::string filter_type; + std::string filter_data; }; } // namespace platform } // namespace score -#endif // DATA_ROUTER_TYPES_H_ +#endif // SCORE_DATAROUTER_INCLUDE_ROUTER_DATA_ROUTER_TYPES_H diff --git a/score/datarouter/include/unix_domain/unix_domain_client.h b/score/datarouter/include/unix_domain/unix_domain_client.h index aae2f05..c104a91 100644 --- a/score/datarouter/include/unix_domain/unix_domain_client.h +++ b/score/datarouter/include/unix_domain/unix_domain_client.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef UNIX_DOMAIN_CLIENT_H_ -#define UNIX_DOMAIN_CLIENT_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_UNIX_DOMAIN_UNIX_DOMAIN_CLIENT_H +#define SCORE_DATAROUTER_INCLUDE_UNIX_DOMAIN_UNIX_DOMAIN_CLIENT_H #include "unix_domain/unix_domain_common.h" @@ -46,24 +46,24 @@ class UnixDomainClient using FdCallback = std::function; using RequestCallback = std::function; UnixDomainClient(UnixDomainSockAddr addr, - Callback onConnect, - Callback onDisconnect, - FdCallback onFd = FdCallback(), - TickCallback onTick = TickCallback(), - RequestCallback onRequest = RequestCallback(), + Callback on_connect, + Callback on_disconnect, + FdCallback on_fd = FdCallback(), + TickCallback on_tick = TickCallback(), + RequestCallback on_request = RequestCallback(), std::unique_ptr signal = std::make_unique()) : addr_(addr), exit_(false), commands_mutex_{}, commands_{}, - client_thread{}, + client_thread_{}, new_socket_retry_{false}, fd_{-1}, - on_connect_(onConnect), - on_disconnect_(onDisconnect), - on_fd_(onFd), - on_tick_(onTick), - on_request_(onRequest), + on_connect_(on_connect), + on_disconnect_(on_disconnect), + on_fd_(on_fd), + on_tick_(on_tick), + on_request_(on_request), signal_(std::move(signal)) { } @@ -71,28 +71,28 @@ class UnixDomainClient ~UnixDomainClient() { exit_ = true; - if (client_thread.joinable()) + if (client_thread_.joinable()) { - client_thread.join(); + client_thread_.join(); } } - void send_response(const std::string& response) + void SendResponse(const std::string& response) { - send_socket_message(fd_, response); + SendSocketMessage(fd_, response); } - void ping(); + void Ping(); private: - void client_routine(); - void update_thread_name_logger(); + void ClientRoutine(); + void UpdateThreadNameLogger(); UnixDomainSockAddr addr_; std::atomic exit_; std::mutex commands_mutex_; std::queue commands_; - std::thread client_thread; + std::thread client_thread_; bool new_socket_retry_; // TODO: temporary workaround, remove @@ -111,4 +111,4 @@ class UnixDomainClient } // namespace platform } // namespace score -#endif // UNIX_DOMAIN_CLIENT_H_ +#endif // SCORE_DATAROUTER_INCLUDE_UNIX_DOMAIN_UNIX_DOMAIN_CLIENT_H diff --git a/score/datarouter/include/unix_domain/unix_domain_common.h b/score/datarouter/include/unix_domain/unix_domain_common.h index 4f4861f..6cd1015 100644 --- a/score/datarouter/include/unix_domain/unix_domain_common.h +++ b/score/datarouter/include/unix_domain/unix_domain_common.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef UNIX_DOMAIN_COMMON_H_ -#define UNIX_DOMAIN_COMMON_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_UNIX_DOMAIN_UNIX_DOMAIN_COMMON_H +#define SCORE_DATAROUTER_INCLUDE_UNIX_DOMAIN_UNIX_DOMAIN_COMMON_H #include #include @@ -50,29 +50,29 @@ struct SocketMessangerHeader // __attribute__((packed)) // TODO: deal with p class UnixDomainSockAddr { public: - UnixDomainSockAddr(const std::string& path, bool isAbstract); - const char* get_address_string() + UnixDomainSockAddr(const std::string& path, bool is_abstract); + const char* GetAddressString() { - std::uint8_t offset = is_abstract() ? 1U : 0U; + std::uint8_t offset = IsAbstract() ? 1U : 0U; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index) -bounds already checked via is_abstract() - return &(addr_.sun_path[offset]); + return &(addr.sun_path[offset]); } - bool is_abstract() + bool IsAbstract() { - return addr_.sun_path[0] == 0U; + return addr.sun_path[0] == 0U; } - struct sockaddr_un addr_; + struct sockaddr_un addr; }; using AncillaryDataFileHandleReceptionCallback = score::cpp::callback(const score::cpp::span buffer)>; /* @file_handle - is optional and used to pass file descriptor on Linux */ -void send_socket_message(std::int32_t connection_file_descriptor, - score::cpp::string_view message, - score::cpp::optional file_handle = score::cpp::nullopt); +void SendSocketMessage(std::int32_t connection_file_descriptor, + score::cpp::string_view message, + score::cpp::optional file_handle = score::cpp::nullopt); /* @data - data to be send over the socket */ void SendAncillaryDataOverSocket(int connection_file_descriptor, score::cpp::span data); @@ -83,11 +83,11 @@ void SendAncillaryDataOverSocket(int connection_file_descriptor, score::cpp::spa * way to retrive fd. For Linux part of the implementation it may be passed by native socket ancillary data. Overload * function with reduced number of arguments is provided when file handle is not expected. */ -score::cpp::optional recv_socket_message( +score::cpp::optional RecvSocketMessage( std::int32_t socket_fd, AncillaryDataFileHandleReceptionCallback ancillary_data_process = AncillaryDataFileHandleReceptionCallback{}); -score::cpp::optional recv_socket_message( +score::cpp::optional RecvSocketMessage( std::int32_t socket_fd, score::cpp::optional& file_handle, score::cpp::optional& peer_pid, @@ -99,4 +99,4 @@ void SetupSignals(const std::unique_ptr& signal); } // namespace platform } // namespace score -#endif // UNIX_DOMAIN_COMMON_H_ +#endif // SCORE_DATAROUTER_INCLUDE_UNIX_DOMAIN_UNIX_DOMAIN_COMMON_H diff --git a/score/datarouter/include/unix_domain/unix_domain_server.h b/score/datarouter/include/unix_domain/unix_domain_server.h index e0f4448..fb656d8 100644 --- a/score/datarouter/include/unix_domain/unix_domain_server.h +++ b/score/datarouter/include/unix_domain/unix_domain_server.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef UNIX_DOMAIN_SERVER_H_ -#define UNIX_DOMAIN_SERVER_H_ +#ifndef SCORE_DATAROUTER_INCLUDE_UNIX_DOMAIN_UNIX_DOMAIN_SERVER_H +#define SCORE_DATAROUTER_INCLUDE_UNIX_DOMAIN_UNIX_DOMAIN_SERVER_H #include "i_session.h" #include "unix_domain/unix_domain_common.h" @@ -46,9 +46,9 @@ class UnixDomainServer public: explicit SessionHandle(int fd) : socket_descriptor_(fd) {} - void pass_message(const std::string& message) const + void PassMessage(const std::string& message) const { - UnixDomainServer::pass_message(socket_descriptor_, message); + UnixDomainServer::PassMessage(socket_descriptor_, message); } private: @@ -65,7 +65,7 @@ class UnixDomainServer SessionWrapper(UnixDomainServer* server, int fd) : server_(server), session_fd_(fd), - timeout_(timestamp_t::clock::now() + std::chrono::milliseconds(500)), + timeout_(TimestampT::clock::now() + std::chrono::milliseconds(500)), enqueued_(false), running_(false), to_delete_(false), @@ -89,36 +89,36 @@ class UnixDomainServer } // returns `false` when the session shall finish - bool handle_command(const std::string& in_string, score::cpp::optional peer_pid = score::cpp::nullopt); + bool HandleCommand(const std::string& in_string, score::cpp::optional peer_pid = score::cpp::nullopt); // returns information about `session_` existance. If the session does not exists (false), any associated // context can be deleted outright, otherwise(true) delay erasing. - bool try_enqueue_for_delete(bool by_peer = false); - bool is_marked_for_delete() + bool TryEnqueueForDelete(bool by_peer = false); + bool IsMarkedForDelete() const { return to_delete_; } - bool get_reset_closed_by_peer() + bool GetResetClosedByPeer() { bool by_peer = closed_by_peer_; closed_by_peer_ = false; return by_peer; } - bool tick(); - void notify_closed_by_peer(); + bool Tick(); + void NotifyClosedByPeer(); - void set_running(); - bool reset_running(bool requeue); + void SetRunning(); + bool ResetRunning(bool requeue); class SessionWrapperTest; private: - using timestamp_t = std::chrono::steady_clock::time_point; + using TimestampT = std::chrono::steady_clock::time_point; UnixDomainServer* server_; int session_fd_; - timestamp_t timeout_; + TimestampT timeout_; bool enqueued_; bool running_; @@ -127,7 +127,7 @@ class UnixDomainServer std::unique_ptr session_; - void enqueue_tick(); + void EnqueueTick(); }; explicit UnixDomainServer(UnixDomainSockAddr addr, @@ -136,9 +136,9 @@ class UnixDomainServer : server_exit_{false}, server_thread_{}, work_queue_{}, factory_(factory), signal_(std::move(signal)) { server_thread_ = score::cpp::jthread([this, addr]() { - server_routine(addr); + ServerRoutine(addr); }); - update_thread_name_server_routine(); + UpdateThreadNameServerRoutine(); } virtual ~UnixDomainServer() @@ -166,23 +166,23 @@ class UnixDomainServer std::vector connection_pollfd_list; }; - static void pass_message(std::int32_t fd, const std::string& message); + static void PassMessage(std::int32_t fd, const std::string& message); - void server_routine(UnixDomainSockAddr addr); + void ServerRoutine(UnixDomainSockAddr addr); - virtual void enqueue_tick_direct(std::int32_t fd); + virtual void EnqueueTickDirect(std::int32_t fd); // returns true if the queue is still not empty: - bool process_queue(std::unordered_map& connection_fd_map); + bool ProcessQueue(std::unordered_map& connection_fd_map); // Methods to process connections - static void process_active_connections(ConnectionState& state); - static void process_idle_connections(ConnectionState& state); - void cleanup_all_connections(ConnectionState& state); - std::int32_t setup_server_socket(UnixDomainSockAddr& addr); - void process_server_iteration(ConnectionState& state, const std::int32_t server_fd, const std::int32_t timeout); + static void ProcessActiveConnections(ConnectionState& state); + static void ProcessIdleConnections(ConnectionState& state); + void CleanupAllConnections(ConnectionState& state); + std::int32_t SetupServerSocket(UnixDomainSockAddr& addr); + void ProcessServerIteration(ConnectionState& state, const std::int32_t server_fd, const std::int32_t timeout); - void update_thread_name_server_routine() noexcept; + void UpdateThreadNameServerRoutine() noexcept; std::atomic_bool server_exit_; score::cpp::jthread server_thread_; @@ -196,14 +196,14 @@ class UnixDomainServer namespace dummy_namespace { // dummy type to avoid warnings Wsuggest-final-types and Wsuggest-final-methods -struct temp_marker final : UnixDomainServer::ISession +struct TempMarker final : UnixDomainServer::ISession { - bool tick() override + bool Tick() override { return false; }; - void on_command(const std::string&) override {} - void on_closed_by_peer() override {} + void OnCommand(const std::string&) override {} + void OnClosedByPeer() override {} }; } // namespace dummy_namespace @@ -211,4 +211,4 @@ struct temp_marker final : UnixDomainServer::ISession } // namespace platform } // namespace score -#endif // UNIX_DOMAIN_SERVER_H_ +#endif // SCORE_DATAROUTER_INCLUDE_UNIX_DOMAIN_UNIX_DOMAIN_SERVER_H diff --git a/score/datarouter/mocks/daemon/diagnostic_job_parser_mock.h b/score/datarouter/mocks/daemon/diagnostic_job_parser_mock.h index b2eda3e..a4745b9 100644 --- a/score/datarouter/mocks/daemon/diagnostic_job_parser_mock.h +++ b/score/datarouter/mocks/daemon/diagnostic_job_parser_mock.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef DIAGNOSTIC_JOB_PARSER_MOCK_H_ -#define DIAGNOSTIC_JOB_PARSER_MOCK_H_ +#ifndef SCORE_DATAROUTER_MOCKS_DAEMON_DIAGNOSTIC_JOB_PARSER_MOCK_H +#define SCORE_DATAROUTER_MOCKS_DAEMON_DIAGNOSTIC_JOB_PARSER_MOCK_H #include @@ -30,7 +30,7 @@ namespace mock class DiagnosticJobParserMock : public IDiagnosticJobParser { public: - MOCK_METHOD(std::unique_ptr, parse, (const std::string&), (override)); + MOCK_METHOD(std::unique_ptr, Parse, (const std::string&), (override)); }; } // namespace mock @@ -39,4 +39,4 @@ class DiagnosticJobParserMock : public IDiagnosticJobParser } // namespace logging } // namespace score -#endif // DIAGNOSTIC_JOB_PARSER_MOCK_H_ +#endif // SCORE_DATAROUTER_MOCKS_DAEMON_DIAGNOSTIC_JOB_PARSER_MOCK_H diff --git a/score/datarouter/mocks/daemon/dlt_log_server_mock.h b/score/datarouter/mocks/daemon/dlt_log_server_mock.h index 99e4192..a151fee 100644 --- a/score/datarouter/mocks/daemon/dlt_log_server_mock.h +++ b/score/datarouter/mocks/daemon/dlt_log_server_mock.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef DLT_LOG_SERVER_MOCK_H_ -#define DLT_LOG_SERVER_MOCK_H_ +#ifndef SCORE_DATAROUTER_MOCKS_DAEMON_DLT_LOG_SERVER_MOCK_H +#define SCORE_DATAROUTER_MOCKS_DAEMON_DLT_LOG_SERVER_MOCK_H #include @@ -30,23 +30,20 @@ namespace mock class DltLogServerMock : public IDltLogServer { public: - MOCK_METHOD(const std::string, ReadLogChannelNames, (), (override)); - MOCK_METHOD(const std::string, ResetToDefault, (), (override)); - MOCK_METHOD(const std::string, StoreDltConfig, (), (override)); - MOCK_METHOD(const std::string, SetTraceState, (), (override)); - MOCK_METHOD(const std::string, SetDefaultTraceState, (), (override)); - MOCK_METHOD(const std::string, SetLogChannelThreshold, (score::platform::dltid_t, loglevel_t), (override)); - MOCK_METHOD(const std::string, - SetLogLevel, - (score::platform::dltid_t, score::platform::dltid_t, threshold_t), - (override)); - MOCK_METHOD(const std::string, SetMessagingFilteringState, (bool), (override)); - MOCK_METHOD(const std::string, SetDefaultLogLevel, (loglevel_t), (override)); - MOCK_METHOD(const std::string, + MOCK_METHOD(std::string, ReadLogChannelNames, (), (override)); + MOCK_METHOD(std::string, ResetToDefault, (), (override)); + MOCK_METHOD(std::string, StoreDltConfig, (), (override)); + MOCK_METHOD(std::string, SetTraceState, (), (override)); + MOCK_METHOD(std::string, SetDefaultTraceState, (), (override)); + MOCK_METHOD(std::string, SetLogChannelThreshold, (score::platform::DltidT, LoglevelT), (override)); + MOCK_METHOD(std::string, SetLogLevel, (score::platform::DltidT, score::platform::DltidT, ThresholdT), (override)); + MOCK_METHOD(std::string, SetMessagingFilteringState, (bool), (override)); + MOCK_METHOD(std::string, SetDefaultLogLevel, (LoglevelT), (override)); + MOCK_METHOD(std::string, SetLogChannelAssignment, - (score::platform::dltid_t, score::platform::dltid_t, score::platform::dltid_t, AssignmentAction), + (score::platform::DltidT, score::platform::DltidT, score::platform::DltidT, AssignmentAction), (override)); - MOCK_METHOD(const std::string, SetDltOutputEnable, (bool), (override)); + MOCK_METHOD(std::string, SetDltOutputEnable, (bool), (override)); }; } // namespace mock @@ -55,4 +52,4 @@ class DltLogServerMock : public IDltLogServer } // namespace logging } // namespace score -#endif // DLT_LOG_SERVER_MOCK_H_ +#endif // SCORE_DATAROUTER_MOCKS_DAEMON_DLT_LOG_SERVER_MOCK_H diff --git a/score/datarouter/mocks/daemon/log_sender_mock.h b/score/datarouter/mocks/daemon/log_sender_mock.h index b05a3fa..b3e5432 100644 --- a/score/datarouter/mocks/daemon/log_sender_mock.h +++ b/score/datarouter/mocks/daemon/log_sender_mock.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef LOG_SENDER_MOCK_H_ -#define LOG_SENDER_MOCK_H_ +#ifndef SCORE_DATAROUTER_MOCKS_DAEMON_LOG_SENDER_MOCK_H +#define SCORE_DATAROUTER_MOCKS_DAEMON_LOG_SENDER_MOCK_H #include @@ -48,8 +48,8 @@ class LogSenderMock : public ILogSender SendFTVerbose, (score::cpp::span data, score::mw::log::LogLevel loglevel, - dltid_t appId, - dltid_t ctxId, + DltidT app_id, + DltidT ctx_id, uint8_t nor, uint32_t tmsp, DltLogChannel& c), @@ -62,4 +62,4 @@ class LogSenderMock : public ILogSender } // namespace logging } // namespace score -#endif // LOG_SENDER_MOCK_H_ +#endif // SCORE_DATAROUTER_MOCKS_DAEMON_LOG_SENDER_MOCK_H diff --git a/score/datarouter/mocks/daemon/udp_stream_output.h b/score/datarouter/mocks/daemon/udp_stream_output.h index f49bd38..875c439 100644 --- a/score/datarouter/mocks/daemon/udp_stream_output.h +++ b/score/datarouter/mocks/daemon/udp_stream_output.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef UDP_STREAM_OUTPUT_H_ -#define UDP_STREAM_OUTPUT_H_ +#ifndef SCORE_DATAROUTER_MOCKS_DAEMON_UDP_STREAM_OUTPUT_H +#define SCORE_DATAROUTER_MOCKS_DAEMON_UDP_STREAM_OUTPUT_H #include #include @@ -39,7 +39,7 @@ class UdpStreamOutput class Tester { public: - static Tester*& instance() + static Tester*& Instance() { static Tester instance; static Tester* p_instance = &instance; // overwritable @@ -47,38 +47,38 @@ class UdpStreamOutput } MOCK_METHOD(void, construct, (UdpStreamOutput*, const char*, uint16_t, const char*)); - MOCK_METHOD(void, move_construct, (UdpStreamOutput*, UdpStreamOutput*)); - MOCK_METHOD(void, destruct, (UdpStreamOutput*)); + MOCK_METHOD(void, MoveConstruct, (UdpStreamOutput*, UdpStreamOutput*)); + MOCK_METHOD(void, Destruct, (UdpStreamOutput*)); - MOCK_METHOD(score::cpp::expected_blank, bind, (UdpStreamOutput*, const char*, uint16_t)); - MOCK_METHOD((score::cpp::expected), send, (UdpStreamOutput*, const iovec*, size_t)); - MOCK_METHOD((score::cpp::expected), send, (UdpStreamOutput*, score::cpp::span)); + MOCK_METHOD(score::cpp::expected_blank, Bind, (UdpStreamOutput*, const char*, uint16_t)); + MOCK_METHOD((score::cpp::expected), Send, (UdpStreamOutput*, const iovec*, size_t)); + MOCK_METHOD((score::cpp::expected), Send, (UdpStreamOutput*, score::cpp::span)); }; - UdpStreamOutput(const char* dstAddr, uint16_t dstPort, const char* multicastInterface) + UdpStreamOutput(const char* dst_addr, uint16_t dst_port, const char* multicast_interface) { - Tester::instance()->construct(this, dstAddr, dstPort, multicastInterface); + Tester::Instance()->construct(this, dst_addr, dst_port, multicast_interface); } ~UdpStreamOutput() { - Tester::instance()->destruct(this); + Tester::Instance()->Destruct(this); } UdpStreamOutput(const UdpStreamOutput&) = delete; UdpStreamOutput(UdpStreamOutput&& from) noexcept { - Tester::instance()->move_construct(this, &from); + Tester::Instance()->MoveConstruct(this, &from); } - score::cpp::expected_blank bind(const char* srcAddr = nullptr, uint16_t srcPort = 0) + score::cpp::expected_blank Bind(const char* src_addr = nullptr, uint16_t src_port = 0) { - return Tester::instance()->bind(this, srcAddr, srcPort); + return Tester::Instance()->Bind(this, src_addr, src_port); } - score::cpp::expected send(const iovec* data, size_t size) + score::cpp::expected Send(const iovec* data, size_t size) { - return Tester::instance()->send(this, data, size); + return Tester::Instance()->Send(this, data, size); } - score::cpp::expected send(score::cpp::span mmsgSpan) + score::cpp::expected Send(score::cpp::span mmsg_span) { - return Tester::instance()->send(this, mmsgSpan); + return Tester::Instance()->Send(this, mmsg_span); } }; @@ -88,4 +88,4 @@ class UdpStreamOutput } // namespace logging } // namespace score -#endif // UDP_STREAM_OUTPUT_H_ +#endif // SCORE_DATAROUTER_MOCKS_DAEMON_UDP_STREAM_OUTPUT_H diff --git a/score/datarouter/mocks/logparser_mock.h b/score/datarouter/mocks/logparser_mock.h index 346deff..f6f725f 100644 --- a/score/datarouter/mocks/logparser_mock.h +++ b/score/datarouter/mocks/logparser_mock.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef PAS_LOGGING_LOGPARSERMOCK_H_ -#define PAS_LOGGING_LOGPARSERMOCK_H_ +#ifndef SCORE_DATAROUTER_MOCKS_LOGPARSER_MOCK_H +#define SCORE_DATAROUTER_MOCKS_LOGPARSER_MOCK_H #include "logparser/i_logparser.h" @@ -34,22 +34,22 @@ class LogParserMock : public ILogParser public: ~LogParserMock() = default; - MOCK_METHOD(void, set_filter_factory, (FilterFunctionFactory factory), (override)); + MOCK_METHOD(void, SetFilterFactory, (FilterFunctionFactory factory), (override)); - MOCK_METHOD(void, add_incoming_type, (const bufsize_t map_index, const std::string& params), (override)); + MOCK_METHOD(void, AddIncomingType, (const BufsizeT map_index, const std::string& params), (override)); MOCK_METHOD(void, AddIncomingType, (const score::mw::log::detail::TypeRegistration&), (override)); - MOCK_METHOD(void, add_type_handler, (const std::string& typeName, TypeHandler& handler), (override)); - MOCK_METHOD(void, add_global_handler, (AnyHandler & handler), (override)); + MOCK_METHOD(void, AddTypeHandler, (const std::string& type_name, TypeHandler& handler), (override)); + MOCK_METHOD(void, AddGlobalHandler, (AnyHandler & handler), (override)); - MOCK_METHOD(void, remove_type_handler, (const std::string& typeName, TypeHandler& handler), (override)); - MOCK_METHOD(void, remove_global_handler, (AnyHandler & handler), (override)); + MOCK_METHOD(void, RemoveTypeHandler, (const std::string& type_name, TypeHandler& handler), (override)); + MOCK_METHOD(void, RemoveGlobalHandler, (AnyHandler & handler), (override)); - MOCK_METHOD(bool, is_type_hndl_registered, (const std::string& typeName, const TypeHandler& handler), (override)); - MOCK_METHOD(bool, is_glb_hndl_registered, (const AnyHandler& handler), (override)); + MOCK_METHOD(bool, IsTypeHndlRegistered, (const std::string& type_name, const TypeHandler& handler), (override)); + MOCK_METHOD(bool, IsGlbHndlRegistered, (const AnyHandler& handler), (override)); - MOCK_METHOD(void, reset_internal_mapping, (), (override)); - MOCK_METHOD(void, parse, (timestamp_t timestamp, const char* data, bufsize_t size), (override)); + MOCK_METHOD(void, ResetInternalMapping, (), (override)); + MOCK_METHOD(void, Parse, (TimestampT timestamp, const char* data, BufsizeT size), (override)); MOCK_METHOD(void, Parse, (const score::mw::log::detail::SharedMemoryRecord& record), (override)); }; @@ -57,4 +57,4 @@ class LogParserMock : public ILogParser } // namespace platform } // namespace score -#endif // PAS_LOGGING_LOGPARSERMOCK_H_ +#endif // SCORE_DATAROUTER_MOCKS_LOGPARSER_MOCK_H diff --git a/score/datarouter/mocks/unix_domain/unix_domain_server.h b/score/datarouter/mocks/unix_domain/unix_domain_server.h index 45ae062..37bc931 100644 --- a/score/datarouter/mocks/unix_domain/unix_domain_server.h +++ b/score/datarouter/mocks/unix_domain/unix_domain_server.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef UNIX_DOMAIN_SERVER_H_ -#define UNIX_DOMAIN_SERVER_H_ +#ifndef SCORE_DATAROUTER_MOCKS_UNIX_DOMAIN_UNIX_DOMAIN_SERVER_H +#define SCORE_DATAROUTER_MOCKS_UNIX_DOMAIN_UNIX_DOMAIN_SERVER_H #include "i_session.h" #include "unix_domain/unix_domain_common.h" @@ -45,7 +45,7 @@ class UnixDomainServer { } - void pass_message(const std::string& message) const + void PassMessage(const std::string& message) const { if (last_message_.has_value()) { @@ -70,14 +70,14 @@ class UnixDomainServer namespace dummy_namespace { // dummy type to avoid warnings Wsuggest-final-types and Wsuggest-final-methods -struct temp_marker final : UnixDomainServer::ISession +struct TempMarker final : UnixDomainServer::ISession { - bool tick() override + bool Tick() override { return false; }; - void on_command(const std::string&) override {} - void on_closed_by_peer() override {} + void OnCommand(const std::string&) override {} + void OnClosedByPeer() override {} }; } // namespace dummy_namespace @@ -87,4 +87,4 @@ struct temp_marker final : UnixDomainServer::ISession } // namespace platform } // namespace score -#endif // UNIX_DOMAIN_SERVER_H_ +#endif // SCORE_DATAROUTER_MOCKS_UNIX_DOMAIN_UNIX_DOMAIN_SERVER_H diff --git a/score/datarouter/src/applications/datarouter_app.cpp b/score/datarouter/src/applications/datarouter_app.cpp index ee2eb8f..27b5dd3 100644 --- a/score/datarouter/src/applications/datarouter_app.cpp +++ b/score/datarouter/src/applications/datarouter_app.cpp @@ -22,7 +22,7 @@ namespace { -const std::string program_version{"Version 0.1s"}; +const std::string kProgramVersion{"Version 0.1s"}; } // namespace namespace score @@ -34,27 +34,27 @@ namespace datarouter using namespace score::platform::datarouter; -void datarouter_app_init() +void DatarouterAppInit() { - score::mw::log::LogInfo() << "datarouter application" << program_version << "starting"; + score::mw::log::LogInfo() << "datarouter application" << kProgramVersion << "starting"; } -void datarouter_app_run(const std::atomic_bool& exit_requested) +void DatarouterAppRun(const std::atomic_bool& exit_requested) { - const score::logging::options::Options& opts = score::logging::options::Options::get(); + const score::logging::options::Options& opts = score::logging::options::Options::Get(); - if (opts.do_nothing()) + if (opts.DoNothing()) { return; } - if (opts.print_version()) + if (opts.PrintVersion()) { - std::cout << program_version << "\n"; + std::cout << kProgramVersion << "\n"; return; } - if (opts.no_adaptive_runtime()) + if (opts.NoAdaptiveRuntime()) { score::mw::log::LogInfo() << "datarouter will not use the Vector stack. Persistency features will not be available."; @@ -62,10 +62,10 @@ void datarouter_app_run(const std::atomic_bool& exit_requested) score::mw::log::LogInfo() << "datarouter successfully completed initialization and goes live!"; - SocketServer::run(exit_requested, opts.no_adaptive_runtime()); + SocketServer::Run(exit_requested, opts.NoAdaptiveRuntime()); } -void datarouter_app_shutdown() +void DatarouterAppShutdown() { score::mw::log::LogInfo() << "shutting down"; } diff --git a/score/datarouter/src/applications/datarouter_app.h b/score/datarouter/src/applications/datarouter_app.h index 96ace74..9993a05 100644 --- a/score/datarouter/src/applications/datarouter_app.h +++ b/score/datarouter/src/applications/datarouter_app.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef LOGGING_APPLICATIONS_DATAROUTER_APP_H_ -#define LOGGING_APPLICATIONS_DATAROUTER_APP_H_ +#ifndef SCORE_DATAROUTER_SRC_APPLICATIONS_DATAROUTER_APP_H +#define SCORE_DATAROUTER_SRC_APPLICATIONS_DATAROUTER_APP_H #include @@ -23,12 +23,12 @@ namespace logging namespace datarouter { -extern void datarouter_app_init(); -extern void datarouter_app_run(const std::atomic_bool& exit_requested); -extern void datarouter_app_shutdown(); +extern void DatarouterAppInit(); +extern void DatarouterAppRun(const std::atomic_bool& exit_requested); +extern void DatarouterAppShutdown(); } // namespace datarouter } // namespace logging } // namespace score -#endif // LOGGING_APPLICATIONS_DATAROUTER_APP_H_ +#endif // SCORE_DATAROUTER_SRC_APPLICATIONS_DATAROUTER_APP_H diff --git a/score/datarouter/src/applications/main_nonadaptive.cpp b/score/datarouter/src/applications/main_nonadaptive.cpp index 7a2cbc1..e514139 100644 --- a/score/datarouter/src/applications/main_nonadaptive.cpp +++ b/score/datarouter/src/applications/main_nonadaptive.cpp @@ -26,18 +26,18 @@ namespace { -std::atomic_bool exit_requested; +std::atomic_bool gExitRequested; -void signal_handler(std::int32_t /* signal */) +void SignalHandler(std::int32_t /* signal */) { - exit_requested = true; + gExitRequested = true; } } // namespace int main(std::int32_t argc, const char* argv[]) { score::cpp::span args(argv, static_cast::size_type>(argc)); - if (!score::logging::options::Options::parse(argc, const_cast(argv))) + if (!score::logging::options::Options::Parse(argc, const_cast(argv))) { // Error messages have already been logged, just say goodbye. score::mw::log::LogError() << std::string_view(args.front()) << "Terminating because of errors in command line"; @@ -55,7 +55,7 @@ int main(std::int32_t argc, const char* argv[]) { score::mw::log::LogError() << res.error(); } - sig_handler.sa_handler = signal_handler; + sig_handler.sa_handler = SignalHandler; sig_handler.sa_mask = sig_set; sig_handler.sa_flags = 0; res = sig.SigAction(SIGTERM, sig_handler, old_sigaction); @@ -63,9 +63,9 @@ int main(std::int32_t argc, const char* argv[]) { score::mw::log::LogError() << res.error(); } - score::logging::datarouter::datarouter_app_init(); - score::logging::datarouter::datarouter_app_run(exit_requested); - score::logging::datarouter::datarouter_app_shutdown(); + score::logging::datarouter::DatarouterAppInit(); + score::logging::datarouter::DatarouterAppRun(gExitRequested); + score::logging::datarouter::DatarouterAppShutdown(); return 0; } diff --git a/score/datarouter/src/applications/options.cpp b/score/datarouter/src/applications/options.cpp index 12d841e..9c9b319 100644 --- a/score/datarouter/src/applications/options.cpp +++ b/score/datarouter/src/applications/options.cpp @@ -25,13 +25,13 @@ namespace { -void emit_message(const std::string& msg) +void EmitMessage(const std::string& msg) { std::cerr << msg << "\n"; score::mw::log::LogError() << "Error in command line:" << msg; } -void report_error(const std::string& text, const char opt_char, const std::string& arg) +void ReportError(const std::string& text, const char opt_char, const std::string& arg) { std::string msg = text; @@ -50,10 +50,10 @@ void report_error(const std::string& text, const char opt_char, const std::strin msg += "\""; - emit_message(msg); + EmitMessage(msg); } -void print_usage(std::string_view program) +void PrintUsage(std::string_view program) { std::cout << "Usage: " << program @@ -76,9 +76,9 @@ namespace options Options::Options() : do_nothing_(false), print_version_(false), verbose_(false), no_adaptive_runtime_(false) {} // NOLINTNEXTLINE(modernize-avoid-c-arrays): C style array is needed as it has to have main style arguments. -bool Options::parse(std::int32_t argc, char* const argv[]) +bool Options::Parse(std::int32_t argc, char* const argv[]) { - Options& options = Options::get(); + Options& options = Options::Get(); score::cpp::span args(argv, static_cast::size_type>(argc)); @@ -92,7 +92,7 @@ bool Options::parse(std::int32_t argc, char* const argv[]) std::string_view long_option_name = argument_token.substr(2); if (long_option_name == "help") { - print_usage(args.front()); + PrintUsage(args.front()); options.do_nothing_ = true; return true; } @@ -111,7 +111,7 @@ bool Options::parse(std::int32_t argc, char* const argv[]) } else { - report_error("Unknown", '?', score::cpp::at(args, arg_index)); + ReportError("Unknown", '?', score::cpp::at(args, arg_index)); return false; } } @@ -127,7 +127,7 @@ bool Options::parse(std::int32_t argc, char* const argv[]) switch (short_option_char) { case 'h': - print_usage(args.front()); + PrintUsage(args.front()); options.do_nothing_ = true; return true; @@ -144,7 +144,7 @@ bool Options::parse(std::int32_t argc, char* const argv[]) return true; default: - report_error("Unknown", short_option_char, score::cpp::at(args, arg_index)); + ReportError("Unknown", short_option_char, score::cpp::at(args, arg_index)); return false; } } @@ -154,7 +154,7 @@ bool Options::parse(std::int32_t argc, char* const argv[]) return true; } -Options& Options::get() +Options& Options::Get() { static Options options; return options; diff --git a/score/datarouter/src/applications/options.h b/score/datarouter/src/applications/options.h index e0b18d7..8b3b375 100644 --- a/score/datarouter/src/applications/options.h +++ b/score/datarouter/src/applications/options.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef LOGGING_APPLICATIONS_OPTIONS_H_ -#define LOGGING_APPLICATIONS_OPTIONS_H_ +#ifndef SCORE_DATAROUTER_SRC_APPLICATIONS_OPTIONS_H +#define SCORE_DATAROUTER_SRC_APPLICATIONS_OPTIONS_H #include @@ -35,22 +35,22 @@ class Options { public: // NOLINTNEXTLINE(modernize-avoid-c-arrays): C style array is needed as it has to have main style arguments. - static bool parse(std::int32_t argc, char* const argv[]); - static Options& get(); + static bool Parse(std::int32_t argc, char* const argv[]); + static Options& Get(); - bool do_nothing() const + bool DoNothing() const { return do_nothing_; } - bool print_version() const + bool PrintVersion() const { return print_version_; } - bool verbose() const + bool Verbose() const { return verbose_; } - bool no_adaptive_runtime() const + bool NoAdaptiveRuntime() const { return no_adaptive_runtime_; } @@ -72,4 +72,4 @@ class Options } // namespace logging } // namespace score -#endif // LOGGING_APPLICATIONS_OPTIONS_H_ +#endif // SCORE_DATAROUTER_SRC_APPLICATIONS_OPTIONS_H diff --git a/score/datarouter/src/configuration/dynamic_config/i_session.h b/score/datarouter/src/configuration/dynamic_config/i_session.h index f26822e..9a3914f 100644 --- a/score/datarouter/src/configuration/dynamic_config/i_session.h +++ b/score/datarouter/src/configuration/dynamic_config/i_session.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef I_SESSION_H -#define I_SESSION_H +#ifndef SCORE_DATAROUTER_SRC_CONFIGURATION_DYNAMIC_CONFIG_I_SESSION_H +#define SCORE_DATAROUTER_SRC_CONFIGURATION_DYNAMIC_CONFIG_I_SESSION_H #include @@ -24,13 +24,13 @@ namespace logging class ISession { public: - virtual bool tick() = 0; - virtual void on_command(const std::string& /*command*/) {} - virtual void on_closed_by_peer() {} + virtual bool Tick() = 0; + virtual void OnCommand(const std::string& /*command*/) {} + virtual void OnClosedByPeer() {} virtual ~ISession() = default; }; } // namespace logging } // namespace score -#endif // I_SESSION_H +#endif // SCORE_DATAROUTER_SRC_CONFIGURATION_DYNAMIC_CONFIG_I_SESSION_H diff --git a/score/datarouter/src/daemon/diagnostic_job_handler.cpp b/score/datarouter/src/daemon/diagnostic_job_handler.cpp index 84b43d1..d90182d 100644 --- a/score/datarouter/src/daemon/diagnostic_job_handler.cpp +++ b/score/datarouter/src/daemon/diagnostic_job_handler.cpp @@ -21,57 +21,57 @@ namespace logging namespace dltserver { -const std::string ReadLogChannelNamesHandler::execute(IDltLogServer& srv) +std::string ReadLogChannelNamesHandler::Execute(IDltLogServer& srv) { return srv.ReadLogChannelNames(); } -const std::string ResetToDefaultHandler::execute(IDltLogServer& srv) +std::string ResetToDefaultHandler::Execute(IDltLogServer& srv) { return srv.ResetToDefault(); } -const std::string StoreDltConfigHandler::execute(IDltLogServer& srv) +std::string StoreDltConfigHandler::Execute(IDltLogServer& srv) { return srv.StoreDltConfig(); } -const std::string SetTraceStateHandler::execute(IDltLogServer& srv) +std::string SetTraceStateHandler::Execute(IDltLogServer& srv) { return srv.SetTraceState(); } -const std::string SetDefaultTraceStateHandler::execute(IDltLogServer& srv) +std::string SetDefaultTraceStateHandler::Execute(IDltLogServer& srv) { return srv.SetDefaultTraceState(); } -const std::string SetLogChannelThresholdHandler::execute(IDltLogServer& srv) +std::string SetLogChannelThresholdHandler::Execute(IDltLogServer& srv) { return srv.SetLogChannelThreshold(channel_, threshold_); } -const std::string SetLogLevelHandler::execute(IDltLogServer& srv) +std::string SetLogLevelHandler::Execute(IDltLogServer& srv) { - return srv.SetLogLevel(appId_, ctxId_, threshold_); + return srv.SetLogLevel(app_id_, ctx_id_, threshold_); } -const std::string SetMessagingFilteringStateHandler::execute(IDltLogServer& srv) +std::string SetMessagingFilteringStateHandler::Execute(IDltLogServer& srv) { return srv.SetMessagingFilteringState(enabled_); } -const std::string SetDefaultLogLevelHandler::execute(IDltLogServer& srv) +std::string SetDefaultLogLevelHandler::Execute(IDltLogServer& srv) { return srv.SetDefaultLogLevel(level_); } -const std::string SetLogChannelAssignmentHandler::execute(IDltLogServer& srv) +std::string SetLogChannelAssignmentHandler::Execute(IDltLogServer& srv) { - return srv.SetLogChannelAssignment(appId_, ctxId_, channel_, assignment_flag_); + return srv.SetLogChannelAssignment(app_id_, ctx_id_, channel_, assignment_flag_); } -const std::string SetDltOutputEnableHandler::execute(IDltLogServer& srv) +std::string SetDltOutputEnableHandler::Execute(IDltLogServer& srv) { return srv.SetDltOutputEnable(enable_); } diff --git a/score/datarouter/src/daemon/diagnostic_job_parser.cpp b/score/datarouter/src/daemon/diagnostic_job_parser.cpp index 461cc78..cf9f314 100644 --- a/score/datarouter/src/daemon/diagnostic_job_parser.cpp +++ b/score/datarouter/src/daemon/diagnostic_job_parser.cpp @@ -30,7 +30,7 @@ constexpr auto kChannelIdSize{4UL}; constexpr auto kTraceStateId{1UL}; constexpr auto kStateSize{1UL}; -score::platform::dltid_t extractId(const std::string& message, const size_t offset) +score::platform::DltidT ExtractId(const std::string& message, const size_t offset) { auto it = message.begin(); if (offset > std::numeric_limits::max()) @@ -39,50 +39,50 @@ score::platform::dltid_t extractId(const std::string& message, const size_t offs return {}; } std::advance(it, static_cast(offset)); - auto* src = std::addressof(*it); - score::platform::dltid_t id(src); + const auto* src = std::addressof(*it); + score::platform::DltidT id(src); return id; } -void appendId(score::platform::dltid_t name, std::string& message) +void AppendId(score::platform::DltidT name, std::string& message) { std::string chunk = static_cast(name).substr(0, 4); // Take only up to 4 characters chunk.resize(4, '\0'); message.append(chunk); } -std::unique_ptr DiagnosticJobParser::parse(const std::string& command) +std::unique_ptr DiagnosticJobParser::Parse(const std::string& command) { if (command.empty()) { return nullptr; } - const auto commandId = static_cast(command[0]); + const auto command_id = static_cast(command[0]); - switch (commandId) + switch (command_id) { - case config::READ_LOG_CHANNEL_NAMES: + case config::kReadLogChannelNames: { return std::make_unique(); } - case config::RESET_TO_DEFAULT: + case config::kResetToDefault: { return std::make_unique(); } - case config::STORE_DLT_CONFIG: + case config::kStoreDltConfig: { return std::make_unique(); } - case config::SET_TRACE_STATE: + case config::kSetTraceState: { return std::make_unique(); } - case config::SET_DEFAULT_TRACE_STATE: + case config::kSetDefaultTraceState: { return std::make_unique(); } - case config::SET_LOG_CHANNEL_THRESHOLD: + case config::kSetLogChannelThreshold: { if (command.size() != kDiagnosticCommandSize + kChannelIdSize + kLogLevelSize + kTraceStateId) @@ -95,7 +95,7 @@ std::unique_ptr DiagnosticJobParser::parse(const std::str if (read_level.has_value()) { auto diag_job_handler = std::make_unique( - extractId(command, kDiagnosticCommandSize), read_level.value()); + ExtractId(command, kDiagnosticCommandSize), read_level.value()); return diag_job_handler; } else @@ -106,7 +106,7 @@ std::unique_ptr DiagnosticJobParser::parse(const std::str // Trace state (command[kDiagnosticCommandSize + kChannelIdSize + kLogLevelSize] is ignored for now } - case config::SET_LOG_LEVEL: + case config::kSetLogLevel: { if (command.size() != kDiagnosticCommandSize + kAppIdSize + kCtxIdSize + kLogLevelSize) @@ -116,15 +116,15 @@ std::unique_ptr DiagnosticJobParser::parse(const std::str auto threshold = static_cast(command[kDiagnosticCommandSize + kAppIdSize + kCtxIdSize]); - if (threshold == static_cast(ThresholdCmd::UseDefault)) + if (threshold == static_cast(ThresholdCmd::kUseDefault)) { // LCOV_EXCL_START : see below // tooling issue, this part is covered by unit tests DiagnosticJobParserTest::SetLogLevel_OK_UseDefault. // For the quality team argumentation, kindly, check Ticket-200702 and Ticket-229594. auto diag_job_handler = - std::make_unique(extractId(command, kDiagnosticCommandSize), - extractId(command, kDiagnosticCommandSize + kAppIdSize), - ThresholdCmd::UseDefault); + std::make_unique(ExtractId(command, kDiagnosticCommandSize), + ExtractId(command, kDiagnosticCommandSize + kAppIdSize), + ThresholdCmd::kUseDefault); // LCOV_EXCL_STOP return diag_job_handler; } @@ -134,8 +134,8 @@ std::unique_ptr DiagnosticJobParser::parse(const std::str if (read_level.has_value()) { auto diag_job_handler = - std::make_unique(extractId(command, kDiagnosticCommandSize), - extractId(command, kDiagnosticCommandSize + kAppIdSize), + std::make_unique(ExtractId(command, kDiagnosticCommandSize), + ExtractId(command, kDiagnosticCommandSize + kAppIdSize), read_level.value()); return diag_job_handler; } @@ -147,7 +147,7 @@ std::unique_ptr DiagnosticJobParser::parse(const std::str } } - case config::SET_MESSAGING_FILTERING_STATE: + case config::kSetMessagingFilteringState: { if (command.size() != kDiagnosticCommandSize + kStateSize) @@ -161,7 +161,7 @@ std::unique_ptr DiagnosticJobParser::parse(const std::str return diag_job_handler; } - case config::SET_DEFAULT_LOG_LEVEL: + case config::kSetDefaultLogLevel: { if (command.size() != kDiagnosticCommandSize + kLogLevelSize) { @@ -185,7 +185,7 @@ std::unique_ptr DiagnosticJobParser::parse(const std::str } } - case config::SET_LOG_CHANNEL_ASSIGNMENT: + case config::kSetLogChannelAssignment: { if (command.size() != kDiagnosticCommandSize + kAppIdSize + kCtxIdSize + kChannelIdSize + kLogLevelSize) { @@ -195,7 +195,7 @@ std::unique_ptr DiagnosticJobParser::parse(const std::str const auto action_byte = static_cast( static_cast(command[kDiagnosticCommandSize + kAppIdSize + kCtxIdSize + kChannelIdSize])); - const auto action_opt = getAssignmentAction(action_byte); + const auto action_opt = GetAssignmentAction(action_byte); if (!action_opt.has_value()) { std::cerr << "Incorrect value of assignment received from diagnostics" << std::endl; @@ -203,27 +203,27 @@ std::unique_ptr DiagnosticJobParser::parse(const std::str } auto diag_job_handler = std::make_unique( - extractId(command, kDiagnosticCommandSize), - extractId(command, kDiagnosticCommandSize + kAppIdSize), - extractId(command, kDiagnosticCommandSize + kAppIdSize + kCtxIdSize), + ExtractId(command, kDiagnosticCommandSize), + ExtractId(command, kDiagnosticCommandSize + kAppIdSize), + ExtractId(command, kDiagnosticCommandSize + kAppIdSize + kCtxIdSize), action_opt.value()); return diag_job_handler; } - case config::SET_DLT_OUTPUT_ENABLE: + case config::kSetDltOutputEnable: { if (command.size() != kDiagnosticCommandSize + kStateSize) { return nullptr; } auto flag = static_cast(command[kDiagnosticCommandSize]); - if (flag != config::ENABLE && flag != config::DISABLE) + if (flag != config::kEnable && flag != config::kDisable) { return nullptr; } - auto diag_job_handler = std::make_unique(flag == config::ENABLE); + auto diag_job_handler = std::make_unique(flag == config::kEnable); return diag_job_handler; } @@ -234,9 +234,9 @@ std::unique_ptr DiagnosticJobParser::parse(const std::str } } -std::optional DiagnosticJobParser::getAssignmentAction(std::uint8_t value) noexcept +std::optional DiagnosticJobParser::GetAssignmentAction(std::uint8_t value) noexcept { - if (value <= static_cast(AssignmentAction::Add)) + if (value <= static_cast(AssignmentAction::kAdd)) { return static_cast(value); } diff --git a/score/datarouter/src/daemon/dlt_log_channel.cpp b/score/datarouter/src/daemon/dlt_log_channel.cpp index 11e904d..4368707 100644 --- a/score/datarouter/src/daemon/dlt_log_channel.cpp +++ b/score/datarouter/src/daemon/dlt_log_channel.cpp @@ -29,12 +29,12 @@ namespace constexpr auto kBurstFileTransferControlCount{5UL}; } // namespace -void DltLogChannel::sendNonVerbose(const score::mw::log::config::NvMsgDescriptor& desc, +void DltLogChannel::SendNonVerbose(const score::mw::log::config::NvMsgDescriptor& desc, uint32_t tmsp, const void* data, size_t size) { - if (desc.GetLogLevel() > channelThreshold_.load(std::memory_order_relaxed)) + if (desc.GetLogLevel() > channel_threshold.load(std::memory_order_relaxed)) { return; } @@ -51,13 +51,13 @@ void DltLogChannel::sendNonVerbose(const score::mw::log::config::NvMsgDescriptor prebuf_is_verbose_ = false; } - if (prebuf_size_ + full_size <= UDP_MAX_PAYLOAD) // add to current buffer as it fits + if (prebuf_size_ + full_size <= kUdpMaxPayload) // add to current buffer as it fits { // Use .at() to avoid "non-constant subscript" warning generated from clang auto& buffer = prebuf_data_.at(vector_index_); // Use iterator arithmetic (not pointer arithmetic) to solve warning generated from clang - auto it = buffer.begin(); + auto* it = buffer.begin(); if (prebuf_size_ > std::numeric_limits::max()) { // This check ensures that `prebuf_size_` can be safely converted to a signed type @@ -83,14 +83,14 @@ void DltLogChannel::sendNonVerbose(const score::mw::log::config::NvMsgDescriptor */ // coverity[autosar_cpp14_m5_2_10_violation] score::platform::internal::ConstructNonVerbosePacket( - dest, data, size, desc.GetIdMsgDescriptor(), ecu_, mcnt_++, tmsp); + dest, data, size, desc.GetIdMsgDescriptor(), ecu, mcnt_++, tmsp); prebuf_size_ += full_size; } else // doesn't fit in current buffer { SendUdp(); - if (full_size < UDP_MAX_PAYLOAD) // fits in our prebuf + if (full_size < kUdpMaxPayload) // fits in our prebuf { // Use .at() to avoid "non-constant subscript" warning generated from clang auto& buffer = prebuf_data_.at(vector_index_); @@ -98,7 +98,7 @@ void DltLogChannel::sendNonVerbose(const score::mw::log::config::NvMsgDescriptor // coverity[autosar_cpp14_m5_2_10_violation] score::platform::internal::ConstructNonVerbosePacket( - dest, data, size, desc.GetIdMsgDescriptor(), ecu_, mcnt_++, tmsp); + dest, data, size, desc.GetIdMsgDescriptor(), ecu, mcnt_++, tmsp); prebuf_size_ += full_size; } @@ -111,7 +111,7 @@ void DltLogChannel::sendNonVerbose(const score::mw::log::config::NvMsgDescriptor score::platform::internal::DltNvHeaderWithMsgid header; // coverity[autosar_cpp14_m5_2_10_violation] const auto header_size = score::platform::internal::ConstructNonVerboseHeader( - header, size, desc.GetIdMsgDescriptor(), ecu_, mcnt_++, tmsp); + header, size, desc.GetIdMsgDescriptor(), ecu, mcnt_++, tmsp); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) iovec is unchangable, It's (POSIX standard) io_vec[0].iov_base = static_cast(&header); io_vec[0].iov_len = header_size; @@ -121,7 +121,7 @@ void DltLogChannel::sendNonVerbose(const score::mw::log::config::NvMsgDescriptor io_vec[1].iov_base = const_cast(data); // NOLINTEND(cppcoreguidelines-pro-type-union-access) io_vec[1].iov_len = size; - const auto send_result = out_.send(io_vec.data(), kVectorStackCount); + const auto send_result = out_.Send(io_vec.data(), kVectorStackCount); if (send_result.has_value() == false) { ++non_verbose_.send_failures_count; @@ -132,11 +132,11 @@ void DltLogChannel::sendNonVerbose(const score::mw::log::config::NvMsgDescriptor } } -void DltLogChannel::sendVerbose( +void DltLogChannel::SendVerbose( const uint32_t tmsp, const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection& entry) { - if (entry.log_level > channelThreshold_.load(std::memory_order_relaxed)) + if (entry.log_level > channel_threshold.load(std::memory_order_relaxed)) { return; } @@ -153,13 +153,13 @@ void DltLogChannel::sendVerbose( SendUdp(); prebuf_is_verbose_ = true; } - if (prebuf_size_ + full_size <= UDP_MAX_PAYLOAD) + if (prebuf_size_ + full_size <= kUdpMaxPayload) { // Use .at() to avoid "non-constant subscript" warning generated from clang auto& buffer = prebuf_data_.at(vector_index_); // Use iterator arithmetic (not pointer arithmetic) to solve warning generated from clang - auto it = buffer.begin(); + auto* it = buffer.begin(); if (prebuf_size_ > std::numeric_limits::max()) { // This check ensures that `prebuf_size_` can be safely converted to a signed type @@ -176,7 +176,7 @@ void DltLogChannel::sendVerbose( auto* dest = std::addressof(*it); // coverity[autosar_cpp14_m5_2_10_violation] - score::platform::internal::ConstructVerbosePacket(dest, entry, ecu_, mcnt_++, tmsp); + score::platform::internal::ConstructVerbosePacket(dest, entry, ecu, mcnt_++, tmsp); prebuf_size_ += full_size; } @@ -184,13 +184,13 @@ void DltLogChannel::sendVerbose( { SendUdp(); - if (full_size < UDP_MAX_PAYLOAD) // just add it into the buffer if it is less than the buffer size + if (full_size < kUdpMaxPayload) // just add it into the buffer if it is less than the buffer size { // Use .at() to avoid "non-constant subscript" warning generated from clang auto& buffer = prebuf_data_.at(vector_index_); auto* dest = buffer.data(); // coverity[autosar_cpp14_m5_2_10_violation] - score::platform::internal::ConstructVerbosePacket(dest, entry, ecu_, mcnt_++, tmsp); + score::platform::internal::ConstructVerbosePacket(dest, entry, ecu, mcnt_++, tmsp); prebuf_size_ += full_size; } @@ -203,8 +203,7 @@ void DltLogChannel::sendVerbose( std::array io_vec{}; score::platform::internal::DltVerboseHeader header; // coverity[autosar_cpp14_m5_2_10_violation] - const auto header_size = - score::platform::internal::ConstructVerboseHeader(header, entry, ecu_, mcnt_++, tmsp); + const auto header_size = score::platform::internal::ConstructVerboseHeader(header, entry, ecu, mcnt_++, tmsp); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access) iovec is unchangable, It's (POSIX standard) io_vec[0].iov_base = static_cast(&header); io_vec[0].iov_len = header_size; @@ -214,7 +213,7 @@ void DltLogChannel::sendVerbose( io_vec[1].iov_base = const_cast(static_cast(entry.GetPayload().data())); // NOLINTEND(cppcoreguidelines-pro-type-union-access) io_vec[1].iov_len = static_cast(entry.GetPayload().size()); - const auto send_result = out_.send(io_vec.data(), kVectorStackCount); + const auto send_result = out_.Send(io_vec.data(), kVectorStackCount); if (send_result.has_value() == false) { ++verbose_.send_failures_count; @@ -225,29 +224,29 @@ void DltLogChannel::sendVerbose( } } -void DltLogChannel::sendFTVerbose(score::cpp::span data, +void DltLogChannel::SendFtVerbose(score::cpp::span data, const mw::log::LogLevel loglevel, - dltid_t appId, - dltid_t ctxId, + DltidT app_id, + DltidT ctx_id, uint8_t nor, uint32_t tmsp) { static auto start = std::chrono::system_clock::now(); - constexpr auto wait = std::chrono::milliseconds{kBurstFileTransferControlCount}; + constexpr auto kWait = std::chrono::milliseconds{kBurstFileTransferControlCount}; static auto iteration_counter = uint32_t{0UL}; iteration_counter++; if (iteration_counter % kBurstFileTransferControlCount == 0UL) { - std::this_thread::sleep_until(start + wait); + std::this_thread::sleep_until(start + kWait); } const auto data_size = static_cast(data.size()); score::platform::internal::DltVerboseHeader hdr; // coverity[autosar_cpp14_m5_2_10_violation] score::platform::internal::ConstructDltStandardHeader(hdr.std, data_size + sizeof(hdr), mcnt_++, true); - score::platform::internal::ConstructDltStandardHeaderExtra(hdr.stde, ecu_, tmsp); - score::platform::internal::ConstructDltExtendedHeader(hdr.ext, loglevel, nor, appId, ctxId); + score::platform::internal::ConstructDltStandardHeaderExtra(hdr.stde, ecu, tmsp); + score::platform::internal::ConstructDltExtendedHeader(hdr.ext, loglevel, nor, app_id, ctx_id); static constexpr auto kVectorStackCount = 2UL; std::array io_vec{}; @@ -264,7 +263,7 @@ void DltLogChannel::sendFTVerbose(score::cpp::span data, { // lock scope std::lock_guard lock(mutex_); FlushUnprotected(); - const auto send_result = out_.send(io_vec.data(), kVectorStackCount); + const auto send_result = out_.Send(io_vec.data(), kVectorStackCount); if (send_result.has_value() == false) { ++verbose_.send_failures_count; @@ -282,7 +281,7 @@ void DltLogChannel::FlushUnprotected() SendUdp(true); } -void DltLogChannel::flush() +void DltLogChannel::Flush() { std::lock_guard lock(mutex_); FlushUnprotected(); diff --git a/score/datarouter/src/daemon/dlt_log_server.cpp b/score/datarouter/src/daemon/dlt_log_server.cpp index da087fb..0f94620 100644 --- a/score/datarouter/src/daemon/dlt_log_server.cpp +++ b/score/datarouter/src/daemon/dlt_log_server.cpp @@ -38,80 +38,80 @@ void DltLogServer::SendNonVerbose(const score::mw::log::config::NvMsgDescriptor& auto sender = [&desc, &tmsp, &data, &size, this](DltLogChannel& c) { log_sender_->SendNonVerbose(desc, tmsp, data, size, c); }; - const auto appId = desc.GetAppId().GetStringView(); - const auto ctxId = desc.GetCtxId().GetStringView(); - filterAndCall(dltid_t{score::cpp::string_view{appId.data(), appId.size()}}, - dltid_t{score::cpp::string_view{ctxId.data(), ctxId.size()}}, + const auto app_id = desc.GetAppId().GetStringView(); + const auto ctx_id = desc.GetCtxId().GetStringView(); + FilterAndCall(DltidT{score::cpp::string_view{app_id.data(), app_id.size()}}, + DltidT{score::cpp::string_view{ctx_id.data(), ctx_id.size()}}, desc.GetLogLevel(), sender); } -void DltLogServer::sendVerbose( +void DltLogServer::SendVerbose( uint32_t tmsp, const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection& entry) { const auto sender = [&tmsp, &entry, this](DltLogChannel& c) { log_sender_->SendVerbose(tmsp, entry, c); }; - filterAndCall( - platform::convertToDltId(entry.app_id), platform::convertToDltId(entry.ctx_id), entry.log_level, sender); + FilterAndCall( + platform::ConvertToDltId(entry.app_id), platform::ConvertToDltId(entry.ctx_id), entry.log_level, sender); } void DltLogServer::SendFtVerbose(score::cpp::span data, mw::log::LogLevel loglevel, - dltid_t appId, - dltid_t ctxId, + DltidT app_id, + DltidT ctx_id, uint8_t nor, uint32_t tmsp) { - const auto sender = [&data, &loglevel, &appId, &ctxId, &nor, &tmsp, this](DltLogChannel& c) { - log_sender_->SendFTVerbose(data, loglevel, appId, ctxId, nor, tmsp, c); + const auto sender = [&data, &loglevel, &app_id, &ctx_id, &nor, &tmsp, this](DltLogChannel& c) { + log_sender_->SendFTVerbose(data, loglevel, app_id, ctx_id, nor, tmsp, c); }; // Coredump channel SIZE_MAX value means that there the configuration settings // don't explicitly specify the coredump channel - if (coredumpChannel_.has_value()) + if (coredump_channel_.has_value()) { - sender(channels_[coredumpChannel_.value()]); + sender(channels_[coredump_channel_.value()]); } else { - filterAndCall(appId, ctxId, loglevel, sender); + FilterAndCall(app_id, ctx_id, loglevel, sender); } } -void DltLogServer::init_log_channels(const bool reloading) +void DltLogServer::InitLogChannels(const bool reloading) { - if (staticConfig_.channels.empty()) + if (static_config_.channels.empty()) { std::cerr << "Empty channel list" << std::endl; - init_log_channels_default(reloading); + InitLogChannelsDefault(reloading); return; } - if (staticConfig_.channels.size() >= channelmask_t{}.size()) + if (static_config_.channels.size() >= ChannelmaskT{}.size()) { std::cerr << "Channel list too long" << std::endl; - init_log_channels_default(reloading); + InitLogChannelsDefault(reloading); return; } - coredumpChannel_ = std::nullopt; - PersistentConfig config{readerCallback_()}; - const bool hasPersistentConfig = !config.channels.empty(); + coredump_channel_ = std::nullopt; + PersistentConfig config{reader_callback_()}; + const bool has_persistent_config = !config.channels.empty(); // channels if (reloading) { for (auto& channel : channels_) { - const auto name = channel.channelName_; - const loglevel_t threshold = hasPersistentConfig ? config.channels[std::string(name)].channelThreshold - : staticConfig_.channels[name].channelThreshold; - channel.channelThreshold_.store(threshold, std::memory_order_relaxed); + const auto name = channel.channel_name; + const LoglevelT threshold = has_persistent_config ? config.channels[std::string(name)].channel_threshold + : static_config_.channels[name].channel_threshold; + channel.channel_threshold.store(threshold, std::memory_order_relaxed); } } else { - const auto& channels = staticConfig_.channels; + const auto& channels = static_config_.channels; size_t i = 0; /* Deviation from Rule M5-2-10: @@ -126,85 +126,86 @@ void DltLogServer::init_log_channels(const bool reloading) { const auto& name = itr->first; const auto& channel = itr->second; - if (staticConfig_.defaultChannel == name) + if (static_config_.default_channel == name) { - defaultChannel_ = i; + default_channel_ = i; } - if (staticConfig_.coredumpChannel == name) + if (static_config_.coredump_channel == name) { - coredumpChannel_ = i; + coredump_channel_ = i; } - const loglevel_t threshold = - hasPersistentConfig ? config.channels[std::string(name)].channelThreshold : channel.channelThreshold; + const LoglevelT threshold = has_persistent_config ? config.channels[std::string(name)].channel_threshold + : channel.channel_threshold; const auto ecu = channel.ecu; - const auto addr = channel.address.c_str(); + const auto* const addr = channel.address.c_str(); const auto port = channel.port; - const auto dstAddress = channel.dstAddress.empty() ? "239.255.42.99" : channel.dstAddress.c_str(); - auto dstPort = channel.dstPort != 0 ? channel.dstPort : 3490U; - const auto multicastInterface = channel.multicastInterface.c_str(); - channels_.emplace_back(name, threshold, ecu, addr, port, dstAddress, dstPort, multicastInterface); - channelNums_[name] = i; + const auto* const dst_address = channel.dst_address.empty() ? "239.255.42.99" : channel.dst_address.c_str(); + auto dst_port = channel.dst_port != 0 ? channel.dst_port : 3490U; + const auto* const multicast_interface = channel.multicast_interface.c_str(); + channels_.emplace_back(name, threshold, ecu, addr, port, dst_address, dst_port, multicast_interface); + channel_nums_[name] = i; } } - channelAssignments_.clear(); - const auto& assignments = hasPersistentConfig ? config.channelAssignments : staticConfig_.channelAssignments; + channel_assignments_.clear(); + const auto& assignments = has_persistent_config ? config.channel_assignments : static_config_.channel_assignments; for (const auto& app : assignments) { - const dltid_t appId = app.first; + const DltidT app_id = app.first; const auto& contexts = app.second; for (const auto& ctx : contexts) { - const dltid_t ctxId = ctx.first; + const DltidT ctx_id = ctx.first; const auto& channels = ctx.second; - channelmask_t channelSet{}; + ChannelmaskT channel_set{}; for (const auto& channel : channels) { - const size_t channelNum = channelNums_[dltid_t{channel}]; - channelSet |= channelmask_t{1U} << channelNum; + const size_t channel_num = channel_nums_[DltidT{channel}]; + channel_set |= ChannelmaskT{1U} << channel_num; } - channelAssignments_.emplace(std::make_pair(appId, ctxId), channelSet); + channel_assignments_.emplace(std::make_pair(app_id, ctx_id), channel_set); } } - filteringEnabled_ = hasPersistentConfig ? config.filteringEnabled : staticConfig_.filteringEnabled; + filtering_enabled_ = has_persistent_config ? config.filtering_enabled : static_config_.filtering_enabled; - const loglevel_t defaultThreshold = hasPersistentConfig ? config.defaultThreshold : staticConfig_.defaultThreshold; - defaultThreshold_ = defaultThreshold; + const LoglevelT default_threshold = + has_persistent_config ? config.default_threshold : static_config_.default_threshold; + default_threshold_ = default_threshold; - messageThresholds_.clear(); - const auto& thresholds = hasPersistentConfig ? config.messageThresholds : staticConfig_.messageThresholds; + message_thresholds_.clear(); + const auto& thresholds = has_persistent_config ? config.message_thresholds : static_config_.message_thresholds; for (const auto& app : thresholds) { - const dltid_t appId = app.first; + const DltidT app_id = app.first; const auto& contexts = app.second; for (const auto& ctx : contexts) { - const dltid_t ctxId = ctx.first; - const loglevel_t threshold = ctx.second; - messageThresholds_.emplace(std::make_pair(appId, ctxId), threshold); + const DltidT ctx_id = ctx.first; + const LoglevelT threshold = ctx.second; + message_thresholds_.emplace(std::make_pair(app_id, ctx_id), threshold); } } - throughput_overall_ = staticConfig_.throughput.overallMbps; + throughput_overall_ = static_config_.throughput.overall_mbps; throughput_apps_.clear(); - for (const auto& app : staticConfig_.throughput.applicationsKbps) + for (const auto& app : static_config_.throughput.applications_kbps) { - const dltid_t appId = app.first; + const DltidT app_id = app.first; const auto& kbps = app.second; - throughput_apps_.emplace(appId, kbps); + throughput_apps_.emplace(app_id, kbps); } } -void DltLogServer::init_log_channels_default(const bool reloading) +void DltLogServer::InitLogChannelsDefault(const bool reloading) { - filteringEnabled_ = false; - defaultThreshold_ = mw::log::LogLevel::kError; - defaultChannel_ = 0; - coredumpChannel_ = std::nullopt; + filtering_enabled_ = false; + default_threshold_ = mw::log::LogLevel::kError; + default_channel_ = 0; + coredump_channel_ = std::nullopt; if (reloading) { - channels_[0].channelThreshold_.store(mw::log::LogLevel::kOff, std::memory_order_relaxed); + channels_[0].channel_threshold.store(mw::log::LogLevel::kOff, std::memory_order_relaxed); } else { @@ -212,201 +213,201 @@ void DltLogServer::init_log_channels_default(const bool reloading) } } -void DltLogServer::set_output_enabled(const bool enabled) +void DltLogServer::SetOutputEnabled(const bool enabled) { - const bool update = (dltOutputEnabled_ != enabled); + const bool update = (dlt_output_enabled_ != enabled); if (update) { - dltOutputEnabled_ = enabled; - if (enabledCallback_) + dlt_output_enabled_ = enabled; + if (enabled_callback_) { - enabledCallback_(enabled); + enabled_callback_(enabled); } } } bool DltLogServer::GetDltEnabled() const noexcept { - return dltOutputEnabled_; + return dlt_output_enabled_; } -void DltLogServer::save_database() +void DltLogServer::SaveDatabase() { PersistentConfig config; for (auto& channel : channels_) { - config.channels[std::string(channel.channelName_)].channelThreshold = channel.channelThreshold_.load(); + config.channels[std::string(channel.channel_name)].channel_threshold = channel.channel_threshold.load(); } - for (auto& assignment : channelAssignments_) + for (auto& assignment : channel_assignments_) { - const dltid_t appId{assignment.first.first}; - const dltid_t ctxId{assignment.first.second}; - const channelmask_t channelSet = assignment.second; - std::vector assignments; + const DltidT app_id{assignment.first.first}; + const DltidT ctx_id{assignment.first.second}; + const ChannelmaskT channel_set = assignment.second; + std::vector assignments; for (size_t i = 0; i < channels_.size(); ++i) { - if (channelSet[i]) + if (channel_set[i]) { - assignments.push_back(channels_[i].channelName_); + assignments.push_back(channels_[i].channel_name); } } - config.channelAssignments[appId][ctxId] = std::move(assignments); + config.channel_assignments[app_id][ctx_id] = std::move(assignments); } - config.filteringEnabled = filteringEnabled_; - config.defaultThreshold = defaultThreshold_; + config.filtering_enabled = filtering_enabled_; + config.default_threshold = default_threshold_; - for (auto& messageThreshold : messageThresholds_) + for (auto& message_threshold : message_thresholds_) { - const dltid_t appId{messageThreshold.first.first}; - const dltid_t ctxId{messageThreshold.first.second}; - const loglevel_t threshold = messageThreshold.second; - config.messageThresholds[appId][ctxId] = threshold; + const DltidT app_id{message_threshold.first.first}; + const DltidT ctx_id{message_threshold.first.second}; + const LoglevelT threshold = message_threshold.second; + config.message_thresholds[app_id][ctx_id] = threshold; } - writerCallback_(std::move(config)); + writer_callback_(std::move(config)); } -void DltLogServer::clear_database() +void DltLogServer::ClearDatabase() { - writerCallback_(PersistentConfig{}); + writer_callback_(PersistentConfig{}); } -const std::string DltLogServer::ReadLogChannelNames() +std::string DltLogServer::ReadLogChannelNames() { - std::string response(1, config::RET_ERROR); + std::string response(1, config::kRetError); - std::lock_guard lock(configMutex_); + std::lock_guard lock(config_mutex_); for (auto& channel : channels_) { - appendId(channel.channelName_, response); + AppendId(channel.channel_name, response); } - response[0] = config::RET_OK; + response[0] = config::kRetOk; return response; } -const std::string DltLogServer::ResetToDefault() +std::string DltLogServer::ResetToDefault() { - std::string response(1, config::RET_ERROR); + std::string response(1, config::kRetError); - std::lock_guard lock(configMutex_); - clear_database(); - init_log_channels(true); + std::lock_guard lock(config_mutex_); + ClearDatabase(); + InitLogChannels(true); - response[0] = config::RET_OK; + response[0] = config::kRetOk; return response; } -const std::string DltLogServer::StoreDltConfig() +std::string DltLogServer::StoreDltConfig() { - std::string response(1, config::RET_ERROR); + std::string response(1, config::kRetError); - std::lock_guard lock(configMutex_); - save_database(); + std::lock_guard lock(config_mutex_); + SaveDatabase(); - response[0] = config::RET_OK; + response[0] = config::kRetOk; return response; } -const std::string DltLogServer::SetTraceState() +std::string DltLogServer::SetTraceState() { - std::string response(1, config::RET_ERROR); + std::string response(1, config::kRetError); - response[0] = config::RET_OK; + response[0] = config::kRetOk; return response; } -const std::string DltLogServer::SetDefaultTraceState() +std::string DltLogServer::SetDefaultTraceState() { - std::string response(1, config::RET_ERROR); + std::string response(1, config::kRetError); - response[0] = config::RET_OK; + response[0] = config::kRetOk; return response; } -const std::string DltLogServer::SetLogChannelThreshold(dltid_t channel, loglevel_t threshold) +std::string DltLogServer::SetLogChannelThreshold(DltidT channel, LoglevelT threshold) { - std::string response(1, config::RET_ERROR); + std::string response(1, config::kRetError); - std::lock_guard lock(configMutex_); - auto channelIt = channelNums_.find(channel); - if (channelIt == channelNums_.end()) + std::lock_guard lock(config_mutex_); + auto channel_it = channel_nums_.find(channel); + if (channel_it == channel_nums_.end()) { - response[0] = config::RET_ERROR; + response[0] = config::kRetError; return response; } - channels_[channelIt->second].channelThreshold_.store(threshold, std::memory_order_relaxed); + channels_[channel_it->second].channel_threshold.store(threshold, std::memory_order_relaxed); // Trace state (command[1 + 4 + 1] is ignored for now - response[0] = config::RET_OK; + response[0] = config::kRetOk; return response; } -const std::string DltLogServer::SetLogLevel(dltid_t appId, dltid_t ctxId, threshold_t threshold) +std::string DltLogServer::SetLogLevel(DltidT app_id, DltidT ctx_id, ThresholdT threshold) { - std::string response(1, config::RET_ERROR); + std::string response(1, config::kRetError); - std::lock_guard lock(configMutex_); - messageThresholds_.erase({appId, ctxId}); - if (std::holds_alternative(threshold)) + std::lock_guard lock(config_mutex_); + message_thresholds_.erase({app_id, ctx_id}); + if (std::holds_alternative(threshold)) { - messageThresholds_.emplace(std::make_pair(appId, ctxId), std::get(threshold)); + message_thresholds_.emplace(std::make_pair(app_id, ctx_id), std::get(threshold)); } - response[0] = config::RET_OK; + response[0] = config::kRetOk; return response; } -const std::string DltLogServer::SetMessagingFilteringState(bool enabled) +std::string DltLogServer::SetMessagingFilteringState(bool enabled) { - std::string response(1, config::RET_ERROR); + std::string response(1, config::kRetError); - std::lock_guard lock(configMutex_); - filteringEnabled_ = enabled; - response[0] = config::RET_OK; + std::lock_guard lock(config_mutex_); + filtering_enabled_ = enabled; + response[0] = config::kRetOk; return response; } -const std::string DltLogServer::SetDefaultLogLevel(loglevel_t level) +std::string DltLogServer::SetDefaultLogLevel(LoglevelT level) { - std::string response(1, config::RET_ERROR); + std::string response(1, config::kRetError); - std::lock_guard lock(configMutex_); - defaultThreshold_ = static_cast(level); - response[0] = config::RET_OK; + std::lock_guard lock(config_mutex_); + default_threshold_ = static_cast(level); + response[0] = config::kRetOk; return response; } -const std::string DltLogServer::SetLogChannelAssignment(dltid_t appId, - dltid_t ctxId, - dltid_t channel, - AssignmentAction assignment_flag) +std::string DltLogServer::SetLogChannelAssignment(DltidT app_id, + DltidT ctx_id, + DltidT channel, + AssignmentAction assignment_flag) { - std::string response(1, config::RET_ERROR); + std::string response(1, config::kRetError); - auto channelIt = channelNums_.find(channel); - if (channelIt == channelNums_.end()) + auto channel_it = channel_nums_.find(channel); + if (channel_it == channel_nums_.end()) { - response[0] = config::RET_ERROR; + response[0] = config::kRetError; return response; } - auto mask = channelmask_t{1U} << channelIt->second; + auto mask = ChannelmaskT{1U} << channel_it->second; - std::lock_guard lock(configMutex_); - auto cap = channelAssignments_.find({appId, ctxId}); - if (cap == channelAssignments_.end()) + std::lock_guard lock(config_mutex_); + auto cap = channel_assignments_.find({app_id, ctx_id}); + if (cap == channel_assignments_.end()) { - if (assignment_flag == AssignmentAction::Add) + if (assignment_flag == AssignmentAction::kAdd) { - channelAssignments_.emplace(std::make_pair(appId, ctxId), mask); + channel_assignments_.emplace(std::make_pair(app_id, ctx_id), mask); } } else { - if (assignment_flag == AssignmentAction::Add) + if (assignment_flag == AssignmentAction::kAdd) { cap->second |= mask; } @@ -417,46 +418,46 @@ const std::string DltLogServer::SetLogChannelAssignment(dltid_t appId, { // Test is available - DltServerWrongChannelsTest, but somehow it is not covered by coverage // tool. - channelAssignments_.erase(cap); // LCOV_EXCL_LINE + channel_assignments_.erase(cap); // LCOV_EXCL_LINE } } } - response[0] = config::RET_OK; + response[0] = config::kRetOk; return response; } -const std::string DltLogServer::SetDltOutputEnable(bool enable) +std::string DltLogServer::SetDltOutputEnable(bool enable) { - std::string response(1, config::RET_ERROR); + std::string response(1, config::kRetError); // Justification: Explicit bool cast required to avoid implicit-conversion warning. // coverity[misra_cpp_2023_rule_7_0_2_violation] - if (enable == static_cast(config::DISABLE)) + if (enable == static_cast(config::kDisable)) { score::mw::log::LogError() << "DRCMD: disable output"; - set_output_enabled(false); - response[0] = config::RET_OK; + SetOutputEnabled(false); + response[0] = config::kRetOk; return response; } else { score::mw::log::LogInfo() << "DRCMD: enable output"; - set_output_enabled(true); - response[0] = config::RET_OK; + SetOutputEnabled(true); + response[0] = config::kRetOk; return response; } } -const std::string DltLogServer::on_config_command(const std::string& command) +std::string DltLogServer::OnConfigCommand(const std::string& command) { - std::unique_ptr cmd = parser_->parse(command); // Parsing the command + std::unique_ptr cmd = parser_->Parse(command); // Parsing the command if (cmd == nullptr) { - const std::string response(1, config::RET_ERROR); + const std::string response(1, config::kRetError); return response; } else { - const auto response = cmd->execute(*this); // Handling the diagnostic job + const auto response = cmd->Execute(*this); // Handling the diagnostic job return response; } } diff --git a/score/datarouter/src/daemon/message_passing_server.cpp b/score/datarouter/src/daemon/message_passing_server.cpp index 225ad42..4539bfd 100644 --- a/score/datarouter/src/daemon/message_passing_server.cpp +++ b/score/datarouter/src/daemon/message_passing_server.cpp @@ -35,58 +35,58 @@ namespace internal using score::mw::log::detail::DatarouterMessageIdentifier; using score::mw::log::detail::MessagePassingConfig; -void MessagePassingServer::SessionWrapper::enqueue_for_delete_while_locked(bool by_peer) +void MessagePassingServer::SessionWrapper::EnqueueForDeleteWhileLocked(bool by_peer) { - to_delete_ = true; - closed_by_peer_ = by_peer; + to_delete = true; + closed_by_peer = by_peer; // in order not to mess with the logic of the queue, we don't enqueue currently running tick. Instead, we mark it // to be deleted (or re-enqueued for post-mortem processing, if closed by peer) at the end of the tick processing - if (!running_ && !enqueued_) + if (!running && !enqueued) { - server_->EnqueueTickWhileLocked(pid_); - enqueued_ = true; + server->EnqueueTickWhileLocked(pid); + enqueued = true; } } -bool MessagePassingServer::SessionWrapper::tick_at_worker_thread() +bool MessagePassingServer::SessionWrapper::TickAtWorkerThread() const { - bool requeue = session_->tick(); + bool requeue = session->Tick(); return requeue; } -void MessagePassingServer::SessionWrapper::notify_closed_by_peer() +void MessagePassingServer::SessionWrapper::NotifyClosedByPeer() const { - session_->on_closed_by_peer(); + session->OnClosedByPeer(); } -void MessagePassingServer::SessionWrapper::set_running_while_locked() +void MessagePassingServer::SessionWrapper::SetRunningWhileLocked() { - enqueued_ = false; - running_ = true; + enqueued = false; + running = true; } -bool MessagePassingServer::SessionWrapper::reset_running_while_locked(bool requeue) +bool MessagePassingServer::SessionWrapper::ResetRunningWhileLocked(bool requeue) { - running_ = false; + running = false; // check if we need to re-enqueue the tick after running again. It may happen because: // 1. not all the work in tick was done (returned early to avoid congestion); // 2. the tick was marked for delete as "closed by peer" when running, but we don't expedite its finishing. - if (requeue || closed_by_peer_) + if (requeue || closed_by_peer) { - enqueued_ = true; + enqueued = true; } - return enqueued_; + return enqueued; } -void MessagePassingServer::SessionWrapper::enqueue_tick_while_locked() +void MessagePassingServer::SessionWrapper::EnqueueTickWhileLocked() { - if (!enqueued_ && !to_delete_) + if (!enqueued && !to_delete) { - if (!running_) + if (!running) { - server_->EnqueueTickWhileLocked(pid_); + server->EnqueueTickWhileLocked(pid); } - enqueued_ = true; + enqueued = true; } } /* @@ -124,17 +124,17 @@ MessagePassingServer::MessagePassingServer(MessagePassingServer::SessionFactory std::cerr << "setname_np: " << ret_pthread.error() << std::endl; } - constexpr score::message_passing::ServiceProtocolConfig service_protocol_config{ + constexpr score::message_passing::ServiceProtocolConfig kServiceProtocolConfig{ MessagePassingConfig::kDatarouterReceiverIdentifier, MessagePassingConfig::kMaxMessageSize, MessagePassingConfig::kMaxReplySize, MessagePassingConfig::kMaxNotifySize}; - constexpr score::message_passing::IServerFactory::ServerConfig server_config{ + constexpr score::message_passing::IServerFactory::ServerConfig kServerConfig{ MessagePassingConfig::kMaxReceiverQueueSize, MessagePassingConfig::kPreAllocConnections, MessagePassingConfig::kMaxQueuedNotifies}; - receiver_ = server_factory_->Create(service_protocol_config, server_config); + receiver_ = server_factory_->Create(kServiceProtocolConfig, kServerConfig); auto connect_callback = [](score::message_passing::IServerConnection& connection) noexcept -> std::uintptr_t { const pid_t client_pid = connection.GetClientIdentity().pid; @@ -147,8 +147,8 @@ MessagePassingServer::MessagePassingServer(MessagePassingServer::SessionFactory if (found != pid_session_map_ptr->end()) { SessionWrapper& wrapper = found->second; - wrapper.to_force_finish_ = true; - found->second.enqueue_for_delete_while_locked(true); + wrapper.to_force_finish = true; + found->second.EnqueueForDeleteWhileLocked(true); } }; auto received_send_message_callback = [this_ptr = this]( @@ -213,8 +213,8 @@ MessagePassingServer::~MessagePassingServer() noexcept void MessagePassingServer::RunWorkerThread() { - constexpr std::int32_t TIMEOUT_IN_MS = 100; - timestamp_t t1 = timestamp_t::clock::now() + std::chrono::milliseconds(TIMEOUT_IN_MS); + constexpr std::int32_t kTimeoutInMs = 100; + TimestampT t1 = TimestampT::clock::now() + std::chrono::milliseconds(kTimeoutInMs); std::unique_lock lock(mutex_); while (!workers_exit_) @@ -224,15 +224,15 @@ void MessagePassingServer::RunWorkerThread() }); if (!workers_exit_) { - timestamp_t now = timestamp_t::clock::now(); - if (connection_timeout_ != timestamp_t{} && now >= connection_timeout_) + TimestampT now = TimestampT::clock::now(); + if (connection_timeout_ != TimestampT{} && now >= connection_timeout_) { - connection_timeout_ = timestamp_t{}; + connection_timeout_ = TimestampT{}; stop_source_.request_stop(); } if (now >= t1) { - t1 = now + std::chrono::milliseconds(TIMEOUT_IN_MS); + t1 = now + std::chrono::milliseconds(kTimeoutInMs); for (auto& ps : pid_session_map_) { if (ps.second.GetIsSourceClosed()) @@ -241,12 +241,12 @@ void MessagePassingServer::RunWorkerThread() this is private functions so it cannot be test. */ // LCOV_EXCL_START - ps.second.enqueue_for_delete_while_locked(true); + ps.second.EnqueueForDeleteWhileLocked(true); // LCOV_EXCL_STOP } else { - ps.second.enqueue_tick_while_locked(); + ps.second.EnqueueTickWhileLocked(); } } } @@ -257,16 +257,16 @@ void MessagePassingServer::RunWorkerThread() pid_t pid = work_queue_.front(); work_queue_.pop(); SessionWrapper& wrapper = pid_session_map_.at(pid); - wrapper.set_running_while_locked(); - bool closed_by_peer = wrapper.get_reset_closed_by_peer(); + wrapper.SetRunningWhileLocked(); + bool closed_by_peer = wrapper.GetResetClosedByPeer(); lock.unlock(); if (closed_by_peer) { - wrapper.notify_closed_by_peer(); + wrapper.NotifyClosedByPeer(); } - bool requeue = wrapper.tick_at_worker_thread(); + bool requeue = wrapper.TickAtWorkerThread(); lock.lock(); - if (wrapper.to_force_finish_) + if (wrapper.to_force_finish) { if (!closed_by_peer) { @@ -276,7 +276,7 @@ void MessagePassingServer::RunWorkerThread() this is private functions so it cannot be test. */ // LCOV_EXCL_START - wrapper.notify_closed_by_peer(); + wrapper.NotifyClosedByPeer(); requeue = true; // LCOV_EXCL_STOP } @@ -288,7 +288,7 @@ void MessagePassingServer::RunWorkerThread() lock.unlock(); do { - requeue = wrapper.tick_at_worker_thread(); + requeue = wrapper.TickAtWorkerThread(); } while (requeue); lock.lock(); // LCOV_EXCL_STOP @@ -303,13 +303,13 @@ void MessagePassingServer::RunWorkerThread() node = {}; lock.lock(); } - else if (wrapper.reset_running_while_locked(requeue)) + else if (wrapper.ResetRunningWhileLocked(requeue)) { // LCOV_EXCL_START: see above EnqueueTickWhileLocked(pid); // LCOV_EXCL_STOP } - else if (wrapper.is_marked_for_delete()) + else if (wrapper.IsMarkedForDelete()) { // Extract the session wrapper to destroy it outside the mutex lock auto node = pid_session_map_.extract(pid); @@ -338,10 +338,10 @@ void MessagePassingServer::FinishPreviousSessionWhileLocked( { const pid_t pid = it->first; SessionWrapper& wrapper = it->second; - wrapper.to_force_finish_ = true; - wrapper.enqueue_for_delete_while_locked(true); + wrapper.to_force_finish = true; + wrapper.EnqueueForDeleteWhileLocked(true); // if enqueued_ (i.e. not running) expedite the workload toward the front of the queue - if (wrapper.enqueued_) + if (wrapper.enqueued) { pid_t front_pid = work_queue_.front(); while (front_pid != pid) @@ -366,7 +366,7 @@ void MessagePassingServer::FinishPreviousSessionWhileLocked( void MessagePassingServer::MessageCallback(const score::cpp::span message, const pid_t pid) { - if (message.size() < 1) + if (message.empty()) { std::cerr << "MessagePassingServer: Empty message received from " << pid; return; @@ -440,10 +440,10 @@ void MessagePassingServer::OnConnectRequest(const score::cpp::spanCreate(protocol_config, client_config); @@ -483,7 +483,7 @@ void MessagePassingServer::OnConnectRequest(const score::cpp::span lock(mutex_); auto emplace_result = pid_session_map_.emplace(pid, SessionWrapper{this, pid, std::move(session)}); // enqueue the tick to speed up processing connection - emplace_result.first->second.enqueue_tick_while_locked(); + emplace_result.first->second.EnqueueTickWhileLocked(); } } @@ -507,9 +507,9 @@ void MessagePassingServer::OnAcquireResponse(const score::cpp::span acq_span{static_cast(static_cast(&acq)), sizeof(acq)}; std::ignore = std::copy(message.begin(), message.end(), acq_span.begin()); - session.session_->on_acquire_response(acq); + session.session->OnAcquireResponse(acq); // enqueue the tick to speed up processing acquire response - session.enqueue_tick_while_locked(); + session.EnqueueTickWhileLocked(); } } @@ -527,7 +527,7 @@ void MessagePassingServer::NotifyAcquireRequestFailed(std::int32_t pid) return; // LCOV_EXCL_STOP } - found->second.enqueue_for_delete_while_locked(true); + found->second.EnqueueForDeleteWhileLocked(true); } bool MessagePassingServer::SessionHandle::AcquireRequest() const @@ -543,8 +543,8 @@ bool MessagePassingServer::SessionHandle::AcquireRequest() const { return false; } - constexpr std::array message{score::cpp::to_underlying(DatarouterMessageIdentifier::kAcquireRequest)}; - auto ret = sender_->Send(message); + constexpr std::array kMessage{score::cpp::to_underlying(DatarouterMessageIdentifier::kAcquireRequest)}; + auto ret = sender_->Send(kMessage); if (!ret) { if (server_ != nullptr) diff --git a/score/datarouter/src/daemon/persistentlogging_config.cpp b/score/datarouter/src/daemon/persistentlogging_config.cpp index e659d05..397656e 100644 --- a/score/datarouter/src/daemon/persistentlogging_config.cpp +++ b/score/datarouter/src/daemon/persistentlogging_config.cpp @@ -34,23 +34,23 @@ namespace platform namespace internal { -const std::string DEFAULT_PERSISTENT_LOGGING_JSON_FILEPATH = "etc/persistent-logging.json"; +const std::string kDefaultPersistentLoggingJsonFilepath = "etc/persistent-logging.json"; -PersistentLoggingConfig readPersistentLoggingConfig(const std::string& filePath) +PersistentLoggingConfig ReadPersistentLoggingConfig(const std::string& file_path) { using ReadResult = PersistentLoggingConfig::ReadResult; PersistentLoggingConfig config; - using unique_file_t = std::unique_ptr; - unique_file_t fp(std::fopen(filePath.c_str(), "r"), &fclose); + using UniqueFileT = std::unique_ptr; + UniqueFileT fp(std::fopen(file_path.c_str(), "r"), &fclose); if (nullptr == fp) { - config.readResult_ = ReadResult::ERROR_OPEN; + config.read_result = ReadResult::kErrorOpen; return config; } - std::string readBuffer(datarouter::JSON_READ_BUFFER_SIZE, '\0'); - rapidjson::FileReadStream is(fp.get(), readBuffer.data(), readBuffer.size()); - rapidjson::Document d = datarouter::createRJDocument(); + std::string read_buffer(datarouter::kJsonReadBufferSize, '\0'); + rapidjson::FileReadStream is(fp.get(), read_buffer.data(), read_buffer.size()); + rapidjson::Document d = datarouter::CreateRjDocument(); rapidjson::ParseResult ok = d.ParseStream(is); fp.reset(); @@ -58,13 +58,13 @@ PersistentLoggingConfig readPersistentLoggingConfig(const std::string& filePath) { score::mw::log::LogError() << "PersistentLoggingConfig:json parser error: " << std::string_view{rapidjson::GetParseError_En(ok.Code())}; - config.readResult_ = ReadResult::ERROR_PARSE; + config.read_result = ReadResult::kErrorParse; return config; } if (false == d.HasMember("verbose_filters") || false == d.HasMember("nonverbose_filters")) { score::mw::log::LogError() << "PersistentLoggingConfig: json filter members not found."; - config.readResult_ = ReadResult::ERROR_CONTENT; + config.read_result = ReadResult::kErrorContent; return config; } const auto& verbose_filters = d["verbose_filters"]; @@ -72,7 +72,7 @@ PersistentLoggingConfig readPersistentLoggingConfig(const std::string& filePath) if (false == verbose_filters.IsArray() || false == nonverbose_filters.IsArray()) { score::mw::log::LogError() << "PersistentLoggingConfig: json filters not array type."; - config.readResult_ = ReadResult::ERROR_CONTENT; + config.read_result = ReadResult::kErrorContent; return config; } @@ -81,22 +81,22 @@ PersistentLoggingConfig readPersistentLoggingConfig(const std::string& filePath) if (false == itr.HasMember("appId") || false == itr.HasMember("ctxId") || false == itr.HasMember("logLevel")) { score::mw::log::LogError() << "PersistentLoggingConfig: json appid, ctxid, ll not found."; - config.readResult_ = ReadResult::ERROR_CONTENT; + config.read_result = ReadResult::kErrorContent; return config; } - const auto& appidValue = itr.FindMember("appId")->value; - const auto& ctxidValue = itr.FindMember("ctxId")->value; - const auto& loglevelValue = itr.FindMember("logLevel")->value; - if (false == appidValue.IsString() || false == ctxidValue.IsString() || false == loglevelValue.IsString()) + const auto& appid_value = itr.FindMember("appId")->value; + const auto& ctxid_value = itr.FindMember("ctxId")->value; + const auto& loglevel_value = itr.FindMember("logLevel")->value; + if (false == appid_value.IsString() || false == ctxid_value.IsString() || false == loglevel_value.IsString()) { score::mw::log::LogError() << "PersistentLoggingConfig: json appid, ctxid, ll not string type."; - config.readResult_ = ReadResult::ERROR_CONTENT; + config.read_result = ReadResult::kErrorContent; return config; } - config.verboseFilters_.emplace_back( - plogfilterdesc{score::mw::log::detail::LoggingIdentifier{appidValue.GetString()}, - score::mw::log::detail::LoggingIdentifier{ctxidValue.GetString()}, - static_cast(logchannel_operations::ToLogLevel(loglevelValue.GetString()))}); + config.verbose_filters.emplace_back( + Plogfilterdesc{score::mw::log::detail::LoggingIdentifier{appid_value.GetString()}, + score::mw::log::detail::LoggingIdentifier{ctxid_value.GetString()}, + static_cast(logchannel_operations::ToLogLevel(loglevel_value.GetString()))}); } for (const auto& itr : nonverbose_filters.GetArray()) @@ -104,12 +104,12 @@ PersistentLoggingConfig readPersistentLoggingConfig(const std::string& filePath) if (false == itr.IsString()) { score::mw::log::LogError() << "PersistentLoggingConfig: non verbose filter not string type."; - config.readResult_ = ReadResult::ERROR_CONTENT; + config.read_result = ReadResult::kErrorContent; return config; } - config.nonVerboseFilters_.emplace_back(itr.GetString()); + config.non_verbose_filters.emplace_back(itr.GetString()); } - config.readResult_ = ReadResult::OK; + config.read_result = ReadResult::kOk; return config; } diff --git a/score/datarouter/src/daemon/socketserver.cpp b/score/datarouter/src/daemon/socketserver.cpp index b52a548..2675c60 100644 --- a/score/datarouter/src/daemon/socketserver.cpp +++ b/score/datarouter/src/daemon/socketserver.cpp @@ -44,17 +44,16 @@ namespace platform namespace datarouter { -using score::platform::internal::LogParser; using score::platform::internal::MessagePassingServer; using score::platform::internal::UnixDomainSockAddr; namespace { -constexpr auto* LOG_CHANNELS_PATH = "./etc/log-channels.json"; +constexpr auto* kLogChannelsPath = "./etc/log-channels.json"; -constexpr std::uint32_t statistics_log_period_us{10000000U}; -constexpr std::uint32_t dlt_flush_period_us{100000U}; -constexpr std::uint32_t throttle_time_us{100000U}; +constexpr std::uint32_t kStatisticsLogPeriodUs{10000000U}; +constexpr std::uint32_t kDltFlushPeriodUs{100000U}; +constexpr std::uint32_t kThrottleTimeUs{100000U}; } // namespace @@ -105,12 +104,12 @@ SocketServer::PersistentStorageHandlers SocketServer::InitializePersistentStorag auto* pd_ptr = persistent_dictionary.get(); handlers.load_dlt = [pd_ptr]() { - return readDlt(*pd_ptr); + return ReadDlt(*pd_ptr); }; handlers.store_dlt = [pd_ptr](const score::logging::dltserver::PersistentConfig& config) { - writeDlt(config, *pd_ptr); + WriteDlt(config, *pd_ptr); }; - handlers.is_dlt_enabled = readDltEnabled(*persistent_dictionary); + handlers.is_dlt_enabled = ReadDltEnabled(*persistent_dictionary); /* Deviation from Rule A16-0-1: @@ -137,11 +136,11 @@ SocketServer::PersistentStorageHandlers SocketServer::InitializePersistentStorag std::unique_ptr SocketServer::CreateDltServer( const PersistentStorageHandlers& storage_handlers) { - const auto static_config = readStaticDlt(LOG_CHANNELS_PATH); + const auto static_config = ReadStaticDlt(kLogChannelsPath); if (!static_config.has_value()) { score::mw::log::LogError() << static_config.error(); - score::mw::log::LogError() << "Error during parsing file " << std::string_view{LOG_CHANNELS_PATH} + score::mw::log::LogError() << "Error during parsing file " << std::string_view{kLogChannelsPath} << ", static config is not available, interrupt work"; return nullptr; } @@ -168,8 +167,8 @@ DataRouter::SourceSetupCallback SocketServer::CreateSourceSetupHandler( */ // coverity[autosar_cpp14_a5_1_4_violation] return [&dlt_server](score::platform::internal::ILogParser&& parser) { - parser.set_filter_factory(getFilterFactory()); - dlt_server.add_handlers(parser); + parser.SetFilterFactory(GetFilterFactory()); + dlt_server.AddHandlers(parser); }; } @@ -178,13 +177,13 @@ void SocketServer::UpdateParserHandlers(score::logging::dltserver::DltLogServer& score::platform::internal::ILogParser& parser, bool enable) { - dlt_server.update_handlers(parser, enable); + dlt_server.UpdateHandlers(parser, enable); } // Static helper: Final update after all parsers processed void SocketServer::UpdateHandlersFinal(score::logging::dltserver::DltLogServer& dlt_server, bool enable) { - dlt_server.update_handlers_final(enable); + dlt_server.UpdateHandlersFinal(enable); } // Static helper: Create a new config session from Unix domain handle @@ -192,7 +191,7 @@ std::unique_ptr SocketServer::CreateConfigSession( score::logging::dltserver::DltLogServer& dlt_server, UnixDomainServer::SessionHandle handle) { - return dlt_server.new_config_session(score::platform::datarouter::ConfigSessionHandleType{std::move(handle)}); + return dlt_server.NewConfigSession(score::platform::datarouter::ConfigSessionHandleType{std::move(handle)}); } std::function SocketServer::CreateEnableHandler(DataRouter& router, @@ -225,8 +224,8 @@ std::function SocketServer::CreateEnableHandler(DataRouter& router, #endif std::cerr << "DRCMD enable callback called with " << enable << std::endl; score::mw::log::LogWarn() << "Changing output enable to " << enable; - writeDltEnabled(enable, persistent_dictionary); - router.for_each_source_parser( + WriteDltEnabled(enable, persistent_dictionary); + router.ForEachSourceParser( std::bind(&SocketServer::UpdateParserHandlers, std::ref(dlt_server), std::placeholders::_1, enable), std::bind(&SocketServer::UpdateHandlersFinal, std::ref(dlt_server), enable), enable); @@ -238,7 +237,7 @@ std::unique_ptr SocketServer::Creat { const auto factory = std::bind(&SocketServer::CreateConfigSession, std::ref(dlt_server), std::placeholders::_2); - const UnixDomainSockAddr addr(score::logging::config::socket_address, true); + const UnixDomainSockAddr addr(score::logging::config::kSocketAddress, true); /* Deviation from Rule A5-1-4: - A lambda expression object shall not outlive any of its reference captured objects. @@ -253,15 +252,15 @@ score::mw::log::NvConfig SocketServer::LoadNvConfig(score::mw::log::Logger& stat { if constexpr (score::platform::datarouter::kNonVerboseDltEnabled) { - auto nvConfigResult = score::mw::log::NvConfigFactory::CreateAndInit(config_path); - if (nvConfigResult.has_value()) + auto nv_config_result = score::mw::log::NvConfigFactory::CreateAndInit(config_path); + if (nv_config_result.has_value()) { stats_logger.LogInfo() << "NvConfig loaded successfully"; - return std::move(nvConfigResult.value()); + return std::move(nv_config_result.value()); } else { - stats_logger.LogWarn() << "Failed to load NvConfig: " << nvConfigResult.error().Message(); + stats_logger.LogWarn() << "Failed to load NvConfig: " << nv_config_result.error().Message(); } } return score::mw::log::NvConfigFactory::CreateEmpty(); @@ -293,11 +292,11 @@ std::unique_ptr SocketServer::CreateMessagePassi } const auto fd = maybe_fd.value(); - const auto quota = dlt_server.get_quota(appid); - const auto quotaEnforcementEnabled = dlt_server.getQuotaEnforcementEnabled(); + const auto quota = dlt_server.GetQuota(appid); + const auto quota_enforcement_enabled = dlt_server.GetQuotaEnforcementEnabled(); const bool is_dlt_enabled = dlt_server.GetDltEnabled(); - auto source_session = router.new_source_session( - fd, appid, is_dlt_enabled, std::move(handle), quota, quotaEnforcementEnabled, client_pid, nv_config); + auto source_session = router.NewSourceSession( + fd, appid, is_dlt_enabled, std::move(handle), quota, quota_enforcement_enabled, client_pid, nv_config); // The reason for banning is, because it's error-prone to use. One should use abstractions e.g. provided by // the C++ standard library. But these abstraction do not support exclusive access, which is why we created // this abstraction library. @@ -324,27 +323,27 @@ void SocketServer::RunEventLoop(const std::atomic_bool& exit_requested, score::mw::log::Logger& stats_logger) { uint16_t count = 0U; - constexpr std::uint32_t statistics_freq_divider = statistics_log_period_us / throttle_time_us; - constexpr std::uint32_t dlt_freq_divider = dlt_flush_period_us / throttle_time_us; + constexpr std::uint32_t kStatisticsFreqDivider = kStatisticsLogPeriodUs / kThrottleTimeUs; + constexpr std::uint32_t kDltFreqDivider = kDltFlushPeriodUs / kThrottleTimeUs; while (!exit_requested.load()) { - usleep(throttle_time_us); + usleep(kThrottleTimeUs); - if ((count % statistics_freq_divider) == 0U) + if ((count % kStatisticsFreqDivider) == 0U) { - router.show_source_statistics(static_cast(count / statistics_freq_divider)); - dlt_server.show_channel_statistics(static_cast(count / statistics_freq_divider), stats_logger); + router.ShowSourceStatistics(static_cast(count / kStatisticsFreqDivider)); + dlt_server.ShowChannelStatistics(static_cast(count / kStatisticsFreqDivider), stats_logger); } - if ((count % dlt_freq_divider) == 0U) + if ((count % kDltFreqDivider) == 0U) { - dlt_server.flush(); + dlt_server.Flush(); } ++count; } } -void SocketServer::doWork(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime) +void SocketServer::DoWork(const std::atomic_bool& exit_requested, const bool no_adaptive_runtime) { SetThreadName(); @@ -374,7 +373,7 @@ void SocketServer::doWork(const std::atomic_bool& exit_requested, const bool no_ // Create and set enable handler const auto enable_handler = CreateEnableHandler(router, *pd, *dlt_server); - dlt_server->set_enabled_callback(enable_handler); + dlt_server->SetEnabledCallback(enable_handler); // Create Unix domain server for config sessions auto unix_domain_server = CreateUnixDomainServer(*dlt_server); diff --git a/score/datarouter/src/daemon/socketserver_config.cpp b/score/datarouter/src/daemon/socketserver_config.cpp index cdb26c1..614b2a9 100644 --- a/score/datarouter/src/daemon/socketserver_config.cpp +++ b/score/datarouter/src/daemon/socketserver_config.cpp @@ -37,24 +37,24 @@ namespace datarouter namespace { -const std::string CONFIG_DATABASE_KEY = "dltConfig"; -const std::string CONFIG_OUTPUT_ENABLED_KEY = "dltOutputEnabled"; +const std::string kConfigDatabaseKey = "dltConfig"; +const std::string kConfigOutputEnabledKey = "dltOutputEnabled"; -using loglevel_t = score::logging::dltserver::loglevel_t; +using LoglevelT = score::logging::dltserver::LoglevelT; -inline loglevel_t ToLogLevelT(const std::string& logLevel) +inline LoglevelT ToLogLevelT(const std::string& log_level) { - return static_cast(logchannel_operations::ToLogLevel(logLevel)); + return static_cast(logchannel_operations::ToLogLevel(log_level)); } -inline std::string GetStringFromLogLevelT(loglevel_t level) +inline std::string GetStringFromLogLevelT(LoglevelT level) { return logchannel_operations::GetStringFromLogLevel(static_cast(level)); } } // namespace -score::Result readStaticDlt(const char* path) +score::Result ReadStaticDlt(const char* path) { using rapidjson::Document; using rapidjson::FileReadStream; @@ -68,9 +68,9 @@ score::Result readStaticDlt(const char* std::cerr << "Could not open file: " << path << std::endl; return score::MakeUnexpected(score::logging::error::LoggingErrorCode::kNoFileFound, "Could not open file"); } - std::array readBuffer{}; - FileReadStream is(fp, readBuffer.data(), readBuffer.size()); - Document d = createRJDocument(); + std::array read_buffer{}; + FileReadStream is(fp, read_buffer.data(), read_buffer.size()); + Document d = CreateRjDocument(); ParseResult ok = d.ParseStream(is); fclose(fp); if (ok.IsError()) @@ -95,110 +95,110 @@ score::Result readStaticDlt(const char* return score::MakeUnexpected(score::logging::error::LoggingErrorCode::kNoChannelsFound); } - config.coredumpChannel = d.HasMember("coredumpChannel") ? dltid_t{d["coredumpChannel"].GetString()} : dltid_t{}; - config.defaultChannel = dltid_t{d["defaultChannel"].GetString()}; + config.coredump_channel = d.HasMember("coredumpChannel") ? DltidT{d["coredumpChannel"].GetString()} : DltidT{}; + config.default_channel = DltidT{d["defaultChannel"].GetString()}; for (auto itr = channels.MemberBegin(); itr != channels.MemberEnd(); ++itr) { - const auto name = itr->name.GetString(); + const auto* const name = itr->name.GetString(); const auto threshold = ToLogLevelT(itr->value["channelThreshold"].GetString()); - dltid_t ecu(itr->value["ecu"].GetString()); - const auto addr = itr->value.HasMember("address") ? itr->value["address"].GetString() : ""; + DltidT ecu(itr->value["ecu"].GetString()); + const auto* const addr = itr->value.HasMember("address") ? itr->value["address"].GetString() : ""; const auto port = static_cast(itr->value["port"].GetUint()); - const auto dstAddress = + const auto* const dst_address = itr->value.HasMember("dstAddress") ? itr->value["dstAddress"].GetString() : "239.255.42.99"; - const auto dstPort = + const auto dst_port = static_cast(itr->value.HasMember("dstPort") ? itr->value["dstPort"].GetInt() : 3490); - const auto multicastInterface = + const auto* const multicast_interface = itr->value.HasMember("multicastInterface") ? itr->value["multicastInterface"].GetString() : ""; score::logging::dltserver::StaticConfig::ChannelDescription channel{ - ecu, addr, port, dstAddress, dstPort, threshold, multicastInterface}; + ecu, addr, port, dst_address, dst_port, threshold, multicast_interface}; config.channels.emplace(name, std::move(channel)); } const auto& assignments = d["channelAssignments"]; for (auto itr1 = assignments.MemberBegin(); itr1 != assignments.MemberEnd(); ++itr1) { - const dltid_t appId(itr1->name.GetString()); + const DltidT app_id(itr1->name.GetString()); const auto& contexts = itr1->value; for (auto itr2 = contexts.MemberBegin(); itr2 != contexts.MemberEnd(); ++itr2) { - const dltid_t ctxId(itr2->name.GetString()); + const DltidT ctx_id(itr2->name.GetString()); const auto& assigned = itr2->value; for (unsigned int itr3 = 0; itr3 < assigned.Size(); ++itr3) { - config.channelAssignments[appId][ctxId].push_back(dltid_t(assigned[itr3].GetString())); + config.channel_assignments[app_id][ctx_id].push_back(DltidT(assigned[itr3].GetString())); } } } if (d.HasMember("filteringEnabled")) { - config.filteringEnabled = d["filteringEnabled"].GetBool(); + config.filtering_enabled = d["filteringEnabled"].GetBool(); } else { - config.filteringEnabled = true; + config.filtering_enabled = true; } if (d.HasMember("defaultThreshold")) { - config.defaultThreshold = ToLogLevelT(d["defaultThreshold"].GetString()); + config.default_threshold = ToLogLevelT(d["defaultThreshold"].GetString()); } else if (d.HasMember("defaultThresold")) { - config.defaultThreshold = ToLogLevelT(d["defaultThresold"].GetString()); + config.default_threshold = ToLogLevelT(d["defaultThresold"].GetString()); } else { std::cerr << "No defaultThreshold or defaultThresold found, set to kVerbose by default" << std::endl; - config.defaultThreshold = mw::log::LogLevel::kVerbose; + config.default_threshold = mw::log::LogLevel::kVerbose; } const auto& thresholds = d["messageThresholds"]; for (auto itr1 = thresholds.MemberBegin(); itr1 != thresholds.MemberEnd(); ++itr1) { - const dltid_t appId(itr1->name.GetString()); + const DltidT app_id(itr1->name.GetString()); const auto& contexts = itr1->value; for (auto itr2 = contexts.MemberBegin(); itr2 != contexts.MemberEnd(); ++itr2) { - const dltid_t ctxId(itr2->name.GetString()); - config.messageThresholds[appId][ctxId] = ToLogLevelT(itr2->value.GetString()); + const DltidT ctx_id(itr2->name.GetString()); + config.message_thresholds[app_id][ctx_id] = ToLogLevelT(itr2->value.GetString()); } } if (d.HasMember("quotas")) { - const std::string quotaEnforcementEnabledParamName = "quotaEnforcementEnabled"; - if (d["quotas"].HasMember(quotaEnforcementEnabledParamName.c_str())) + const std::string quota_enforcement_enabled_param_name = "quotaEnforcementEnabled"; + if (d["quotas"].HasMember(quota_enforcement_enabled_param_name.c_str())) { - config.quotaEnforcementEnabled = d["quotas"][quotaEnforcementEnabledParamName.c_str()].GetBool(); + config.quota_enforcement_enabled = d["quotas"][quota_enforcement_enabled_param_name.c_str()].GetBool(); } else { - config.quotaEnforcementEnabled = false; + config.quota_enforcement_enabled = false; } const auto& throughput = d["quotas"]["throughput"]; - config.throughput.overallMbps = throughput["overallMbps"].GetDouble(); - const auto& applicationsKbps = throughput["applicationsKbps"]; - for (auto itr1 = applicationsKbps.MemberBegin(); itr1 != applicationsKbps.MemberEnd(); ++itr1) + config.throughput.overall_mbps = throughput["overallMbps"].GetDouble(); + const auto& applications_kbps = throughput["applicationsKbps"]; + for (auto itr1 = applications_kbps.MemberBegin(); itr1 != applications_kbps.MemberEnd(); ++itr1) { - config.throughput.applicationsKbps.emplace(dltid_t(itr1->name.GetString()), itr1->value.GetDouble()); + config.throughput.applications_kbps.emplace(DltidT(itr1->name.GetString()), itr1->value.GetDouble()); } } return config; } -score::logging::dltserver::PersistentConfig readDlt(IPersistentDictionary& pd) +score::logging::dltserver::PersistentConfig ReadDlt(IPersistentDictionary& pd) { using rapidjson::Document; using rapidjson::ParseResult; score::logging::dltserver::PersistentConfig config{}; - const std::string json = pd.GetString(CONFIG_DATABASE_KEY, "{}"); + const std::string json = pd.GetString(kConfigDatabaseKey, "{}"); - Document d = createRJDocument(); + Document d = CreateRjDocument(); ParseResult ok = d.Parse(json.c_str()); if (ok.IsError() || !d.HasMember("channels")) @@ -213,7 +213,7 @@ score::logging::dltserver::PersistentConfig readDlt(IPersistentDictionary& pd) for (auto itr = channels.MemberBegin(); itr != channels.MemberEnd(); ++itr) { - const auto name = itr->name.GetString(); + const auto* const name = itr->name.GetString(); const auto threshold = ToLogLevelT(itr->value["channelThreshold"].GetString()); score::logging::dltserver::PersistentConfig::ChannelDescription channel{threshold}; config.channels.emplace(name, channel); @@ -222,122 +222,123 @@ score::logging::dltserver::PersistentConfig readDlt(IPersistentDictionary& pd) const auto& assignments = d["channelAssignments"]; for (auto itr1 = assignments.MemberBegin(); itr1 != assignments.MemberEnd(); ++itr1) { - const dltid_t appId(itr1->name.GetString()); + const DltidT app_id(itr1->name.GetString()); const auto& contexts = itr1->value; for (auto itr2 = contexts.MemberBegin(); itr2 != contexts.MemberEnd(); ++itr2) { - const dltid_t ctxId(itr2->name.GetString()); + const DltidT ctx_id(itr2->name.GetString()); const auto& assigned = itr2->value; for (unsigned int itr3 = 0; itr3 < assigned.Size(); ++itr3) { - config.channelAssignments[appId][ctxId].push_back(dltid_t(assigned[itr3].GetString())); + config.channel_assignments[app_id][ctx_id].push_back(DltidT(assigned[itr3].GetString())); } } } if (d.HasMember("filteringEnabled")) { - config.filteringEnabled = d["filteringEnabled"].GetBool(); + config.filtering_enabled = d["filteringEnabled"].GetBool(); } else { - config.filteringEnabled = true; + config.filtering_enabled = true; } // TODO: fix typo - config.defaultThreshold = ToLogLevelT(d["defaultThresold"].GetString()); + config.default_threshold = ToLogLevelT(d["defaultThresold"].GetString()); const auto& thresholds = d["messageThresholds"]; for (auto itr1 = thresholds.MemberBegin(); itr1 != thresholds.MemberEnd(); ++itr1) { - const dltid_t appId(itr1->name.GetString()); - auto& contexts = itr1->value; + const DltidT app_id(itr1->name.GetString()); + const auto& contexts = itr1->value; for (auto itr2 = contexts.MemberBegin(); itr2 != contexts.MemberEnd(); ++itr2) { - const dltid_t ctxId(itr2->name.GetString()); - config.messageThresholds[appId][ctxId] = ToLogLevelT(itr2->value.GetString()); + const DltidT ctx_id(itr2->name.GetString()); + config.message_thresholds[app_id][ctx_id] = ToLogLevelT(itr2->value.GetString()); } } return config; } -void writeDlt(const score::logging::dltserver::PersistentConfig& config, IPersistentDictionary& pd) +void WriteDlt(const score::logging::dltserver::PersistentConfig& config, IPersistentDictionary& pd) { using rapidjson::Document; using rapidjson::StringBuffer; using rapidjson::Value; using rapidjson::Writer; - Document d = createRJDocument(); + Document d = CreateRjDocument(); d.SetObject(); auto& allocator = d.GetAllocator(); // channels Value channels(rapidjson::kObjectType); - for (auto& channel : config.channels) + for (const auto& channel : config.channels) { - const std::string& channelName = channel.first; - const std::string& channelThreshold = GetStringFromLogLevelT(channel.second.channelThreshold); - Value channelJson(rapidjson::kObjectType); - channelJson.AddMember("channelThreshold", Value(channelThreshold.c_str(), allocator).Move(), allocator); - channels.AddMember(Value(channelName.c_str(), allocator).Move(), channelJson.Move(), allocator); + const std::string& channel_name = channel.first; + const std::string& channel_threshold = GetStringFromLogLevelT(channel.second.channel_threshold); + Value channel_json(rapidjson::kObjectType); + channel_json.AddMember("channelThreshold", Value(channel_threshold.c_str(), allocator).Move(), allocator); + channels.AddMember(Value(channel_name.c_str(), allocator).Move(), channel_json.Move(), allocator); } d.AddMember("channels", channels.Move(), allocator); // channel assignments - Value rAssignments(rapidjson::kObjectType); - for (const auto& app : config.channelAssignments) + Value r_assignments(rapidjson::kObjectType); + for (const auto& app : config.channel_assignments) { - const std::string& appId = std::string(app.first); + const std::string& app_id = std::string(app.first); const auto& contexts = app.second; - Value rContexts{rapidjson::kObjectType}; + Value r_contexts{rapidjson::kObjectType}; for (const auto& ctx : contexts) { - const std::string& ctxId = std::string(ctx.first); + const std::string& ctx_id = std::string(ctx.first); const auto& assigned = ctx.second; - Value rChannels{rapidjson::kArrayType}; + Value r_channels{rapidjson::kArrayType}; for (const auto& channel : assigned) { - rChannels.PushBack(Value(std::string{channel}.c_str(), allocator).Move(), allocator); + r_channels.PushBack(Value(std::string{channel}.c_str(), allocator).Move(), allocator); } - rContexts.AddMember(Value(ctxId.c_str(), allocator).Move(), rChannels.Move(), allocator); + r_contexts.AddMember(Value(ctx_id.c_str(), allocator).Move(), r_channels.Move(), allocator); } - rAssignments.AddMember(Value(appId.c_str(), allocator).Move(), rContexts.Move(), allocator); + r_assignments.AddMember(Value(app_id.c_str(), allocator).Move(), r_contexts.Move(), allocator); } - d.AddMember("channelAssignments", rAssignments.Move(), allocator); + d.AddMember("channelAssignments", r_assignments.Move(), allocator); - d.AddMember("filteringEnabled", config.filteringEnabled, allocator); + d.AddMember("filteringEnabled", config.filtering_enabled, allocator); // TODO: fix typo - d.AddMember( - "defaultThresold", Value(GetStringFromLogLevelT(config.defaultThreshold).c_str(), allocator).Move(), allocator); + d.AddMember("defaultThresold", + Value(GetStringFromLogLevelT(config.default_threshold).c_str(), allocator).Move(), + allocator); - Value rThresholds(rapidjson::kObjectType); - for (const auto& app : config.messageThresholds) + Value r_thresholds(rapidjson::kObjectType); + for (const auto& app : config.message_thresholds) { - const std::string& appId = std::string(app.first); + const std::string& app_id = std::string(app.first); const auto& contexts = app.second; - Value rContexts{rapidjson::kObjectType}; + Value r_contexts{rapidjson::kObjectType}; for (const auto& ctx : contexts) { - const std::string& ctxId = std::string(ctx.first); + const std::string& ctx_id = std::string(ctx.first); const auto& threshold = GetStringFromLogLevelT(ctx.second); - rContexts.AddMember( - Value(ctxId.c_str(), allocator).Move(), Value(threshold.c_str(), allocator).Move(), allocator); + r_contexts.AddMember( + Value(ctx_id.c_str(), allocator).Move(), Value(threshold.c_str(), allocator).Move(), allocator); } - rThresholds.AddMember(Value(appId.c_str(), allocator).Move(), rContexts.Move(), allocator); + r_thresholds.AddMember(Value(app_id.c_str(), allocator).Move(), r_contexts.Move(), allocator); } - d.AddMember("messageThresholds", rThresholds.Move(), allocator); + d.AddMember("messageThresholds", r_thresholds.Move(), allocator); StringBuffer buffer(nullptr); Writer writer(buffer, nullptr); d.Accept(writer); const std::string json = buffer.GetString(); - pd.SetString(CONFIG_DATABASE_KEY, json); + pd.SetString(kConfigDatabaseKey, json); } -bool readDltEnabled(IPersistentDictionary& pd) +bool ReadDltEnabled(IPersistentDictionary& pd) { - const bool enabled = pd.GetBool(CONFIG_OUTPUT_ENABLED_KEY, true); + const bool enabled = pd.GetBool(kConfigOutputEnabledKey, true); if constexpr (kPersistentConfigFeatureEnabled) { std::cout << "Loaded output enable = " << enabled << " from KVS" << std::endl; @@ -345,9 +346,9 @@ bool readDltEnabled(IPersistentDictionary& pd) return enabled; } -void writeDltEnabled(bool enabled, IPersistentDictionary& pd) +void WriteDltEnabled(bool enabled, IPersistentDictionary& pd) { - pd.SetBool(CONFIG_OUTPUT_ENABLED_KEY, enabled); + pd.SetBool(kConfigOutputEnabledKey, enabled); } } // namespace datarouter diff --git a/score/datarouter/src/daemon/socketserver_filter_factory.cpp b/score/datarouter/src/daemon/socketserver_filter_factory.cpp index a5cab0e..5f23a1f 100644 --- a/score/datarouter/src/daemon/socketserver_filter_factory.cpp +++ b/score/datarouter/src/daemon/socketserver_filter_factory.cpp @@ -61,9 +61,9 @@ static_assert(v::is_payload_compatible> payload; }; @@ -73,32 +73,32 @@ struct DataFilterable // coverity[autosar_cpp14_a18_9_4_violation] STRUCT_TRACEABLE(DataFilterable, serviceId, instanceId, attributeId, payload) -score::platform::internal::LogParser::FilterFunctionFactory getFilterFactory() +score::platform::internal::LogParser::FilterFunctionFactory GetFilterFactory() { - auto factory = [](const std::string& typeName, + auto factory = [](const std::string& type_name, const DataFilter& filter) -> score::platform::internal::LogParser::FilterFunction { - if (typeName == v::struct_visitable::name() && - filter.filterType == v::struct_visitable::name()) + if (type_name == v::struct_visitable::name() && + filter.filter_type == v::struct_visitable::name()) { - score::platform::internal::LogEntryFilter entryFilter; - using s = v::logging_serializer; - if (s::deserialize(filter.filterData.data(), filter.filterData.size(), entryFilter)) + score::platform::internal::LogEntryFilter entry_filter; + using S = v::logging_serializer; + if (S::deserialize(filter.filter_data.data(), filter.filter_data.size(), entry_filter)) { - return [entryFilter](const char* const data, const bufsize_t size) { + return [entry_filter](const char* const data, const BufsizeT size) { LogEntryFilterable entry; - if (!s::deserialize(data, size, entry)) + if (!S::deserialize(data, size, entry)) { return false; } - const bool appIdMatch = entryFilter.app_id == score::mw::log::detail::LoggingIdentifier{""} || - entryFilter.app_id == entry.app_id; - const bool ctxIdMatch = entryFilter.ctx_id == score::mw::log::detail::LoggingIdentifier{""} || - // condition tested :FALSE POSITIVE. - // LCOV_EXCL_START - entryFilter.ctx_id == entry.ctx_id; + const bool app_id_match = entry_filter.app_id == score::mw::log::detail::LoggingIdentifier{""} || + entry_filter.app_id == entry.app_id; + const bool ctx_id_match = entry_filter.ctx_id == score::mw::log::detail::LoggingIdentifier{""} || + // condition tested :FALSE POSITIVE. + // LCOV_EXCL_START + entry_filter.ctx_id == entry.ctx_id; // LCOV_EXCL_STOP - const bool logLevelMatch = entryFilter.logLevelThreshold >= entry.log_level; - return appIdMatch && ctxIdMatch && logLevelMatch; + const bool log_level_match = entry_filter.log_level_threshold >= entry.log_level; + return app_id_match && ctx_id_match && log_level_match; }; } } diff --git a/score/datarouter/src/daemon/udp_stream_output.cpp b/score/datarouter/src/daemon/udp_stream_output.cpp index 9a6bb58..00b64f9 100644 --- a/score/datarouter/src/daemon/udp_stream_output.cpp +++ b/score/datarouter/src/daemon/udp_stream_output.cpp @@ -22,16 +22,16 @@ #include #include -score::logging::dltserver::UdpStreamOutput::UdpStreamOutput(const char* dstAddr, - uint16_t dstPort, - const char* multicastInterface, +score::logging::dltserver::UdpStreamOutput::UdpStreamOutput(const char* dst_addr, + uint16_t dst_port, + const char* multicast_interface, std::unique_ptr socket_instance, score::os::Vlan& vlan) : socket_{-1}, dst_{}, pthread_{score::os::Pthread::Default()}, socket_instance_{std::move(socket_instance)} { dst_.sin_family = AF_INET; - dst_.sin_port = htons(dstPort); - if (dstAddr == nullptr || inet_aton(dstAddr, &dst_.sin_addr) == 0) + dst_.sin_port = htons(dst_port); + if (dst_addr == nullptr || inet_aton(dst_addr, &dst_.sin_addr) == 0) { dst_.sin_addr.s_addr = INADDR_ANY; } @@ -55,9 +55,9 @@ score::logging::dltserver::UdpStreamOutput::UdpStreamOutput(const char* dstAddr, } { - constexpr int32_t SOCK_OPT_ENABLE = 1; + constexpr int32_t kSockOptEnable = 1; const auto ret_setsockopt_reuseport = - socket_instance_->setsockopt(socket_, SOL_SOCKET, SO_REUSEPORT, &SOCK_OPT_ENABLE, sizeof(int)); + socket_instance_->setsockopt(socket_, SOL_SOCKET, SO_REUSEPORT, &kSockOptEnable, sizeof(int)); if (!ret_setsockopt_reuseport.has_value()) { const auto error_string = ret_setsockopt_reuseport.error().ToString(); @@ -68,9 +68,9 @@ score::logging::dltserver::UdpStreamOutput::UdpStreamOutput(const char* dstAddr, { // On QNX when the buffer is smaller than the message we are trying to send _sendto_ failes with negative // code 64 K is the maximum length of the DLT message. - constexpr std::int32_t socket_sndbuf_size = 64L * 1024UL; - const auto ret_setsockopt_sndbuf = socket_instance_->setsockopt( - socket_, SOL_SOCKET, SO_SNDBUF, &socket_sndbuf_size, sizeof(socket_sndbuf_size)); + constexpr std::int32_t kSocketSndbufSize = 64L * 1024UL; + const auto ret_setsockopt_sndbuf = + socket_instance_->setsockopt(socket_, SOL_SOCKET, SO_SNDBUF, &kSocketSndbufSize, sizeof(kSocketSndbufSize)); if (!ret_setsockopt_sndbuf.has_value()) { const auto error_string = ret_setsockopt_sndbuf.error().ToString(); @@ -79,9 +79,9 @@ score::logging::dltserver::UdpStreamOutput::UdpStreamOutput(const char* dstAddr, } { - constexpr int32_t SOCK_OPT_ENABLE_REUSEADDR = 1; + constexpr int32_t kSockOptEnableReuseaddr = 1; const auto ret_setsockopt_reuseaddress = - socket_instance_->setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, &SOCK_OPT_ENABLE_REUSEADDR, sizeof(int)); + socket_instance_->setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR, &kSockOptEnableReuseaddr, sizeof(int)); if (!ret_setsockopt_reuseaddress.has_value()) { const auto error_string = ret_setsockopt_reuseaddress.error().ToString(); @@ -89,13 +89,13 @@ score::logging::dltserver::UdpStreamOutput::UdpStreamOutput(const char* dstAddr, } } - if (multicastInterface != nullptr) + if (multicast_interface != nullptr) { - const std::string_view strViewMulticastInterface{multicastInterface}; - if (strViewMulticastInterface.length() != 0) + const std::string_view str_view_multicast_interface{multicast_interface}; + if (!str_view_multicast_interface.empty()) { struct in_addr addr{}; - if (inet_aton(multicastInterface, &addr) != 0) + if (inet_aton(multicast_interface, &addr) != 0) { if (setsockopt(socket_, IPPROTO_IP, IP_MULTICAST_IF, &addr, sizeof(addr)) == -1) { @@ -112,7 +112,7 @@ score::logging::dltserver::UdpStreamOutput::UdpStreamOutput(const char* dstAddr, } else { - std::cerr << "ERROR: Invalid multicast interface address: " << multicastInterface + std::cerr << "ERROR: Invalid multicast interface address: " << multicast_interface << " " // coverity[autosar_cpp14_m19_3_1_violation] << std::system_category().message(errno) << std::endl; @@ -136,7 +136,7 @@ inclusion and include guards, and using the following directives: (1) #ifndef, static_cast(vlan); // coverity[autosar_cpp14_a16_0_1_violation] see above #else - constexpr std::uint8_t kDltPcpPriority = 1u; + constexpr std::uint8_t kDltPcpPriority = 1U; const auto pcp_result = vlan.SetVlanPriorityOfSocket(kDltPcpPriority, socket_); if (!pcp_result.has_value()) { @@ -168,13 +168,13 @@ score::logging::dltserver::UdpStreamOutput::UdpStreamOutput(UdpStreamOutput&& fr from.socket_ = -1; } -score::cpp::expected_blank score::logging::dltserver::UdpStreamOutput::bind(const char* srcAddr, - uint16_t srcPort) noexcept +score::cpp::expected_blank score::logging::dltserver::UdpStreamOutput::Bind(const char* src_addr, + uint16_t src_port) noexcept { struct sockaddr_in src{}; src.sin_family = AF_INET; - src.sin_port = htons(srcPort); - if (srcAddr == nullptr || inet_aton(srcAddr, &src.sin_addr) == 0) + src.sin_port = htons(src_port); + if (src_addr == nullptr || inet_aton(src_addr, &src.sin_addr) == 0) { src.sin_addr.s_addr = INADDR_ANY; } @@ -195,19 +195,19 @@ score::cpp::expected_blank score::logging::dltserver::UdpStrea - This is safe because sockaddr_in and sockaddr have the same initial structure (`__SOCKADDR_COMMON`). */ // coverity[autosar_cpp14_m5_2_8_violation] - const auto addr = static_cast(sockaddr_void_ptr); + const auto* const addr = static_cast(sockaddr_void_ptr); const auto ret = socket_instance_->bind(socket_, addr, sizeof(src)); if (!ret.has_value()) { auto errstr = ret.error().ToString(); - std::cerr << "ERROR: (UDP) socket cannot bind to (" << (srcAddr != nullptr ? srcAddr : "any") << ":" << srcPort - << "): " << errstr << std::endl; + std::cerr << "ERROR: (UDP) socket cannot bind to (" << (src_addr != nullptr ? src_addr : "any") << ":" + << src_port << "): " << errstr << std::endl; } return ret; } -score::cpp::expected score::logging::dltserver::UdpStreamOutput::send( +score::cpp::expected score::logging::dltserver::UdpStreamOutput::Send( score::cpp::span mmsg) noexcept { for (auto& msg : mmsg) @@ -223,7 +223,7 @@ score::cpp::expected score::logging::dltserver:: } // Used to send single big message: -score::cpp::expected score::logging::dltserver::UdpStreamOutput::send(const iovec* iovec_tab, +score::cpp::expected score::logging::dltserver::UdpStreamOutput::Send(const iovec* iovec_tab, const size_t size) noexcept { struct msghdr msg{}; diff --git a/score/datarouter/src/daemon/utility.cpp b/score/datarouter/src/daemon/utility.cpp index 95d5774..7cc81a0 100644 --- a/score/datarouter/src/daemon/utility.cpp +++ b/score/datarouter/src/daemon/utility.cpp @@ -19,7 +19,7 @@ namespace logging_daemon namespace logchannel_utility { -const std::unordered_map loglevel_map = { +const std::unordered_map kLoglevelMap = { {"kOff", score::mw::log::LogLevel::kOff}, {"kFatal", score::mw::log::LogLevel::kFatal}, {"kError", score::mw::log::LogLevel::kError}, @@ -28,19 +28,19 @@ const std::unordered_map loglevel_map = { {"kDebug", score::mw::log::LogLevel::kDebug}, {"kVerbose", score::mw::log::LogLevel::kVerbose}}; -score::mw::log::LogLevel ToLogLevel(const std::string& logLevel) +score::mw::log::LogLevel ToLogLevel(const std::string& log_level) { - score::mw::log::LogLevel mappedLevel = score::mw::log::LogLevel::kOff; - auto it = loglevel_map.find(logLevel); - if (it != loglevel_map.end()) + score::mw::log::LogLevel mapped_level = score::mw::log::LogLevel::kOff; + auto it = kLoglevelMap.find(log_level); + if (it != kLoglevelMap.end()) { - mappedLevel = it->second; + mapped_level = it->second; } else { - std::cerr << "Invalid Log Level String!!!:" << logLevel << std::endl; + std::cerr << "Invalid Log Level String!!!:" << log_level << std::endl; } - return mappedLevel; + return mapped_level; } std::string ToString(const score::mw::log::LogLevel level) { diff --git a/score/datarouter/src/daemon/verbose_dlt.cpp b/score/datarouter/src/daemon/verbose_dlt.cpp index c0c0934..53709f3 100644 --- a/score/datarouter/src/daemon/verbose_dlt.cpp +++ b/score/datarouter/src/daemon/verbose_dlt.cpp @@ -23,17 +23,17 @@ namespace logging namespace dltserver { -void DltVerboseHandler::handle(timestamp_t timestamp, const char* data, bufsize_t size) +void DltVerboseHandler::Handle(TimestampT timestamp, const char* data, BufsizeT size) { namespace dlt_server_logging = ::score::mw::log::detail::log_entry_deserialization; - using dlt_duration_t = std::chrono::duration>; - uint32_t duration = std::chrono::duration_cast(timestamp.time_since_epoch()).count(); + using DltDurationT = std::chrono::duration>; + uint32_t duration = std::chrono::duration_cast(timestamp.time_since_epoch()).count(); dlt_server_logging::LogEntryDeserializationReflection log_entry_deserialization_reflection; - using s = ::score::common::visitor::logging_serializer; + using S = ::score::common::visitor::logging_serializer; - s::deserialize(data, size, log_entry_deserialization_reflection); + S::deserialize(data, size, log_entry_deserialization_reflection); - output_.sendVerbose(duration, log_entry_deserialization_reflection); + output_.SendVerbose(duration, log_entry_deserialization_reflection); } } // namespace dltserver diff --git a/score/datarouter/src/dlt/dltid_converter.cpp b/score/datarouter/src/dlt/dltid_converter.cpp index 9878f55..18c8cad 100644 --- a/score/datarouter/src/dlt/dltid_converter.cpp +++ b/score/datarouter/src/dlt/dltid_converter.cpp @@ -18,9 +18,9 @@ namespace score namespace platform { -dltid_t convertToDltId(const score::mw::log::detail::LoggingIdentifier& logging_identifier) +DltidT ConvertToDltId(const score::mw::log::detail::LoggingIdentifier& logging_identifier) { - return dltid_t{logging_identifier.GetStringView()}; + return DltidT{logging_identifier.GetStringView()}; } } // namespace platform diff --git a/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.cpp b/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.cpp index 2dc4d17..c69bd38 100644 --- a/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.cpp +++ b/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.cpp @@ -27,13 +27,13 @@ DltNonverboseHandler::DltNonverboseHandler(IOutput& output) { } -void DltNonverboseHandler::handle(const TypeInfo& type_info, timestamp_t timestamp, const char* data, bufsize_t size) +void DltNonverboseHandler::Handle(const TypeInfo& type_info, TimestampT timestamp, const char* data, BufsizeT size) { - if (type_info.nvMsgDesc != nullptr) + if (type_info.nv_msg_desc != nullptr) { using DltDurationT = std::chrono::duration>; uint32_t tmsp = std::chrono::duration_cast(timestamp.time_since_epoch()).count(); - output_.SendNonVerbose(*type_info.nvMsgDesc, tmsp, data, size); + output_.SendNonVerbose(*type_info.nv_msg_desc, tmsp, data, size); } } diff --git a/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h b/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h index e4c0104..eaf9cdb 100644 --- a/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h +++ b/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h @@ -43,7 +43,7 @@ class DltNonverboseHandler : public LogParser::AnyHandler }; explicit DltNonverboseHandler(IOutput& output); - virtual void handle(const TypeInfo& type_info, timestamp_t timestamp, const char* data, bufsize_t size) override; + virtual void Handle(const TypeInfo& type_info, TimestampT timestamp, const char* data, BufsizeT size) override; private: score::mw::log::Logger& logger_; diff --git a/score/datarouter/src/dlt/nonverbose_dlt_stub/stub_nonverbose_dlt.h b/score/datarouter/src/dlt/nonverbose_dlt_stub/stub_nonverbose_dlt.h index 02937db..e4622da 100644 --- a/score/datarouter/src/dlt/nonverbose_dlt_stub/stub_nonverbose_dlt.h +++ b/score/datarouter/src/dlt/nonverbose_dlt_stub/stub_nonverbose_dlt.h @@ -44,7 +44,7 @@ class StubDltNonverboseHandler : public LogParser::AnyHandler explicit StubDltNonverboseHandler(IOutput&) {} - void handle(const TypeInfo&, timestamp_t, const char*, bufsize_t) override + void Handle(const TypeInfo&, TimestampT, const char*, BufsizeT) override { // Stub implementation does nothing } diff --git a/score/datarouter/src/file_transfer/file_transfer_handler_factory.hpp b/score/datarouter/src/file_transfer/file_transfer_handler_factory.hpp index 7c35a65..6b441a1 100644 --- a/score/datarouter/src/file_transfer/file_transfer_handler_factory.hpp +++ b/score/datarouter/src/file_transfer/file_transfer_handler_factory.hpp @@ -34,9 +34,9 @@ template class FileTransferHandlerFactory { public: - std::unique_ptr create() + std::unique_ptr Create() { - return static_cast(*this).createConcreteHandler(); + return static_cast(*this).CreateConcreteHandler(); } private: diff --git a/score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_handler_factory_stub.h b/score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_handler_factory_stub.h index cf94259..c2b4fec 100644 --- a/score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_handler_factory_stub.h +++ b/score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_handler_factory_stub.h @@ -37,8 +37,8 @@ class Output : public StubFileTransferStreamHandler::IOutput SendFtVerbose, (score::cpp::span data, mw::log::LogLevel loglevel, - dltid_t appId, - dltid_t ctxId, + DltidT appId, + DltidT ctxId, uint8_t nor, uint32_t time_tmsp), (override)); diff --git a/score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_stream_handler_stub.h b/score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_stream_handler_stub.h index da6e674..840b1b0 100644 --- a/score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_stream_handler_stub.h +++ b/score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_stream_handler_stub.h @@ -41,8 +41,8 @@ class StubFileTransferStreamHandler : public LogParser::TypeHandler public: virtual void SendFtVerbose(score::cpp::span data, mw::log::LogLevel loglevel, - dltid_t appId, - dltid_t ctxId, + DltidT appId, + DltidT ctxId, uint8_t nor, uint32_t time_tmsp) = 0; @@ -58,7 +58,7 @@ class StubFileTransferStreamHandler : public LogParser::TypeHandler ~StubFileTransferStreamHandler() = default; - virtual void handle(timestamp_t /*timestamp*/, const char* /*buffer*/, bufsize_t /*size*/) override + virtual void Handle(TimestampT /*timestamp*/, const char* /*buffer*/, BufsizeT /*size*/) override { score::mw::log::LogWarn() << "File transfer feature is disabled!"; } diff --git a/score/datarouter/src/logparser/logparser.cpp b/score/datarouter/src/logparser/logparser.cpp index d46385f..923f950 100644 --- a/score/datarouter/src/logparser/logparser.cpp +++ b/score/datarouter/src/logparser/logparser.cpp @@ -25,16 +25,16 @@ namespace { template -inline std::string logger_unmemcpy(const std::string& params, T& t) +inline std::string LoggerUnmemcpy(const std::string& params, T& t) { std::copy_n(params.begin(), sizeof(T), score::cpp::bit_cast(&t)); return params.substr(sizeof(T)); } -void logger_unpack_string(std::string params, std::string& str) +void LoggerUnpackString(std::string params, std::string& str) { uint32_t size = 0U; - params = logger_unmemcpy(params, size); + params = LoggerUnmemcpy(params, size); // We can't test the False, the size of argument 'params' can't be negative. Suppress. if (size <= params.size()) // LCOV_EXCL_BR_LINE { @@ -61,21 +61,21 @@ namespace internal LogParser::LogParser(const score::mw::log::INvConfig& nv_config) : ILogParser(), - filter_factory{}, - handle_request_map{}, - typename_to_index{}, - index_parser_map{}, - global_handlers{}, + filter_factory_{}, + handle_request_map_{}, + typename_to_index_{}, + index_parser_map_{}, + global_handlers_{}, nv_config_(nv_config) { } -void LogParser::IndexParser::add_handler(const LogParser::HandleRequestMap::value_type& request) +void LogParser::IndexParser::AddHandler(const LogParser::HandleRequestMap::value_type& request) { handlers_.push_back(Handler{&request, request.second.handler}); } -void LogParser::IndexParser::remove_handler(const LogParser::HandleRequestMap::value_type& request) +void LogParser::IndexParser::RemoveHandler(const LogParser::HandleRequestMap::value_type& request) { const auto finder = [&request](const auto& v) { return v.request == &request; @@ -87,17 +87,17 @@ void LogParser::IndexParser::remove_handler(const LogParser::HandleRequestMap::v } } -void LogParser::IndexParser::parse(const timestamp_t timestamp, const char* const data, const bufsize_t size) +void LogParser::IndexParser::Parse(const TimestampT timestamp, const char* const data, const BufsizeT size) { for (const auto& handler : handlers_) { - handler.handler->handle(timestamp, data, size); + handler.handler->Handle(timestamp, data, size); } } -void LogParser::add_incoming_type(const bufsize_t map_index, const std::string& params) +void LogParser::AddIncomingType(const BufsizeT map_index, const std::string& params) { - // params format: { dltid_t versionId{0}; dltid_t ecuId; dltid_t appId; + // params format: { DltidT versionId{0}; DltidT ecuId; DltidT appId; // uint32_t typenameLen; char typename[typenameLen]; // [optional, TBD] char payload_format_description[]; } if (params.size() <= 12 + sizeof(uint32_t) || params[0] != 0 || params[1] != 0 || params[2] != 0 || params[3] != 0) @@ -105,81 +105,82 @@ void LogParser::add_incoming_type(const bufsize_t map_index, const std::string& // TODO: report return; } - dltid_t ecuId{params.substr(4U, 4U)}; - dltid_t appId{params.substr(8U, 4U)}; - std::string typeName; - logger_unpack_string(params.substr(12U), typeName); - - typename_to_index.emplace(typeName, map_index); - IndexParser indexParser{TypeInfo{nv_config_.GetDltMsgDesc(typeName), map_index, params, typeName, ecuId, appId}}; - const auto ith_range = handle_request_map.equal_range(typeName); + DltidT ecu_id{params.substr(4U, 4U)}; + DltidT app_id{params.substr(8U, 4U)}; + std::string type_name; + LoggerUnpackString(params.substr(12U), type_name); + + typename_to_index_.emplace(type_name, map_index); + IndexParser index_parser{ + TypeInfo{nv_config_.GetDltMsgDesc(type_name), map_index, params, type_name, ecu_id, app_id}}; + const auto ith_range = handle_request_map_.equal_range(type_name); for (auto ith = ith_range.first; ith != ith_range.second; ++ith) { - indexParser.add_handler(*ith); + index_parser.AddHandler(*ith); } - index_parser_map.emplace(map_index, std::move(indexParser)); + index_parser_map_.emplace(map_index, std::move(index_parser)); } void LogParser::AddIncomingType(const score::mw::log::detail::TypeRegistration& type_registration) { std::string params{type_registration.registration_data.data(), score::mw::log::detail::GetDataSizeAsLength(type_registration.registration_data)}; - this->add_incoming_type(type_registration.type_id, params); + this->AddIncomingType(type_registration.type_id, params); } -void LogParser::add_global_handler(AnyHandler& handler) +void LogParser::AddGlobalHandler(AnyHandler& handler) { - if (is_glb_hndl_registered(handler) == false) + if (IsGlbHndlRegistered(handler) == false) { - global_handlers.push_back(&handler); + global_handlers_.push_back(&handler); } } -void LogParser::remove_global_handler(AnyHandler& handler) +void LogParser::RemoveGlobalHandler(AnyHandler& handler) { - const auto it = std::find(global_handlers.begin(), global_handlers.end(), &handler); - if (it != global_handlers.end()) + const auto it = std::find(global_handlers_.begin(), global_handlers_.end(), &handler); + if (it != global_handlers_.end()) { - global_handlers.erase(it); + global_handlers_.erase(it); } } -void LogParser::add_type_handler(const std::string& typeName, TypeHandler& handler) +void LogParser::AddTypeHandler(const std::string& type_name, TypeHandler& handler) { - if (is_type_hndl_registered(typeName, handler)) + if (IsTypeHndlRegistered(type_name, handler)) { return; } - const auto ith = handle_request_map.emplace(typeName, HandleRequest{&handler}); - const auto iti_range = typename_to_index.equal_range(typeName); + const auto ith = handle_request_map_.emplace(type_name, HandleRequest{&handler}); + const auto iti_range = typename_to_index_.equal_range(type_name); for (auto iti = iti_range.first; iti != iti_range.second; ++iti) { - index_parser_map.at(iti->second).add_handler(*ith); + index_parser_map_.at(iti->second).AddHandler(*ith); } } -void LogParser::remove_type_handler(const std::string& typeName, TypeHandler& handler) +void LogParser::RemoveTypeHandler(const std::string& type_name, TypeHandler& handler) { - const auto ith_range = handle_request_map.equal_range(typeName); + const auto ith_range = handle_request_map_.equal_range(type_name); const auto finder = [&handler](const auto& v) { return v.second.handler == &handler; }; const auto ith = std::find_if(ith_range.first, ith_range.second, finder); if (ith != ith_range.second) { - const auto iti_range = typename_to_index.equal_range(typeName); + const auto iti_range = typename_to_index_.equal_range(type_name); for (auto iti = iti_range.first; iti != iti_range.second; ++iti) { - index_parser_map.at(iti->second).remove_handler(*ith); + index_parser_map_.at(iti->second).RemoveHandler(*ith); } - handle_request_map.erase(ith); + handle_request_map_.erase(ith); } } -bool LogParser::is_type_hndl_registered(const std::string& typeName, const TypeHandler& handler) +bool LogParser::IsTypeHndlRegistered(const std::string& type_name, const TypeHandler& handler) { bool retval = false; - const auto ith_range = handle_request_map.equal_range(typeName); + const auto ith_range = handle_request_map_.equal_range(type_name); const auto finder = [&handler](const auto& v) { return v.second.handler == &handler; }; @@ -191,31 +192,31 @@ bool LogParser::is_type_hndl_registered(const std::string& typeName, const TypeH return retval; } -bool LogParser::is_glb_hndl_registered(const AnyHandler& handler) +bool LogParser::IsGlbHndlRegistered(const AnyHandler& handler) { - const auto it = std::find(global_handlers.begin(), global_handlers.end(), &handler); + const auto it = std::find(global_handlers_.begin(), global_handlers_.end(), &handler); bool retval = false; - if (it != global_handlers.end()) + if (it != global_handlers_.end()) { retval = true; } return retval; } -void LogParser::reset_internal_mapping() +void LogParser::ResetInternalMapping() { - typename_to_index.clear(); - index_parser_map.clear(); + typename_to_index_.clear(); + index_parser_map_.clear(); } -void LogParser::parse(timestamp_t timestamp, const char* data, bufsize_t size) +void LogParser::Parse(TimestampT timestamp, const char* data, BufsizeT size) { // TODO: move index storage and handling to MwsrHeader - if (size < sizeof(bufsize_t)) + if (size < sizeof(BufsizeT)) { return; } - bufsize_t index = 0U; + BufsizeT index = 0U; /* Deviation from Rule M5-0-16: - A pointer operand and any pointer resulting from pointer arithmetic using that operand shall both address elements @@ -227,29 +228,29 @@ void LogParser::parse(timestamp_t timestamp, const char* data, bufsize_t size) std::copy_n(data, sizeof(index), score::cpp::bit_cast(&index)); std::advance(data, sizeof(index)); - size -= static_cast(sizeof(index)); + size -= static_cast(sizeof(index)); - const auto iParser = index_parser_map.find(index); - if (iParser == index_parser_map.end()) + const auto i_parser = index_parser_map_.find(index); + if (i_parser == index_parser_map_.end()) { // TODO: somehow report inconsistency? return; } - auto& indexParser = iParser->second; - indexParser.parse(timestamp, data, size); + auto& index_parser = i_parser->second; + index_parser.Parse(timestamp, data, size); - const auto& typeInfo = indexParser.info_; - for (const auto handler : global_handlers) + const auto& type_info = index_parser.info; + for (auto* const handler : global_handlers_) { - handler->handle(typeInfo, timestamp, data, size); + handler->Handle(type_info, timestamp, data, size); } } void LogParser::Parse(const score::mw::log::detail::SharedMemoryRecord& record) { - const auto index_parser_entry = index_parser_map.find(record.header.type_identifier); - if (index_parser_entry == index_parser_map.end()) + const auto index_parser_entry = index_parser_map_.find(record.header.type_identifier); + if (index_parser_entry == index_parser_map_.end()) { return; } @@ -261,23 +262,23 @@ void LogParser::Parse(const score::mw::log::detail::SharedMemoryRecord& record) // We can't test the True case because: // - The 'payload_length' is the length of the score::cpp::span incoming variable and the max size of // the 'score::cpp::span' is 'std::size_t' which is UINT_MAX (as mentioned in the cppreference). - // - And because the 'bufsize_t' is unsigned int32. + // - And because the 'BufsizeT' is unsigned int32. // So, we can't pass a bigger value than unsigned int32 to match the True case below because // it will overflow and reset the variable. - if (payload_length > std::numeric_limits::max()) // LCOV_EXCL_BR_LINE + if (payload_length > std::numeric_limits::max()) // LCOV_EXCL_BR_LINE { return; // LCOV_EXCL_LINE } - const auto payload_length_buf_size = static_cast(payload_length); - const auto payload_ptr = record.payload.data(); + const auto payload_length_buf_size = static_cast(payload_length); + auto* const payload_ptr = record.payload.data(); - index_parser.parse(record.header.time_stamp, payload_ptr, payload_length_buf_size); + index_parser.Parse(record.header.time_stamp, payload_ptr, payload_length_buf_size); - const auto& type_info = index_parser.info_; - for (const auto handler : global_handlers) + const auto& type_info = index_parser.info; + for (auto* const handler : global_handlers_) { - handler->handle(type_info, record.header.time_stamp, payload_ptr, payload_length_buf_size); + handler->Handle(type_info, record.header.time_stamp, payload_ptr, payload_length_buf_size); } } diff --git a/score/datarouter/src/persistency/mock_persistent_dictionary.h b/score/datarouter/src/persistency/mock_persistent_dictionary.h index d87affa..6fcdb68 100644 --- a/score/datarouter/src/persistency/mock_persistent_dictionary.h +++ b/score/datarouter/src/persistency/mock_persistent_dictionary.h @@ -29,8 +29,8 @@ namespace datarouter class MockPersistentDictionary : public ::score::platform::datarouter::IPersistentDictionary { public: - MOCK_METHOD(std::string, GetString, (const std::string& key, const std::string& defaultValue), (override final)); - MOCK_METHOD(bool, GetBool, (const std::string& key, const bool defaultValue), (override final)); + MOCK_METHOD(std::string, GetString, (const std::string& key, const std::string& default_value), (override final)); + MOCK_METHOD(bool, GetBool, (const std::string& key, const bool default_value), (override final)); MOCK_METHOD(void, SetString, (const std::string& key, const std::string& value), (override final)); MOCK_METHOD(void, SetBool, (const std::string& key, const bool value), (override final)); diff --git a/score/datarouter/src/persistent_logging/isysedr_handler.h b/score/datarouter/src/persistent_logging/isysedr_handler.h index bc730a7..b177d4d 100644 --- a/score/datarouter/src/persistent_logging/isysedr_handler.h +++ b/score/datarouter/src/persistent_logging/isysedr_handler.h @@ -32,13 +32,12 @@ class ISysedrHandler : public LogParser::TypeHandler, public LogParser::AnyHandl protected: // LogParser::TypeHandler - void handle(timestamp_t /* timestamp */, const char* /*data*/, bufsize_t /*size*/) override {}; - + void Handle(TimestampT /* timestamp */, const char* /*data*/, BufsizeT /*size*/) override {}; // LogParser::AnyHandler - void handle(const TypeInfo& /*typeInfo*/, - timestamp_t /*timestamp*/, + void Handle(const TypeInfo& /*typeInfo*/, + TimestampT /*timestamp*/, const char* /*data*/, - bufsize_t /*size*/) override {}; + BufsizeT /*size*/) override {}; }; // LCOV_EXCL_STOP diff --git a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.cpp b/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.cpp index 8d48028..3a6b406 100644 --- a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.cpp +++ b/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.cpp @@ -22,10 +22,10 @@ namespace internal // LCOV_EXCL_START (nothing to test because there is no implementation) // LogParser::TypeHandler -void StubSysedrHandler::handle(timestamp_t /* timestamp */, const char* data, bufsize_t size) {} +void StubSysedrHandler::Handle(TimestampT /* timestamp */, const char* data, BufsizeT size) {} // LogParser::AnyHandler -void StubSysedrHandler::handle(const TypeInfo& type_info, timestamp_t timestamp, const char* data, bufsize_t size) {} +void StubSysedrHandler::Handle(const TypeInfo& type_info, TimestampT timestamp, const char* data, BufsizeT size) {} // LCOV_EXCL_STOP diff --git a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h b/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h index c88fecf..1112877 100644 --- a/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h +++ b/score/datarouter/src/persistent_logging/persistent_logging_stub/stub_sysedr_handler.h @@ -28,10 +28,10 @@ class StubSysedrHandler final : public ISysedrHandler private: // LogParser::TypeHandler - void handle(timestamp_t /* timestamp */, const char* data, bufsize_t size) override; + void Handle(TimestampT /* timestamp */, const char* data, BufsizeT size) override; // LogParser::AnyHandler - void handle(const TypeInfo& type_info, timestamp_t timestamp, const char* data, bufsize_t size) override; + void Handle(const TypeInfo& type_info, TimestampT timestamp, const char* data, BufsizeT size) override; }; } // namespace internal diff --git a/score/datarouter/src/unix_domain/unix_domain_client.cpp b/score/datarouter/src/unix_domain/unix_domain_client.cpp index 784afee..203582a 100644 --- a/score/datarouter/src/unix_domain/unix_domain_client.cpp +++ b/score/datarouter/src/unix_domain/unix_domain_client.cpp @@ -67,14 +67,14 @@ score::cpp::optional OpenReceivedSharedMemoryFileHandle( #endif // defined(__QNXNTO__) } // namespace -void UnixDomainClient::client_routine() +void UnixDomainClient::ClientRoutine() { SetupSignals(signal_); - std::uniform_int_distribution reconnectMsRange(75, 125); + std::uniform_int_distribution reconnect_ms_range(75, 125); std::mt19937 gen{std::random_device{}()}; // random per thread instance, constant for a thread instance, initialized early - const auto reconnectDelay = std::chrono::milliseconds(reconnectMsRange(gen)); + const auto reconnect_delay = std::chrono::milliseconds(reconnect_ms_range(gen)); while (false == exit_.load()) { @@ -99,7 +99,7 @@ void UnixDomainClient::client_routine() while (false == exit_.load()) { - auto connectRetryDelay = 100ms; + auto connect_retry_delay = 100ms; std::int32_t ret = connect(fd, static_cast(static_cast(&addr_)), sizeof(sockaddr_un)); if (ret == -1) @@ -115,11 +115,11 @@ void UnixDomainClient::client_routine() // coverity[autosar_cpp14_m19_3_1_violation] if (errno == ECONNREFUSED || errno == EAGAIN || errno == ENOENT) { - std::this_thread::sleep_for(connectRetryDelay); - connectRetryDelay *= 2; - if (connectRetryDelay > 5000ms) + std::this_thread::sleep_for(connect_retry_delay); + connect_retry_delay *= 2; + if (connect_retry_delay > 5000ms) { - connectRetryDelay = 5000ms; + connect_retry_delay = 5000ms; } /* Deviation from Rule M6-6-3: @@ -178,7 +178,7 @@ void UnixDomainClient::client_routine() } else { - send_socket_message(fd, out_string); + SendSocketMessage(fd, out_string); command_in_transit = true; } } @@ -187,14 +187,14 @@ void UnixDomainClient::client_routine() score::cpp::optional pid_in; score::cpp::optional result_fd; #if defined(__QNXNTO__) - const auto response = recv_socket_message(fd, result_fd, pid_in, OpenReceivedSharedMemoryFileHandle); + const auto response = RecvSocketMessage(fd, result_fd, pid_in, OpenReceivedSharedMemoryFileHandle); #else - const auto response = recv_socket_message(fd, result_fd, pid_in); + const auto response = RecvSocketMessage(fd, result_fd, pid_in); #endif // defined(__QNXNTO__) if (false == response.has_value()) { - std::this_thread::sleep_for(reconnectDelay); + std::this_thread::sleep_for(reconnect_delay); break; } @@ -245,17 +245,17 @@ void UnixDomainClient::client_routine() } } -void UnixDomainClient::ping() +void UnixDomainClient::Ping() { if (true != exit_.load() && fd_.load() != -1) { - send_socket_message(fd_.load(), std::string()); + SendSocketMessage(fd_.load(), std::string()); } } -void UnixDomainClient::update_thread_name_logger() +void UnixDomainClient::UpdateThreadNameLogger() { - auto ret = score::os::Pthread::instance().setname_np(client_thread.native_handle(), "logger"); + auto ret = score::os::Pthread::instance().setname_np(client_thread_.native_handle(), "logger"); if (!ret.has_value()) { auto errstr = ret.error().ToString(); diff --git a/score/datarouter/src/unix_domain/unix_domain_common.cpp b/score/datarouter/src/unix_domain/unix_domain_common.cpp index b023a82..7960b5a 100644 --- a/score/datarouter/src/unix_domain/unix_domain_common.cpp +++ b/score/datarouter/src/unix_domain/unix_domain_common.cpp @@ -50,7 +50,7 @@ static_assert(kSocketCmsgSpace == CMSG_SPACE(sizeof(int) * 1U), "Invalid constan } // namespace -void cmsg_len_suppress_warnings(struct cmsghdr* cmsg_, size_t num_fds_) +void CmsgLenSuppressWarnings(struct cmsghdr* cmsg, size_t num_fds) { #ifdef __QNX__ // NOLINTBEGIN(score-banned-preprocessor-directives) : required due to compiler warning for qnx @@ -64,18 +64,18 @@ Deviation from Rule A16-7-1: #pragma GCC diagnostic push // coverity[autosar_cpp14_a16_7_1_violation] see above #pragma GCC diagnostic ignored "-Wsign-conversion" - cmsg_->cmsg_len = static_cast(CMSG_LEN(sizeof(std::int32_t) * num_fds_)); + cmsg->cmsg_len = static_cast(CMSG_LEN(sizeof(std::int32_t) * num_fds)); // coverity[autosar_cpp14_a16_7_1_violation] see above #pragma GCC diagnostic pop // NOLINTEND(score-banned-preprocessor-directives) #else - cmsg_->cmsg_len = CMSG_LEN(sizeof(std::int32_t) * num_fds_); + cmsg->cmsg_len = CMSG_LEN(sizeof(std::int32_t) * num_fds); #endif } -int32_t* cmsg_data_suppress_warning(struct cmsghdr* cmsg_) +int32_t* CmsgDataSuppressWarning(struct cmsghdr* cmsg) { - int32_t* fdptr_ = nullptr; + int32_t* fdptr = nullptr; #ifdef __QNX__ // NOLINTBEGIN(score-banned-preprocessor-directives) : required due to compiler warning for qnx // coverity[autosar_cpp14_a16_7_1_violation] see above @@ -93,24 +93,24 @@ int32_t* cmsg_data_suppress_warning(struct cmsghdr* cmsg_) */ // coverity[autosar_cpp14_m5_0_15_violation] // coverity[autosar_cpp14_m5_2_8_violation] - fdptr_ = static_cast(static_cast(CMSG_DATA(cmsg_))); + fdptr = static_cast(static_cast(CMSG_DATA(cmsg))); // coverity[autosar_cpp14_a16_7_1_violation] see above #pragma GCC diagnostic pop // NOLINTEND(score-banned-preprocessor-directives) #else // coverity[autosar_cpp14_m5_0_15_violation] see above // coverity[autosar_cpp14_m5_2_8_violation] see above - fdptr_ = static_cast(static_cast(CMSG_DATA(cmsg_))); + fdptr = static_cast(static_cast(CMSG_DATA(cmsg))); #endif - return fdptr_; + return fdptr; } -UnixDomainSockAddr::UnixDomainSockAddr(const std::string& path, bool isAbstract) : addr_() +UnixDomainSockAddr::UnixDomainSockAddr(const std::string& path, bool is_abstract) : addr() { - addr_.sun_family = static_cast(AF_UNIX); - size_t len = std::min(sizeof(addr_.sun_path) - 1U - (isAbstract ? 1U : 0U), path.length()); - auto addr_iter = std::begin(addr_.sun_path); - std::advance(addr_iter, static_cast(isAbstract)); + addr.sun_family = static_cast(AF_UNIX); + size_t len = std::min(sizeof(addr.sun_path) - 1U - (is_abstract ? 1U : 0U), path.length()); + auto* addr_iter = std::begin(addr.sun_path); + std::advance(addr_iter, static_cast(is_abstract)); std::copy_n(path.begin(), len, addr_iter); } @@ -170,9 +170,9 @@ void SendAncillaryDataOverSocket(int connection_file_descriptor, score::cpp::spa /* Send message without file descriptor option * * One of the function is to pass a handle to shared memory file */ -void send_socket_message(std::int32_t connection_file_descriptor, - score::cpp::string_view message, - score::cpp::optional file_handle) +void SendSocketMessage(std::int32_t connection_file_descriptor, + score::cpp::string_view message, + score::cpp::optional file_handle) { // TODO: currently checking viability. Redo in a safe way @@ -250,8 +250,8 @@ void send_socket_message(std::int32_t connection_file_descriptor, cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; - cmsg_len_suppress_warnings(cmsg, num_fds); - std::int32_t* fdptr = cmsg_data_suppress_warning(cmsg); + CmsgLenSuppressWarnings(cmsg, num_fds); + std::int32_t* fdptr = CmsgDataSuppressWarning(cmsg); if (num_fds > 0) { fdptr[0] = file_handle.value(); @@ -259,7 +259,7 @@ void send_socket_message(std::int32_t connection_file_descriptor, #endif // USE_SECURE_FILE_HANDLE_IPC } - bool is_ping = (num_fds == 0) && (message.size() == 0); + bool is_ping = (num_fds == 0) && (message.empty()); auto ret = score::os::Socket::instance().sendmsg( connection_file_descriptor, &msg, @@ -284,18 +284,18 @@ void send_socket_message(std::int32_t connection_file_descriptor, } } -score::cpp::optional recv_socket_message(std::int32_t socket_fd, - AncillaryDataFileHandleReceptionCallback ancillary_data_process) +score::cpp::optional RecvSocketMessage(std::int32_t socket_fd, + AncillaryDataFileHandleReceptionCallback ancillary_data_process) { score::cpp::optional discard_file_handle = score::cpp::nullopt; score::cpp::optional discard_pid = score::cpp::nullopt; - return recv_socket_message(socket_fd, discard_file_handle, discard_pid, std::move(ancillary_data_process)); + return RecvSocketMessage(socket_fd, discard_file_handle, discard_pid, std::move(ancillary_data_process)); } -score::cpp::optional recv_socket_message(std::int32_t socket_fd, - score::cpp::optional& file_handle, - score::cpp::optional& peer_pid, - AncillaryDataFileHandleReceptionCallback ancillary_data_process) +score::cpp::optional RecvSocketMessage(std::int32_t socket_fd, + score::cpp::optional& file_handle, + score::cpp::optional& peer_pid, + AncillaryDataFileHandleReceptionCallback ancillary_data_process) { score::cpp::optional result = score::cpp::nullopt; @@ -352,11 +352,11 @@ score::cpp::optional recv_socket_message(std::int32_t socket_fd, cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; - size_t len_ = sizeof(std::int32_t) * static_cast(1U); - cmsg_len_suppress_warnings(cmsg, len_); - fdptr = cmsg_data_suppress_warning(cmsg); + size_t len = sizeof(std::int32_t) * static_cast(1U); + CmsgLenSuppressWarnings(cmsg, len); + fdptr = CmsgDataSuppressWarning(cmsg); static constexpr std::int32_t kNotAssigned = -1; - score::cpp::span(fdptr, len_).front() = kNotAssigned; + score::cpp::span(fdptr, len).front() = kNotAssigned; auto ret = score::os::Socket::instance().recvmsg(socket_fd, &msg, score::os::Socket::MessageFlag::kWaitAll); @@ -381,12 +381,12 @@ score::cpp::optional recv_socket_message(std::int32_t socket_fd, } // can not be tested since no control on fdptr. // LCOV_EXCL_START - if (kNotAssigned != score::cpp::span(fdptr, len_).front()) + if (kNotAssigned != score::cpp::span(fdptr, len).front()) { #if USE_SECURE_FILE_HANDLE_IPC std::cerr << "Warning: received handle over Socket Ancillary Message on QNX." << std::endl; #endif // USE_SECURE_FILE_HANDLE_IPC - file_handle = score::cpp::span(fdptr, len_).front(); + file_handle = score::cpp::span(fdptr, len).front(); } // LCOV_EXCL_STOP diff --git a/score/datarouter/src/unix_domain/unix_domain_server.cpp b/score/datarouter/src/unix_domain/unix_domain_server.cpp index a3c3d77..708300f 100644 --- a/score/datarouter/src/unix_domain/unix_domain_server.cpp +++ b/score/datarouter/src/unix_domain/unix_domain_server.cpp @@ -44,8 +44,7 @@ UnixDomainServer::SessionWrapper::~SessionWrapper() } } -bool UnixDomainServer::SessionWrapper::handle_command(const std::string& in_string, - score::cpp::optional peer_pid) +bool UnixDomainServer::SessionWrapper::HandleCommand(const std::string& in_string, score::cpp::optional peer_pid) { if (nullptr == session_) { @@ -62,21 +61,21 @@ bool UnixDomainServer::SessionWrapper::handle_command(const std::string& in_stri } else { - return timestamp_t::clock::now() < timeout_; + return TimestampT::clock::now() < timeout_; } } else { if (!in_string.empty()) { - session_->on_command(in_string); + session_->OnCommand(in_string); } } - enqueue_tick(); + EnqueueTick(); return true; } -bool UnixDomainServer::SessionWrapper::try_enqueue_for_delete(bool by_peer) +bool UnixDomainServer::SessionWrapper::TryEnqueueForDelete(bool by_peer) { if (nullptr != session_) { @@ -84,7 +83,7 @@ bool UnixDomainServer::SessionWrapper::try_enqueue_for_delete(bool by_peer) closed_by_peer_ = by_peer; if (!running_ && !enqueued_) { - server_->enqueue_tick_direct(session_fd_); + server_->EnqueueTickDirect(session_fd_); enqueued_ = true; } return true; @@ -96,24 +95,24 @@ bool UnixDomainServer::SessionWrapper::try_enqueue_for_delete(bool by_peer) } } -bool UnixDomainServer::SessionWrapper::tick() +bool UnixDomainServer::SessionWrapper::Tick() { - bool requeue = session_->tick(); + bool requeue = session_->Tick(); return requeue; } -void UnixDomainServer::SessionWrapper::notify_closed_by_peer() +void UnixDomainServer::SessionWrapper::NotifyClosedByPeer() { - session_->on_closed_by_peer(); + session_->OnClosedByPeer(); } -void UnixDomainServer::SessionWrapper::set_running() +void UnixDomainServer::SessionWrapper::SetRunning() { enqueued_ = false; running_ = true; } -bool UnixDomainServer::SessionWrapper::reset_running(bool requeue) +bool UnixDomainServer::SessionWrapper::ResetRunning(bool requeue) { running_ = false; if (requeue) @@ -123,23 +122,23 @@ bool UnixDomainServer::SessionWrapper::reset_running(bool requeue) return enqueued_; } -void UnixDomainServer::SessionWrapper::enqueue_tick() +void UnixDomainServer::SessionWrapper::EnqueueTick() { if (!enqueued_ && !to_delete_) { if (!running_) { - server_->enqueue_tick_direct(session_fd_); + server_->EnqueueTickDirect(session_fd_); } enqueued_ = true; } } -void UnixDomainServer::server_routine(UnixDomainSockAddr addr) +void UnixDomainServer::ServerRoutine(UnixDomainSockAddr addr) { SetupSignals(signal_); - const std::int32_t server_fd = setup_server_socket(addr); + const std::int32_t server_fd = SetupServerSocket(addr); // Create connection state struct with server file descriptor // The first element in the pollfd list is special - it is the server file descriptor. @@ -147,39 +146,39 @@ void UnixDomainServer::server_routine(UnixDomainSockAddr addr) ConnectionState state{}; state.connection_pollfd_list.push_back({server_fd, POLLIN, 0}); - using timestamp_t = std::chrono::steady_clock::time_point; - timestamp_t t1 = timestamp_t::clock::now() + std::chrono::milliseconds(100); + using TimestampT = std::chrono::steady_clock::time_point; + TimestampT t1 = TimestampT::clock::now() + std::chrono::milliseconds(100); while (false == server_exit_.load()) { std::int32_t timeout = static_cast( - std::chrono::duration_cast(t1 - timestamp_t::clock::now()).count()); + std::chrono::duration_cast(t1 - TimestampT::clock::now()).count()); if (timeout <= 0) { timeout = 0; - t1 = timestamp_t::clock::now() + std::chrono::milliseconds(100); + t1 = TimestampT::clock::now() + std::chrono::milliseconds(100); } - process_server_iteration(state, server_fd, timeout); + ProcessServerIteration(state, server_fd, timeout); } // while (false == server_exit_.load()) // Cleanup all connections on shutdown - cleanup_all_connections(state); + CleanupAllConnections(state); // Suppressed here as it is safely used, and it is among safety headers. // NOLINTNEXTLINE(score-banned-function) see comment above score::cpp::ignore = score::os::Unistd::instance().close(server_fd); } -std::int32_t UnixDomainServer::setup_server_socket(UnixDomainSockAddr& addr) +std::int32_t UnixDomainServer::SetupServerSocket(UnixDomainSockAddr& addr) { - if (!addr.is_abstract()) + if (!addr.IsAbstract()) { - const auto unlink_ret = score::os::Unistd::instance().unlink(static_cast(addr.addr_.sun_path)); + const auto unlink_ret = score::os::Unistd::instance().unlink(static_cast(addr.addr.sun_path)); if (!unlink_ret.has_value()) { std::perror("unlink"); - std::fprintf(stderr, "address: %s\n", static_cast(addr.addr_.sun_path)); + std::fprintf(stderr, "address: %s\n", static_cast(addr.addr.sun_path)); } } const auto socket_ret = score::os::Socket::instance().socket(score::os::Socket::Domain::kUnix, SOCK_STREAM, 0); @@ -206,7 +205,7 @@ std::int32_t UnixDomainServer::setup_server_socket(UnixDomainSockAddr& addr) if (!bind_ret.has_value()) { std::perror("bind"); - std::cerr << "address: " << addr.get_address_string() << std::endl; + std::cerr << "address: " << addr.GetAddressString() << std::endl; // NOLINTNEXTLINE(score-banned-function): Suppressed here because of error handling std::exit(EXIT_FAILURE); } @@ -222,9 +221,9 @@ std::int32_t UnixDomainServer::setup_server_socket(UnixDomainSockAddr& addr) return server_fd; } -void UnixDomainServer::process_server_iteration(ConnectionState& state, - const std::int32_t server_fd, - const std::int32_t timeout) +void UnixDomainServer::ProcessServerIteration(ConnectionState& state, + const std::int32_t server_fd, + const std::int32_t timeout) { const auto size = state.connection_pollfd_list.size(); // Suppressed here as it is safely used, and it is among safety headers. @@ -263,9 +262,9 @@ void UnixDomainServer::process_server_iteration(ConnectionState& state, } // Process connections with incoming data - process_active_connections(state); + ProcessActiveConnections(state); - process_queue(state.connection_fd_map); + ProcessQueue(state.connection_fd_map); if (timeout > 0) { @@ -273,12 +272,12 @@ void UnixDomainServer::process_server_iteration(ConnectionState& state, } // Process idle connections - process_idle_connections(state); + ProcessIdleConnections(state); - process_queue(state.connection_fd_map); + ProcessQueue(state.connection_fd_map); } -void UnixDomainServer::process_active_connections(ConnectionState& state) +void UnixDomainServer::ProcessActiveConnections(ConnectionState& state) { auto server_fd_advance_iterator = state.connection_pollfd_list.begin(); if (server_fd_advance_iterator != state.connection_pollfd_list.end()) @@ -303,10 +302,10 @@ void UnixDomainServer::process_active_connections(ConnectionState& state) score::cpp::optional file_handle = score::cpp::nullopt; // File descriptor is no longer sent from client to server and server uses universal API and // thus FD is discarded - const auto response = recv_socket_message(session_fd, file_handle, in_pid); - if (!response.has_value() || !session.handle_command(response.value(), in_pid)) + const auto response = RecvSocketMessage(session_fd, file_handle, in_pid); + if (!response.has_value() || !session.HandleCommand(response.value(), in_pid)) { - const bool delayed = session.try_enqueue_for_delete(true); + const bool delayed = session.TryEnqueueForDelete(true); it = state.connection_pollfd_list.erase(it); if (!delayed) @@ -334,7 +333,7 @@ void UnixDomainServer::process_active_connections(ConnectionState& state) } } -void UnixDomainServer::process_idle_connections(ConnectionState& state) +void UnixDomainServer::ProcessIdleConnections(ConnectionState& state) { // Process elements that are idle i.e. pollfd did not report any events for those elements: auto server_fd_advance_iterator = state.connection_pollfd_list.begin(); @@ -357,9 +356,9 @@ void UnixDomainServer::process_idle_connections(ConnectionState& state) { auto& [fd_map, session] = *session_it; std::string in_string; - if (!session.handle_command(in_string)) + if (!session.HandleCommand(in_string)) { - const bool delayed = session.try_enqueue_for_delete(); + const bool delayed = session.TryEnqueueForDelete(); it = state.connection_pollfd_list.erase(it); if (!delayed) { @@ -384,7 +383,7 @@ void UnixDomainServer::process_idle_connections(ConnectionState& state) } } -void UnixDomainServer::cleanup_all_connections(ConnectionState& state) +void UnixDomainServer::CleanupAllConnections(ConnectionState& state) { // Go over all elements auto server_fd_advance_iterator = state.connection_pollfd_list.begin(); @@ -404,7 +403,7 @@ void UnixDomainServer::cleanup_all_connections(ConnectionState& state) if (session_it != state.connection_fd_map.end()) { auto& [fd_map, session] = *session_it; - const bool delayed = session.try_enqueue_for_delete(); + const bool delayed = session.TryEnqueueForDelete(); if (!delayed) { state.connection_fd_map.erase(session_fd); @@ -416,7 +415,7 @@ void UnixDomainServer::cleanup_all_connections(ConnectionState& state) state.connection_fd_map.clear(); } -bool UnixDomainServer::process_queue(std::unordered_map& connection_fd_map) +bool UnixDomainServer::ProcessQueue(std::unordered_map& connection_fd_map) { // Deviation from Rule A6-5-2: // - Numeric loop counter cannot be used because work_queue_ is popped inside the loop @@ -430,19 +429,19 @@ bool UnixDomainServer::process_queue(std::unordered_map& co if (wrapper_iterator != connection_fd_map.end()) { auto& [fd_map, wrapper] = *wrapper_iterator; - wrapper.set_running(); - const bool closed_by_peer = wrapper.get_reset_closed_by_peer(); + wrapper.SetRunning(); + const bool closed_by_peer = wrapper.GetResetClosedByPeer(); if (closed_by_peer) { - wrapper.notify_closed_by_peer(); + wrapper.NotifyClosedByPeer(); } - const bool requeue = wrapper.tick(); + const bool requeue = wrapper.Tick(); - if (wrapper.reset_running(requeue)) + if (wrapper.ResetRunning(requeue)) { - enqueue_tick_direct(fd); + EnqueueTickDirect(fd); } - else if (wrapper.is_marked_for_delete()) + else if (wrapper.IsMarkedForDelete()) { connection_fd_map.erase(fd); } @@ -455,17 +454,17 @@ bool UnixDomainServer::process_queue(std::unordered_map& co return false; } -void UnixDomainServer::enqueue_tick_direct(std::int32_t fd) +void UnixDomainServer::EnqueueTickDirect(std::int32_t fd) { work_queue_.push(fd); } -void UnixDomainServer::pass_message(std::int32_t fd, const std::string& message) +void UnixDomainServer::PassMessage(std::int32_t fd, const std::string& message) { - send_socket_message(fd, message); + SendSocketMessage(fd, message); } -void UnixDomainServer::update_thread_name_server_routine() noexcept +void UnixDomainServer::UpdateThreadNameServerRoutine() noexcept { auto ret = score::os::Pthread::instance().setname_np(server_thread_.native_handle(), "server_routine"); if (!ret.has_value()) diff --git a/score/datarouter/test/ut/ut_logging/test_config_session_factory.cpp b/score/datarouter/test/ut/ut_logging/test_config_session_factory.cpp index fc81b8c..8a24fce 100644 --- a/score/datarouter/test/ut/ut_logging/test_config_session_factory.cpp +++ b/score/datarouter/test/ut/ut_logging/test_config_session_factory.cpp @@ -31,10 +31,10 @@ using score::logging::dltserver::mock::UdpStreamOutput; TEST(ConfigSessionFactoryUT, CreateSessionsAndHandleCommands) { StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; EXPECT_CALL(outputs, construct(_, _, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, _, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); + EXPECT_CALL(outputs, Bind(_, _, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); StaticConfig s_config{}; PersistentConfig p_config{}; @@ -47,14 +47,14 @@ TEST(ConfigSessionFactoryUT, CreateSessionsAndHandleCommands) std::string resp_dyn; auto dyn_session = dyn_factory.CreateConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{resp_dyn}}, - server.make_config_command_handler()); + server.MakeConfigCommandHandler()); ASSERT_NE(dyn_session, nullptr); - std::array bad_enable_dyn{score::logging::dltserver::config::SET_DLT_OUTPUT_ENABLE, 2}; - dyn_session->on_command(std::string{bad_enable_dyn.begin(), bad_enable_dyn.end()}); + std::array bad_enable_dyn{score::logging::dltserver::config::kSetDltOutputEnable, 2}; + dyn_session->OnCommand(std::string{bad_enable_dyn.begin(), bad_enable_dyn.end()}); if (!resp_dyn.empty()) { EXPECT_EQ(resp_dyn.size(), 1U); - EXPECT_EQ(resp_dyn[0], static_cast(score::logging::dltserver::config::RET_ERROR)); + EXPECT_EQ(resp_dyn[0], static_cast(score::logging::dltserver::config::kRetError)); } } diff --git a/score/datarouter/test/ut/ut_logging/test_datarouter_app.cpp b/score/datarouter/test/ut/ut_logging/test_datarouter_app.cpp index 882788c..6a5da39 100644 --- a/score/datarouter/test/ut/ut_logging/test_datarouter_app.cpp +++ b/score/datarouter/test/ut/ut_logging/test_datarouter_app.cpp @@ -24,7 +24,7 @@ class DatarouterAppTest : public ::testing::Test { protected: - // We'll keep an atomic_bool to pass to datarouter_app_run() + // We'll keep an atomic_bool to pass to DatarouterAppRun() std::atomic_bool exit_requested_{false}; void SetUp() override @@ -42,7 +42,7 @@ TEST_F(DatarouterAppTest, AppInit) { // Just call it. Usually logs "datarouter application Version 0.1s starting" // No direct assertions, but at least ensures no crash. - EXPECT_NO_FATAL_FAILURE(score::logging::datarouter::datarouter_app_init()); + EXPECT_NO_FATAL_FAILURE(score::logging::datarouter::DatarouterAppInit()); } TEST_F(DatarouterAppTest, AppRunNoAdaptiveRuntime) @@ -53,10 +53,10 @@ TEST_F(DatarouterAppTest, AppRunNoAdaptiveRuntime) char no_adaptive_arg[] = "-n"; char* argv[] = {prog, no_adaptive_arg, nullptr}; - bool parse_ok = score::logging::options::Options::parse(argc, argv); + bool parse_ok = score::logging::options::Options::Parse(argc, argv); ASSERT_TRUE(parse_ok); - EXPECT_NO_FATAL_FAILURE(score::logging::datarouter::datarouter_app_run(exit_requested_)); + EXPECT_NO_FATAL_FAILURE(score::logging::datarouter::DatarouterAppRun(exit_requested_)); } TEST_F(DatarouterAppTest, AppRunPrintVersion) @@ -67,12 +67,12 @@ TEST_F(DatarouterAppTest, AppRunPrintVersion) char version_arg[] = "--version"; char* argv[] = {prog, version_arg, nullptr}; - bool parse_ok = score::logging::options::Options::parse(argc, argv); + bool parse_ok = score::logging::options::Options::Parse(argc, argv); ASSERT_TRUE(parse_ok); // We'll capture stdout to verify that "Version 0.1s" was printed testing::internal::CaptureStdout(); - score::logging::datarouter::datarouter_app_run(exit_requested_); + score::logging::datarouter::DatarouterAppRun(exit_requested_); std::string output = testing::internal::GetCapturedStdout(); // Check if the version string is present @@ -89,16 +89,16 @@ TEST_F(DatarouterAppTest, AppRunDoNothing) char* argv[] = {prog, do_nothing_arg, nullptr}; // parse sets do_nothing_ = true - bool parse_ok = score::logging::options::Options::parse(argc, argv); + bool parse_ok = score::logging::options::Options::Parse(argc, argv); ASSERT_TRUE(parse_ok); // Now call run. Because do_nothing() is true, it should return immediately. - EXPECT_NO_FATAL_FAILURE(score::logging::datarouter::datarouter_app_run(exit_requested_)); + EXPECT_NO_FATAL_FAILURE(score::logging::datarouter::DatarouterAppRun(exit_requested_)); } TEST_F(DatarouterAppTest, AppShutdown) { // Typically logs "shutting down" // No direct assertion, but ensures it doesn't crash - EXPECT_NO_FATAL_FAILURE(score::logging::datarouter::datarouter_app_shutdown()); + EXPECT_NO_FATAL_FAILURE(score::logging::datarouter::DatarouterAppShutdown()); } diff --git a/score/datarouter/test/ut/ut_logging/test_diagnostic_job_handler.cpp b/score/datarouter/test/ut/ut_logging/test_diagnostic_job_handler.cpp index ed4842d..1f786f9 100644 --- a/score/datarouter/test/ut/ut_logging/test_diagnostic_job_handler.cpp +++ b/score/datarouter/test/ut/ut_logging/test_diagnostic_job_handler.cpp @@ -47,7 +47,7 @@ TEST_F(DiagnosticJobHandlerTest, ReadLogChannelNamesHandler_OK) EXPECT_CALL(dltlogserver_mock, ReadLogChannelNames()).Times(1); - handler->execute(dltlogserver_mock); + handler->Execute(dltlogserver_mock); } TEST_F(DiagnosticJobHandlerTest, ResetToDefaultHandler_OK) @@ -56,7 +56,7 @@ TEST_F(DiagnosticJobHandlerTest, ResetToDefaultHandler_OK) EXPECT_CALL(dltlogserver_mock, ResetToDefault()).Times(1); - handler->execute(dltlogserver_mock); + handler->Execute(dltlogserver_mock); } TEST_F(DiagnosticJobHandlerTest, StoreDltConfigHandler_OK) @@ -65,7 +65,7 @@ TEST_F(DiagnosticJobHandlerTest, StoreDltConfigHandler_OK) EXPECT_CALL(dltlogserver_mock, StoreDltConfig()).Times(1); - handler->execute(dltlogserver_mock); + handler->Execute(dltlogserver_mock); } TEST_F(DiagnosticJobHandlerTest, SetTraceStateHandler_OK) @@ -74,7 +74,7 @@ TEST_F(DiagnosticJobHandlerTest, SetTraceStateHandler_OK) EXPECT_CALL(dltlogserver_mock, SetTraceState()).Times(1); - handler->execute(dltlogserver_mock); + handler->Execute(dltlogserver_mock); } TEST_F(DiagnosticJobHandlerTest, SetDefaultTraceStateHandler_OK) @@ -83,33 +83,33 @@ TEST_F(DiagnosticJobHandlerTest, SetDefaultTraceStateHandler_OK) EXPECT_CALL(dltlogserver_mock, SetDefaultTraceState()).Times(1); - handler->execute(dltlogserver_mock); + handler->Execute(dltlogserver_mock); } TEST_F(DiagnosticJobHandlerTest, SetLogChannelThresholdHandler_OK) { - loglevel_t threshold = loglevel_t::kFatal; - score::platform::dltid_t channel = extractId("1", 1); + LoglevelT threshold = LoglevelT::kFatal; + score::platform::DltidT channel = ExtractId("1", 1); std::unique_ptr handler = std::make_unique(channel, threshold); EXPECT_CALL(dltlogserver_mock, SetLogChannelThreshold(channel, threshold)).Times(1); - handler->execute(dltlogserver_mock); + handler->Execute(dltlogserver_mock); } TEST_F(DiagnosticJobHandlerTest, SetLogLevelHandler_OK) { - score::platform::dltid_t app_id = extractId("1", 1); - score::platform::dltid_t ctx_id = extractId("2", 1); - threshold_t threshold = ThresholdCmd::UseDefault; + score::platform::DltidT app_id = ExtractId("1", 1); + score::platform::DltidT ctx_id = ExtractId("2", 1); + ThresholdT threshold = ThresholdCmd::kUseDefault; std::unique_ptr handler = std::make_unique(app_id, ctx_id, threshold); EXPECT_CALL(dltlogserver_mock, SetLogLevel(app_id, ctx_id, threshold)).Times(1); - handler->execute(dltlogserver_mock); + handler->Execute(dltlogserver_mock); } TEST_F(DiagnosticJobHandlerTest, SetMessagingFilteringStateHandler_OK) @@ -120,45 +120,45 @@ TEST_F(DiagnosticJobHandlerTest, SetMessagingFilteringStateHandler_OK) EXPECT_CALL(dltlogserver_mock, SetMessagingFilteringState(enabled)).Times(1); - handler->execute(dltlogserver_mock); + handler->Execute(dltlogserver_mock); } TEST_F(DiagnosticJobHandlerTest, SetDefaultLogLevelHandler_OK) { - loglevel_t threshold = loglevel_t::kFatal; + LoglevelT threshold = LoglevelT::kFatal; std::unique_ptr handler = std::make_unique(threshold); EXPECT_CALL(dltlogserver_mock, SetDefaultLogLevel(threshold)).Times(1); - handler->execute(dltlogserver_mock); + handler->Execute(dltlogserver_mock); } TEST_F(DiagnosticJobHandlerTest, SetLogChannelAssignmentHandler_OK) { - score::platform::dltid_t app_id = extractId("1", 1); - score::platform::dltid_t ctx_id = extractId("2", 1); - score::platform::dltid_t channel = extractId("2", 1); + score::platform::DltidT app_id = ExtractId("1", 1); + score::platform::DltidT ctx_id = ExtractId("2", 1); + score::platform::DltidT channel = ExtractId("2", 1); - AssignmentAction assignment_flag = AssignmentAction::Add; + AssignmentAction assignment_flag = AssignmentAction::kAdd; std::unique_ptr handler = std::make_unique(app_id, ctx_id, channel, assignment_flag); EXPECT_CALL(dltlogserver_mock, SetLogChannelAssignment(app_id, ctx_id, channel, assignment_flag)).Times(1); - handler->execute(dltlogserver_mock); + handler->Execute(dltlogserver_mock); } TEST_F(DiagnosticJobHandlerTest, SetDltOutputEnableHandler_OK) { - auto flag = config::DISABLE; + auto flag = config::kDisable; std::unique_ptr handler = std::make_unique(flag); EXPECT_CALL(dltlogserver_mock, SetDltOutputEnable(flag)).Times(1); - handler->execute(dltlogserver_mock); + handler->Execute(dltlogserver_mock); } } // namespace test diff --git a/score/datarouter/test/ut/ut_logging/test_diagnostic_job_parser.cpp b/score/datarouter/test/ut/ut_logging/test_diagnostic_job_parser.cpp index ec1b95f..d97670e 100644 --- a/score/datarouter/test/ut/ut_logging/test_diagnostic_job_parser.cpp +++ b/score/datarouter/test/ut/ut_logging/test_diagnostic_job_parser.cpp @@ -52,45 +52,45 @@ using namespace score::logging::dltserver; TEST_F(DiagnosticJobParserTest, ReadLogChannelNames_OK) { auto correct_handler = std::make_unique(); - auto handler = uut.parse(std::string{char(config::READ_LOG_CHANNEL_NAMES)}); + auto handler = uut.Parse(std::string{char(config::kReadLogChannelNames)}); EXPECT_NE(ConvertHandlerTypeTo(handler), nullptr); } TEST_F(DiagnosticJobParserTest, ResetToDefault_OK) { auto correct_handler = std::make_unique(); - auto handler = uut.parse(std::string{char(config::RESET_TO_DEFAULT)}); + auto handler = uut.Parse(std::string{char(config::kResetToDefault)}); EXPECT_NE(ConvertHandlerTypeTo(handler), nullptr); } TEST_F(DiagnosticJobParserTest, StoreDltConfig_OK) { auto correct_handler = std::make_unique(); - auto handler = uut.parse(std::string{char(config::STORE_DLT_CONFIG)}); + auto handler = uut.Parse(std::string{char(config::kStoreDltConfig)}); EXPECT_NE(ConvertHandlerTypeTo(handler), nullptr); } TEST_F(DiagnosticJobParserTest, SetTraceState_OK) { auto correct_handler = std::make_unique(); - auto handler = uut.parse(std::string{char(config::SET_TRACE_STATE)}); + auto handler = uut.Parse(std::string{char(config::kSetTraceState)}); EXPECT_NE(ConvertHandlerTypeTo(handler), nullptr); } TEST_F(DiagnosticJobParserTest, SetDefaultTraceState_OK) { auto correct_handler = std::make_unique(); - auto handler = uut.parse(std::string{char(config::SET_DEFAULT_TRACE_STATE)}); + auto handler = uut.Parse(std::string{char(config::kSetDefaultTraceState)}); EXPECT_NE(ConvertHandlerTypeTo(handler), nullptr); } TEST_F(DiagnosticJobParserTest, SetLogChannelThreshold_OK) { - score::platform::dltid_t id("CORE"); + score::platform::DltidT id("CORE"); auto correct_handler = std::make_unique(id, score::mw::log::LogLevel::kDebug); - std::array command_buffer{config::SET_LOG_CHANNEL_THRESHOLD, 0x43, 0x4f, 0x52, 0x45, 5, 6}; + std::array command_buffer{config::kSetLogChannelThreshold, 0x43, 0x4f, 0x52, 0x45, 5, 6}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); const auto* actual = ConvertHandlerTypeTo(handler); EXPECT_NE(actual, nullptr); EXPECT_EQ(*actual, *correct_handler); @@ -98,10 +98,10 @@ TEST_F(DiagnosticJobParserTest, SetLogChannelThreshold_OK) TEST_F(DiagnosticJobParserTest, SetLogLevel_OK_UseDefault) { - score::platform::dltid_t id_1("CORE"); - score::platform::dltid_t id_2("APP0"); - auto correct_handler = std::make_unique(id_1, id_2, ThresholdCmd::UseDefault); - std::array command_buffer{config::SET_LOG_LEVEL, + score::platform::DltidT id_1("CORE"); + score::platform::DltidT id_2("APP0"); + auto correct_handler = std::make_unique(id_1, id_2, ThresholdCmd::kUseDefault); + std::array command_buffer{config::kSetLogLevel, 0x43, 0x4f, 0x52, @@ -110,9 +110,9 @@ TEST_F(DiagnosticJobParserTest, SetLogLevel_OK_UseDefault) 0x50, 0x50, 0x30, - static_cast(ThresholdCmd::UseDefault)}; + static_cast(ThresholdCmd::kUseDefault)}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); const auto* actual = ConvertHandlerTypeTo(handler); EXPECT_NE(actual, nullptr); EXPECT_EQ(*actual, *correct_handler); @@ -120,13 +120,13 @@ TEST_F(DiagnosticJobParserTest, SetLogLevel_OK_UseDefault) TEST_F(DiagnosticJobParserTest, SetLogLevel_OK_ExplicitLevel) { - score::platform::dltid_t id_1("CORE"); - score::platform::dltid_t id_2("APP0"); + score::platform::DltidT id_1("CORE"); + score::platform::DltidT id_2("APP0"); auto correct_handler = std::make_unique(id_1, id_2, score::mw::log::LogLevel::kVerbose); std::array command_buffer{ - config::SET_LOG_LEVEL, 0x43, 0x4f, 0x52, 0x45, 0x41, 0x50, 0x50, 0x30, 6}; + config::kSetLogLevel, 0x43, 0x4f, 0x52, 0x45, 0x41, 0x50, 0x50, 0x30, 6}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); const auto* actual = ConvertHandlerTypeTo(handler); EXPECT_NE(actual, nullptr); EXPECT_EQ(*actual, *correct_handler); @@ -135,9 +135,9 @@ TEST_F(DiagnosticJobParserTest, SetLogLevel_OK_ExplicitLevel) TEST_F(DiagnosticJobParserTest, SetMessagingFilteringState_OK) { auto correct_handler = std::make_unique(true); - std::array command_buffer{config::SET_MESSAGING_FILTERING_STATE, 1}; + std::array command_buffer{config::kSetMessagingFilteringState, 1}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); const auto* actual = ConvertHandlerTypeTo(handler); EXPECT_NE(actual, nullptr); EXPECT_EQ(*actual, *correct_handler); @@ -146,9 +146,9 @@ TEST_F(DiagnosticJobParserTest, SetMessagingFilteringState_OK) TEST_F(DiagnosticJobParserTest, SetDefaultLogLevel_OK) { auto correct_handler = std::make_unique(score::mw::log::LogLevel::kFatal); - std::array command_buffer{config::SET_DEFAULT_LOG_LEVEL, 1}; + std::array command_buffer{config::kSetDefaultLogLevel, 1}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); const auto* actual = ConvertHandlerTypeTo(handler); EXPECT_NE(actual, nullptr); EXPECT_EQ(*actual, *correct_handler); @@ -156,14 +156,14 @@ TEST_F(DiagnosticJobParserTest, SetDefaultLogLevel_OK) TEST_F(DiagnosticJobParserTest, SetLogChannelAssignment_OK) { - score::platform::dltid_t id_1("APP0"); - score::platform::dltid_t id_2("CTX0"); - score::platform::dltid_t id_3("CORE"); - auto correct_handler = std::make_unique(id_1, id_2, id_3, AssignmentAction::Add); + score::platform::DltidT id_1("APP0"); + score::platform::DltidT id_2("CTX0"); + score::platform::DltidT id_3("CORE"); + auto correct_handler = std::make_unique(id_1, id_2, id_3, AssignmentAction::kAdd); std::array command_buffer{ - config::SET_LOG_CHANNEL_ASSIGNMENT, 0x41, 0x50, 0x50, 0x30, 0x43, 0x54, 0x58, 0x30, 0x43, 0x4f, 0x52, 0x45, 1}; + config::kSetLogChannelAssignment, 0x41, 0x50, 0x50, 0x30, 0x43, 0x54, 0x58, 0x30, 0x43, 0x4f, 0x52, 0x45, 1}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); const auto* actual = ConvertHandlerTypeTo(handler); EXPECT_NE(actual, nullptr); EXPECT_EQ(*actual, *correct_handler); @@ -172,9 +172,9 @@ TEST_F(DiagnosticJobParserTest, SetLogChannelAssignment_OK) TEST_F(DiagnosticJobParserTest, SetDltOutputEnable_OK) { auto correct_handler = std::make_unique(true); - std::array command_buffer{config::SET_DLT_OUTPUT_ENABLE, 1}; + std::array command_buffer{config::kSetDltOutputEnable, 1}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); const auto* actual = ConvertHandlerTypeTo(handler); EXPECT_NE(actual, nullptr); EXPECT_EQ(*actual, *correct_handler); @@ -185,101 +185,101 @@ TEST_F(DiagnosticJobParserTest, SetDltOutputEnable_OK) *----------------------------------------------------------------*/ TEST_F(DiagnosticJobParserTest, EmptyCommandWillReturnNullPtr) { - auto handler = uut.parse(""); + auto handler = uut.Parse(""); ASSERT_EQ(nullptr, handler); } TEST_F(DiagnosticJobParserTest, UnknownCommand_ReturnsNull) { - auto handler = uut.parse("\x7F"); + auto handler = uut.Parse("\x7F"); ASSERT_EQ(nullptr, handler); } TEST_F(DiagnosticJobParserTest, Threshold_WrongSize_ReturnsNull) { - std::string command_buffer{char(config::SET_LOG_CHANNEL_THRESHOLD)}; - auto handler = uut.parse(command_buffer); + std::string command_buffer{char(config::kSetLogChannelThreshold)}; + auto handler = uut.Parse(command_buffer); ASSERT_EQ(nullptr, handler); } TEST_F(DiagnosticJobParserTest, Threshold_InvalidLevel_ReturnsNull) { - std::array command_buffer{config::SET_LOG_CHANNEL_THRESHOLD, 1, 2, 3, 4, 0xFF, 6}; + std::array command_buffer{config::kSetLogChannelThreshold, 1, 2, 3, 4, 0xFF, 6}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); ASSERT_EQ(nullptr, handler); } TEST_F(DiagnosticJobParserTest, LogLevel_WrongSize_ReturnsNull) { - std::string command_buffer{char(config::SET_LOG_LEVEL)}; + std::string command_buffer{char(config::kSetLogLevel)}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); ASSERT_EQ(nullptr, handler); } TEST_F(DiagnosticJobParserTest, LogLevel_InvalidThresholdByte_ReturnsNull) { - std::array command_buffer{config::SET_LOG_LEVEL, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + std::array command_buffer{config::kSetLogLevel, 1, 2, 3, 4, 5, 6, 7, 8, 9}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); ASSERT_EQ(nullptr, handler); } TEST_F(DiagnosticJobParserTest, MessagingFiltering_WrongSize_ReturnsNull) { - std::string command_buffer{char(config::SET_MESSAGING_FILTERING_STATE)}; + std::string command_buffer{char(config::kSetMessagingFilteringState)}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); ASSERT_EQ(nullptr, handler); } TEST_F(DiagnosticJobParserTest, DefaultLogLevel_WrongSize_ReturnsNull) { - std::string command_buffer{char(config::SET_DEFAULT_LOG_LEVEL)}; + std::string command_buffer{char(config::kSetDefaultLogLevel)}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); ASSERT_EQ(nullptr, handler); } TEST_F(DiagnosticJobParserTest, DefaultLogLevel_InvalidLevel_ReturnsNull) { - std::array command_buffer{config::SET_DEFAULT_LOG_LEVEL, 7}; + std::array command_buffer{config::kSetDefaultLogLevel, 7}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); ASSERT_EQ(nullptr, handler); } TEST_F(DiagnosticJobParserTest, Assignment_WrongSize_ReturnsNull) { - std::string command_buffer{char(config::SET_LOG_CHANNEL_ASSIGNMENT)}; + std::string command_buffer{char(config::kSetLogChannelAssignment)}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); ASSERT_EQ(nullptr, handler); } TEST_F(DiagnosticJobParserTest, Assignment_InvalidAction_ReturnsNull) { std::array command_buffer{ - config::SET_LOG_CHANNEL_ASSIGNMENT, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; + config::kSetLogChannelAssignment, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); ASSERT_EQ(nullptr, handler); } TEST_F(DiagnosticJobParserTest, OutputEnable_WrongSize_ReturnsNull) { - std::string command_buffer{char(config::SET_DLT_OUTPUT_ENABLE)}; + std::string command_buffer{char(config::kSetDltOutputEnable)}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); ASSERT_EQ(nullptr, handler); } TEST_F(DiagnosticJobParserTest, OutputEnable_InvalidFlag_ReturnsNull1) { - std::array command_buffer{config::SET_DLT_OUTPUT_ENABLE, 2}; + std::array command_buffer{config::kSetDltOutputEnable, 2}; const std::string command{command_buffer.begin(), command_buffer.end()}; - auto handler = uut.parse(command); + auto handler = uut.Parse(command); ASSERT_EQ(nullptr, handler); } diff --git a/score/datarouter/test/ut/ut_logging/test_dltchannel.cpp b/score/datarouter/test/ut/ut_logging/test_dltchannel.cpp index 6492eb5..239b583 100644 --- a/score/datarouter/test/ut/ut_logging/test_dltchannel.cpp +++ b/score/datarouter/test/ut/ut_logging/test_dltchannel.cpp @@ -93,33 +93,33 @@ class DltChannelTest : public ::testing::Test TEST_F(DltChannelTest, WhenCreatedDefault) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; EXPECT_CALL(outputs, construct(_, nullptr, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, nullptr, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); + EXPECT_CALL(outputs, Bind(_, nullptr, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); DltLogChannel dlt_channel( - dltid_t{"CHN0"}, score::mw::log::LogLevel::kOff, dltid_t{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); + DltidT{"CHN0"}, score::mw::log::LogLevel::kOff, DltidT{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); } TEST_F(DltChannelTest, WhenSendingNonverboseTwice) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; mmsghdr mmsghdr_data; score::cpp::span mmsg_span(&mmsghdr_data, 1); EXPECT_CALL(outputs, construct(_, nullptr, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, nullptr, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); - EXPECT_CALL(outputs, send(_, A>())).WillOnce(DoAll(SaveArg<1>(&mmsg_span), Return(1))); + EXPECT_CALL(outputs, Bind(_, nullptr, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); + EXPECT_CALL(outputs, Send(_, A>())).WillOnce(DoAll(SaveArg<1>(&mmsg_span), Return(1))); DltLogChannel dlt_channel( - dltid_t{"CHN0"}, score::mw::log::LogLevel::kOff, dltid_t{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); + DltidT{"CHN0"}, score::mw::log::LogLevel::kOff, DltidT{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); - dlt_channel.sendNonVerbose(nv_desc1_, 1U, msg1_.data(), msg1_.size()); - dlt_channel.sendNonVerbose(nv_desc2_, 2U, msg2_.data(), msg2_.size()); - dlt_channel.flush(); + dlt_channel.SendNonVerbose(nv_desc1_, 1U, msg1_.data(), msg1_.size()); + dlt_channel.SendNonVerbose(nv_desc2_, 2U, msg2_.data(), msg2_.size()); + dlt_channel.Flush(); // check 2 non-verbose messages on UDP level (check by size) const auto sent_messages_count = 2; @@ -128,27 +128,27 @@ TEST_F(DltChannelTest, WhenSendingNonverboseTwice) ((sizeof(DltNvHeaderWithMsgid) + 8) * sent_messages_count)); Logger logger; - dlt_channel.show_stats(logger); + dlt_channel.ShowStats(logger); } TEST_F(DltChannelTest, WhenSendingVerboseTwice) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; mmsghdr mmsghdr_data; score::cpp::span mmsg_span(&mmsghdr_data, 1); EXPECT_CALL(outputs, construct(_, nullptr, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, nullptr, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); - EXPECT_CALL(outputs, send(_, A>())).WillOnce(DoAll(SaveArg<1>(&mmsg_span), Return(1))); + EXPECT_CALL(outputs, Bind(_, nullptr, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); + EXPECT_CALL(outputs, Send(_, A>())).WillOnce(DoAll(SaveArg<1>(&mmsg_span), Return(1))); DltLogChannel dlt_channel( - dltid_t{"CHN0"}, score::mw::log::LogLevel::kOff, dltid_t{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); + DltidT{"CHN0"}, score::mw::log::LogLevel::kOff, DltidT{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); - dlt_channel.sendVerbose(1U, verbose_entry1_); - dlt_channel.sendVerbose(2U, verbose_entry2_); - dlt_channel.flush(); + dlt_channel.SendVerbose(1U, verbose_entry1_); + dlt_channel.SendVerbose(2U, verbose_entry2_); + dlt_channel.Flush(); // check 2 verbose messages on UDP level (check by size) const auto sent_messages_count = 2; @@ -157,19 +157,19 @@ TEST_F(DltChannelTest, WhenSendingVerboseTwice) ((sizeof(DltVerboseHeader) + 8) * sent_messages_count)); Logger logger; - dlt_channel.show_stats(logger); + dlt_channel.ShowStats(logger); } TEST_F(DltChannelTest, WhenSendingNvVNv) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; EXPECT_CALL(outputs, construct(_, nullptr, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, nullptr, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); + EXPECT_CALL(outputs, Bind(_, nullptr, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); - EXPECT_CALL(outputs, send(_, A>())) + EXPECT_CALL(outputs, Send(_, A>())) .WillOnce(DoAll(Invoke([](UdpStreamOutput*, score::cpp::span data_span) { const auto expected_data_size_1 = sizeof(DltNvHeaderWithMsgid) + 8; const auto expected_data_size_2 = sizeof(DltVerboseHeader) + 8; @@ -184,49 +184,49 @@ TEST_F(DltChannelTest, WhenSendingNvVNv) Return(1))); DltLogChannel dlt_channel( - dltid_t{"CHN0"}, score::mw::log::LogLevel::kOff, dltid_t{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); + DltidT{"CHN0"}, score::mw::log::LogLevel::kOff, DltidT{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); - dlt_channel.sendNonVerbose(nv_desc1_, 1U, msg1_.data(), msg1_.size()); - dlt_channel.sendVerbose(2U, verbose_entry1_); - dlt_channel.sendNonVerbose(nv_desc2_, 3U, msg2_.data(), msg2_.size()); - dlt_channel.flush(); + dlt_channel.SendNonVerbose(nv_desc1_, 1U, msg1_.data(), msg1_.size()); + dlt_channel.SendVerbose(2U, verbose_entry1_); + dlt_channel.SendNonVerbose(nv_desc2_, 3U, msg2_.data(), msg2_.size()); + dlt_channel.Flush(); Logger logger; - dlt_channel.show_stats(logger); + dlt_channel.ShowStats(logger); } TEST_F(DltChannelTest, TestSendUdpBufferingNonVerbose) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; EXPECT_CALL(outputs, construct(_, nullptr, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, nullptr, 3491U)).Times(1); + EXPECT_CALL(outputs, Bind(_, nullptr, 3491U)).Times(1); DltLogChannel dlt_channel( - dltid_t{"CHN0"}, score::mw::log::LogLevel::kOff, dltid_t{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); + DltidT{"CHN0"}, score::mw::log::LogLevel::kOff, DltidT{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); // all data should be buffered, without send to socket - EXPECT_CALL(outputs, send(_, A>())).Times(0); + EXPECT_CALL(outputs, Send(_, A>())).Times(0); // send a lot of data to fill DltLogChannel::prebuf_data_ to force using next buffer const auto expected_prebuf_size = kUdpMaxPayload; const auto length_of_one_message = (sizeof(DltNvHeaderWithMsgid) + msg1_.size()); const auto message_count_to_fill_prebuf = expected_prebuf_size / length_of_one_message; for (size_t i = 0; i < message_count_to_fill_prebuf; ++i) { - dlt_channel.sendNonVerbose(nv_desc1_, static_cast(i + 1), msg1_.data(), msg1_.size()); + dlt_channel.SendNonVerbose(nv_desc1_, static_cast(i + 1), msg1_.data(), msg1_.size()); } Mock::VerifyAndClearExpectations(&outputs); // send another packet. it should be put to another buffer, because first buffer is already full // all data still should be buffered, no calls to socket - EXPECT_CALL(outputs, send(_, A>())).Times(0); - dlt_channel.sendNonVerbose(nv_desc2_, 1U, msg2_.data(), msg2_.size()); + EXPECT_CALL(outputs, Send(_, A>())).Times(0); + dlt_channel.SendNonVerbose(nv_desc2_, 1U, msg2_.data(), msg2_.size()); Mock::VerifyAndClearExpectations(&outputs); - // flush data and send it to socket - EXPECT_CALL(outputs, destruct(_)).Times(1); - EXPECT_CALL(outputs, send(_, A>())) + // Flush data and send it to socket + EXPECT_CALL(outputs, Destruct(_)).Times(1); + EXPECT_CALL(outputs, Send(_, A>())) .WillOnce(DoAll(Invoke([length_of_one_message, message_count_to_fill_prebuf](UdpStreamOutput*, score::cpp::span data_span) { // first buffer if full @@ -241,25 +241,25 @@ TEST_F(DltChannelTest, TestSendUdpBufferingNonVerbose) }), Return(1))); - dlt_channel.flush(); + dlt_channel.Flush(); Logger logger; - dlt_channel.show_stats(logger); + dlt_channel.ShowStats(logger); } TEST_F(DltChannelTest, TestSendUdpBufferingForVerbose) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; EXPECT_CALL(outputs, construct(_, nullptr, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, nullptr, 3491U)).Times(1); + EXPECT_CALL(outputs, Bind(_, nullptr, 3491U)).Times(1); DltLogChannel dlt_channel( - dltid_t{"CHN0"}, score::mw::log::LogLevel::kOff, dltid_t{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); + DltidT{"CHN0"}, score::mw::log::LogLevel::kOff, DltidT{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); // Ensure data should be buffered without sending it - EXPECT_CALL(outputs, send(_, A>())).Times(0); + EXPECT_CALL(outputs, Send(_, A>())).Times(0); // Fill the prebuffer until it's full but still below UDP_MAX_PAYLOAD const auto expected_prebuf_size = kUdpMaxPayload; @@ -268,19 +268,19 @@ TEST_F(DltChannelTest, TestSendUdpBufferingForVerbose) for (size_t i = 0; i < message_count_to_fill_prebuf; ++i) { - dlt_channel.sendVerbose(1U, verbose_entry1_); + dlt_channel.SendVerbose(1U, verbose_entry1_); } Mock::VerifyAndClearExpectations(&outputs); // Send another verbose message, which should be placed into a new buffer - EXPECT_CALL(outputs, send(_, A>())).Times(0); - dlt_channel.sendVerbose(2U, verbose_entry2_); + EXPECT_CALL(outputs, Send(_, A>())).Times(0); + dlt_channel.SendVerbose(2U, verbose_entry2_); Mock::VerifyAndClearExpectations(&outputs); // Flush data and validate it is sent in two chunks (one full buffer + one extra) - EXPECT_CALL(outputs, destruct(_)).Times(1); - EXPECT_CALL(outputs, send(_, A>())) + EXPECT_CALL(outputs, Destruct(_)).Times(1); + EXPECT_CALL(outputs, Send(_, A>())) .WillOnce(DoAll(Invoke([length_of_one_message, message_count_to_fill_prebuf](UdpStreamOutput*, score::cpp::span data_span) { // First buffer is full @@ -295,106 +295,106 @@ TEST_F(DltChannelTest, TestSendUdpBufferingForVerbose) }), Return(1))); - dlt_channel.flush(); + dlt_channel.Flush(); Logger logger; - dlt_channel.show_stats(logger); + dlt_channel.ShowStats(logger); } TEST_F(DltChannelTest, WhenSendFailsWithOnlyVerboseMessages) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; mmsghdr mmsghdr_data; score::cpp::span mmsg_span(&mmsghdr_data, 1); EXPECT_CALL(outputs, construct(_, nullptr, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, nullptr, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); - EXPECT_CALL(outputs, send(_, A>())) + EXPECT_CALL(outputs, Bind(_, nullptr, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); + EXPECT_CALL(outputs, Send(_, A>())) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EIO)))); DltLogChannel dlt_channel( - dltid_t{"CHN0"}, score::mw::log::LogLevel::kOff, dltid_t{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); + DltidT{"CHN0"}, score::mw::log::LogLevel::kOff, DltidT{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); - dlt_channel.sendVerbose(1U, verbose_entry1_); - dlt_channel.sendVerbose(2U, verbose_entry2_); + dlt_channel.SendVerbose(1U, verbose_entry1_); + dlt_channel.SendVerbose(2U, verbose_entry2_); - dlt_channel.flush(); + dlt_channel.Flush(); Logger logger; - dlt_channel.show_stats(logger); + dlt_channel.ShowStats(logger); } TEST_F(DltChannelTest, WhenSendFailsWithOnlyNonVerboseMessages) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; mmsghdr mmsghdr_data; score::cpp::span mmsg_span(&mmsghdr_data, 1); EXPECT_CALL(outputs, construct(_, nullptr, 3490U, Eq(std::string("")))).Times(1); ; - EXPECT_CALL(outputs, bind(_, nullptr, 3491U)) + EXPECT_CALL(outputs, Bind(_, nullptr, 3491U)) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EACCES)))); - EXPECT_CALL(outputs, destruct(_)).Times(1); - EXPECT_CALL(outputs, send(_, A>())) + EXPECT_CALL(outputs, Destruct(_)).Times(1); + EXPECT_CALL(outputs, Send(_, A>())) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EIO)))); DltLogChannel dlt_channel( - dltid_t{"CHN0"}, score::mw::log::LogLevel::kOff, dltid_t{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); + DltidT{"CHN0"}, score::mw::log::LogLevel::kOff, DltidT{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); // Add only non-verbose messages - dlt_channel.sendNonVerbose(nv_desc1_, 1U, msg1_.data(), msg1_.size()); - dlt_channel.sendNonVerbose(nv_desc2_, 2U, msg2_.data(), msg2_.size()); + dlt_channel.SendNonVerbose(nv_desc1_, 1U, msg1_.data(), msg1_.size()); + dlt_channel.SendNonVerbose(nv_desc2_, 2U, msg2_.data(), msg2_.size()); - dlt_channel.flush(); + dlt_channel.Flush(); Logger logger; - dlt_channel.show_stats(logger); + dlt_channel.ShowStats(logger); } TEST_F(DltChannelTest, WhenSendingLargeMessage_GoesToElse) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; EXPECT_CALL(outputs, construct(_, nullptr, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, nullptr, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); + EXPECT_CALL(outputs, Bind(_, nullptr, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); - EXPECT_CALL(outputs, send(_, A(), A())) + EXPECT_CALL(outputs, Send(_, A(), A())) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EACCES)))); DltLogChannel dlt_channel( - dltid_t{"CHN0"}, score::mw::log::LogLevel::kOff, dltid_t{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); + DltidT{"CHN0"}, score::mw::log::LogLevel::kOff, DltidT{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); // Create a single large message bigger than UDP_MAX_PAYLOAD std::vector large_msg(kUdpMaxPayload + 100, 0xAA); // Large message (slightly bigger than the max) - dlt_channel.sendNonVerbose(nv_desc1_, 1U, large_msg.data(), large_msg.size()); // Send oversized message + dlt_channel.SendNonVerbose(nv_desc1_, 1U, large_msg.data(), large_msg.size()); // Send oversized message - dlt_channel.flush(); + dlt_channel.Flush(); Logger logger; - dlt_channel.show_stats(logger); + dlt_channel.ShowStats(logger); } TEST_F(DltChannelTest, WhenSendFailsWithLargeVerboseMessage) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; // Expect the constructor and binding to be called EXPECT_CALL(outputs, construct(_, nullptr, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, nullptr, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); + EXPECT_CALL(outputs, Bind(_, nullptr, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); // Make sendmsg return an error (simulate failure when sending large verbose message) - EXPECT_CALL(outputs, send(_, A(), A())) + EXPECT_CALL(outputs, Send(_, A(), A())) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EIO)))); DltLogChannel dlt_channel( - dltid_t{"CHN0"}, score::mw::log::LogLevel::kOff, dltid_t{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); + DltidT{"CHN0"}, score::mw::log::LogLevel::kOff, DltidT{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); // Send a large verbose message to trigger the failure condition std::vector large_payload(kUdpMaxPayload + 1, 0xAB); // Large payload @@ -404,83 +404,83 @@ TEST_F(DltChannelTest, WhenSendFailsWithLargeVerboseMessage) 1, score::mw::log::LogLevel::kOff}; - dlt_channel.sendVerbose(1U, large_verbose_entry); // Should go to "sendmsg" instead of "sendmmsg" - dlt_channel.flush(); + dlt_channel.SendVerbose(1U, large_verbose_entry); // Should go to "sendmsg" instead of "sendmmsg" + dlt_channel.Flush(); Logger logger; - dlt_channel.show_stats(logger); + dlt_channel.ShowStats(logger); } TEST_F(DltChannelTest, WhenSendingFTVerboseHitsSleepCondition) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; using namespace score::mw::log; score::cpp::span msg_data(msg1_.data(), msg1_.size()); LogLevel log_level = LogLevel::kOff; // Fixed namespace usage - dltid_t app_id{"APP0"}; - dltid_t ctx_id{"CTX0"}; + DltidT app_id{"APP0"}; + DltidT ctx_id{"CTX0"}; uint8_t nor = 1; uint32_t timestamp = 1; EXPECT_CALL(outputs, construct(_, nullptr, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, nullptr, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); - EXPECT_CALL(outputs, send(_, A(), A())) + EXPECT_CALL(outputs, Bind(_, nullptr, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); + EXPECT_CALL(outputs, Send(_, A(), A())) .WillRepeatedly(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EACCES)))); - DltLogChannel dlt_channel(dltid_t{"CHN0"}, log_level, dltid_t{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); + DltLogChannel dlt_channel(DltidT{"CHN0"}, log_level, DltidT{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); // Trigger iteration counter to reach kBurstFileTransferControlCount threshold constexpr auto kTestBurstFileTransferControlCount = 5UL; for (size_t i = 0; i < kTestBurstFileTransferControlCount; ++i) { - dlt_channel.sendFTVerbose(msg_data, log_level, app_id, ctx_id, nor, timestamp); + dlt_channel.SendFtVerbose(msg_data, log_level, app_id, ctx_id, nor, timestamp); } Logger logger; - dlt_channel.show_stats(logger); + dlt_channel.ShowStats(logger); } TEST_F(DltChannelTest, WhenLogLevelExceedsThreshold_Verbose) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; EXPECT_CALL(outputs, construct(_, nullptr, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, nullptr, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); + EXPECT_CALL(outputs, Bind(_, nullptr, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); DltLogChannel dlt_channel( - dltid_t{"CHN0"}, score::mw::log::LogLevel::kOff, dltid_t{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); + DltidT{"CHN0"}, score::mw::log::LogLevel::kOff, DltidT{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); // Set a high log level that should be ignored LogEntryT high_log_entry = verbose_entry1_; high_log_entry.log_level = score::mw::log::LogLevel::kFatal; - EXPECT_CALL(outputs, send(_, A>())).Times(0); + EXPECT_CALL(outputs, Send(_, A>())).Times(0); - dlt_channel.sendVerbose(1U, high_log_entry); + dlt_channel.SendVerbose(1U, high_log_entry); } TEST_F(DltChannelTest, WhenNonVerboseLogLevelExceedsThreshold) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; EXPECT_CALL(outputs, construct(_, nullptr, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, nullptr, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); + EXPECT_CALL(outputs, Bind(_, nullptr, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); DltLogChannel dlt_channel( - dltid_t{"CHN0"}, score::mw::log::LogLevel::kOff, dltid_t{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); + DltidT{"CHN0"}, score::mw::log::LogLevel::kOff, DltidT{"ECU0"}, nullptr, 3491U, nullptr, 3490U, ""); auto high_log_desc = nv_desc1_; high_log_desc.SetLogLevel(score::mw::log::LogLevel::kFatal); - EXPECT_CALL(outputs, send(_, A>())).Times(0); - dlt_channel.sendNonVerbose(high_log_desc, 1U, msg1_.data(), msg1_.size()); + EXPECT_CALL(outputs, Send(_, A>())).Times(0); + dlt_channel.SendNonVerbose(high_log_desc, 1U, msg1_.data(), msg1_.size()); } } // namespace test diff --git a/score/datarouter/test/ut/ut_logging/test_dltprotocol.cpp b/score/datarouter/test/ut/ut_logging/test_dltprotocol.cpp index 7e15a2c..525e2be 100644 --- a/score/datarouter/test/ut/ut_logging/test_dltprotocol.cpp +++ b/score/datarouter/test/ut/ut_logging/test_dltprotocol.cpp @@ -81,7 +81,7 @@ TEST(DltProtocolTest, PackageFileDataShallWriteDataCorrectlyWithCorrectData) // Kindly, check the code, inside the "PackageFileData" method for the reasons of disabling this test. TEST(DltProtocolTest, DISABLED_PackageFileDataShallReturnsNulloptIfItWorkedOnAlreadyClosedFile) { - std::array buffer{}; + std::array buffer{}; auto data_span = score::cpp::span{buffer.data(), buffer.size()}; const uint32_t serial_number{0U}; const uint32_t pkg_number{0}; @@ -118,10 +118,10 @@ TEST(DltProtocolTest, PackageFileEndShallWriteHeaderCorrectlyWithCorrectData) TEST(DltProtocolTest, PackageFileErrorShallReturnFLER_FILE_NORIfTheFilePathIsExist) { - std::array buffer{}; + std::array buffer{}; auto data_span = score::cpp::span{buffer.data(), buffer.size()}; // Any error code. - const int16_t error_code{DLT_FILETRANSFER_ERROR_FILE_DATA}; + const int16_t error_code{kDltFiletransferErrorFileData}; const uint32_t serial_number{0U}; const std::string file_name{kFileName}; const uint32_t file_size{0U}; @@ -132,15 +132,15 @@ TEST(DltProtocolTest, PackageFileErrorShallReturnFLER_FILE_NORIfTheFilePathIsExi auto result = PackageFileError( data_span, error_code, serial_number, file_name, file_size, creation_date, package_count, error_message); // Index '1' to get the 'nor' from the tuple. - EXPECT_EQ(std::get<1>(result.value()), FLER_FILE_NOR); + EXPECT_EQ(std::get<1>(result.value()), kFlerFileNor); } TEST(DltProtocolTest, PackageFileErrorShallReturnFLER_FILE_NORPlusOneIfTheFilePathExistAndTheErrorMessageIsNotEmpty) { - std::array buffer{}; + std::array buffer{}; auto data_span = score::cpp::span{buffer.data(), buffer.size()}; // Any error code. - const int16_t error_code{DLT_FILETRANSFER_ERROR_FILE_DATA}; + const int16_t error_code{kDltFiletransferErrorFileData}; const uint32_t serial_number{0U}; const std::string file_name{kFileName}; const uint32_t file_size{0U}; @@ -151,17 +151,17 @@ TEST(DltProtocolTest, PackageFileErrorShallReturnFLER_FILE_NORPlusOneIfTheFilePa auto result = PackageFileError( data_span, error_code, serial_number, file_name, file_size, creation_date, package_count, error_message); // Index '1' to get the 'nor' from the tuple. - EXPECT_EQ(std::get<1>(result.value()), FLER_FILE_NOR + 1); + EXPECT_EQ(std::get<1>(result.value()), kFlerFileNor + 1); } TEST(DltProtocolTest, PackageFileErrorShallReturnFLER_NO_FILE_NORIfTheFilePathIsExist) { auto temp = errno; errno = ENOENT; - std::array buffer{}; + std::array buffer{}; auto data_span = score::cpp::span{buffer.data(), buffer.size()}; // Any error code. - const int16_t error_code{DLT_FILETRANSFER_ERROR_FILE_DATA}; + const int16_t error_code{kDltFiletransferErrorFileData}; const uint32_t serial_number{0U}; const std::string file_name{kFileName}; const uint32_t file_size{0U}; @@ -173,7 +173,7 @@ TEST(DltProtocolTest, PackageFileErrorShallReturnFLER_NO_FILE_NORIfTheFilePathIs data_span, error_code, serial_number, file_name, file_size, creation_date, package_count, error_message); // Index '1' to get the 'nor' from the tuple. errno = temp; - EXPECT_EQ(std::get<1>(result.value()), FLER_NO_FILE_NOR); + EXPECT_EQ(std::get<1>(result.value()), kFlerNoFileNor); } TEST(DltProtocolTest, PackageFileInformationShallReturnNulloptDueToBufferTooSmall) @@ -211,15 +211,15 @@ TEST(DltProtocolTest, PackageFileInformationShallReturnDataOnCorrectSize) TEST(DltIdTest, TestInitializeInstanceWithEmptyConstructionInTheStack) { // If it failed, the whole test proccess will fail. - score::platform::dltid_t dlt_id{}; + score::platform::DltidT dlt_id{}; } TEST(DltIdTest, TestTheSingleargumentCharPointerConstructionAndGetTheData) { const char* char_pointer_str{FOUR_CHAR_STRING}; - score::platform::dltid_t dlt_id{char_pointer_str}; + score::platform::DltidT dlt_id{char_pointer_str}; - const char* get_data = dlt_id.data(); + const char* get_data = dlt_id.Data(); // The size of dlt id is four. EXPECT_EQ(get_data[0], char_pointer_str[0]); @@ -231,8 +231,8 @@ TEST(DltIdTest, TestTheSingleargumentCharPointerConstructionAndGetTheData) TEST(DltIdTest, TestDltIdEqualityOperator) { const char* char_pointer_str{FOUR_CHAR_STRING}; - score::platform::dltid_t dlt_id{char_pointer_str}; - score::platform::dltid_t dlt_id_1{char_pointer_str}; + score::platform::DltidT dlt_id{char_pointer_str}; + score::platform::DltidT dlt_id_1{char_pointer_str}; EXPECT_TRUE(dlt_id_1 == dlt_id); } @@ -241,27 +241,27 @@ TEST(DltIdTest, TestTheSingleargumentStringConstruction) { // If it failed, the whole test proccess will fail. const std::string str{FOUR_CHAR_STRING}; - score::platform::dltid_t dlt_id{str}; + score::platform::DltidT dlt_id{str}; } TEST(DltIdTest, TestTheSingleargumentStringViewConstruction) { // If it failed, the whole test proccess will fail. const score::cpp::string_view str_view{FOUR_CHAR_STRING}; - score::platform::dltid_t dlt_id{str_view}; + score::platform::DltidT dlt_id{str_view}; } TEST(DltIdTest, DltIdSizeShouldBeEqualToFour) { const std::string str{FOUR_CHAR_STRING}; - score::platform::dltid_t dlt_id{str}; + score::platform::DltidT dlt_id{str}; - EXPECT_EQ(dlt_id.size(), score::platform::dltid_t::kSize); + EXPECT_EQ(dlt_id.size(), score::platform::DltidT::kSize); } TEST(DltIdTest, TestDltIdAssignOperator) { - score::platform::dltid_t dlt_id{}; + score::platform::DltidT dlt_id{}; auto dlt_id_1 = dlt_id; EXPECT_TRUE(dlt_id_1 == dlt_id); @@ -270,7 +270,7 @@ TEST(DltIdTest, TestDltIdAssignOperator) TEST(DltIdTest, TestDltIdStringOperator) { const std::string str{FOUR_CHAR_STRING}; - score::platform::dltid_t dlt_id{str}; + score::platform::DltidT dlt_id{str}; // Casting to std::string. auto dlt_id_string = std::string(dlt_id); @@ -282,7 +282,7 @@ TEST(DltIdTest, TestDltIdStringOperator) TEST(DltIdTest, TestDltIdAssignmentOperator) { const std::string str{FOUR_CHAR_STRING}; - score::platform::dltid_t dlt_id; + score::platform::DltidT dlt_id; dlt_id = str; // Casting to std::string. @@ -295,9 +295,9 @@ TEST(DltIdTest, TestDltIdAssignmentOperator) TEST(DltIdTest, TestHashStruct) { const std::string str{FOUR_CHAR_STRING}; - score::platform::dltid_t dlt_id{str}; + score::platform::DltidT dlt_id{str}; - std::hash hash_instance; + std::hash hash_instance; std::size_t dlt_id_value = hash_instance(dlt_id); // operator() EXPECT_EQ(dlt_id_value, dlt_id.value); diff --git a/score/datarouter/test/ut/ut_logging/test_dltserver.cpp b/score/datarouter/test/ut/ut_logging/test_dltserver.cpp index 68bdbd9..a5f390c 100644 --- a/score/datarouter/test/ut/ut_logging/test_dltserver.cpp +++ b/score/datarouter/test/ut/ut_logging/test_dltserver.cpp @@ -54,7 +54,7 @@ constexpr auto kCommandResponseSize{1UL}; if (!(resp).empty()) \ { \ EXPECT_EQ((resp).size(), kCommandResponseSize); \ - EXPECT_EQ((resp)[0], static_cast(config::RET_OK)); \ + EXPECT_EQ((resp)[0], static_cast(config::kRetOk)); \ } \ else \ { \ @@ -68,7 +68,7 @@ constexpr auto kCommandResponseSize{1UL}; if (!(resp).empty()) \ { \ EXPECT_EQ((resp).size(), kCommandResponseSize); \ - EXPECT_EQ((resp)[0], static_cast(config::RET_ERROR)); \ + EXPECT_EQ((resp)[0], static_cast(config::kRetError)); \ } \ else \ { \ @@ -109,7 +109,7 @@ class DltLogServer::DltLogServerTest : public DltLogServer public: using DltLogServer::SendFtVerbose; using DltLogServer::SendNonVerbose; - using DltLogServer::sendVerbose; + using DltLogServer::SendVerbose; }; } // namespace dltserver @@ -127,10 +127,10 @@ class DltServerCreatedWithoutConfigFixture : public ::testing::Test protected: void SetUp() override { - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; EXPECT_CALL(outputs, construct(_, _, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, _, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); + EXPECT_CALL(outputs, Bind(_, _, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); } void TearDown() override {} @@ -157,14 +157,14 @@ TEST_F(DltServerCreatedWithoutConfigFixture, WhenCreatedDefaultDltEnabledTrue) TEST_F(DltServerCreatedWithoutConfigFixture, QuotaEnforcementEnabledExpectFalse) { DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); - EXPECT_FALSE(dlt_server.getQuotaEnforcementEnabled()); + EXPECT_FALSE(dlt_server.GetQuotaEnforcementEnabled()); } TEST_F(DltServerCreatedWithoutConfigFixture, QuotaEnforcementEnabledExpectTrue) { - s_config.quotaEnforcementEnabled = true; + s_config.quota_enforcement_enabled = true; DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); - EXPECT_TRUE(dlt_server.getQuotaEnforcementEnabled()); + EXPECT_TRUE(dlt_server.GetQuotaEnforcementEnabled()); } class DltServerCreatedWithConfigFixture : public ::testing::Test @@ -174,35 +174,34 @@ class DltServerCreatedWithConfigFixture : public ::testing::Test { log_sender_mock = std::make_unique(); log_sender_mock_raw_ptr = log_sender_mock.get(); - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; EXPECT_CALL(outputs, construct(_, _, 3491U, Eq(std::string("160.48.199.34")))).Times(1); EXPECT_CALL(outputs, construct(_, _, 3492U, Eq(std::string("160.48.199.101")))).Times(1); - EXPECT_CALL(outputs, move_construct(_, _)).Times(AtLeast(0)); - EXPECT_CALL(outputs, bind(_, _, 3490U)).Times(2); - EXPECT_CALL(outputs, destruct(_)).Times(AtLeast(2)); + EXPECT_CALL(outputs, MoveConstruct(_, _)).Times(AtLeast(0)); + EXPECT_CALL(outputs, Bind(_, _, 3490U)).Times(2); + EXPECT_CALL(outputs, Destruct(_)).Times(AtLeast(2)); } void TearDown() override {} public: testing::StrictMock outputs; - std::vector both_channels{{dltid_t("DFLT"), dltid_t("CORE")}}; + std::vector both_channels{{DltidT("DFLT"), DltidT("CORE")}}; StaticConfig s_config{ - dltid_t("CORE"), - dltid_t("DFLT"), + DltidT("CORE"), + DltidT("DFLT"), { - // channels as std::unordered_map - {dltid_t("DFLT"), {dltid_t("ECU0"), "", 3490U, "", 3491U, score::mw::log::LogLevel::kFatal, "160.48.199.34"}}, - {dltid_t("CORE"), - {dltid_t("ECU0"), "", 3490U, "", 3492U, score::mw::log::LogLevel::kError, "160.48.199.101"}}, + // channels as std::unordered_map + {DltidT("DFLT"), {DltidT("ECU0"), "", 3490U, "", 3491U, score::mw::log::LogLevel::kFatal, "160.48.199.34"}}, + {DltidT("CORE"), {DltidT("ECU0"), "", 3490U, "", 3492U, score::mw::log::LogLevel::kError, "160.48.199.101"}}, }, true, // filteringEnabled score::mw::log::LogLevel::kOff, { - {dltid_t("APP0"), {{dltid_t("CTX0"), both_channels}}}, + {DltidT("APP0"), {{DltidT("CTX0"), both_channels}}}, }, - {{dltid_t("APP0"), {{dltid_t("CTX0"), score::mw::log::LogLevel::kOff}}}}, - {100., {{dltid_t("APP0"), 1000.}}}, + {{DltidT("APP0"), {{DltidT("CTX0"), score::mw::log::LogLevel::kOff}}}}, + {100., {{DltidT("APP0"), 1000.}}}, false}; PersistentConfig p_config{}; @@ -219,7 +218,7 @@ TEST_F(DltServerCreatedWithConfigFixture, FlushChannelsExpectNoThrowException) EXPECT_CALL(write_callback, Call(_)).Times(0); DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); - EXPECT_NO_THROW(dlt_server.flush()); + EXPECT_NO_THROW(dlt_server.Flush()); } TEST_F(DltServerCreatedWithConfigFixture, GetQuotaCorrectAppNameExpectCorrectValue) @@ -228,7 +227,7 @@ TEST_F(DltServerCreatedWithConfigFixture, GetQuotaCorrectAppNameExpectCorrectVal EXPECT_CALL(write_callback, Call(_)).Times(0); DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); - const auto ret_val = dlt_server.get_quota("APP0"); + const auto ret_val = dlt_server.GetQuota("APP0"); EXPECT_EQ(ret_val, 1000); } @@ -238,17 +237,17 @@ TEST_F(DltServerCreatedWithConfigFixture, GetQuotaCorrectWrongAppNameExpectDefau EXPECT_CALL(write_callback, Call(_)).Times(0); DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); - const auto ret_val = dlt_server.get_quota("AAAA"); + const auto ret_val = dlt_server.GetQuota("AAAA"); EXPECT_EQ(ret_val, 1.0); } TEST(ResetToDefaultTest, ResetToDefaultCommandEmptyChannelsNoReadCallback) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; EXPECT_CALL(outputs, construct(_, _, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, _, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); + EXPECT_CALL(outputs, Bind(_, _, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); const StaticConfig s_config{}; PersistentConfig p_config{}; @@ -261,10 +260,10 @@ TEST(ResetToDefaultTest, ResetToDefaultCommandEmptyChannelsNoReadCallback) DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - session->on_command(std::string(kCommandSize, config::RESET_TO_DEFAULT)); + session->OnCommand(std::string(kCommandSize, config::kResetToDefault)); EXPECT_OK_OR_NOOP(response); } @@ -272,10 +271,10 @@ TEST(ResetToDefaultTest, ResetToDefaultCommandEmptyChannelsNoReadCallback) TEST(ResetToDefaultTest, ResetToDefaultCommandChannelsSizeTooBigNoReadCallback) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; EXPECT_CALL(outputs, construct(_, _, 3490U, Eq(std::string("")))).Times(1); - EXPECT_CALL(outputs, bind(_, _, 3491U)).Times(1); - EXPECT_CALL(outputs, destruct(_)).Times(1); + EXPECT_CALL(outputs, Bind(_, _, 3491U)).Times(1); + EXPECT_CALL(outputs, Destruct(_)).Times(1); StaticConfig s_config{}; const std::int32_t unexpected_channels_size{33}; @@ -295,10 +294,10 @@ TEST(ResetToDefaultTest, ResetToDefaultCommandChannelsSizeTooBigNoReadCallback) DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - session->on_command(std::string(kCommandSize, config::RESET_TO_DEFAULT)); + session->OnCommand(std::string(kCommandSize, config::kResetToDefault)); EXPECT_OK_OR_NOOP(response); } @@ -311,10 +310,10 @@ TEST_F(DltServerCreatedWithConfigFixture, SetDefaultLogLevelWrongCommandExpectRe DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - session->on_command(std::string(kCommandSize, config::SET_DEFAULT_LOG_LEVEL)); + session->OnCommand(std::string(kCommandSize, config::kSetDefaultLogLevel)); EXPECT_ERR_OR_NOOP(response); } @@ -327,12 +326,12 @@ TEST_F(DltServerCreatedWithConfigFixture, SetDefaultLogLevelCommandExpectReadCal DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - std::array command_buffer{config::SET_DEFAULT_LOG_LEVEL, 1}; + std::array command_buffer{config::kSetDefaultLogLevel, 1}; const std::string command{command_buffer.begin(), command_buffer.end()}; - session->on_command(command); + session->OnCommand(command); EXPECT_OK_OR_NOOP(response); } @@ -345,12 +344,12 @@ TEST_F(DltServerCreatedWithConfigFixture, SetDefaultLogLevelCommandReadLevelErro DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - std::array command_buffer{config::SET_DEFAULT_LOG_LEVEL, 7}; + std::array command_buffer{config::kSetDefaultLogLevel, 7}; const std::string command{command_buffer.begin(), command_buffer.end()}; - session->on_command(command); + session->OnCommand(command); EXPECT_ERR_OR_NOOP(response); } @@ -363,10 +362,10 @@ TEST_F(DltServerCreatedWithConfigFixture, SetTraceStateCommandExpectReadCallback DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - session->on_command(std::string(kCommandSize, config::SET_TRACE_STATE)); + session->OnCommand(std::string(kCommandSize, config::kSetTraceState)); EXPECT_OK_OR_NOOP(response); } @@ -379,10 +378,10 @@ TEST_F(DltServerCreatedWithConfigFixture, SetDefaultTraceStateCommandExpectReadC DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - session->on_command(std::string(kCommandSize, config::SET_DEFAULT_TRACE_STATE)); + session->OnCommand(std::string(kCommandSize, config::kSetDefaultTraceState)); EXPECT_OK_OR_NOOP(response); } @@ -395,10 +394,10 @@ TEST_F(DltServerCreatedWithConfigFixture, SetLogChannelAssignmentWrongCommandExp DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - session->on_command(std::string(kCommandSize, config::SET_LOG_CHANNEL_ASSIGNMENT)); + session->OnCommand(std::string(kCommandSize, config::kSetLogChannelAssignment)); EXPECT_ERR_OR_NOOP(response); } @@ -411,13 +410,13 @@ TEST_F(DltServerCreatedWithConfigFixture, SetLogChannelAssignmentCommandNoChanne DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); std::array command_buffer{ - config::SET_LOG_CHANNEL_ASSIGNMENT, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; + config::kSetLogChannelAssignment, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; const std::string command{command_buffer.begin(), command_buffer.end()}; - session->on_command(command); + session->OnCommand(command); EXPECT_ERR_OR_NOOP(response); } @@ -430,13 +429,13 @@ TEST_F(DltServerCreatedWithConfigFixture, SetLogChannelAssignmentCommandFoundCha DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); std::array command_buffer{ - config::SET_LOG_CHANNEL_ASSIGNMENT, 0x41, 0x50, 0x50, 0x30, 0x43, 0x54, 0x58, 0x30, 0x43, 0x4f, 0x52, 0x45, 1}; + config::kSetLogChannelAssignment, 0x41, 0x50, 0x50, 0x30, 0x43, 0x54, 0x58, 0x30, 0x43, 0x4f, 0x52, 0x45, 1}; const std::string command{command_buffer.begin(), command_buffer.end()}; - session->on_command(command); + session->OnCommand(command); EXPECT_OK_OR_NOOP(response); } @@ -450,13 +449,13 @@ TEST_F(DltServerCreatedWithConfigFixture, DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); std::array command_buffer{ - config::SET_LOG_CHANNEL_ASSIGNMENT, 0x41, 0x50, 0x50, 0x30, 0x43, 0x54, 0x58, 0x30, 0x43, 0x4f, 0x52, 0x45, 0}; + config::kSetLogChannelAssignment, 0x41, 0x50, 0x50, 0x30, 0x43, 0x54, 0x58, 0x30, 0x43, 0x4f, 0x52, 0x45, 0}; const std::string command{command_buffer.begin(), command_buffer.end()}; - session->on_command(command); + session->OnCommand(command); EXPECT_OK_OR_NOOP(response); } @@ -465,28 +464,27 @@ TEST(DltServerWrongChannelsTest, SetLogChannelAssignmentCommandFoundChannelAssignmentFoundRemoveFailedExpectReadCallback) { testing::StrictMock outputs; - UdpStreamOutput::Tester::instance() = &outputs; + UdpStreamOutput::Tester::Instance() = &outputs; EXPECT_CALL(outputs, construct(_, _, _, _)).Times(AtLeast(0)); - EXPECT_CALL(outputs, move_construct(_, _)).Times(AtLeast(0)); - EXPECT_CALL(outputs, bind(_, _, _)).Times(AtLeast(0)); - EXPECT_CALL(outputs, destruct(_)).Times(AtLeast(0)); + EXPECT_CALL(outputs, MoveConstruct(_, _)).Times(AtLeast(0)); + EXPECT_CALL(outputs, Bind(_, _, _)).Times(AtLeast(0)); + EXPECT_CALL(outputs, Destruct(_)).Times(AtLeast(0)); - std::vector both_channels{{dltid_t("DFL1"), dltid_t("COR1")}}; + std::vector both_channels{{DltidT("DFL1"), DltidT("COR1")}}; StaticConfig s_config{ - dltid_t("CORE"), - dltid_t("DFLT"), + DltidT("CORE"), + DltidT("DFLT"), { - {dltid_t("DFLT"), {dltid_t("ECU0"), "", 3490U, "", 3491U, score::mw::log::LogLevel::kFatal, "160.48.199.34"}}, - {dltid_t("CORE"), - {dltid_t("ECU0"), "", 3490U, "", 3492U, score::mw::log::LogLevel::kError, "160.48.199.101"}}, + {DltidT("DFLT"), {DltidT("ECU0"), "", 3490U, "", 3491U, score::mw::log::LogLevel::kFatal, "160.48.199.34"}}, + {DltidT("CORE"), {DltidT("ECU0"), "", 3490U, "", 3492U, score::mw::log::LogLevel::kError, "160.48.199.101"}}, }, true, score::mw::log::LogLevel::kOff, { - {dltid_t("APP0"), {{dltid_t("CTX0"), both_channels}}}, + {DltidT("APP0"), {{DltidT("CTX0"), both_channels}}}, }, - {{dltid_t("APP0"), {{dltid_t("CTX0"), score::mw::log::LogLevel::kOff}}}}, - {100., {{dltid_t("APP0"), 1000.}}}, + {{DltidT("APP0"), {{DltidT("CTX0"), score::mw::log::LogLevel::kOff}}}}, + {100., {{DltidT("APP0"), 1000.}}}, false}; PersistentConfig p_config{}; @@ -499,13 +497,13 @@ TEST(DltServerWrongChannelsTest, DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); std::array command_buffer{ - config::SET_LOG_CHANNEL_ASSIGNMENT, 0x41, 0x50, 0x50, 0x30, 0x43, 0x54, 0x58, 0x30, 0x43, 0x4f, 0x52, 0x45, 0}; + config::kSetLogChannelAssignment, 0x41, 0x50, 0x50, 0x30, 0x43, 0x54, 0x58, 0x30, 0x43, 0x4f, 0x52, 0x45, 0}; const std::string command{command_buffer.begin(), command_buffer.end()}; - session->on_command(command); + session->OnCommand(command); EXPECT_OK_OR_NOOP(response); } @@ -519,13 +517,13 @@ TEST_F(DltServerCreatedWithConfigFixture, DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); std::array command_buffer{ - config::SET_LOG_CHANNEL_ASSIGNMENT, 0, 0, 0, 0, 0, 0, 0, 0, 0x44, 0x46, 0x4c, 0x54, 1}; + config::kSetLogChannelAssignment, 0, 0, 0, 0, 0, 0, 0, 0, 0x44, 0x46, 0x4c, 0x54, 1}; const std::string command{command_buffer.begin(), command_buffer.end()}; - session->on_command(command); + session->OnCommand(command); EXPECT_OK_OR_NOOP(response); } @@ -538,9 +536,9 @@ TEST_F(DltServerCreatedWithConfigFixture, SetLogChannelAssignmentWrongChannel) DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response = - dlt_server.SetLogChannelAssignment(dltid_t("fake"), dltid_t("fake"), dltid_t("fake"), AssignmentAction::Add); + dlt_server.SetLogChannelAssignment(DltidT("fake"), DltidT("fake"), DltidT("fake"), AssignmentAction::kAdd); ASSERT_FALSE(response.empty()); - EXPECT_EQ(response[0], config::RET_ERROR); + EXPECT_EQ(response[0], config::kRetError); } TEST_F(DltServerCreatedWithConfigFixture, SetLogChannelAssignmentBehaviorRemovesChannel) @@ -558,23 +556,23 @@ TEST_F(DltServerCreatedWithConfigFixture, SetLogChannelAssignmentBehaviorRemoves app_id, ctx_id, {}, 0, score::mw::log::LogLevel::kOff}; const auto resp_add = - dlt_server.SetLogChannelAssignment(dltid_t{"APP0"}, dltid_t{"CTX0"}, dltid_t{"CORE"}, AssignmentAction::Add); + dlt_server.SetLogChannelAssignment(DltidT{"APP0"}, DltidT{"CTX0"}, DltidT{"CORE"}, AssignmentAction::kAdd); ASSERT_FALSE(resp_add.empty()); - EXPECT_EQ(resp_add[0], static_cast(config::RET_OK)); + EXPECT_EQ(resp_add[0], static_cast(config::kRetOk)); // With both channels assigned: 2 sends. EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(2); - dlt_server.sendVerbose(100U, entry); + dlt_server.SendVerbose(100U, entry); ::testing::Mock::VerifyAndClearExpectations(log_sender_mock_raw_ptr); const auto resp_remove = - dlt_server.SetLogChannelAssignment(dltid_t{"APP0"}, dltid_t{"CTX0"}, dltid_t{"CORE"}, AssignmentAction::Remove); + dlt_server.SetLogChannelAssignment(DltidT{"APP0"}, DltidT{"CTX0"}, DltidT{"CORE"}, AssignmentAction::kRemove); ASSERT_FALSE(resp_remove.empty()); - EXPECT_EQ(resp_remove[0], static_cast(config::RET_OK)); + EXPECT_EQ(resp_remove[0], static_cast(config::kRetOk)); // After removing CORE: back to DFLT-only -> 1 send. EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(1); - dlt_server.sendVerbose(100U, entry); + dlt_server.SendVerbose(100U, entry); } TEST_F(DltServerCreatedWithConfigFixture, SetDltOutputEnableCommandCallbackEnabledExpectCallbackCall) @@ -587,15 +585,15 @@ TEST_F(DltServerCreatedWithConfigFixture, SetDltOutputEnableCommandCallbackEnabl testing::StrictMock> enabled_callback; // If dynamic configuration is disabled, no callback will be invoked; allow at most one call. EXPECT_CALL(enabled_callback, Call(_)).Times(::testing::AtMost(1)); - dlt_server.set_enabled_callback(enabled_callback.AsStdFunction()); + dlt_server.SetEnabledCallback(enabled_callback.AsStdFunction()); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - std::array command_buffer{config::SET_DLT_OUTPUT_ENABLE, 0}; + std::array command_buffer{config::kSetDltOutputEnable, 0}; const std::string command{command_buffer.begin(), command_buffer.end()}; - session->on_command(command); + session->OnCommand(command); EXPECT_OK_OR_NOOP(response); } @@ -608,10 +606,10 @@ TEST_F(DltServerCreatedWithConfigFixture, SetMessagingFilteringStateWrongCommand DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - session->on_command(std::string(kCommandSize, config::SET_MESSAGING_FILTERING_STATE)); + session->OnCommand(std::string(kCommandSize, config::kSetMessagingFilteringState)); EXPECT_ERR_OR_NOOP(response); } @@ -624,12 +622,12 @@ TEST_F(DltServerCreatedWithConfigFixture, SetMessagingFilteringStateCommandExpec DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - std::array command_buffer{config::SET_MESSAGING_FILTERING_STATE, 1}; + std::array command_buffer{config::kSetMessagingFilteringState, 1}; const std::string command{command_buffer.begin(), command_buffer.end()}; - session->on_command(command); + session->OnCommand(command); EXPECT_OK_OR_NOOP(response); } @@ -651,18 +649,18 @@ TEST_F(DltServerCreatedWithConfigFixture, SetLogLevelBehaviorIncreaseThresholdAl // Initially threshold for APP0/CTX0 is kOff, so verbose should be filtered out. EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(0); - dlt_server.sendVerbose(100U, verbose_entry); + dlt_server.SendVerbose(100U, verbose_entry); ::testing::Mock::VerifyAndClearExpectations(log_sender_mock_raw_ptr); // Increase threshold to kVerbose for APP0/CTX0 using direct API - const threshold_t new_threshold{loglevel_t{score::mw::log::LogLevel::kVerbose}}; - const auto resp = dlt_server.SetLogLevel(dltid_t{"APP0"}, dltid_t{"CTX0"}, new_threshold); + const ThresholdT new_threshold{LoglevelT{score::mw::log::LogLevel::kVerbose}}; + const auto resp = dlt_server.SetLogLevel(DltidT{"APP0"}, DltidT{"CTX0"}, new_threshold); // Response always one byte RET_OK - EXPECT_EQ(resp[0], static_cast(config::RET_OK)); + EXPECT_EQ(resp[0], static_cast(config::kRetOk)); // Now verbose should pass filtering and be forwarded once per assigned channel (DFLT + CORE) -> 2 calls. EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(2); - dlt_server.sendVerbose(100U, verbose_entry); + dlt_server.SendVerbose(100U, verbose_entry); } TEST_F(DltServerCreatedWithConfigFixture, SetLogLevelBehaviorResetToDefaultBlocksVerboseAgain) @@ -679,22 +677,22 @@ TEST_F(DltServerCreatedWithConfigFixture, SetLogLevelBehaviorResetToDefaultBlock app_id, ctx_id, {}, 0, score::mw::log::LogLevel::kVerbose}; // Raise threshold first so verbose is forwarded - const threshold_t raise_threshold{loglevel_t{score::mw::log::LogLevel::kVerbose}}; - const auto resp_raise = dlt_server.SetLogLevel(dltid_t{"APP0"}, dltid_t{"CTX0"}, raise_threshold); - EXPECT_EQ(resp_raise[0], static_cast(config::RET_OK)); + const ThresholdT raise_threshold{LoglevelT{score::mw::log::LogLevel::kVerbose}}; + const auto resp_raise = dlt_server.SetLogLevel(DltidT{"APP0"}, DltidT{"CTX0"}, raise_threshold); + EXPECT_EQ(resp_raise[0], static_cast(config::kRetOk)); // With raise_threshold, verbose accepted and forwarded for both assigned channels -> 2 calls. EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(2); - dlt_server.sendVerbose(100U, verbose_entry); + dlt_server.SendVerbose(100U, verbose_entry); ::testing::Mock::VerifyAndClearExpectations(log_sender_mock_raw_ptr); // Now reset to default (ThresholdCmd::UseDefault removes specific mapping) - const threshold_t reset_threshold{ThresholdCmd::UseDefault}; - const auto resp_reset = dlt_server.SetLogLevel(dltid_t{"APP0"}, dltid_t{"CTX0"}, reset_threshold); - EXPECT_EQ(resp_reset[0], static_cast(config::RET_OK)); + const ThresholdT reset_threshold{ThresholdCmd::kUseDefault}; + const auto resp_reset = dlt_server.SetLogLevel(DltidT{"APP0"}, DltidT{"CTX0"}, reset_threshold); + EXPECT_EQ(resp_reset[0], static_cast(config::kRetOk)); // With default threshold kOff, verbose must be filtered again EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(0); - dlt_server.sendVerbose(100U, verbose_entry); + dlt_server.SendVerbose(100U, verbose_entry); } TEST_F(DltServerCreatedWithConfigFixture, SetLogChannelThresholdWrongCommandExpectReadCallback) @@ -705,10 +703,10 @@ TEST_F(DltServerCreatedWithConfigFixture, SetLogChannelThresholdWrongCommandExpe DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - session->on_command(std::string(kCommandSize, config::SET_LOG_CHANNEL_THRESHOLD)); + session->OnCommand(std::string(kCommandSize, config::kSetLogChannelThreshold)); EXPECT_ERR_OR_NOOP(response); } @@ -721,12 +719,12 @@ TEST_F(DltServerCreatedWithConfigFixture, SetLogChannelThresholdChannelNotFoundC DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - std::array command_buffer{config::SET_LOG_CHANNEL_THRESHOLD, 1, 2, 3, 4, 5, 6}; + std::array command_buffer{config::kSetLogChannelThreshold, 1, 2, 3, 4, 5, 6}; const std::string command{command_buffer.begin(), command_buffer.end()}; - session->on_command(command); + session->OnCommand(command); EXPECT_ERR_OR_NOOP(response); } @@ -739,12 +737,12 @@ TEST_F(DltServerCreatedWithConfigFixture, SetLogChannelThresholdChannelFoundComm DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); std::string response{}; - auto session = dlt_server.new_config_session( + auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - std::array command_buffer{config::SET_LOG_CHANNEL_THRESHOLD, 0x43, 0x4f, 0x52, 0x45, 5, 6}; + std::array command_buffer{config::kSetLogChannelThreshold, 0x43, 0x4f, 0x52, 0x45, 5, 6}; const std::string command{command_buffer.begin(), command_buffer.end()}; - session->on_command(command); + session->OnCommand(command); EXPECT_OK_OR_NOOP(response); } @@ -753,8 +751,8 @@ TEST(DltServerTest, ExtractIdValidInputDataExpectValidResult) { const std::string input_message{"asdAPP012345678zxccvb86545"}; const size_t offset{3}; - const auto ret_value = extractId(input_message, offset); - const std::string ret_val_string(ret_value.data(), ret_value.size()); + const auto ret_value = ExtractId(input_message, offset); + const std::string ret_val_string(ret_value.Data(), ret_value.size()); constexpr std::string_view kExpectedString{"APP0"}; EXPECT_EQ(ret_val_string, kExpectedString); @@ -765,8 +763,8 @@ TEST(DltServerTest, ExtractIdNonValidInputDataExpectNonValidResult) { const std::string input_message; const size_t offset{static_cast(std::numeric_limits::max() + 1UL)}; - const auto ret_value = extractId(input_message, offset); - const std::string ret_val_string(ret_value.data(), ret_value.size()); + const auto ret_value = ExtractId(input_message, offset); + const std::string ret_val_string(ret_value.Data(), ret_value.size()); const std::string expected_string{0x00, 0x00, 0x00, 0x00}; EXPECT_EQ(ret_val_string, expected_string); @@ -775,11 +773,11 @@ TEST(DltServerTest, ExtractIdNonValidInputDataExpectNonValidResult) TEST(DltServerTest, AppendIdValidInputDataExpectValidResult) { - // dltid_t bytes buffer has size 4. + // DltidT bytes buffer has size 4. constexpr std::string_view kExpectedMsgName{"expe"}; - score::logging::dltserver::dltid_t name{"expected name"}; + score::logging::dltserver::DltidT name{"expected name"}; std::string ret_message{}; - appendId(name, ret_message); + AppendId(name, ret_message); EXPECT_EQ(ret_message, kExpectedMsgName); } @@ -791,7 +789,7 @@ TEST_F(DltServerCreatedWithConfigFixture, SendNonVerboseFilteringDisabledExpectS EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); EXPECT_CALL(write_callback, Call(_)).Times(0); - s_config.filteringEnabled = false; + s_config.filtering_enabled = false; score::logging::dltserver::DltLogServer::DltLogServerTest dlt_server( s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true, std::move(log_sender_mock)); @@ -839,7 +837,7 @@ TEST_F(DltServerCreatedWithConfigFixture, SendVerboseNoAppIdAcceptedByFilteringN s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true, std::move(log_sender_mock)); EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(1); - dlt_server.sendVerbose(100U, {}); + dlt_server.SendVerbose(100U, {}); } TEST_F(DltServerCreatedWithConfigFixture, SendVerboseAppIdAcceptedByFilteringExpectSendCallTwice) @@ -856,7 +854,7 @@ TEST_F(DltServerCreatedWithConfigFixture, SendVerboseAppIdAcceptedByFilteringExp app_id, ctx_id, {}, 0, score::mw::log::LogLevel::kOff}; EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(2); - dlt_server.sendVerbose(100U, entry); + dlt_server.SendVerbose(100U, entry); } TEST_F(DltServerCreatedWithConfigFixture, SendVerboseAppIdNotExpectedLogLevelExpectSendNoCall) @@ -872,7 +870,7 @@ TEST_F(DltServerCreatedWithConfigFixture, SendVerboseAppIdNotExpectedLogLevelExp app_id, ctx_id, {}, 0, score::mw::log::LogLevel::kVerbose}; EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(0); - dlt_server.sendVerbose(100U, entry); + dlt_server.SendVerbose(100U, entry); } // sendFTVerbose test. @@ -885,8 +883,8 @@ TEST_F(DltServerCreatedWithConfigFixture, SendFVerboseNoAppIdWithCoreChannelExpe score::logging::dltserver::DltLogServer::DltLogServerTest dlt_server( s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true, std::move(log_sender_mock)); - const score::logging::dltserver::dltid_t app_id{""}; - const score::logging::dltserver::dltid_t ctx_id{""}; + const score::logging::dltserver::DltidT app_id{""}; + const score::logging::dltserver::DltidT ctx_id{""}; EXPECT_CALL(*log_sender_mock_raw_ptr, SendFTVerbose(_, _, _, _, _, _, _)).Times(1); dlt_server.SendFtVerbose({}, score::mw::log::LogLevel::kOff, app_id, ctx_id, 0U, 100U); } @@ -898,8 +896,8 @@ TEST_F(DltServerCreatedWithConfigFixture, SendFVerboseAppIdWithCoreChannelExpect score::logging::dltserver::DltLogServer::DltLogServerTest dlt_server( s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true, std::move(log_sender_mock)); - const score::logging::dltserver::dltid_t app_id{"APP0"}; - const score::logging::dltserver::dltid_t ctx_id{"CTX0"}; + const score::logging::dltserver::DltidT app_id{"APP0"}; + const score::logging::dltserver::DltidT ctx_id{"CTX0"}; EXPECT_CALL(*log_sender_mock_raw_ptr, SendFTVerbose(_, _, _, _, _, _, _)).Times(1); dlt_server.SendFtVerbose({}, score::mw::log::LogLevel::kOff, app_id, ctx_id, 0U, 100U); } @@ -913,8 +911,8 @@ TEST_F(DltServerCreatedWithoutConfigFixture, SendFTVerboseAppIdNoCoreChannelExpe LogSenderMock* log_sender_mock_raw_ptr = log_sender_mock.get(); score::logging::dltserver::DltLogServer::DltLogServerTest dlt_server( s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true, std::move(log_sender_mock)); - const score::logging::dltserver::dltid_t app_id{"APP0"}; - const score::logging::dltserver::dltid_t ctx_id{"CTX0"}; + const score::logging::dltserver::DltidT app_id{"APP0"}; + const score::logging::dltserver::DltidT ctx_id{"CTX0"}; EXPECT_CALL(*log_sender_mock_raw_ptr, SendFTVerbose(_, _, _, _, _, _, _)).Times(1); dlt_server.SendFtVerbose({}, score::mw::log::LogLevel::kVerbose, app_id, ctx_id, 0U, 100U); } @@ -927,7 +925,7 @@ TEST_F(DltServerCreatedWithoutConfigFixture, UpdateHandlersFinalToTrueExpectDltO score::logging::dltserver::DltLogServer::DltLogServerTest dlt_server( s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); - dlt_server.update_handlers_final(true); + dlt_server.UpdateHandlersFinal(true); EXPECT_TRUE(dlt_server.GetDltEnabled()); } @@ -939,11 +937,11 @@ TEST_F(DltServerCreatedWithConfigFixture, SetLogChannelThresholdChannelMissingDi DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); // Use a channel name that does not exist in sConfig.channels - const auto resp = dlt_server.SetLogChannelThreshold(dltid_t("MISS"), score::mw::log::LogLevel::kInfo); + const auto resp = dlt_server.SetLogChannelThreshold(DltidT("MISS"), score::mw::log::LogLevel::kInfo); // This path must return a one-byte RET_ERROR response EXPECT_EQ(resp.size(), 1U); - EXPECT_EQ(resp[0], static_cast(config::RET_ERROR)); + EXPECT_EQ(resp[0], static_cast(config::kRetError)); } TEST_F(DltServerCreatedWithConfigFixture, MakeConfigCommandHandlerReturnsValidFunction) @@ -953,18 +951,18 @@ TEST_F(DltServerCreatedWithConfigFixture, MakeConfigCommandHandlerReturnsValidFu DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); // Test that make_config_command_handler() returns a valid function - auto handler = dlt_server.make_config_command_handler(); + auto handler = dlt_server.MakeConfigCommandHandler(); EXPECT_TRUE(handler != nullptr); // Test that the handler can be called with a valid command - std::string response = handler(std::string(kCommandSize, config::READ_LOG_CHANNEL_NAMES)); + std::string response = handler(std::string(kCommandSize, config::kReadLogChannelNames)); // Response should be either OK with channel names (dynamic) or empty (stub) if (!response.empty()) { // Dynamic configuration - should get channel names EXPECT_GT(response.size(), kCommandResponseSize); - EXPECT_EQ(response[0], static_cast(config::RET_OK)); + EXPECT_EQ(response[0], static_cast(config::kRetOk)); } else { @@ -980,7 +978,7 @@ TEST_F(DltServerCreatedWithConfigFixture, MakeConfigCommandHandlerWithInvalidCom DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); // Test that make_config_command_handler() handles invalid commands - auto handler = dlt_server.make_config_command_handler(); + auto handler = dlt_server.MakeConfigCommandHandler(); EXPECT_TRUE(handler != nullptr); // Test with an invalid command @@ -991,7 +989,7 @@ TEST_F(DltServerCreatedWithConfigFixture, MakeConfigCommandHandlerWithInvalidCom { // Dynamic configuration - should get error response EXPECT_EQ(response.size(), kCommandResponseSize); - EXPECT_EQ(response[0], static_cast(config::RET_ERROR)); + EXPECT_EQ(response[0], static_cast(config::kRetError)); } else { @@ -1014,7 +1012,7 @@ TEST_F(DltServerCreatedWithConfigFixture, ResetToDefaultDirectCallReloadsChannel // Should always return OK status (single byte with RET_OK) EXPECT_EQ(response.size(), kCommandResponseSize); - EXPECT_EQ(response[0], static_cast(config::RET_OK)); + EXPECT_EQ(response[0], static_cast(config::kRetOk)); } TEST_F(DltServerCreatedWithConfigFixture, ReadLogChannelNamesDirectCall) @@ -1030,7 +1028,7 @@ TEST_F(DltServerCreatedWithConfigFixture, ReadLogChannelNamesDirectCall) // Should return OK status and channel names EXPECT_GT(response.size(), kCommandResponseSize); - EXPECT_EQ(response[0], static_cast(config::RET_OK)); + EXPECT_EQ(response[0], static_cast(config::kRetOk)); } TEST_F(DltServerCreatedWithConfigFixture, StoreDltConfigDirectCall) @@ -1047,7 +1045,7 @@ TEST_F(DltServerCreatedWithConfigFixture, StoreDltConfigDirectCall) // Should return OK status (single byte with RET_OK) EXPECT_EQ(response.size(), kCommandResponseSize); - EXPECT_EQ(response[0], static_cast(config::RET_OK)); + EXPECT_EQ(response[0], static_cast(config::kRetOk)); } TEST_F(DltServerCreatedWithConfigFixture, SetDltOutputEnableDirectCall) @@ -1062,13 +1060,13 @@ TEST_F(DltServerCreatedWithConfigFixture, SetDltOutputEnableDirectCall) // Test enabling output through public method auto response = dlt_server.SetDltOutputEnable(true); EXPECT_EQ(response.size(), kCommandResponseSize); - EXPECT_EQ(response[0], static_cast(config::RET_OK)); + EXPECT_EQ(response[0], static_cast(config::kRetOk)); EXPECT_TRUE(dlt_server.GetDltEnabled()); // Test disabling output through public method response = dlt_server.SetDltOutputEnable(false); EXPECT_EQ(response.size(), kCommandResponseSize); - EXPECT_EQ(response[0], static_cast(config::RET_OK)); + EXPECT_EQ(response[0], static_cast(config::kRetOk)); EXPECT_FALSE(dlt_server.GetDltEnabled()); } @@ -1091,18 +1089,18 @@ TEST_F(DltServerCreatedWithConfigFixture, SetDltOutputEnableBehaviorBlocksAllSen // Disable output: this should gate sending completely. const auto disable_resp = dlt_server.SetDltOutputEnable(false); EXPECT_EQ(disable_resp.size(), kCommandResponseSize); - EXPECT_EQ(disable_resp[0], static_cast(config::RET_OK)); + EXPECT_EQ(disable_resp[0], static_cast(config::kRetOk)); EXPECT_FALSE(dlt_server.GetDltEnabled()); // Re-enable output: sending should resume. const auto enable_resp = dlt_server.SetDltOutputEnable(true); EXPECT_EQ(enable_resp.size(), kCommandResponseSize); - EXPECT_EQ(enable_resp[0], static_cast(config::RET_OK)); + EXPECT_EQ(enable_resp[0], static_cast(config::kRetOk)); EXPECT_TRUE(dlt_server.GetDltEnabled()); // Basic sanity: calling sendVerbose still forwards to the log sender (2 channels). EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(2); - dlt_server.sendVerbose(100U, entry); + dlt_server.SendVerbose(100U, entry); } TEST_F(DltServerCreatedWithConfigFixture, ResetToDefaultBehaviorRestoresInitialThresholds) @@ -1123,27 +1121,27 @@ TEST_F(DltServerCreatedWithConfigFixture, ResetToDefaultBehaviorRestoresInitialT // Initially threshold for APP0/CTX0 is kOff, so verbose should be filtered out EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(0); - dlt_server.sendVerbose(100U, verbose_entry); + dlt_server.SendVerbose(100U, verbose_entry); ::testing::Mock::VerifyAndClearExpectations(log_sender_mock_raw_ptr); // Increase threshold to kVerbose so verbose messages pass filtering - const threshold_t new_threshold{loglevel_t{score::mw::log::LogLevel::kVerbose}}; - const auto resp = dlt_server.SetLogLevel(dltid_t{"APP0"}, dltid_t{"CTX0"}, new_threshold); - EXPECT_EQ(resp[0], static_cast(config::RET_OK)); + const ThresholdT new_threshold{LoglevelT{score::mw::log::LogLevel::kVerbose}}; + const auto resp = dlt_server.SetLogLevel(DltidT{"APP0"}, DltidT{"CTX0"}, new_threshold); + EXPECT_EQ(resp[0], static_cast(config::kRetOk)); // Verify verbose now passes (2 channels: DFLT + CORE) EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(2); - dlt_server.sendVerbose(100U, verbose_entry); + dlt_server.SendVerbose(100U, verbose_entry); ::testing::Mock::VerifyAndClearExpectations(log_sender_mock_raw_ptr); // Call ResetToDefault() to restore initial thresholds const auto reset_resp = dlt_server.ResetToDefault(); EXPECT_EQ(reset_resp.size(), kCommandResponseSize); - EXPECT_EQ(reset_resp[0], static_cast(config::RET_OK)); + EXPECT_EQ(reset_resp[0], static_cast(config::kRetOk)); // After reset, threshold should be back to kOff, so verbose is filtered again EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(0); - dlt_server.sendVerbose(100U, verbose_entry); + dlt_server.SendVerbose(100U, verbose_entry); } TEST_F(DltServerCreatedWithConfigFixture, ReadLogChannelNamesDirectCallContainsExpectedChannels) @@ -1159,7 +1157,7 @@ TEST_F(DltServerCreatedWithConfigFixture, ReadLogChannelNamesDirectCallContainsE // Should return OK status and channel names ASSERT_GT(response.size(), kCommandResponseSize); - EXPECT_EQ(response[0], static_cast(config::RET_OK)); + EXPECT_EQ(response[0], static_cast(config::kRetOk)); // Verify response contains expected channel names from sConfig const std::string response_str(response.begin() + kCommandResponseSize, response.end()); diff --git a/score/datarouter/test/ut/ut_logging/test_file_transfer_handler_factory.cpp b/score/datarouter/test/ut/ut_logging/test_file_transfer_handler_factory.cpp index 1ac05e4..0f3722c 100644 --- a/score/datarouter/test/ut/ut_logging/test_file_transfer_handler_factory.cpp +++ b/score/datarouter/test/ut/ut_logging/test_file_transfer_handler_factory.cpp @@ -57,7 +57,7 @@ TEST(FileTransferStreamHandlerFactoryTest, #else StubFileTransferHandlerFactory factory(output); #endif - std::unique_ptr stream_handler = factory.create(); + std::unique_ptr stream_handler = factory.Create(); // Check that the returned unique_ptr is not null ASSERT_NE(stream_handler, nullptr); diff --git a/score/datarouter/test/ut/ut_logging/test_filetransfer_stream.cpp b/score/datarouter/test/ut/ut_logging/test_filetransfer_stream.cpp index ce2c26d..8e334a6 100644 --- a/score/datarouter/test/ut/ut_logging/test_filetransfer_stream.cpp +++ b/score/datarouter/test/ut/ut_logging/test_filetransfer_stream.cpp @@ -34,8 +34,8 @@ class MockFTOutput : public FileTransferStreamHandler::IOutput SendFtVerbose, (score::cpp::span data, score::mw::log::LogLevel loglevel, - score::platform::dltid_t app_id, - score::platform::dltid_t ctx_id, + score::platform::DltidT app_id, + score::platform::DltidT ctx_id, uint8_t nor, uint32_t time_tmsp), (override)); @@ -93,10 +93,10 @@ TEST_F(FileTransferStreamTest, ShouldTransferFileSuccessfully) EXPECT_CALL( *mock_output_, SendFtVerbose( - _, score::mw::log::LogLevel::kInfo, score::platform::dltid_t("APPX"), score::platform::dltid_t("CTXX"), _, _)) + _, score::mw::log::LogLevel::kInfo, score::platform::DltidT("APPX"), score::platform::DltidT("CTXX"), _, _)) .Times(AtLeast(3)); - handler_->handle({}, data.c_str(), static_cast(data.size())); + handler_->Handle({}, data.c_str(), static_cast(data.size())); std::this_thread::sleep_for(std::chrono::milliseconds(500)); EXPECT_FALSE(path.empty()); std::remove(path.c_str()); @@ -110,10 +110,10 @@ TEST_F(FileTransferStreamTest, ShouldLogErrorWhenFileNotFound) EXPECT_CALL( *mock_output_, SendFtVerbose( - _, score::mw::log::LogLevel::kError, score::platform::dltid_t("APPX"), score::platform::dltid_t("CTXX"), _, _)) + _, score::mw::log::LogLevel::kError, score::platform::DltidT("APPX"), score::platform::DltidT("CTXX"), _, _)) .Times(1); - handler_->handle({}, data.c_str(), static_cast(data.size())); + handler_->Handle({}, data.c_str(), static_cast(data.size())); std::this_thread::sleep_for(std::chrono::milliseconds(300)); EXPECT_NE(data.find("abc.txt"), std::string::npos); } @@ -126,10 +126,10 @@ TEST_F(FileTransferStreamTest, ShouldDeleteFileIfFlagSet) EXPECT_CALL( *mock_output_, SendFtVerbose( - _, score::mw::log::LogLevel::kInfo, score::platform::dltid_t("APPX"), score::platform::dltid_t("CTXX"), _, _)) + _, score::mw::log::LogLevel::kInfo, score::platform::DltidT("APPX"), score::platform::DltidT("CTXX"), _, _)) .Times(AtLeast(2)); - handler_->handle({}, data.c_str(), static_cast(data.size())); + handler_->Handle({}, data.c_str(), static_cast(data.size())); std::this_thread::sleep_for(std::chrono::milliseconds(300)); ASSERT_FALSE(std::ifstream(path).good()); EXPECT_NE(data.find("APPX"), std::string::npos); @@ -141,7 +141,7 @@ TEST_F(FileTransferStreamTest, ShouldIgnoreInvalidSerializedInput) std::fill(garbage.begin(), garbage.end(), 'Z'); // No expectations because deserialization will likely fail silently - handler_->handle({}, garbage.data(), static_cast(garbage.size())); + handler_->Handle({}, garbage.data(), static_cast(garbage.size())); std::this_thread::sleep_for(std::chrono::milliseconds(200)); EXPECT_EQ(garbage[0], 'Z'); } @@ -152,7 +152,7 @@ TEST_F(FileTransferStreamTest, ShouldReturnExtraPackageWhenFileNotDivisible) auto path = CreateTempFile(1500); auto data = SerializeFileTransferEntry(path, false); - handler_->handle({}, data.c_str(), static_cast(data.size())); + handler_->Handle({}, data.c_str(), static_cast(data.size())); std::this_thread::sleep_for(std::chrono::milliseconds(500)); std::ifstream file(path); EXPECT_TRUE(file.good()); diff --git a/score/datarouter/test/ut/ut_logging/test_logparser.cpp b/score/datarouter/test/ut/ut_logging/test_logparser.cpp index a9f9771..0024344 100644 --- a/score/datarouter/test/ut/ut_logging/test_logparser.cpp +++ b/score/datarouter/test/ut/ut_logging/test_logparser.cpp @@ -52,17 +52,17 @@ STRUCT_VISITABLE(TestMessage, test_field) STRUCT_VISITABLE(TestFilter, test_field) template -std::string MakeTypeParams(dltid_t ecu_id, dltid_t app_id) +std::string MakeTypeParams(DltidT ecu_id, DltidT app_id) { - return std::string(4, char(0)) + std::string(ecu_id.data(), 4) + std::string(app_id.data(), 4) + + return std::string(4, char(0)) + std::string(ecu_id.Data(), 4) + std::string(app_id.Data(), 4) + ::score::common::visitor::logger_type_string(); } template -std::string MakeWrongTypeParams(dltid_t ecu_id, dltid_t app_id) +std::string MakeWrongTypeParams(DltidT ecu_id, DltidT app_id) { // Without the first four zeros. - return std::string(ecu_id.data(), 4) + std::string(app_id.data(), 4) + + return std::string(ecu_id.Data(), 4) + std::string(app_id.Data(), 4) + ::score::common::visitor::logger_type_string(); } @@ -81,52 +81,52 @@ std::string MakeMessage(S type_index, const T& t) class AnyHandlerMock : public LogParser::AnyHandler { public: - MOCK_METHOD(void, handle, (const TypeInfo&, timestamp_t, const char*, bufsize_t), (override final)); + MOCK_METHOD(void, Handle, (const TypeInfo&, TimestampT, const char*, BufsizeT), (override final)); }; class TypeHandlerMock : public LogParser::TypeHandler { public: - MOCK_METHOD(void, handle, (timestamp_t, const char*, bufsize_t), (override final)); + MOCK_METHOD(void, Handle, (TimestampT, const char*, BufsizeT), (override final)); }; TEST(LogParserTest, SingleMessageHandler) { testing::StrictMock any_handler; - EXPECT_CALL(any_handler, handle(_, _, _, _)).Times(1); + EXPECT_CALL(any_handler, Handle(_, _, _, _)).Times(1); testing::StrictMock type_handler_yes; - EXPECT_CALL(type_handler_yes, handle(_, _, _)).Times(1); + EXPECT_CALL(type_handler_yes, Handle(_, _, _)).Times(1); testing::StrictMock type_handler_no; - EXPECT_CALL(type_handler_no, handle(_, _, _)).Times(0); + EXPECT_CALL(type_handler_no, Handle(_, _, _)).Times(0); - const timestamp_t time_now = timestamp_t::clock::now(); - const std::string type_params = MakeTypeParams(dltid_t{"ECU0"}, dltid_t{"APP0"}); - constexpr bufsize_t kTestMessageIndex = 1234; + const TimestampT time_now = TimestampT::clock::now(); + const std::string type_params = MakeTypeParams(DltidT{"ECU0"}, DltidT{"APP0"}); + constexpr BufsizeT kTestMessageIndex = 1234; const std::string message = MakeMessage(kTestMessageIndex, TestMessage{2345}); LogParser parser(CreateTestNvConfig()); - parser.add_global_handler(any_handler); - parser.add_type_handler("test::TestMessage", type_handler_yes); - parser.add_type_handler("test::notTestMessage", type_handler_no); + parser.AddGlobalHandler(any_handler); + parser.AddTypeHandler("test::TestMessage", type_handler_yes); + parser.AddTypeHandler("test::notTestMessage", type_handler_no); - parser.add_incoming_type(kTestMessageIndex, type_params); + parser.AddIncomingType(kTestMessageIndex, type_params); - parser.parse(time_now, message.data(), static_cast(message.size())); + parser.Parse(time_now, message.data(), static_cast(message.size())); } TEST(LogParserTest, FilterForwarderWithSingleForwarder) { using namespace std::chrono_literals; - const std::string type_params = MakeTypeParams(dltid_t{"ECU4"}, dltid_t{"APP0"}); + const std::string type_params = MakeTypeParams(DltidT{"ECU4"}, DltidT{"APP0"}); LogParser parser(CreateTestNvConfig()); const auto factory = [](const std::string& type_name, const DataFilter& filter) -> LogParser::FilterFunction { - if (type_name == "test::TestMessage" && filter.filterType == "test::TestFilter") + if (type_name == "test::TestMessage" && filter.filter_type == "test::TestFilter") { TestFilter test_filter; using S = ::score::common::visitor::logging_serializer; - if (S::deserialize(filter.filterData.data(), filter.filterData.size(), test_filter)) + if (S::deserialize(filter.filter_data.data(), filter.filter_data.size(), test_filter)) { - return [test_filter](const char* const data, const bufsize_t size) { + return [test_filter](const char* const data, const BufsizeT size) { TestMessage message; if (S::deserialize(data, size, message)) { @@ -141,17 +141,17 @@ TEST(LogParserTest, FilterForwarderWithSingleForwarder) } return {}; }; - parser.set_filter_factory(factory); + parser.SetFilterFactory(factory); - constexpr bufsize_t kTestMessageIndex = 1234; - parser.add_incoming_type(kTestMessageIndex, type_params); + constexpr BufsizeT kTestMessageIndex = 1234; + parser.AddIncomingType(kTestMessageIndex, type_params); const std::string message1 = MakeMessage(kTestMessageIndex, TestMessage{1}); - parser.parse(timestamp_t{1s}, message1.data(), static_cast(message1.size())); + parser.Parse(TimestampT{1s}, message1.data(), static_cast(message1.size())); const std::string message2 = MakeMessage(kTestMessageIndex, TestMessage{2}); - parser.parse(timestamp_t{2s}, message2.data(), static_cast(message2.size())); + parser.Parse(TimestampT{2s}, message2.data(), static_cast(message2.size())); const std::string message3 = MakeMessage(kTestMessageIndex, TestMessage{3}); - parser.parse(timestamp_t{3s}, message3.data(), static_cast(message3.size())); + parser.Parse(TimestampT{3s}, message3.data(), static_cast(message3.size())); } // Test the else case in the below condition in 'remove_type_handler' and 'remove_handler' methods. @@ -162,23 +162,23 @@ TEST(LogParserTest, TestRemoveTypeHandler) { LogParser parser(CreateTestNvConfig()); testing::StrictMock type_handler_yes; - parser.add_type_handler("test::TestMessage", type_handler_yes); - parser.add_type_handler("test::TestMessage", type_handler_yes); + parser.AddTypeHandler("test::TestMessage", type_handler_yes); + parser.AddTypeHandler("test::TestMessage", type_handler_yes); testing::StrictMock type_handler_no; - EXPECT_CALL(type_handler_no, handle(_, _, _)).Times(0); + EXPECT_CALL(type_handler_no, Handle(_, _, _)).Times(0); - parser.add_type_handler("test::notTestMessage", type_handler_no); + parser.AddTypeHandler("test::notTestMessage", type_handler_no); - const std::string type_params = MakeTypeParams(dltid_t{"ECU0"}, dltid_t{"APP0"}); - constexpr bufsize_t kTestMessageIndex = 1234; + const std::string type_params = MakeTypeParams(DltidT{"ECU0"}, DltidT{"APP0"}); + constexpr BufsizeT kTestMessageIndex = 1234; // Add the type twice. - parser.add_incoming_type(kTestMessageIndex, type_params); - parser.add_incoming_type(kTestMessageIndex, type_params); - parser.remove_type_handler("test::TestMessage", type_handler_yes); + parser.AddIncomingType(kTestMessageIndex, type_params); + parser.AddIncomingType(kTestMessageIndex, type_params); + parser.RemoveTypeHandler("test::TestMessage", type_handler_yes); // Remove non existent type handler. - parser.remove_type_handler("test::TestMessage", type_handler_yes); + parser.RemoveTypeHandler("test::TestMessage", type_handler_yes); } // Test the True case for the below condition for 'add_incoming_type' method. @@ -188,9 +188,9 @@ TEST(LogParserTest, TestRemoveTypeHandler) TEST(LogParserTest, TestWrongTypeParameter) { LogParser parser(CreateTestNvConfig()); - const std::string type_params = MakeWrongTypeParams(dltid_t{"ECU0"}, dltid_t{"APP0"}); - constexpr bufsize_t kTestMessageIndex = 1234; - parser.add_incoming_type(kTestMessageIndex, type_params); + const std::string type_params = MakeWrongTypeParams(DltidT{"ECU0"}, DltidT{"APP0"}); + constexpr BufsizeT kTestMessageIndex = 1234; + parser.AddIncomingType(kTestMessageIndex, type_params); } // The purpose of the test is to cover the else case for the below condition for 'add_global_handler' method. @@ -201,11 +201,11 @@ TEST(LogParserTest, TestRegisterGlobalHandler) LogParser parser(CreateTestNvConfig()); testing::StrictMock any_handler; // Register the same global handler twice. - EXPECT_FALSE(parser.is_glb_hndl_registered(any_handler)); - parser.add_global_handler(any_handler); - EXPECT_TRUE(parser.is_glb_hndl_registered(any_handler)); + EXPECT_FALSE(parser.IsGlbHndlRegistered(any_handler)); + parser.AddGlobalHandler(any_handler); + EXPECT_TRUE(parser.IsGlbHndlRegistered(any_handler)); // To reach the else case in the condition there. - parser.add_global_handler(any_handler); + parser.AddGlobalHandler(any_handler); } // The purpose of the test is to cover the else case for the below condition for 'remove_global_handler' method. @@ -216,17 +216,17 @@ TEST(LogParserTest, TestRemovingGlobalHandler) LogParser parser(CreateTestNvConfig()); testing::StrictMock any_handler; // Check non-registered handler. - EXPECT_FALSE(parser.is_glb_hndl_registered(any_handler)); + EXPECT_FALSE(parser.IsGlbHndlRegistered(any_handler)); // Register new handler. - parser.add_global_handler(any_handler); + parser.AddGlobalHandler(any_handler); // Check registered handler. - EXPECT_TRUE(parser.is_glb_hndl_registered(any_handler)); + EXPECT_TRUE(parser.IsGlbHndlRegistered(any_handler)); // Remove the handler. - parser.remove_global_handler(any_handler); + parser.RemoveGlobalHandler(any_handler); // Handler no more exist. - EXPECT_FALSE(parser.is_glb_hndl_registered(any_handler)); + EXPECT_FALSE(parser.IsGlbHndlRegistered(any_handler)); // Try remove non registered handler (To reach the else case in the condition there). - parser.remove_global_handler(any_handler); + parser.RemoveGlobalHandler(any_handler); } // Test the if condition in the 'add_type_handler' method. @@ -237,10 +237,10 @@ TEST(LogParserTest, TestAlreadyRegisteredTypeHandler) testing::StrictMock type_handler_yes; LogParser parser(CreateTestNvConfig()); - parser.add_type_handler("test::TestMessage", type_handler_yes); - parser.add_type_handler("test::TestMessage", type_handler_yes); + parser.AddTypeHandler("test::TestMessage", type_handler_yes); + parser.AddTypeHandler("test::TestMessage", type_handler_yes); - EXPECT_TRUE(parser.is_type_hndl_registered("test::TestMessage", type_handler_yes)); + EXPECT_TRUE(parser.IsTypeHndlRegistered("test::TestMessage", type_handler_yes)); } TEST(LogParserTest, TestRegisteringNewTypeHandler) @@ -248,14 +248,14 @@ TEST(LogParserTest, TestRegisteringNewTypeHandler) LogParser parser(CreateTestNvConfig()); testing::StrictMock type_handler_yes; - EXPECT_FALSE(parser.is_type_hndl_registered("test::TestMessage", type_handler_yes)); + EXPECT_FALSE(parser.IsTypeHndlRegistered("test::TestMessage", type_handler_yes)); - const std::string type_params = MakeTypeParams(dltid_t{"ECU0"}, dltid_t{"APP0"}); - constexpr bufsize_t kTestMessageIndex = 1234; - parser.add_incoming_type(kTestMessageIndex, type_params); - parser.add_type_handler("test::TestMessage", type_handler_yes); + const std::string type_params = MakeTypeParams(DltidT{"ECU0"}, DltidT{"APP0"}); + constexpr BufsizeT kTestMessageIndex = 1234; + parser.AddIncomingType(kTestMessageIndex, type_params); + parser.AddTypeHandler("test::TestMessage", type_handler_yes); - EXPECT_TRUE(parser.is_type_hndl_registered("test::TestMessage", type_handler_yes)); + EXPECT_TRUE(parser.IsTypeHndlRegistered("test::TestMessage", type_handler_yes)); } // The purpose of this test is to enhance the line coverage for 'reset_internal_mapping' method. @@ -264,7 +264,7 @@ TEST(LogParserTest, TestResetInternalMapping) LogParser parser(CreateTestNvConfig()); // Unfortunately, there other way to set expectation for calling this method. // And there is no other methods are using it internally. - EXPECT_NO_FATAL_FAILURE(parser.reset_internal_mapping()); + EXPECT_NO_FATAL_FAILURE(parser.ResetInternalMapping()); } struct SmallTestMessage @@ -274,19 +274,19 @@ struct SmallTestMessage STRUCT_VISITABLE(SmallTestMessage, test_field) // The purpose of this test is to enhance the line coverage for -// parse(timestamp_t timestamp, const char* data, bufsize_t size) method. +// parse(TimestampT timestamp, const char* data, BufsizeT size) method. TEST(LogParserTest, WeCanNotParseIfTheSizeOfTheSerializedMessageSmallerThanTheExpectedBufferSizeUint32) { - const timestamp_t time_now = timestamp_t::clock::now(); + const TimestampT time_now = TimestampT::clock::now(); constexpr uint8_t kSmallTestMessageIndex = 3; const std::string message = MakeMessage(kSmallTestMessageIndex, SmallTestMessage{7}); LogParser parser(CreateTestNvConfig()); // Unfortunately, there other way to set expectation for calling this method. // And there is no other methods are using it internally. - EXPECT_NO_FATAL_FAILURE(parser.parse(time_now, message.data(), static_cast(message.size()))); - EXPECT_NO_FATAL_FAILURE(parser.reset_internal_mapping()); - EXPECT_NO_FATAL_FAILURE(parser.parse(time_now, message.data(), static_cast(message.size()))); + EXPECT_NO_FATAL_FAILURE(parser.Parse(time_now, message.data(), static_cast(message.size()))); + EXPECT_NO_FATAL_FAILURE(parser.ResetInternalMapping()); + EXPECT_NO_FATAL_FAILURE(parser.Parse(time_now, message.data(), static_cast(message.size()))); } // The purpose of this test is to enhance the line coverage for 'parse' with covering the below condition. @@ -294,14 +294,14 @@ TEST(LogParserTest, WeCanNotParseIfTheSizeOfTheSerializedMessageSmallerThanTheEx // if (iParser == index_parser_map.end()) TEST(LogParserTest, WeCanNotParseIfTheIndexIsNotWithinTheIndexParserMap) { - const timestamp_t time_now = timestamp_t::clock::now(); - constexpr bufsize_t kTestMessageIndex = 1235; + const TimestampT time_now = TimestampT::clock::now(); + constexpr BufsizeT kTestMessageIndex = 1235; const std::string message = MakeMessage(kTestMessageIndex, TestMessage{1234}); LogParser parser(CreateTestNvConfig()); // Unfortunately, there other way to set expectation for calling this method. // And there is no other methods are using it internally. - EXPECT_NO_FATAL_FAILURE(parser.parse(time_now, message.data(), static_cast(message.size()))); + EXPECT_NO_FATAL_FAILURE(parser.Parse(time_now, message.data(), static_cast(message.size()))); // Since we didn't fill any values to 'index_parser_map' map, it will be empty which leads to immediate returning. } diff --git a/score/datarouter/test/ut/ut_logging/test_message_passing_server.cpp b/score/datarouter/test/ut/ut_logging/test_message_passing_server.cpp index 3c5f702..ccbdc72 100644 --- a/score/datarouter/test/ut/ut_logging/test_message_passing_server.cpp +++ b/score/datarouter/test/ut/ut_logging/test_message_passing_server.cpp @@ -85,10 +85,10 @@ std::uint32_t gKReceiverQueueMaxSize = 0; class MockSession : public MessagePassingServer::ISession { public: - MOCK_METHOD(bool, tick, (), (override final)); - MOCK_METHOD(void, on_acquire_response, (const score::mw::log::detail::ReadAcquireResult&), (override final)); - MOCK_METHOD(void, on_closed_by_peer, (), (override final)); - MOCK_METHOD(bool, is_source_closed, (), (override)); + MOCK_METHOD(bool, Tick, (), (override final)); + MOCK_METHOD(void, OnAcquireResponse, (const score::mw::log::detail::ReadAcquireResult&), (override final)); + MOCK_METHOD(void, OnClosedByPeer, (), (override final)); + MOCK_METHOD(bool, IsSourceClosed, (), (override)); MOCK_METHOD(void, Destruct, (), ()); @@ -176,21 +176,21 @@ class MessagePassingServerFixture : public ::testing::Test ++construct_count; auto session = std::make_unique(); - EXPECT_CALL(*session, tick).Times(AnyNumber()).WillRepeatedly([this, &status]() { + EXPECT_CALL(*session, Tick).Times(AnyNumber()).WillRepeatedly([this, &status]() { ++tick_count; status.IncrementTickCount(); CheckWaitTickUnblock(); return false; }); - EXPECT_CALL(*session, on_acquire_response) + EXPECT_CALL(*session, OnAcquireResponse) .Times(AnyNumber()) .WillRepeatedly([this](const score::mw::log::detail::ReadAcquireResult&) { ++acquire_response_count; }); - EXPECT_CALL(*session, on_closed_by_peer).Times(AtMost(1)).WillOnce([this]() { + EXPECT_CALL(*session, OnClosedByPeer).Times(AtMost(1)).WillOnce([this]() { ++closed_by_peer_count; }); - EXPECT_CALL(*session, is_source_closed).Times(AnyNumber()).WillRepeatedly(Return(false)); + EXPECT_CALL(*session, IsSourceClosed).Times(AnyNumber()).WillRepeatedly(Return(false)); EXPECT_CALL(*session, Destruct).Times(1).WillOnce([this, &status]() { ++destruct_count; std::lock_guard erase_lock(map_mutex); @@ -640,16 +640,16 @@ TEST(MessagePassingServerTests, sessionWrapperCreateTest) MessagePassingServer::MessagePassingServerForTest::SessionWrapper session_wrapper( nullptr, 0, std::move(session_mock)); - EXPECT_FALSE(session_wrapper.is_marked_for_delete()); - session_wrapper.to_delete_ = true; - EXPECT_TRUE(session_wrapper.is_marked_for_delete()); + EXPECT_FALSE(session_wrapper.IsMarkedForDelete()); + session_wrapper.to_delete = true; + EXPECT_TRUE(session_wrapper.IsMarkedForDelete()); - session_wrapper.closed_by_peer_ = true; - EXPECT_TRUE(session_wrapper.get_reset_closed_by_peer()); - EXPECT_FALSE(session_wrapper.get_reset_closed_by_peer()); + session_wrapper.closed_by_peer = true; + EXPECT_TRUE(session_wrapper.GetResetClosedByPeer()); + EXPECT_FALSE(session_wrapper.GetResetClosedByPeer()); - EXPECT_CALL(*session_mock_ptr, is_source_closed).WillOnce(Return(true)); - EXPECT_CALL(*session_mock_ptr, is_source_closed).WillOnce(Return(false)); + EXPECT_CALL(*session_mock_ptr, IsSourceClosed).WillOnce(Return(true)); + EXPECT_CALL(*session_mock_ptr, IsSourceClosed).WillOnce(Return(false)); EXPECT_TRUE(session_wrapper.GetIsSourceClosed()); EXPECT_FALSE(session_wrapper.GetIsSourceClosed()); } @@ -724,12 +724,12 @@ TEST_P(SessionWrapperParamTest, EnqueueForDeleteWhileLockedTest) EXPECT_CALL(server_mock, EnqueueTickWhileLocked(pid)).Times(test_params.expected_enqueued_called_count); - session_wrapper.enqueued_ = test_params.input_enqueued; - session_wrapper.running_ = test_params.input_running; - session_wrapper.enqueue_for_delete_while_locked(test_params.input_closed_by_peer); - EXPECT_EQ(session_wrapper.running_, test_params.expected_running); - EXPECT_EQ(session_wrapper.enqueued_, test_params.expected_enqueued); - EXPECT_EQ(session_wrapper.closed_by_peer_, test_params.expected_closed_by_peer); + session_wrapper.enqueued = test_params.input_enqueued; + session_wrapper.running = test_params.input_running; + session_wrapper.EnqueueForDeleteWhileLocked(test_params.input_closed_by_peer); + EXPECT_EQ(session_wrapper.running, test_params.expected_running); + EXPECT_EQ(session_wrapper.enqueued, test_params.expected_enqueued); + EXPECT_EQ(session_wrapper.closed_by_peer, test_params.expected_closed_by_peer); } TEST(SessionWrapperTest, ResetRunningWhileLocked) @@ -741,16 +741,16 @@ TEST(SessionWrapperTest, ResetRunningWhileLocked) { // with enqueued - session_wrapper.enqueued_ = false; - session_wrapper.reset_running_while_locked(true); - EXPECT_TRUE(session_wrapper.enqueued_); + session_wrapper.enqueued = false; + session_wrapper.ResetRunningWhileLocked(true); + EXPECT_TRUE(session_wrapper.enqueued); } { // without enqueued - session_wrapper.enqueued_ = false; - session_wrapper.reset_running_while_locked(false); - EXPECT_FALSE(session_wrapper.enqueued_); + session_wrapper.enqueued = false; + session_wrapper.ResetRunningWhileLocked(false); + EXPECT_FALSE(session_wrapper.enqueued); } } diff --git a/score/datarouter/test/ut/ut_logging/test_nonverbosedlt.cpp b/score/datarouter/test/ut/ut_logging/test_nonverbosedlt.cpp index e531f70..2596888 100644 --- a/score/datarouter/test/ut/ut_logging/test_nonverbosedlt.cpp +++ b/score/datarouter/test/ut/ut_logging/test_nonverbosedlt.cpp @@ -65,32 +65,32 @@ class DltNonverboseHandlerTest : public ::testing::Test TEST_F(DltNonverboseHandlerTest, HandleShouldCallSendNonVerbose) { TypeInfo type_info; - type_info.typeName = "score::platform::datarouter::test::TestTraceableStruct"; - timestamp_t timestamp = score::os::HighResolutionSteadyClock::now(); + type_info.type_name = "score::platform::datarouter::test::TestTraceableStruct"; + TimestampT timestamp = score::os::HighResolutionSteadyClock::now(); const char* data = "TestData"; - bufsize_t size = 10; + BufsizeT size = 10; score::mw::log::config::NvMsgDescriptor descriptor; - type_info.nvMsgDesc = &descriptor; + type_info.nv_msg_desc = &descriptor; - handler_->handle(type_info, timestamp, data, size); + handler_->Handle(type_info, timestamp, data, size); } TEST(DltNonverboseHandler_T, HandleShouldNotCallSendNonVerboseWhenDescriptorIsNull) { TypeInfo type_info; - type_info.typeName = "score::platform::datarouter::test::TestTraceableStruct"; - type_info.nvMsgDesc = nullptr; - timestamp_t timestamp = score::os::HighResolutionSteadyClock::now(); + type_info.type_name = "score::platform::datarouter::test::TestTraceableStruct"; + type_info.nv_msg_desc = nullptr; + TimestampT timestamp = score::os::HighResolutionSteadyClock::now(); const char data[] = "TestLogData"; - bufsize_t size = sizeof(data); + BufsizeT size = sizeof(data); MockDltOutput mock_output; DltNonverboseHandler handler(mock_output); EXPECT_CALL(mock_output, SendNonVerbose(_, _, _, _)).Times(0); - handler.handle(type_info, timestamp, data, size); + handler.Handle(type_info, timestamp, data, size); } TEST(DltNonverboseHandler_T, HandleCallSendNonVerboseWhenDltMsgDesc) @@ -107,11 +107,11 @@ TEST(DltNonverboseHandler_T, HandleCallSendNonVerboseWhenDltMsgDesc) DltNonverboseHandler handler(mock_output); TypeInfo type_info; - type_info.typeName = "score::platform::datarouter::test::TestTraceableStruct"; - type_info.nvMsgDesc = &kDescriptor; + type_info.type_name = "score::platform::datarouter::test::TestTraceableStruct"; + type_info.nv_msg_desc = &kDescriptor; - timestamp_t timestamp = score::os::HighResolutionSteadyClock::now(); + TimestampT timestamp = score::os::HighResolutionSteadyClock::now(); const char data[] = "TestData"; - bufsize_t size = sizeof(data); - handler.handle(type_info, timestamp, data, size); + BufsizeT size = sizeof(data); + handler.Handle(type_info, timestamp, data, size); } diff --git a/score/datarouter/test/ut/ut_logging/test_options.cpp b/score/datarouter/test/ut/ut_logging/test_options.cpp index 082abc3..fb3651b 100644 --- a/score/datarouter/test/ut/ut_logging/test_options.cpp +++ b/score/datarouter/test/ut/ut_logging/test_options.cpp @@ -36,15 +36,15 @@ TEST_F(OptionsTest, ParseNoArguments) char* argv[] = {program_name, nullptr}; // parse returns true on success - bool result = score::logging::options::Options::parse(argc, argv); + bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_TRUE(result); // Check flags - score::logging::options::Options& opts = score::logging::options::Options::get(); - EXPECT_FALSE(opts.do_nothing()); - EXPECT_FALSE(opts.print_version()); - EXPECT_FALSE(opts.verbose()); - EXPECT_FALSE(opts.no_adaptive_runtime()); + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_FALSE(opts.DoNothing()); + EXPECT_FALSE(opts.PrintVersion()); + EXPECT_FALSE(opts.Verbose()); + EXPECT_FALSE(opts.NoAdaptiveRuntime()); } TEST_F(OptionsTest, ParseHelpShortOptionH) @@ -56,15 +56,15 @@ TEST_F(OptionsTest, ParseHelpShortOptionH) char* argv[] = {program_name, help_option, nullptr}; // parse should return true - bool result = score::logging::options::Options::parse(argc, argv); + bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_TRUE(result); // Because -h triggers usage, do_nothing_ is set (and we return early) - score::logging::options::Options& opts = score::logging::options::Options::get(); - EXPECT_TRUE(opts.do_nothing()); - EXPECT_FALSE(opts.print_version()); - EXPECT_FALSE(opts.verbose()); - EXPECT_FALSE(opts.no_adaptive_runtime()); + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_TRUE(opts.DoNothing()); + EXPECT_FALSE(opts.PrintVersion()); + EXPECT_FALSE(opts.Verbose()); + EXPECT_FALSE(opts.NoAdaptiveRuntime()); } TEST_F(OptionsTest, ParseVerboseShortOptionV) @@ -76,12 +76,12 @@ TEST_F(OptionsTest, ParseVerboseShortOptionV) char* argv[] = {program_name, help_option, nullptr}; // parse should return true - bool result = score::logging::options::Options::parse(argc, argv); + bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_TRUE(result); - score::logging::options::Options& opts = score::logging::options::Options::get(); - EXPECT_TRUE(opts.verbose()); - EXPECT_TRUE(opts.do_nothing()); + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_TRUE(opts.Verbose()); + EXPECT_TRUE(opts.DoNothing()); } TEST_F(OptionsTest, ParseVerboseLongOptionV) @@ -93,12 +93,12 @@ TEST_F(OptionsTest, ParseVerboseLongOptionV) char verbose_option[] = "--verbose"; char* argv[] = {program_name, verbose_option, nullptr}; - bool result = score::logging::options::Options::parse(argc, argv); + bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_TRUE(result); - score::logging::options::Options& opts = score::logging::options::Options::get(); - EXPECT_TRUE(opts.verbose()); - EXPECT_TRUE(opts.do_nothing()); + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_TRUE(opts.Verbose()); + EXPECT_TRUE(opts.DoNothing()); } TEST_F(OptionsTest, ParseVerboseLongOptionHelp) @@ -109,11 +109,11 @@ TEST_F(OptionsTest, ParseVerboseLongOptionHelp) char verbose_option[] = "--help"; char* argv[] = {program_name, verbose_option, nullptr}; - bool result = score::logging::options::Options::parse(argc, argv); + bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_TRUE(result); - score::logging::options::Options& opts = score::logging::options::Options::get(); - EXPECT_TRUE(opts.do_nothing()); + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_TRUE(opts.DoNothing()); } TEST_F(OptionsTest, ParseVerboseLongOptionNoAdaptiveRuntime) @@ -124,11 +124,11 @@ TEST_F(OptionsTest, ParseVerboseLongOptionNoAdaptiveRuntime) char verbose_option[] = "--no_adaptive_runtime"; char* argv[] = {program_name, verbose_option, nullptr}; - bool result = score::logging::options::Options::parse(argc, argv); + bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_TRUE(result); - score::logging::options::Options& opts = score::logging::options::Options::get(); - EXPECT_TRUE(opts.no_adaptive_runtime()); + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_TRUE(opts.NoAdaptiveRuntime()); } TEST_F(OptionsTest, ParseNoAdaptiveRuntimeShortOptionN) @@ -139,12 +139,12 @@ TEST_F(OptionsTest, ParseNoAdaptiveRuntimeShortOptionN) char no_adaptive_option[] = "-n"; char* argv[] = {program_name, no_adaptive_option, nullptr}; - bool result = score::logging::options::Options::parse(argc, argv); + bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_TRUE(result); - score::logging::options::Options& opts = score::logging::options::Options::get(); - EXPECT_TRUE(opts.no_adaptive_runtime()); - EXPECT_TRUE(opts.do_nothing()); + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_TRUE(opts.NoAdaptiveRuntime()); + EXPECT_TRUE(opts.DoNothing()); } TEST_F(OptionsTest, ParseNoAdaptiveRuntimeShortOptionV) @@ -155,11 +155,11 @@ TEST_F(OptionsTest, ParseNoAdaptiveRuntimeShortOptionV) char no_adaptive_option[] = "-V"; char* argv[] = {program_name, no_adaptive_option, nullptr}; - bool result = score::logging::options::Options::parse(argc, argv); + bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_TRUE(result); - score::logging::options::Options& opts = score::logging::options::Options::get(); - EXPECT_TRUE(opts.print_version()); + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_TRUE(opts.PrintVersion()); } TEST_F(OptionsTest, ParseVersionLongOption) @@ -171,13 +171,13 @@ TEST_F(OptionsTest, ParseVersionLongOption) char version_option[] = "--version"; char* argv[] = {program_name, version_option, nullptr}; - bool result = score::logging::options::Options::parse(argc, argv); + bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_TRUE(result); // 'print_version_' is set, parse returns early - score::logging::options::Options& opts = score::logging::options::Options::get(); - EXPECT_TRUE(opts.print_version()); - EXPECT_TRUE(opts.no_adaptive_runtime()); + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_TRUE(opts.PrintVersion()); + EXPECT_TRUE(opts.NoAdaptiveRuntime()); } TEST_F(OptionsTest, ParseUnknownOptionSimiColon) @@ -189,13 +189,13 @@ TEST_F(OptionsTest, ParseUnknownOptionSimiColon) char* argv[] = {program_name, unknown_option, nullptr}; // parse should return false for unknown option - bool result = score::logging::options::Options::parse(argc, argv); + bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_TRUE(result); - score::logging::options::Options& opts = score::logging::options::Options::get(); - EXPECT_TRUE(opts.print_version()); - EXPECT_TRUE(opts.no_adaptive_runtime()); - EXPECT_TRUE(opts.do_nothing()); + score::logging::options::Options& opts = score::logging::options::Options::Get(); + EXPECT_TRUE(opts.PrintVersion()); + EXPECT_TRUE(opts.NoAdaptiveRuntime()); + EXPECT_TRUE(opts.DoNothing()); } TEST_F(OptionsTest, ParseUnknownOption) @@ -207,7 +207,7 @@ TEST_F(OptionsTest, ParseUnknownOption) char* argv[] = {program_name, unknown_option, nullptr}; // parse should return false for unknown option - bool result = score::logging::options::Options::parse(argc, argv); + bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_FALSE(result); } @@ -223,7 +223,7 @@ TEST_F(OptionsTest, ParseMissingArg) char missing_arg_option[] = "-d"; char* argv[] = {program_name, missing_arg_option, nullptr}; - bool result = score::logging::options::Options::parse(argc, argv); + bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_FALSE(result); } @@ -237,6 +237,6 @@ TEST_F(OptionsTest, ParseUnknownOptionDoubleQuestionDashDash) char* argv[] = {program_name, unknown_option, nullptr}; // parse should return false for this unknown option - bool result = score::logging::options::Options::parse(argc, argv); + bool result = score::logging::options::Options::Parse(argc, argv); EXPECT_FALSE(result); } diff --git a/score/datarouter/test/ut/ut_logging/test_persistentlog_config.cpp b/score/datarouter/test/ut/ut_logging/test_persistentlog_config.cpp index f7ee72c..560ca9e 100644 --- a/score/datarouter/test/ut/ut_logging/test_persistentlog_config.cpp +++ b/score/datarouter/test/ut/ut_logging/test_persistentlog_config.cpp @@ -69,38 +69,38 @@ class DltSetLogLevelTest : public ::testing::Test { const std::string complete_test_path = "score/datarouter/test/ut/etc/datarouter/"; - gPerLogConfOk = readPersistentLoggingConfig(complete_test_path + std::string("persistent-logging.json")); - gPerLogConfErrOpn = readPersistentLoggingConfig("persistent-ln"); + gPerLogConfOk = ReadPersistentLoggingConfig(complete_test_path + std::string("persistent-logging.json")); + gPerLogConfErrOpn = ReadPersistentLoggingConfig("persistent-ln"); gPerLogConfErrParse = - readPersistentLoggingConfig(complete_test_path + std::string("persistent-logging_test_1.json")); + ReadPersistentLoggingConfig(complete_test_path + std::string("persistent-logging_test_1.json")); gPerLogConfErrContent1 = - readPersistentLoggingConfig(complete_test_path + std::string("persistent-logging_test_2.json")); + ReadPersistentLoggingConfig(complete_test_path + std::string("persistent-logging_test_2.json")); gPerLogConfErrContent2 = - readPersistentLoggingConfig(complete_test_path + std::string("persistent-logging_test_3.json")); + ReadPersistentLoggingConfig(complete_test_path + std::string("persistent-logging_test_3.json")); gPerLogConfErrContent3 = - readPersistentLoggingConfig(complete_test_path + std::string("persistent-logging_test_4.json")); + ReadPersistentLoggingConfig(complete_test_path + std::string("persistent-logging_test_4.json")); gPerLogConfErrContent4 = - readPersistentLoggingConfig(complete_test_path + std::string("persistent-logging_test_5.json")); + ReadPersistentLoggingConfig(complete_test_path + std::string("persistent-logging_test_5.json")); gPerLogConfErrContent5 = - readPersistentLoggingConfig(complete_test_path + std::string("persistent-logging_test_6.json")); + ReadPersistentLoggingConfig(complete_test_path + std::string("persistent-logging_test_6.json")); } virtual void TearDown() override {} }; TEST_F(DltSetLogLevelTest, JSON_OK) { - EXPECT_TRUE(gPerLogConfOk.readResult_ == score::platform::internal::PersistentLoggingConfig::ReadResult::OK); - auto& verbose_filters = gPerLogConfOk.verboseFilters_; - auto& non_verbose_filters = gPerLogConfOk.nonVerboseFilters_; + EXPECT_TRUE(gPerLogConfOk.read_result == score::platform::internal::PersistentLoggingConfig::ReadResult::kOk); + auto& verbose_filters = gPerLogConfOk.verbose_filters; + auto& non_verbose_filters = gPerLogConfOk.non_verbose_filters; VerbFilterType conv_verbose_filter; for (const auto& filter : verbose_filters) { char temp_buf[8] = {0}; - std::memcpy(temp_buf, filter.appid_.GetStringView().data(), 4); + std::memcpy(temp_buf, filter.appid.GetStringView().data(), 4); std::string app_id(temp_buf); - std::memcpy(temp_buf, filter.ctxid_.GetStringView().data(), 4); + std::memcpy(temp_buf, filter.ctxid.GetStringView().data(), 4); std::string ctxid(temp_buf); - conv_verbose_filter.emplace_back(app_id, ctxid, filter.logLevel_); + conv_verbose_filter.emplace_back(app_id, ctxid, filter.log_level); } using LmbTpl = std::tuple; @@ -123,44 +123,44 @@ TEST_F(DltSetLogLevelTest, JSON_OK) TEST_F(DltSetLogLevelTest, NO_JSON_FILE) { - EXPECT_TRUE(gPerLogConfErrOpn.readResult_ == - score::platform::internal::PersistentLoggingConfig::ReadResult::ERROR_OPEN); + EXPECT_TRUE(gPerLogConfErrOpn.read_result == + score::platform::internal::PersistentLoggingConfig::ReadResult::kErrorOpen); } TEST_F(DltSetLogLevelTest, JSON_FILE_ERROR) { - EXPECT_TRUE(gPerLogConfErrParse.readResult_ == - score::platform::internal::PersistentLoggingConfig::ReadResult::ERROR_PARSE); + EXPECT_TRUE(gPerLogConfErrParse.read_result == + score::platform::internal::PersistentLoggingConfig::ReadResult::kErrorParse); } TEST_F(DltSetLogLevelTest, JSON_ERROR_NO_FILTERS) { - EXPECT_TRUE(gPerLogConfErrContent1.readResult_ == - score::platform::internal::PersistentLoggingConfig::ReadResult::ERROR_CONTENT); + EXPECT_TRUE(gPerLogConfErrContent1.read_result == + score::platform::internal::PersistentLoggingConfig::ReadResult::kErrorContent); } TEST_F(DltSetLogLevelTest, JSON_ERROR_VERBOSE_FILTERS) { - EXPECT_TRUE(gPerLogConfErrContent2.readResult_ == - score::platform::internal::PersistentLoggingConfig::ReadResult::ERROR_CONTENT); + EXPECT_TRUE(gPerLogConfErrContent2.read_result == + score::platform::internal::PersistentLoggingConfig::ReadResult::kErrorContent); } TEST_F(DltSetLogLevelTest, JSON_ERROR_VERBOSE_FILTERS_NOT_STRING) { - EXPECT_TRUE(gPerLogConfErrContent3.readResult_ == - score::platform::internal::PersistentLoggingConfig::ReadResult::ERROR_CONTENT); + EXPECT_TRUE(gPerLogConfErrContent3.read_result == + score::platform::internal::PersistentLoggingConfig::ReadResult::kErrorContent); } TEST_F(DltSetLogLevelTest, JSON_ERROR_NON_VERBOSE_FILTERS_NOT_STRING) { - EXPECT_TRUE(gPerLogConfErrContent4.readResult_ == - score::platform::internal::PersistentLoggingConfig::ReadResult::ERROR_CONTENT); + EXPECT_TRUE(gPerLogConfErrContent4.read_result == + score::platform::internal::PersistentLoggingConfig::ReadResult::kErrorContent); } TEST_F(DltSetLogLevelTest, JSON_ERROR_NON_VERBOSE_FILTERS) { - EXPECT_TRUE(gPerLogConfErrContent5.readResult_ == - score::platform::internal::PersistentLoggingConfig::ReadResult::ERROR_CONTENT); + EXPECT_TRUE(gPerLogConfErrContent5.read_result == + score::platform::internal::PersistentLoggingConfig::ReadResult::kErrorContent); } } // namespace internal diff --git a/score/datarouter/test/ut/ut_logging/test_socketserver_config.cpp b/score/datarouter/test/ut/ut_logging/test_socketserver_config.cpp index 19fc835..90f4d5e 100644 --- a/score/datarouter/test/ut/ut_logging/test_socketserver_config.cpp +++ b/score/datarouter/test/ut/ut_logging/test_socketserver_config.cpp @@ -49,17 +49,17 @@ std::string TypeName() TEST(SocketserverConfigTest, FilterFactoryDefault) { - const auto factory = ::score::platform::datarouter::getFilterFactory(); + const auto factory = ::score::platform::datarouter::GetFilterFactory(); EXPECT_TRUE(factory); EXPECT_FALSE(factory("", ::score::platform::DataFilter{})); } TEST(SocketserverConfigTest, FilterFactoryLogEntry) { - const auto factory = ::score::platform::datarouter::getFilterFactory(); + const auto factory = ::score::platform::datarouter::GetFilterFactory(); using ::score::mw::log::detail::LogEntry; - using ::score::platform::dltid_t; + using ::score::platform::DltidT; using ::score::platform::internal::LogEntryFilter; using S = ::score::common::visitor::logging_serializer; @@ -114,85 +114,85 @@ std::string PrepareLogChannelsPath(const std::string& file_name) return override_path; } -// readStaticDlt unit tests +// ReadStaticDlt unit tests TEST(SocketserverConfigTest, ReadCorrectLogChannelsNoErrorsExpected) { - const auto result = readStaticDlt(PrepareLogChannelsPath("log-channels.json").c_str()); + const auto result = ReadStaticDlt(PrepareLogChannelsPath("log-channels.json").c_str()); EXPECT_TRUE(result.has_value()); EXPECT_THAT(result.value().channels, SizeIs(3)); - EXPECT_THAT(result.value().channelAssignments, SizeIs(2)); - EXPECT_THAT(result.value().messageThresholds, SizeIs(3)); - EXPECT_TRUE(result.value().filteringEnabled); + EXPECT_THAT(result.value().channel_assignments, SizeIs(2)); + EXPECT_THAT(result.value().message_thresholds, SizeIs(3)); + EXPECT_TRUE(result.value().filtering_enabled); } TEST(SocketserverConfigTest, ReadNonExistingPathErrorExpected) { - const auto result = readStaticDlt(""); + const auto result = ReadStaticDlt(""); EXPECT_FALSE(result.has_value()); } TEST(SocketserverConfigTest, ReadEmptyLogChannelErrorExpected) { - const auto result = readStaticDlt(PrepareLogChannelsPath("log-channels-empty.json").c_str()); + const auto result = ReadStaticDlt(PrepareLogChannelsPath("log-channels-empty.json").c_str()); EXPECT_FALSE(result.has_value()); } TEST(SocketserverConfigTest, JsonWithoutChannelsErrorExpected) { - const auto result = readStaticDlt(PrepareLogChannelsPath("log-channels-without-channels.json").c_str()); + const auto result = ReadStaticDlt(PrepareLogChannelsPath("log-channels-without-channels.json").c_str()); EXPECT_FALSE(result.has_value()); } TEST(SocketserverConfigTest, JsonEmptyChannelsErrorExpected) { - const auto result = readStaticDlt(PrepareLogChannelsPath("log-channels-empty-channels.json").c_str()); + const auto result = ReadStaticDlt(PrepareLogChannelsPath("log-channels-empty-channels.json").c_str()); EXPECT_FALSE(result.has_value()); } TEST(SocketserverConfigTest, JsonFilteringEnabledExpectConfigFilterTrue) { - const auto result = readStaticDlt(PrepareLogChannelsPath("log-channels-filtering-enabled.json").c_str()); + const auto result = ReadStaticDlt(PrepareLogChannelsPath("log-channels-filtering-enabled.json").c_str()); EXPECT_TRUE(result.has_value()); - EXPECT_TRUE(result.value().filteringEnabled); + EXPECT_TRUE(result.value().filtering_enabled); } TEST(SocketserverConfigTest, JsonQuotasEnabledExpectConfigFilterTrue) { - const auto result = readStaticDlt(PrepareLogChannelsPath("log-channels-quotas.json").c_str()); + const auto result = ReadStaticDlt(PrepareLogChannelsPath("log-channels-quotas.json").c_str()); ASSERT_TRUE(result.has_value()); - EXPECT_EQ(result.value().throughput.overallMbps, 100); - EXPECT_FALSE(result.value().quotaEnforcementEnabled); - EXPECT_THAT(result.value().throughput.applicationsKbps, SizeIs(1)); + EXPECT_EQ(result.value().throughput.overall_mbps, 100); + EXPECT_FALSE(result.value().quota_enforcement_enabled); + EXPECT_THAT(result.value().throughput.applications_kbps, SizeIs(1)); } TEST(SocketserverConfigTest, JsonQuotasEnabledActivated) { - const auto result = readStaticDlt(PrepareLogChannelsPath("log-channels-quotas-activated.json").c_str()); + const auto result = ReadStaticDlt(PrepareLogChannelsPath("log-channels-quotas-activated.json").c_str()); ASSERT_TRUE(result.has_value()); - EXPECT_TRUE(result.value().quotaEnforcementEnabled); + EXPECT_TRUE(result.value().quota_enforcement_enabled); } TEST(SocketserverConfigTest, JsonQuotasEnabledDeactivated) { - const auto result = readStaticDlt(PrepareLogChannelsPath("log-channels-quotas-deactivated.json").c_str()); + const auto result = ReadStaticDlt(PrepareLogChannelsPath("log-channels-quotas-deactivated.json").c_str()); ASSERT_TRUE(result.has_value()); - EXPECT_FALSE(result.value().quotaEnforcementEnabled); + EXPECT_FALSE(result.value().quota_enforcement_enabled); } TEST(SocketserverConfigTest, JsonOldFormatErrorExpected) { - const auto result = readStaticDlt(PrepareLogChannelsPath("log-channels-old-format.json").c_str()); + const auto result = ReadStaticDlt(PrepareLogChannelsPath("log-channels-old-format.json").c_str()); EXPECT_FALSE(result.has_value()); } -// readDlt unit tests +// ReadDlt unit tests TEST(SocketserverConfigTest, PersistentDictionaryEmptyJsonErrorExpected) { StrictMock pd; EXPECT_CALL(pd, GetString(StrEq("dltConfig"), "{}")).Times(1).WillOnce(Return("{}")); - const auto result = readDlt(pd); + const auto result = ReadDlt(pd); EXPECT_THAT(result.channels, SizeIs(0)); } @@ -210,11 +210,11 @@ TEST(SocketserverConfigTest, PersistentDictionaryCorrectJsonNoErrorsExpected) StrictMock pd; EXPECT_CALL(pd, GetString(StrEq("dltConfig"), "{}")).Times(1).WillOnce(Return(expected_json)); - const auto result = readDlt(pd); - EXPECT_TRUE(result.filteringEnabled); + const auto result = ReadDlt(pd); + EXPECT_TRUE(result.filtering_enabled); EXPECT_THAT(result.channels, SizeIs(3)); - EXPECT_THAT(result.channelAssignments, SizeIs(2)); - EXPECT_THAT(result.messageThresholds, SizeIs(3)); + EXPECT_THAT(result.channel_assignments, SizeIs(2)); + EXPECT_THAT(result.message_thresholds, SizeIs(3)); } TEST(SocketserverConfigTest, PersistentDictionaryEmptyChannelsErrorExpected) @@ -227,7 +227,7 @@ TEST(SocketserverConfigTest, PersistentDictionaryEmptyChannelsErrorExpected) StrictMock pd; EXPECT_CALL(pd, GetString(StrEq("dltConfig"), "{}")).Times(1).WillOnce(Return(expected_json)); - const auto result = readDlt(pd); + const auto result = ReadDlt(pd); EXPECT_THAT(result.channels, SizeIs(0)); } @@ -245,26 +245,26 @@ TEST(SocketserverConfigTest, PersistentDictionaryNoFilteringEnabledExpectTrueByD StrictMock pd; EXPECT_CALL(pd, GetString(StrEq("dltConfig"), "{}")).Times(1).WillOnce(Return(expected_json)); - const auto result = readDlt(pd); - EXPECT_TRUE(result.filteringEnabled); + const auto result = ReadDlt(pd); + EXPECT_TRUE(result.filtering_enabled); } -// writeDltEnabled unit test +// WriteDltEnabled unit test TEST(SocketserverConfigTest, WriteDltEnabledCallSetBoolExpected) { StrictMock pd; EXPECT_CALL(pd, SetBool(StrEq("dltOutputEnabled"), true)).Times(1); - writeDltEnabled(true, pd); + WriteDltEnabled(true, pd); } -// readDltEnabled unit test +// ReadDltEnabled unit test TEST(SocketserverConfigTest, ReadDltEnabledTrueResultExpected) { StrictMock pd; EXPECT_CALL(pd, GetBool(StrEq("dltOutputEnabled"), true)).WillOnce(Return(true)); - const auto result = readDltEnabled(pd); + const auto result = ReadDltEnabled(pd); EXPECT_TRUE(result); } @@ -278,13 +278,13 @@ TEST(SocketserverConfigTest, WriteDltFilledPersistentConfigNoErrorExpected) "\"111\":\"kVerbose\"}}}"}; StrictMock pd; score::logging::dltserver::PersistentConfig config; - config.filteringEnabled = true; + config.filtering_enabled = true; config.channels["3491"] = {mw::log::LogLevel::kVerbose}; - config.defaultThreshold = mw::log::LogLevel::kVerbose; - config.channelAssignments[dltid_t("000")][dltid_t("111")].push_back(dltid_t("22222")); - config.messageThresholds[dltid_t("000")][dltid_t("111")] = mw::log::LogLevel::kVerbose; + config.default_threshold = mw::log::LogLevel::kVerbose; + config.channel_assignments[DltidT("000")][DltidT("111")].push_back(DltidT("22222")); + config.message_thresholds[DltidT("000")][DltidT("111")] = mw::log::LogLevel::kVerbose; EXPECT_CALL(pd, SetString(StrEq("dltConfig"), expected_json)).Times(1); - writeDlt(config, pd); + WriteDlt(config, pd); } // defaultThresold typo tests @@ -293,34 +293,34 @@ TEST(SocketserverConfigTest, WriteDltFilledPersistentConfigNoErrorExpected) TEST(SocketserverConfigTest, DefaultThresholdValuePresentTakeIt) { - const auto result = readStaticDlt(PrepareLogChannelsPath("log-channels-default-threshold.json").c_str()); + const auto result = ReadStaticDlt(PrepareLogChannelsPath("log-channels-default-threshold.json").c_str()); EXPECT_TRUE(result.has_value()); const auto expected_log_level_threshold = mw::log::LogLevel::kDebug; - EXPECT_EQ(result.value().defaultThreshold, expected_log_level_threshold); + EXPECT_EQ(result.value().default_threshold, expected_log_level_threshold); } TEST(SocketserverConfigTest, DefaultThresoldValuePresentTakeIt) { - const auto result = readStaticDlt(PrepareLogChannelsPath("log-channels-default-thresold.json").c_str()); + const auto result = ReadStaticDlt(PrepareLogChannelsPath("log-channels-default-thresold.json").c_str()); EXPECT_TRUE(result.has_value()); const auto expected_log_level_threshold = mw::log::LogLevel::kDebug; - EXPECT_EQ(result.value().defaultThreshold, expected_log_level_threshold); + EXPECT_EQ(result.value().default_threshold, expected_log_level_threshold); } TEST(SocketserverConfigTest, BothValuesPresentTakeDefaultThreshold) { - const auto result = readStaticDlt(PrepareLogChannelsPath("log-channels-thresold-and-threshold.json").c_str()); + const auto result = ReadStaticDlt(PrepareLogChannelsPath("log-channels-thresold-and-threshold.json").c_str()); EXPECT_TRUE(result.has_value()); const auto expected_log_level_threshold = mw::log::LogLevel::kInfo; - EXPECT_EQ(result.value().defaultThreshold, expected_log_level_threshold); + EXPECT_EQ(result.value().default_threshold, expected_log_level_threshold); } TEST(SocketserverConfigTest, NoValuesSetkVerboseAsDefault) { - const auto result = readStaticDlt(PrepareLogChannelsPath("log-channels-no-default-threshold.json").c_str()); + const auto result = ReadStaticDlt(PrepareLogChannelsPath("log-channels-no-default-threshold.json").c_str()); EXPECT_TRUE(result.has_value()); const auto expected_log_level_threshold = mw::log::LogLevel::kVerbose; - EXPECT_EQ(result.value().defaultThreshold, expected_log_level_threshold); + EXPECT_EQ(result.value().default_threshold, expected_log_level_threshold); } TEST(SocketserverConfigTest, GetStringCallExpected) diff --git a/score/datarouter/test/ut/ut_logging/test_udp_stream_output.cpp b/score/datarouter/test/ut/ut_logging/test_udp_stream_output.cpp index f7f33cc..59477e4 100644 --- a/score/datarouter/test/ut/ut_logging/test_udp_stream_output.cpp +++ b/score/datarouter/test/ut/ut_logging/test_udp_stream_output.cpp @@ -118,7 +118,7 @@ TEST_F(UdpStreamOutputFixture, BindMethodShallNotReturnValueInCaseOfFailure) stream_output_ = std::make_unique(addr_, port_, multicast_interface_, std::move(sock_mock_)); // And calling UdpStreamOutput's bind method. - auto ret = stream_output_->bind(); + auto ret = stream_output_->Bind(); // It shall fail. EXPECT_FALSE(ret.has_value()); @@ -135,7 +135,7 @@ TEST_F(UdpStreamOutputFixture, BindMethodShallReturnValueIfItSucceeded) stream_output_ = std::make_unique(addr_, port_, multicast_interface_, std::move(sock_mock_)); // And calling UdpStreamOutput's bind method. - auto ret = stream_output_->bind(); + auto ret = stream_output_->Bind(); // It shall succeed. EXPECT_TRUE(ret.has_value()); @@ -156,7 +156,7 @@ TEST_F(UdpStreamOutputFixture, SendMethodShallFailIfSendmmsgFailed) // And calling UdpStreamOutput's send method. score::cpp::span mmsg_span(mmsg_hdr_array, size); - auto ret = stream_output_->send(mmsg_span); + auto ret = stream_output_->Send(mmsg_span); // It shall fail. EXPECT_FALSE(ret.has_value()); @@ -181,7 +181,7 @@ TEST_F(UdpStreamOutputFixture, SendMethodShallSucceedIfSendmmsgSucceeded) // And calling UdpStreamOutput's send method. score::cpp::span mmsg_span(mmsg_hdr_array, size); - auto ret = stream_output_->send(mmsg_span); + auto ret = stream_output_->Send(mmsg_span); // It shall succeed. EXPECT_TRUE(ret.has_value()); @@ -206,7 +206,7 @@ TEST_F(UdpStreamOutputFixture, SendMethodShallSucceedIfSendmmsgSucceededWithMmsg // And calling UdpStreamOutput's send method. score::cpp::span mmsg_span(mmsg_hdr_array, size); - auto ret = stream_output_->send(mmsg_span); + auto ret = stream_output_->Send(mmsg_span); // It shall succeed. EXPECT_TRUE(ret.has_value()); @@ -226,7 +226,7 @@ TEST_F(UdpStreamOutputFixture, SendMethodShallSucceedIfSendmsgSucceeded) stream_output_ = std::make_unique(addr_, port_, multicast_interface_, std::move(sock_mock_)); // And calling UdpStreamOutput's send method. - auto ret = stream_output_->send(io_vec, size); + auto ret = stream_output_->Send(io_vec, size); // It shall fail. EXPECT_FALSE(ret.has_value()); @@ -250,7 +250,7 @@ TEST_F(UdpStreamOutputFixture, SendMethodShallFailIfSendmsgFailed) stream_output_ = std::make_unique(addr_, port_, multicast_interface_, std::move(sock_mock_)); // And calling UdpStreamOutput's send method. - auto ret = stream_output_->send(io_vec, size); + auto ret = stream_output_->Send(io_vec, size); // It shall succeed. EXPECT_TRUE(ret.has_value()); diff --git a/score/datarouter/test/ut/ut_logging/test_unix_domain_server.cpp b/score/datarouter/test/ut/ut_logging/test_unix_domain_server.cpp index 5cfdbfd..4fe1299 100644 --- a/score/datarouter/test/ut/ut_logging/test_unix_domain_server.cpp +++ b/score/datarouter/test/ut/ut_logging/test_unix_domain_server.cpp @@ -34,9 +34,9 @@ class ISessionMock : public UnixDomainServer::ISession public: ISessionMock(UnixDomainServer::SessionHandle /*h*/) {} - MOCK_METHOD(bool, tick, (), (override)); - MOCK_METHOD(void, on_closed_by_peer, (), (override)); - MOCK_METHOD(void, on_command, (const std::string&), (override)); + MOCK_METHOD(bool, Tick, (), (override)); + MOCK_METHOD(void, OnClosedByPeer, (), (override)); + MOCK_METHOD(void, OnCommand, (const std::string&), (override)); }; class UnixDomainServer::SessionWrapper::SessionWrapperTest : public UnixDomainServer::SessionWrapper @@ -63,16 +63,16 @@ class UnixDomainServer::UnixDomainServerTest : public UnixDomainServer } using UnixDomainServer::ConnectionState; - using UnixDomainServer::enqueue_tick_direct; - using UnixDomainServer::process_queue; + using UnixDomainServer::EnqueueTickDirect; + using UnixDomainServer::ProcessQueue; using UnixDomainServer::work_queue_; // Expose extracted methods for testing - using UnixDomainServer::cleanup_all_connections; - using UnixDomainServer::process_active_connections; - using UnixDomainServer::process_idle_connections; - using UnixDomainServer::process_server_iteration; - using UnixDomainServer::setup_server_socket; + using UnixDomainServer::CleanupAllConnections; + using UnixDomainServer::ProcessActiveConnections; + using UnixDomainServer::ProcessIdleConnections; + using UnixDomainServer::ProcessServerIteration; + using UnixDomainServer::SetupServerSocket; }; class UnixDomainServerMock : public UnixDomainServer @@ -84,7 +84,7 @@ class UnixDomainServerMock : public UnixDomainServer { } - MOCK_METHOD(void, enqueue_tick_direct, (std::int32_t fd), (override)); + MOCK_METHOD(void, EnqueueTickDirect, (std::int32_t fd), (override)); }; namespace dummy_namespace @@ -92,36 +92,36 @@ namespace dummy_namespace TEST(TempMarker, TickAlwaysFalse) { - temp_marker m; - EXPECT_FALSE(m.tick()); - EXPECT_NO_FATAL_FAILURE(m.on_command("anything")); - EXPECT_NO_FATAL_FAILURE(m.on_closed_by_peer()); + TempMarker m; + EXPECT_FALSE(m.Tick()); + EXPECT_NO_FATAL_FAILURE(m.OnCommand("anything")); + EXPECT_NO_FATAL_FAILURE(m.OnClosedByPeer()); } TEST(TempMarker, PolymorphicThroughISession) { - std::unique_ptr p = std::make_unique(); - EXPECT_FALSE(p->tick()); - EXPECT_NO_FATAL_FAILURE(p->on_command("cmd")); - EXPECT_NO_FATAL_FAILURE(p->on_closed_by_peer()); + std::unique_ptr p = std::make_unique(); + EXPECT_FALSE(p->Tick()); + EXPECT_NO_FATAL_FAILURE(p->OnCommand("cmd")); + EXPECT_NO_FATAL_FAILURE(p->OnClosedByPeer()); } class StubISession : public UnixDomainServer::ISession { public: - bool tick() override + bool Tick() override { return true; } - // no overrides for on_command() or on_closed_by_peer() + // no overrides for OnCommand() or OnClosedByPeer() }; TEST(ISessionTest, ISessionTestSuccessfully) { StubISession m; - EXPECT_TRUE(m.tick()); - EXPECT_NO_FATAL_FAILURE(m.on_command("anything")); - EXPECT_NO_FATAL_FAILURE(m.on_closed_by_peer()); + EXPECT_TRUE(m.Tick()); + EXPECT_NO_FATAL_FAILURE(m.OnCommand("anything")); + EXPECT_NO_FATAL_FAILURE(m.OnClosedByPeer()); } TEST(SessionWrapperTest, HandleCommand) @@ -132,41 +132,41 @@ TEST(SessionWrapperTest, HandleCommand) bool tick_called = false; std::string last_command{}; bool closed_by_peer_called = false; - EXPECT_CALL(server_mock, enqueue_tick_direct(kServerFd)); + EXPECT_CALL(server_mock, EnqueueTickDirect(kServerFd)); UnixDomainServer::SessionWrapper::SessionWrapperTest session_test(&server_mock, kServerFd); auto isession_mock = std::make_unique(UnixDomainServer::SessionHandle{kServerFd}); ISessionMock* raw_isession_mock_ptr = isession_mock.get(); - EXPECT_CALL(*raw_isession_mock_ptr, tick()).WillRepeatedly([&tick_called]() { + EXPECT_CALL(*raw_isession_mock_ptr, Tick()).WillRepeatedly([&tick_called]() { tick_called = true; return false; }); - EXPECT_CALL(*raw_isession_mock_ptr, on_closed_by_peer()).WillRepeatedly([&closed_by_peer_called]() { + EXPECT_CALL(*raw_isession_mock_ptr, OnClosedByPeer()).WillRepeatedly([&closed_by_peer_called]() { closed_by_peer_called = true; }); session_test.session_ = std::move(isession_mock); std::string test_command = "test_command"; - EXPECT_CALL(*raw_isession_mock_ptr, on_command(test_command)) + EXPECT_CALL(*raw_isession_mock_ptr, OnCommand(test_command)) .WillRepeatedly([&last_command](const std::string& command) { last_command = command; }); - bool result = session_test.handle_command(test_command, kPeerPid); + bool result = session_test.HandleCommand(test_command, kPeerPid); EXPECT_TRUE(result); EXPECT_EQ(last_command, test_command); - bool tick_result = session_test.tick(); + bool tick_result = session_test.Tick(); EXPECT_FALSE(tick_result); EXPECT_TRUE(tick_called); - session_test.notify_closed_by_peer(); + session_test.NotifyClosedByPeer(); EXPECT_TRUE(closed_by_peer_called); } class EnqueueSession : public UnixDomainServer::ISession { public: - bool tick() override + bool Tick() override { return true; } @@ -181,7 +181,7 @@ TEST(SessionWrapperTest, TryEnqueueForDeleteWithSessionAlreadyRunningNoEnqueue) wrapper.running_ = true; wrapper.enqueued_ = false; - bool result = wrapper.try_enqueue_for_delete(false); + bool result = wrapper.TryEnqueueForDelete(false); EXPECT_TRUE(result); } @@ -191,7 +191,7 @@ TEST(SessionWrapperTest, TryEnqueueForDeleteWithSessionTriggersEnqueue) constexpr std::uint8_t kServerFd = 42U; uint8_t enqueue_call_count = 0U; std::int32_t last_fd = 0U; - EXPECT_CALL(server_mock, enqueue_tick_direct(kServerFd)) + EXPECT_CALL(server_mock, EnqueueTickDirect(kServerFd)) .WillRepeatedly([&enqueue_call_count, &last_fd](std::int32_t fd) { ++enqueue_call_count; last_fd = fd; @@ -201,7 +201,7 @@ TEST(SessionWrapperTest, TryEnqueueForDeleteWithSessionTriggersEnqueue) wrapper.running_ = false; wrapper.enqueued_ = false; - bool result = wrapper.try_enqueue_for_delete(true); + bool result = wrapper.TryEnqueueForDelete(true); EXPECT_TRUE(result); EXPECT_EQ(enqueue_call_count, 1); EXPECT_EQ(last_fd, kServerFd); @@ -215,12 +215,12 @@ TEST(SessionWrapperTest, TryEnqueueForDeleteWithSessionTriggersEnqueue) namespace { -// we will reuse your temp_marker -using dummy_namespace::temp_marker; +// we will reuse your TempMarker +using dummy_namespace::TempMarker; -// a tiny factory that always returns a temp_marker +// a tiny factory that always returns a TempMarker const UnixDomainServer::SessionFactory kFactory = [](const std::string&, UnixDomainServer::SessionHandle) { - return std::make_unique(); + return std::make_unique(); }; class CountingSession : public UnixDomainServer::ISession @@ -230,12 +230,12 @@ class CountingSession : public UnixDomainServer::ISession { ++gConstructed; } - bool tick() override + bool Tick() override { ++gTicks; return false; } - void on_command(const std::string&) override + void OnCommand(const std::string&) override { ++gCommands; } @@ -271,11 +271,11 @@ UnixDomainSockAddr MakeTempAddrAbstractFalse(std::string& name) TEST(UnixDomainSockAddr, NonAbstractRoundTrip) { UnixDomainSockAddr addr("datarouter_socket", false); - EXPECT_FALSE(addr.is_abstract()); - const char* s = addr.get_address_string(); + EXPECT_FALSE(addr.IsAbstract()); + const char* s = addr.GetAddressString(); // since we constructed with isAbstract=false, sun_path[0] ≠ '\0' EXPECT_NE(s[0], '\0'); - EXPECT_STREQ(s, addr.addr_.sun_path); + EXPECT_STREQ(s, addr.addr.sun_path); } TEST(UnixDomainServerSessionWrapper, BasicFlagsAndTimeout) @@ -284,17 +284,17 @@ TEST(UnixDomainServerSessionWrapper, BasicFlagsAndTimeout) UnixDomainServer server(addr, UnixDomainServer::SessionFactory()); UnixDomainServer::SessionWrapper w(&server, /*fd=*/7); - EXPECT_FALSE(w.is_marked_for_delete()); - EXPECT_FALSE(w.get_reset_closed_by_peer()); + EXPECT_FALSE(w.IsMarkedForDelete()); + EXPECT_FALSE(w.GetResetClosedByPeer()); // before a real session_ is constructed, handle_command("") returns now(::getpid()))); + EXPECT_TRUE(w.HandleCommand("someName", score::cpp::nullopt)); + EXPECT_TRUE(w.HandleCommand("someName", score::cpp::nullopt)); + EXPECT_TRUE(w.HandleCommand("subscriberName", /*peer_pid=*/static_cast(::getpid()))); } TEST(UnixDomainServerAcceptTest, AcceptsOneClientConnection) @@ -436,9 +436,9 @@ TEST(UnixDomainServerHandleCmd, AllBranchesViaFramedMessages) ASSERT_EQ(::connect(cfd, reinterpret_cast(&su), sizeof(su)), 0) << strerror(errno); // send messages using the correct framing helper - send_socket_message(cfd, std::string("subName")); - send_socket_message(cfd, std::string("cmd1")); - send_socket_message(cfd, std::string("cmd2")); + SendSocketMessage(cfd, std::string("subName")); + SendSocketMessage(cfd, std::string("cmd1")); + SendSocketMessage(cfd, std::string("cmd2")); // give the worker thread some time to dequeue & process for (int i = 0; i < 50 && CountingSession::gTicks.load() == 0; ++i) @@ -496,11 +496,11 @@ class CommandErrorInjectingSession : public UnixDomainServer::ISession { public: explicit CommandErrorInjectingSession(UnixDomainServer::SessionHandle) {} - bool tick() override + bool Tick() override { return false; } - void on_command(const std::string&) override + void OnCommand(const std::string&) override { throw std::runtime_error("boom!"); } @@ -535,7 +535,7 @@ TEST(UnixDomainServerExceptions, CatchStdExceptionInServerRoutine) const char* subscribe = "subName"; ASSERT_EQ(::send(cfd, subscribe, strlen(subscribe), 0), static_cast(strlen(subscribe))); - /* second message -> on_command() causes error */ + /* second message -> OnCommand() causes error */ const char* bad_msg = "this_will_cause_error"; ASSERT_EQ(::send(cfd, bad_msg, strlen(bad_msg), 0), static_cast(strlen(bad_msg))); @@ -557,11 +557,11 @@ class CloseAwareSession : public UnixDomainServer::ISession public: explicit CloseAwareSession(UnixDomainServer::SessionHandle /*h*/) {} - bool tick() override + bool Tick() override { return false; } // no re‑queue - void on_closed_by_peer() override + void OnClosedByPeer() override { ++gPeerClosed; } // mark call @@ -598,7 +598,7 @@ TEST(UnixDomainServer, NotifiesClosedByPeer) ASSERT_EQ(::connect(cfd, reinterpret_cast(&su), sizeof(su)), 0) << strerror(errno); - send_socket_message(cfd, std::string("subscriber")); + SendSocketMessage(cfd, std::string("subscriber")); // grace interval for server to accept and build the session std::this_thread::sleep_for(std::chrono::milliseconds(80)); @@ -620,7 +620,7 @@ class RequeueSession : public UnixDomainServer::ISession public: explicit RequeueSession(UnixDomainServer::SessionHandle /*h*/) {} - bool tick() override + bool Tick() override { ++gTicks; return gTicks.load() == 1; // true once, false afterwards @@ -659,7 +659,7 @@ TEST(UnixDomainServer, WorkerRequeuesOnTrueTick) ASSERT_EQ(::connect(cfd, reinterpret_cast(&su), sizeof(su)), 0) << strerror(errno); // send a name so server builds the session - send_socket_message(cfd, std::string("subscriber")); + SendSocketMessage(cfd, std::string("subscriber")); // wait until the worker thread has processed the session at least twice // (first tick returns true -> re‑queue, second tick returns false) @@ -677,11 +677,11 @@ class ErrorInjectingSession : public UnixDomainServer::ISession { public: explicit ErrorInjectingSession(UnixDomainServer::SessionHandle /*h*/) {} - bool tick() override + bool Tick() override { - throw std::runtime_error("boom from tick()"); + throw std::runtime_error("boom from Tick()"); } - void on_command(const std::string&) override {} + void OnCommand(const std::string&) override {} }; // simple factory that builds a ErrorInjectingSession @@ -711,7 +711,7 @@ TEST(UnixDomainServer, ServerCatchesSessionFailure) ssize_t n = ::send(cfd, sub, std::strlen(sub), 0); ASSERT_EQ(n, static_cast(std::strlen(sub))) << strerror(errno); - /* give the server thread enough time to dequeue & run tick() (⇒ error) */ + /* give the server thread enough time to dequeue & run Tick() (⇒ error) */ std::this_thread::sleep_for(std::chrono::milliseconds(250)); /* clean up the client socket */ @@ -954,7 +954,7 @@ TEST(UnixDomainCommon, SetupSignalsFailurePath) TEST(UnixDomainServerExtractedMethods, ProcessIdleConnectionsRemovesOrphanedFd) { - // Test orphaned FD cleanup in process_idle_connections + // Test orphaned FD cleanup in ProcessIdleConnections UnixDomainServer::UnixDomainServerTest::ConnectionState state; // Add server FD at index 0 (skipped by loop) @@ -974,7 +974,7 @@ TEST(UnixDomainServerExtractedMethods, ProcessIdleConnectionsRemovesOrphanedFd) ASSERT_EQ(state.connection_pollfd_list.size(), 2U); ASSERT_EQ(state.connection_fd_map.size(), 0U); - UnixDomainServer::UnixDomainServerTest::process_idle_connections(state); + UnixDomainServer::UnixDomainServerTest::ProcessIdleConnections(state); // Orphaned FD removed, only server FD remains ASSERT_EQ(state.connection_pollfd_list.size(), 1U); @@ -988,7 +988,7 @@ TEST(UnixDomainServerExtractedMethods, ProcessIdleConnectionsRemovesOrphanedFd) TEST(UnixDomainServerExtractedMethods, ProcessIdleConnectionsSkipsActiveConnections) { - // Test that active connections (with POLLIN) are skipped by process_idle_connections + // Test that active connections (with POLLIN) are skipped by ProcessIdleConnections UnixDomainServer::UnixDomainServerTest::ConnectionState state; pollfd server_pfd{}; @@ -1006,16 +1006,16 @@ TEST(UnixDomainServerExtractedMethods, ProcessIdleConnectionsSkipsActiveConnecti ASSERT_EQ(state.connection_pollfd_list.size(), 2U); - UnixDomainServer::UnixDomainServerTest::process_idle_connections(state); + UnixDomainServer::UnixDomainServerTest::ProcessIdleConnections(state); - // Size unchanged: process_idle_connections() should skip active connections (POLLIN set) + // Size unchanged: ProcessIdleConnections() should skip active connections (POLLIN set) // and only process idle ones, so both FDs remain in the list EXPECT_EQ(state.connection_pollfd_list.size(), 2U); } TEST(UnixDomainServerExtractedMethods, ProcessActiveConnectionsRemovesOrphanedFd) { - // Test orphaned FD cleanup in process_active_connections + // Test orphaned FD cleanup in ProcessActiveConnections UnixDomainServer::UnixDomainServerTest::ConnectionState state; pollfd server_pfd{}; @@ -1033,7 +1033,7 @@ TEST(UnixDomainServerExtractedMethods, ProcessActiveConnectionsRemovesOrphanedFd ASSERT_EQ(state.connection_pollfd_list.size(), 2U); ASSERT_EQ(state.connection_fd_map.size(), 0U); - UnixDomainServer::UnixDomainServerTest::process_active_connections(state); + UnixDomainServer::UnixDomainServerTest::ProcessActiveConnections(state); ASSERT_EQ(state.connection_pollfd_list.size(), 1U); EXPECT_EQ(state.connection_pollfd_list[0].fd, 1); diff --git a/score/datarouter/test/ut/ut_logging/test_verbose_dlt.cpp b/score/datarouter/test/ut/ut_logging/test_verbose_dlt.cpp index 1d754de..054dfef 100644 --- a/score/datarouter/test/ut/ut_logging/test_verbose_dlt.cpp +++ b/score/datarouter/test/ut/ut_logging/test_verbose_dlt.cpp @@ -23,7 +23,7 @@ class MockDltVerboseHandlerOutput : public DltVerboseHandler::IOutput { public: MOCK_METHOD(void, - sendVerbose, + SendVerbose, (uint32_t, const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection&), (override)); virtual ~MockDltVerboseHandlerOutput() = default; @@ -34,11 +34,11 @@ TEST(DltVerboseHandlerTest, sendVerboseTest) MockDltVerboseHandlerOutput mock_dlt_output; DltVerboseHandler handler(mock_dlt_output); - const timestamp_t timestamp = score::os::HighResolutionSteadyClock::time_point{}; + const TimestampT timestamp = score::os::HighResolutionSteadyClock::time_point{}; const char* data = "data"; - const bufsize_t data_size = static_cast(strlen(data)); + const BufsizeT data_size = static_cast(strlen(data)); - EXPECT_CALL(mock_dlt_output, sendVerbose(_, _)).Times(1); + EXPECT_CALL(mock_dlt_output, SendVerbose(_, _)).Times(1); - handler.handle(timestamp, data, data_size); + handler.Handle(timestamp, data, data_size); } diff --git a/score/datarouter/test/utils/data_router_test_utils.h b/score/datarouter/test/utils/data_router_test_utils.h index a491c8d..02a5ac1 100644 --- a/score/datarouter/test/utils/data_router_test_utils.h +++ b/score/datarouter/test/utils/data_router_test_utils.h @@ -46,7 +46,7 @@ struct TestTypeInfo template TestTypeInfo CreateTypeInfo() { - constexpr static std::size_t kIdsize = score::platform::dltid_t::size(); + constexpr static std::size_t kIdsize = score::platform::DltidT::size(); const std::string app_prefix(kIdsize * 3, char{0}); TestTypeInfo type_info{}; type_info.type_params = app_prefix + ::score::common::visitor::logger_type_string(); From 7cf57432bf38f74369c28c0b6572ea5f6a15a222 Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Mon, 2 Feb 2026 14:08:56 +0100 Subject: [PATCH 04/12] Enable extra clang_tidy checks for the following folders: - platform/aas/mw/log/detail GIT_ORIGIN_SPP_REV_ID: 9779b2453267c0166c1e92acfaf27bf67f8beca2 --- score/datarouter/include/dlt/dltid.h | 6 +- score/mw/log/detail/common/dlt_format.cpp | 18 +++--- .../data_router/data_router_backend.cpp | 2 +- .../data_router/data_router_backend_test.cpp | 4 +- .../data_router/data_router_recorder.cpp | 14 ++-- .../data_router/data_router_recorder_test.cpp | 10 +-- .../file_recorder/dlt_message_builder.cpp | 16 ++--- .../dlt_message_builder_test.cpp | 2 +- .../detail/file_recorder/file_recorder.cpp | 8 +-- .../file_recorder/file_recorder_test.cpp | 10 +-- score/mw/log/detail/slog/slog_backend.cpp | 2 +- .../mw/log/detail/slog/slog_backend_test.cpp | 2 +- .../alternating_control_block.h | 6 +- .../alternating_reader.cpp | 6 +- .../alternating_reader.h | 6 +- .../alternating_reader_proxy.h | 6 +- .../linear_control_block.h | 2 +- .../linear_control_block_test.cpp | 6 +- .../wait_free_producer_queue/linear_reader.h | 2 +- .../linear_reader_test.cpp | 2 +- .../wait_free_alternating_writer.h | 6 +- .../wait_free_alternating_writer_test.cpp | 22 +++---- .../wait_free_linear_writer.h | 10 +-- .../wait_free_linear_writer_test.cpp | 64 +++++++++---------- .../legacy_non_verbose_api/tracing_test.cpp | 4 +- 25 files changed, 118 insertions(+), 118 deletions(-) diff --git a/score/datarouter/include/dlt/dltid.h b/score/datarouter/include/dlt/dltid.h index 008aa26..a201d84 100644 --- a/score/datarouter/include/dlt/dltid.h +++ b/score/datarouter/include/dlt/dltid.h @@ -59,7 +59,7 @@ struct DltidT { // Determine the length of the C-string stored in bytes, // but do not exceed the size of the array. - return std::string(bytes.data_.data(), bytes.data_.size()); + return std::string(bytes.data.data(), bytes.data.size()); } bool operator==(const DltidT& id) const @@ -69,12 +69,12 @@ struct DltidT char* Data() { - return bytes.data_.data(); + return bytes.data.data(); } const char* Data() const { - return bytes.data_.data(); + return bytes.data.data(); } constexpr static size_t size() diff --git a/score/mw/log/detail/common/dlt_format.cpp b/score/mw/log/detail/common/dlt_format.cpp index 188e698..efce059 100644 --- a/score/mw/log/detail/common/dlt_format.cpp +++ b/score/mw/log/detail/common/dlt_format.cpp @@ -274,9 +274,9 @@ score::mw::log::detail::AddArgumentResult Store(score::mw::log::detail::VerboseP payload.Put(byte_view.data(), static_cast(byte_view.size())); }, data_for_payload...); - return score::mw::log::detail::AddArgumentResult::Added; + return score::mw::log::detail::AddArgumentResult::kAdded; } - return score::mw::log::detail::AddArgumentResult::NotAdded; + return score::mw::log::detail::AddArgumentResult::kNotAdded; } score::mw::log::detail::AddArgumentResult TryStore(score::mw::log::detail::VerbosePayload& payload, @@ -322,7 +322,7 @@ score::mw::log::detail::AddArgumentResult LogData(score::mw::log::detail::Verbos // LCOV_EXCL_START :we can't cover true case as type_length are constant in the calling funcion & can't control if ((type_info.Set(type_length).has_value() == false) || (type_info.Set(repr).has_value() == false)) { - return score::mw::log::detail::AddArgumentResult::NotAdded; + return score::mw::log::detail::AddArgumentResult::kNotAdded; // LCOV_EXCL_STOP } @@ -347,7 +347,7 @@ AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const bool data) noexc // LCOV_EXCL_START : we can't cover true case as TypeLength and TypeInfo are constant and harded code if (type_info.Set(TypeLength::k8Bit).has_value() == false) { - return AddArgumentResult::NotAdded; + return AddArgumentResult::kNotAdded; // LCOV_EXCL_STOP } @@ -472,7 +472,7 @@ AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const float data) noex // LCOV_EXCL_START : we can't cover true case as TypeLength and TypeInfo are constant and harded code if (type_info.Set(TypeLength::k32Bit).has_value() == false) { - return AddArgumentResult::NotAdded; + return AddArgumentResult::kNotAdded; // LCOV_EXCL_STOP } @@ -487,7 +487,7 @@ AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const double data) noe // LCOV_EXCL_START : we can't cover true case as TypeLength and TypeInfo are constant and harded code if (type_info.Set(TypeLength::k64Bit).has_value() == false) { - return AddArgumentResult::NotAdded; + return AddArgumentResult::kNotAdded; // LCOV_EXCL_STOP } @@ -502,7 +502,7 @@ AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const std::string_view // LCOV_EXCL_START : we can't cover true case as TypeLength and TypeInfo are constant and harded code if (type_info.Set(StringEncoding::kUTF8).has_value() == false) { - return AddArgumentResult::NotAdded; + return AddArgumentResult::kNotAdded; // LCOV_EXCL_STOP } @@ -524,7 +524,7 @@ AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const std::string_view if (payload.RemainingCapacity() <= kHeaderSize) { // No space left in buffer for payload. - return AddArgumentResult::NotAdded; + return AddArgumentResult::kNotAdded; } // Now figure out how many bytes we can store for the string (including null terminator). @@ -559,7 +559,7 @@ AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const LogRawBuffer dat if (payload.RemainingCapacity() <= kHeaderSize) { // No space left in buffer for payload. - return AddArgumentResult::NotAdded; + return AddArgumentResult::kNotAdded; } // Calculate how many bytes can remain for the raw buffer after the header. diff --git a/score/mw/log/detail/data_router/data_router_backend.cpp b/score/mw/log/detail/data_router/data_router_backend.cpp index 98659f7..886e0c2 100644 --- a/score/mw/log/detail/data_router/data_router_backend.cpp +++ b/score/mw/log/detail/data_router/data_router_backend.cpp @@ -97,7 +97,7 @@ void DataRouterBackend::FlushSlot(const SlotHandle& slot) noexcept { // Cast from std::uint8_t to std::size_t is valid. To prevent implicit conversion. auto& log_entry = - buffer_.GetUnderlyingBufferFor(static_cast(slot.GetSlotOfSelectedRecorder())).getLogEntry(); + buffer_.GetUnderlyingBufferFor(static_cast(slot.GetSlotOfSelectedRecorder())).GetLogEntry(); switch (log_entry.log_level) { diff --git a/score/mw/log/detail/data_router/data_router_backend_test.cpp b/score/mw/log/detail/data_router/data_router_backend_test.cpp index ad4f5ce..e502e79 100644 --- a/score/mw/log/detail/data_router/data_router_backend_test.cpp +++ b/score/mw/log/detail/data_router/data_router_backend_test.cpp @@ -201,13 +201,13 @@ class DataRouterBackendFixture : public ::testing::Test, public ::testing::WithP const auto slot = unit_.ReserveSlot().value(); auto&& log_record = unit_.GetLogRecord(slot); - auto& log_entry = log_record.getLogEntry(); + auto& log_entry = log_record.GetLogEntry(); log_entry.app_id = LoggingIdentifier{app_id}; log_entry.ctx_id = LoggingIdentifier{context_id}; log_entry.log_level = log_level; log_entry.num_of_args = 5; - log_record.getVerbosePayload().Put("ABC DEF", 7); + log_record.GetVerbosePayload().Put("ABC DEF", 7); unit_.FlushSlot(slot); diff --git a/score/mw/log/detail/data_router/data_router_recorder.cpp b/score/mw/log/detail/data_router/data_router_recorder.cpp index 0ba1aab..083c44d 100644 --- a/score/mw/log/detail/data_router/data_router_recorder.cpp +++ b/score/mw/log/detail/data_router/data_router_recorder.cpp @@ -35,14 +35,14 @@ constexpr auto kStatisticsReportInterval = std::chrono::seconds{5}; void CleanLogRecord(LogRecord& log_record) noexcept { - auto& log_entry = log_record.getLogEntry(); + auto& log_entry = log_record.GetLogEntry(); log_entry.num_of_args = 0U; log_entry.payload.clear(); } void SetContext(LogRecord& log_record, const std::string_view context_id) noexcept { - auto& log_entry = log_record.getLogEntry(); + auto& log_entry = log_record.GetLogEntry(); log_entry.ctx_id = LoggingIdentifier{context_id}; } @@ -50,7 +50,7 @@ void SetLogLevel(LogRecord& log_record, const LogLevel level) noexcept { static_assert(std::is_same::type, std::uint8_t>::value, "LogLevel is not of expected type. Static cast will be invalid."); - log_record.getLogEntry().log_level = level; + log_record.GetLogEntry().log_level = level; } } // namespace @@ -100,10 +100,10 @@ template void DataRouterRecorder::LogData(const SlotHandle& slot, const T data) noexcept { auto& log_record = backend_->GetLogRecord(slot); - DltArgumentCounter counter{log_record.getLogEntry().num_of_args}; + DltArgumentCounter counter{log_record.GetLogEntry().num_of_args}; std::ignore = counter.TryAddArgument([data, &log_record, this]() noexcept { - const auto result = DLTFormat::Log(log_record.getVerbosePayload(), data); - if (result == AddArgumentResult::NotAdded) + const auto result = DLTFormat::Log(log_record.GetVerbosePayload(), data); + if (result == AddArgumentResult::kNotAdded) { this->statistics_reporter_.IncrementMessageTooLong(); } @@ -223,7 +223,7 @@ void DataRouterRecorder::Log(const SlotHandle& slot, const LogSlog2Message data) void DataRouterRecorder::SetApplicationId(LogRecord& log_record) noexcept { - auto& log_entry = log_record.getLogEntry(); + auto& log_entry = log_record.GetLogEntry(); const auto app_id = config_.GetAppId(); log_entry.app_id = LoggingIdentifier{app_id}; } diff --git a/score/mw/log/detail/data_router/data_router_recorder_test.cpp b/score/mw/log/detail/data_router/data_router_recorder_test.cpp index f549ecb..42cb3b5 100644 --- a/score/mw/log/detail/data_router/data_router_recorder_test.cpp +++ b/score/mw/log/detail/data_router/data_router_recorder_test.cpp @@ -139,7 +139,7 @@ class DataRouterRecorderFixture : public ::testing::Test void TearDown() override { - const auto& log_entry = log_record_.getLogEntry(); + const auto& log_entry = log_record_.GetLogEntry(); const auto config_app_id = config_.GetAppId(); const auto log_entry_app_id = log_entry.app_id.GetStringView(); EXPECT_EQ(config_app_id, log_entry_app_id); @@ -168,7 +168,7 @@ TEST_F(DataRouterRecorderFixture, TooManyArgumentsWillYieldTruncatedLog) RecordProperty("TestType", "Interface test"); constexpr std::size_t kTypeInfoByteSizeAccordingToSpecification = 4; - const std::size_t number_of_arguments = log_record_.getLogEntry().payload.capacity() / + const std::size_t number_of_arguments = log_record_.GetLogEntry().payload.capacity() / (kTypeInfoByteSizeAccordingToSpecification + sizeof(std::uint32_t)); for (std::size_t i = 0; i < number_of_arguments + 5; ++i) { @@ -186,7 +186,7 @@ TEST_F(DataRouterRecorderFixture, TooLargeSinglePayloadWillYieldTruncatedLog) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - const std::size_t too_big_data_size = log_record_.getLogEntry().payload.capacity() + 1UL; + const std::size_t too_big_data_size = log_record_.GetLogEntry().payload.capacity() + 1UL; std::vector vec(too_big_data_size); std::fill(vec.begin(), vec.end(), 'o'); recorder_->Log(SlotHandle{}, std::string_view{vec.data(), too_big_data_size}); @@ -442,8 +442,8 @@ TEST(DataRouterRecorderTests, DatarouterRecorderShouldClearSlotOnStart) // Expect that the previous data is cleared. recorder->StartRecord(kContext, kActiveLogLevel); - EXPECT_EQ(log_record.getVerbosePayload().GetSpan().size(), 0); - EXPECT_EQ(log_record.getLogEntry().num_of_args, 0); + EXPECT_EQ(log_record.GetVerbosePayload().GetSpan().size(), 0); + EXPECT_EQ(log_record.GetLogEntry().num_of_args, 0); } } // namespace diff --git a/score/mw/log/detail/file_recorder/dlt_message_builder.cpp b/score/mw/log/detail/file_recorder/dlt_message_builder.cpp index ee224b2..53fce5e 100644 --- a/score/mw/log/detail/file_recorder/dlt_message_builder.cpp +++ b/score/mw/log/detail/file_recorder/dlt_message_builder.cpp @@ -49,9 +49,9 @@ void ConstructDltStandardHeaderExtra(score::mw::log::detail::DltStandardHeaderEx const score::mw::log::detail::LoggingIdentifier& ecu, const std::uint32_t tmsp) noexcept { - static_assert(sizeof(decltype(standard_extra_header.ecu)) == sizeof(decltype(ecu.data_)), + static_assert(sizeof(decltype(standard_extra_header.ecu)) == sizeof(decltype(ecu.data)), "Types storing logging ID should be the same."); - std::ignore = std::copy(ecu.data_.begin(), ecu.data_.end(), standard_extra_header.ecu.begin()); + std::ignore = std::copy(ecu.data.begin(), ecu.data.end(), standard_extra_header.ecu.begin()); // htonl is library function which uses c-style conversion // coverity[autosar_cpp14_a5_2_2_violation] standard_extra_header.tmsp = htonl(tmsp); @@ -71,12 +71,12 @@ void ConstructDltExtendedHeader(score::mw::log::detail::DltExtendedHeader& exten // static_cast operation within uint8_t range extended_header.msin = static_cast(message_info); extended_header.noar = number_of_arguments; - static_assert(sizeof(decltype(extended_header.apid)) == sizeof(decltype(app_id.data_)), + static_assert(sizeof(decltype(extended_header.apid)) == sizeof(decltype(app_id.data)), "Types storing logging ID should be the same."); - std::ignore = std::copy(app_id.data_.begin(), app_id.data_.end(), extended_header.apid.begin()); - static_assert(sizeof(decltype(extended_header.ctid)) == sizeof(decltype(ctx_id.data_)), + std::ignore = std::copy(app_id.data.begin(), app_id.data.end(), extended_header.apid.begin()); + static_assert(sizeof(decltype(extended_header.ctid)) == sizeof(decltype(ctx_id.data)), "Types storing logging ID should be the same."); - std::ignore = std::copy(ctx_id.data_.begin(), ctx_id.data_.end(), extended_header.ctid.begin()); + std::ignore = std::copy(ctx_id.data.begin(), ctx_id.data.end(), extended_header.ctid.begin()); } void ConstructStorageVerbosePacket(score::mw::log::detail::VerbosePayload& header_payload, @@ -168,7 +168,7 @@ void DltMessageBuilder::SetNextMessage(LogRecord& log_record) noexcept { log_record_ = log_record; - const auto& entry = log_record.getLogEntry(); + const auto& entry = log_record.GetLogEntry(); const auto time_stamp = TimestampT::clock::now().time_since_epoch(); const auto time_epoch = SystimeT::clock::now().time_since_epoch(); @@ -205,7 +205,7 @@ score::cpp::optional> DltMessageBuilder::Ge score::cpp::optional> return_result = {}; - detail::VerbosePayload& verbose_payload = log_record_.value().get().getVerbosePayload(); + detail::VerbosePayload& verbose_payload = log_record_.value().get().GetVerbosePayload(); switch (parsing_phase_) // LCOV_EXCL_BR_LINE: exclude the "default" branch. { case ParsingPhase::kHeader: diff --git a/score/mw/log/detail/file_recorder/dlt_message_builder_test.cpp b/score/mw/log/detail/file_recorder/dlt_message_builder_test.cpp index f948019..584b11f 100644 --- a/score/mw/log/detail/file_recorder/dlt_message_builder_test.cpp +++ b/score/mw/log/detail/file_recorder/dlt_message_builder_test.cpp @@ -47,7 +47,7 @@ class DltMessageBuilderFixture : public ::testing::Test public: void SetUp() override { - auto& log_entry = log_record_.getLogEntry(); + auto& log_entry = log_record_.GetLogEntry(); log_entry.app_id = LoggingIdentifier{"TMB"}; log_entry.ctx_id = LoggingIdentifier{"CTX"}; diff --git a/score/mw/log/detail/file_recorder/file_recorder.cpp b/score/mw/log/detail/file_recorder/file_recorder.cpp index 0d25456..7896011 100644 --- a/score/mw/log/detail/file_recorder/file_recorder.cpp +++ b/score/mw/log/detail/file_recorder/file_recorder.cpp @@ -36,8 +36,8 @@ template inline void LogData(const SlotHandle& slot, detail::Backend& backend, const T data) noexcept { auto& log_record = backend.GetLogRecord(slot); - DltArgumentCounter counter{log_record.getLogEntry().num_of_args}; - auto& payload = log_record.getVerbosePayload(); + DltArgumentCounter counter{log_record.GetLogEntry().num_of_args}; + auto& payload = log_record.GetVerbosePayload(); std::ignore = counter.TryAddArgument([data, &payload]() { const auto result = DLTFormat::Log(payload, data); return result; @@ -65,14 +65,14 @@ score::cpp::optional FileRecorder::StartRecord(const std::string_vie if (slot_handle.has_value()) { auto& log_record = backend_->GetLogRecord(slot_handle.value()); - auto& log_entry = log_record.getLogEntry(); + auto& log_entry = log_record.GetLogEntry(); const auto app_id = config_.GetAppId(); log_entry.app_id = detail::LoggingIdentifier{app_id}; log_entry.ctx_id = detail::LoggingIdentifier{context_id}; log_entry.num_of_args = 0U; log_entry.log_level = log_level; - log_record.getVerbosePayload().Reset(); + log_record.GetVerbosePayload().Reset(); } return slot_handle; } diff --git a/score/mw/log/detail/file_recorder/file_recorder_test.cpp b/score/mw/log/detail/file_recorder/file_recorder_test.cpp index bb2ca93..9b3020e 100644 --- a/score/mw/log/detail/file_recorder/file_recorder_test.cpp +++ b/score/mw/log/detail/file_recorder/file_recorder_test.cpp @@ -134,7 +134,7 @@ class FileRecorderFixture : public ::testing::Test void TearDown() override { - const auto& log_entry = log_record_.getLogEntry(); + const auto& log_entry = log_record_.GetLogEntry(); EXPECT_EQ(log_entry.ctx_id.GetStringView(), context_id_); EXPECT_EQ(log_entry.log_level, log_level_); EXPECT_EQ(log_entry.num_of_args, expected_number_of_arguments_at_teardown_); @@ -161,7 +161,7 @@ TEST_F(FileRecorderFixture, TooManyArgumentsWillYieldTruncatedLog) RecordProperty("DerivationTechnique", "Analysis of requirements"); constexpr std::size_t kTypeInfoByteSizeAccordingToSpecification = 4; - const std::size_t number_of_arguments = log_record_.getLogEntry().payload.capacity() / + const std::size_t number_of_arguments = log_record_.GetLogEntry().payload.capacity() / (kTypeInfoByteSizeAccordingToSpecification + sizeof(std::uint32_t)); for (std::size_t i = 0; i < number_of_arguments + 5; ++i) { @@ -180,7 +180,7 @@ TEST_F(FileRecorderFixture, TooLargeSinglePayloadWillYieldTruncatedLog) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const std::size_t too_big_data_size = log_record_.getLogEntry().payload.capacity() + 1UL; + const std::size_t too_big_data_size = log_record_.GetLogEntry().payload.capacity() + 1UL; std::vector vec(too_big_data_size); std::fill(vec.begin(), vec.end(), 'o'); recorder_->Log(SlotHandle{}, std::string_view{vec.data(), too_big_data_size}); @@ -455,8 +455,8 @@ TEST(FileRecorderTests, FileRecorderShouldClearSlotOnStart) // Expect that the previous data is cleared. recorder->StartRecord(kContext, kActiveLogLevel); - EXPECT_EQ(log_record.getVerbosePayload().GetSpan().size(), 0); - EXPECT_EQ(log_record.getLogEntry().num_of_args, 0); + EXPECT_EQ(log_record.GetVerbosePayload().GetSpan().size(), 0); + EXPECT_EQ(log_record.GetLogEntry().num_of_args, 0); } } // namespace diff --git a/score/mw/log/detail/slog/slog_backend.cpp b/score/mw/log/detail/slog/slog_backend.cpp index ba60880..51918a2 100644 --- a/score/mw/log/detail/slog/slog_backend.cpp +++ b/score/mw/log/detail/slog/slog_backend.cpp @@ -147,7 +147,7 @@ void SlogBackend::FlushSlot(const SlotHandle& slot) noexcept { // static cast from std::uint8_t to std::size_t auto& log_entry = - buffer_.GetUnderlyingBufferFor(static_cast(slot.GetSlotOfSelectedRecorder())).getLogEntry(); + buffer_.GetUnderlyingBufferFor(static_cast(slot.GetSlotOfSelectedRecorder())).GetLogEntry(); constexpr std::size_t kMaxIdLength{4U}; diff --git a/score/mw/log/detail/slog/slog_backend_test.cpp b/score/mw/log/detail/slog/slog_backend_test.cpp index 1980665..9ca1558 100644 --- a/score/mw/log/detail/slog/slog_backend_test.cpp +++ b/score/mw/log/detail/slog/slog_backend_test.cpp @@ -61,7 +61,7 @@ struct SlogBackendFixture : ::testing::Test EXPECT_TRUE(slot.has_value()); auto& payload = backend.GetLogRecord(slot.value()); - auto& log_entry = payload.getLogEntry(); + auto& log_entry = payload.GetLogEntry(); log_entry.ctx_id = LoggingIdentifier(std::string_view(ctx_id)); log_entry.log_level = log_level; log_entry.payload = ByteVector(message.begin(), message.end()); diff --git a/score/mw/log/detail/wait_free_producer_queue/alternating_control_block.h b/score/mw/log/detail/wait_free_producer_queue/alternating_control_block.h index 941ca17..15b07c9 100644 --- a/score/mw/log/detail/wait_free_producer_queue/alternating_control_block.h +++ b/score/mw/log/detail/wait_free_producer_queue/alternating_control_block.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_WAIT_FREE_ALTERNATING_CONTROL_BLOCK_H -#define SCORE_MW_LOG_DETAIL_WAIT_FREE_ALTERNATING_CONTROL_BLOCK_H +#ifndef SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_ALTERNATING_CONTROL_BLOCK_H +#define SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_ALTERNATING_CONTROL_BLOCK_H #include "score/mw/log/detail/wait_free_producer_queue/linear_control_block.h" @@ -80,4 +80,4 @@ AlternatingControlBlockSelectId SelectLinearControlBlockId(std::uint32_t count); } // namespace mw } // namespace score -#endif +#endif // SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_ALTERNATING_CONTROL_BLOCK_H diff --git a/score/mw/log/detail/wait_free_producer_queue/alternating_reader.cpp b/score/mw/log/detail/wait_free_producer_queue/alternating_reader.cpp index 9f95117..d0da463 100644 --- a/score/mw/log/detail/wait_free_producer_queue/alternating_reader.cpp +++ b/score/mw/log/detail/wait_free_producer_queue/alternating_reader.cpp @@ -34,18 +34,18 @@ AlternatingReadOnlyReader::AlternatingReadOnlyReader(const AlternatingControlBlo LinearReader AlternatingReadOnlyReader::CreateLinearReader(const std::uint32_t block_id_count) noexcept { auto block_id = SelectLinearControlBlockId(block_id_count); - auto& block = SelectLinearControlBlockReference(block_id, alternating_control_block_); + const auto& block = SelectLinearControlBlockReference(block_id, alternating_control_block_); const auto written_bytes = block.written_index.load(); - auto& buffer = block_id == AlternatingControlBlockSelectId::kBlockEven ? buffer_even_ : buffer_odd_; + const auto& buffer = block_id == AlternatingControlBlockSelectId::kBlockEven ? buffer_even_ : buffer_odd_; return CreateLinearReaderFromDataAndLength(buffer, written_bytes); } bool AlternatingReadOnlyReader::IsBlockReleasedByWriters(const std::uint32_t block_id_count) const noexcept { auto block_id = SelectLinearControlBlockId(block_id_count); - auto& block = SelectLinearControlBlockReference(block_id, alternating_control_block_); + const auto& block = SelectLinearControlBlockReference(block_id, alternating_control_block_); const bool result = (block.number_of_writers.load() == static_cast(0)) && (block.written_index.load() == block.acquired_index.load()); diff --git a/score/mw/log/detail/wait_free_producer_queue/alternating_reader.h b/score/mw/log/detail/wait_free_producer_queue/alternating_reader.h index 69f9867..c1f1329 100644 --- a/score/mw/log/detail/wait_free_producer_queue/alternating_reader.h +++ b/score/mw/log/detail/wait_free_producer_queue/alternating_reader.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_WAIT_FREE_ALTERNATING_READER_H -#define SCORE_MW_LOG_DETAIL_WAIT_FREE_ALTERNATING_READER_H +#ifndef SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_ALTERNATING_READER_H +#define SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_ALTERNATING_READER_H #include "score/mw/log/detail/wait_free_producer_queue/alternating_control_block.h" #include "score/mw/log/detail/wait_free_producer_queue/linear_reader.h" @@ -53,4 +53,4 @@ class AlternatingReadOnlyReader } // namespace mw } // namespace score -#endif +#endif // SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_ALTERNATING_READER_H diff --git a/score/mw/log/detail/wait_free_producer_queue/alternating_reader_proxy.h b/score/mw/log/detail/wait_free_producer_queue/alternating_reader_proxy.h index 8c3ed6d..f2a82b8 100644 --- a/score/mw/log/detail/wait_free_producer_queue/alternating_reader_proxy.h +++ b/score/mw/log/detail/wait_free_producer_queue/alternating_reader_proxy.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_WAIT_FREE_ALTERNATING_READER_PROXY_H -#define SCORE_MW_LOG_DETAIL_WAIT_FREE_ALTERNATING_READER_PROXY_H +#ifndef SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_ALTERNATING_READER_PROXY_H +#define SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_ALTERNATING_READER_PROXY_H #include "score/mw/log/detail/wait_free_producer_queue/alternating_control_block.h" @@ -83,4 +83,4 @@ class TerminatingBlockReference } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_WAIT_FREE_ALTERNATING_READER_PROXY_H +#endif // SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_ALTERNATING_READER_PROXY_H diff --git a/score/mw/log/detail/wait_free_producer_queue/linear_control_block.h b/score/mw/log/detail/wait_free_producer_queue/linear_control_block.h index eb3ec07..dd0c0f6 100644 --- a/score/mw/log/detail/wait_free_producer_queue/linear_control_block.h +++ b/score/mw/log/detail/wait_free_producer_queue/linear_control_block.h @@ -102,4 +102,4 @@ Length GetDataSizeAsLength(const score::cpp::span& data) noexcept; } // namespace mw } // namespace score -#endif +#endif // SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_LINEAR_CONTROL_BLOCK_H diff --git a/score/mw/log/detail/wait_free_producer_queue/linear_control_block_test.cpp b/score/mw/log/detail/wait_free_producer_queue/linear_control_block_test.cpp index 938bee6..b277a84 100644 --- a/score/mw/log/detail/wait_free_producer_queue/linear_control_block_test.cpp +++ b/score/mw/log/detail/wait_free_producer_queue/linear_control_block_test.cpp @@ -42,13 +42,13 @@ TEST(LinearControlBlock, LengthExceedingMaxThresholdShouldReturnTruncated) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - constexpr auto kBufferSize = 5ul; + constexpr auto kBufferSize = 5UL; std::vector buffer(kBufferSize); auto data = score::cpp::span(buffer.data(), static_cast(buffer.size())); - const auto invalid_offset = kBufferSize + 1ul; - constexpr auto kArbitraryBytesCount = 2ul; + const auto invalid_offset = kBufferSize + 1UL; + constexpr auto kArbitraryBytesCount = 2UL; ASSERT_FALSE(DoBytesFitInRemainingCapacity(data, invalid_offset, kArbitraryBytesCount)); } diff --git a/score/mw/log/detail/wait_free_producer_queue/linear_reader.h b/score/mw/log/detail/wait_free_producer_queue/linear_reader.h index 6532a00..db271d0 100644 --- a/score/mw/log/detail/wait_free_producer_queue/linear_reader.h +++ b/score/mw/log/detail/wait_free_producer_queue/linear_reader.h @@ -57,4 +57,4 @@ LinearReader CreateLinearReaderFromDataAndLength(const score::cpp::span& d } // namespace mw } // namespace score -#endif +#endif // SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_LINEAR_READER_H diff --git a/score/mw/log/detail/wait_free_producer_queue/linear_reader_test.cpp b/score/mw/log/detail/wait_free_producer_queue/linear_reader_test.cpp index 730d514..4919661 100644 --- a/score/mw/log/detail/wait_free_producer_queue/linear_reader_test.cpp +++ b/score/mw/log/detail/wait_free_producer_queue/linear_reader_test.cpp @@ -33,7 +33,7 @@ TEST(LinearReaderTests, LengthExceedingMaxThresholdShouldReturnEmpty) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - constexpr auto kBufferSize = score::mw::log::detail::GetLengthOffsetBytes() * 2u; + constexpr auto kBufferSize = score::mw::log::detail::GetLengthOffsetBytes() * 2U; std::vector buffer(kBufferSize); auto data = score::cpp::span(buffer.data(), static_cast(buffer.size())); diff --git a/score/mw/log/detail/wait_free_producer_queue/wait_free_alternating_writer.h b/score/mw/log/detail/wait_free_producer_queue/wait_free_alternating_writer.h index f1ae728..45a32b9 100644 --- a/score/mw/log/detail/wait_free_producer_queue/wait_free_alternating_writer.h +++ b/score/mw/log/detail/wait_free_producer_queue/wait_free_alternating_writer.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_WAIT_FREE_ALTERNATING_WRITER_H -#define SCORE_MW_LOG_DETAIL_WAIT_FREE_ALTERNATING_WRITER_H +#ifndef SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_WAIT_FREE_ALTERNATING_WRITER_H +#define SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_WAIT_FREE_ALTERNATING_WRITER_H #include "score/mw/log/detail/wait_free_producer_queue/alternating_control_block.h" #include "score/mw/log/detail/wait_free_producer_queue/wait_free_linear_writer.h" @@ -76,4 +76,4 @@ class WaitFreeAlternatingWriter } // namespace mw } // namespace score -#endif +#endif // SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_WAIT_FREE_ALTERNATING_WRITER_H diff --git a/score/mw/log/detail/wait_free_producer_queue/wait_free_alternating_writer_test.cpp b/score/mw/log/detail/wait_free_producer_queue/wait_free_alternating_writer_test.cpp index 4a9549a..f944b26 100644 --- a/score/mw/log/detail/wait_free_producer_queue/wait_free_alternating_writer_test.cpp +++ b/score/mw/log/detail/wait_free_producer_queue/wait_free_alternating_writer_test.cpp @@ -49,7 +49,7 @@ TEST(WaitFreeAlternatingWriterTests, WriteBufferFullShouldReturnExpectedData) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - constexpr auto kBufferSize = 10u * 64u * 1024u; + constexpr auto kBufferSize = 10U * 64U * 1024U; std::vector buffer_even(kBufferSize); std::vector buffer_odd(kBufferSize); score::mw::log::detail::AlternatingControlBlock control_block{}; @@ -59,15 +59,15 @@ TEST(WaitFreeAlternatingWriterTests, WriteBufferFullShouldReturnExpectedData) score::mw::log::detail::WaitFreeAlternatingWriter writer{InitializeAlternatingControlBlock(control_block)}; - const auto kNumberOfWriterThreads = std::thread::hardware_concurrency(); - std::vector threads(kNumberOfWriterThreads); + const auto k_number_of_writer_threads = std::thread::hardware_concurrency(); + std::vector threads(k_number_of_writer_threads); - const auto kAcquireLength = kBufferSize / kNumberOfWriterThreads; + const auto k_acquire_length = kBufferSize / k_number_of_writer_threads; constexpr auto kNumberOfPacketsPerThread = 3; - for (auto i = 0u; i < kNumberOfWriterThreads; i++) + for (auto i = 0U; i < k_number_of_writer_threads; i++) { - threads[i] = std::thread([kAcquireLength, &writer]() { + threads[i] = std::thread([k_acquire_length, &writer]() { for (auto packet_number = 0; packet_number < kNumberOfPacketsPerThread; packet_number++) { // Loop until we succeeded to reserve data on the buffer @@ -75,18 +75,18 @@ TEST(WaitFreeAlternatingWriterTests, WriteBufferFullShouldReturnExpectedData) while (acquire_result.has_value() == false) { - acquire_result = writer.Acquire(kAcquireLength); + acquire_result = writer.Acquire(k_acquire_length); std::this_thread::sleep_for(10us); } auto acquired_data = acquire_result.value().data; - if (acquired_data.size() != kAcquireLength) + if (acquired_data.size() != k_acquire_length) { std::abort(); } // Write data into the complete acquired span. - acquired_data.data()[0] = static_cast(packet_number); + acquired_data[0] = static_cast(packet_number); writer.Release(acquire_result.value()); } @@ -123,7 +123,7 @@ TEST(WaitFreeAlternatingWriterTests, WriteBufferFullShouldReturnExpectedData) all_packets_received = true; for (const auto& counter : number_of_packets_received) { - if (counter != kNumberOfWriterThreads) + if (counter != k_number_of_writer_threads) { all_packets_received = false; break; @@ -210,7 +210,7 @@ TEST(AlternatingReaderTest, EnsureToNotAcquireAnyBlockAndReturnNullInCaseTheSwit RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - constexpr auto kBufferSize = 10u * 64u * 1024u; + constexpr auto kBufferSize = 10U * 64U * 1024U; std::vector buffer1(kBufferSize); std::vector buffer2(kBufferSize); diff --git a/score/mw/log/detail/wait_free_producer_queue/wait_free_linear_writer.h b/score/mw/log/detail/wait_free_producer_queue/wait_free_linear_writer.h index c16b72f..cc597ca 100644 --- a/score/mw/log/detail/wait_free_producer_queue/wait_free_linear_writer.h +++ b/score/mw/log/detail/wait_free_producer_queue/wait_free_linear_writer.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_WAIT_FREE_LINEAR_WRITER_H -#define SCORE_MW_LOG_DETAIL_WAIT_FREE_LINEAR_WRITER_H +#ifndef SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_WAIT_FREE_LINEAR_WRITER_H +#define SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_WAIT_FREE_LINEAR_WRITER_H #include "score/mw/log/detail/wait_free_producer_queue/linear_control_block.h" @@ -53,7 +53,7 @@ class WaitFreeLinearWriter { public: explicit WaitFreeLinearWriter(LinearControlBlock& cb, - PreAcquireHook pre_acquire_hook = std::move(empty_hook)) noexcept; + PreAcquireHook pre_acquire_hook = std::move(EmptyHook)) noexcept; /// \brief Try to acquire the length for writing. /// Returns empty if there is not enough space available. @@ -63,7 +63,7 @@ class WaitFreeLinearWriter void Release(const AcquiredData& acquired_data) noexcept; private: - static inline void empty_hook(WaitFreeLinearWriter&) noexcept {} + static inline void EmptyHook(WaitFreeLinearWriter&) noexcept {} private: LinearControlBlock& control_block_; @@ -75,4 +75,4 @@ class WaitFreeLinearWriter } // namespace mw } // namespace score -#endif +#endif // SCORE_MW_LOG_DETAIL_WAIT_FREE_PRODUCER_QUEUE_WAIT_FREE_LINEAR_WRITER_H diff --git a/score/mw/log/detail/wait_free_producer_queue/wait_free_linear_writer_test.cpp b/score/mw/log/detail/wait_free_producer_queue/wait_free_linear_writer_test.cpp index 3974568..e56a7a1 100644 --- a/score/mw/log/detail/wait_free_producer_queue/wait_free_linear_writer_test.cpp +++ b/score/mw/log/detail/wait_free_producer_queue/wait_free_linear_writer_test.cpp @@ -46,24 +46,24 @@ TEST(WaitFreeLinearWriter, WriteBufferFullShouldReturnExpectedData) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - constexpr auto kBufferSize = 10u * 64u * 1024u; + constexpr auto kBufferSize = 10U * 64U * 1024U; std::vector buffer(kBufferSize); score::mw::log::detail::LinearControlBlock control_block{}; control_block.data = score::cpp::span(buffer.data(), buffer.size()); score::mw::log::detail::WaitFreeLinearWriter writer{control_block}; - const auto kNumberOfWriterThreads = std::thread::hardware_concurrency(); - std::vector threads(kNumberOfWriterThreads); + const auto k_number_of_writer_threads = std::thread::hardware_concurrency(); + std::vector threads(k_number_of_writer_threads); - const auto kThreadAcquireFactor = kBufferSize / kNumberOfWriterThreads; + const auto k_thread_acquire_factor = kBufferSize / k_number_of_writer_threads; - for (auto i = 0u; i < kNumberOfWriterThreads; i++) + for (auto i = 0U; i < k_number_of_writer_threads; i++) { - threads[i] = std::thread([i, kThreadAcquireFactor, &writer]() { - const auto kAcquireLength = kThreadAcquireFactor * i; + threads[i] = std::thread([i, k_thread_acquire_factor, &writer]() { + const auto k_acquire_length = k_thread_acquire_factor * i; - const auto acquire_result = writer.Acquire(kAcquireLength); + const auto acquire_result = writer.Acquire(k_acquire_length); if (acquire_result.has_value() == false) { @@ -73,14 +73,14 @@ TEST(WaitFreeLinearWriter, WriteBufferFullShouldReturnExpectedData) // Write data into the complete acquired span. const auto acquired_data = acquire_result.value().data; - if (acquired_data.size() != kAcquireLength) + if (acquired_data.size() != k_acquire_length) { std::abort(); } - for (auto payload_index = 0u; payload_index < acquired_data.size(); payload_index++) + for (auto payload_index = 0U; payload_index < acquired_data.size(); payload_index++) { - acquired_data.data()[payload_index] = static_cast(payload_index); + acquired_data[payload_index] = static_cast(payload_index); } writer.Release(acquire_result.value()); @@ -102,7 +102,7 @@ TEST(WaitFreeLinearWriter, WriteBufferFullShouldReturnExpectedData) break; } - for (auto payload_index = 0u; payload_index < read_result.value().size(); payload_index++) + for (auto payload_index = 0U; payload_index < read_result.value().size(); payload_index++) { ASSERT_EQ(read_result.value().data()[payload_index], static_cast(payload_index)); @@ -118,24 +118,24 @@ TEST(WaitFreeLinearWriter, WriterBigDataTest) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - constexpr auto kBufferSize = 10u * 10u * 64u * 1024u; + constexpr auto kBufferSize = 10U * 10U * 64U * 1024U; std::vector buffer(kBufferSize); score::mw::log::detail::LinearControlBlock control_block{}; control_block.data = score::cpp::span(buffer.data(), buffer.size()); score::mw::log::detail::WaitFreeLinearWriter writer{control_block}; - const auto kNumberOfWriterThreads = std::thread::hardware_concurrency(); - std::vector threads(kNumberOfWriterThreads); + const auto k_number_of_writer_threads = std::thread::hardware_concurrency(); + std::vector threads(k_number_of_writer_threads); - const auto kThreadAcquireFactor = kBufferSize / kNumberOfWriterThreads; + const auto k_thread_acquire_factor = kBufferSize / k_number_of_writer_threads; - for (auto i = 0u; i < kNumberOfWriterThreads; i++) + for (auto i = 0U; i < k_number_of_writer_threads; i++) { - threads[i] = std::thread([i, kThreadAcquireFactor, &writer]() { - const auto kAcquireLength = kThreadAcquireFactor * i; + threads[i] = std::thread([i, k_thread_acquire_factor, &writer]() { + const auto k_acquire_length = k_thread_acquire_factor * i; - const auto acquire_result = writer.Acquire(kAcquireLength); + const auto acquire_result = writer.Acquire(k_acquire_length); if (acquire_result.has_value() == false) { @@ -144,7 +144,7 @@ TEST(WaitFreeLinearWriter, WriterBigDataTest) const auto acquired_data = acquire_result.value().data; - if (acquired_data.size() != kAcquireLength) + if (acquired_data.size() != k_acquire_length) { std::abort(); } @@ -153,7 +153,7 @@ TEST(WaitFreeLinearWriter, WriterBigDataTest) if (acquired_data.size() >= 2) { *acquired_data.begin() = 1; - acquired_data.data()[acquired_data.size() - 1] = 2; + acquired_data[acquired_data.size() - 1] = 2; } writer.Release(acquire_result.value()); @@ -192,14 +192,14 @@ TEST(WaitFreeLinearWriter, TooManyConcurrentWriterShouldReturnEmpty) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - constexpr auto kBufferSize = 10u * 10u * 64u * 1024u; + constexpr auto kBufferSize = 10U * 10U * 64U * 1024U; std::vector buffer(kBufferSize); score::mw::log::detail::LinearControlBlock control_block{}; control_block.data = score::cpp::span(buffer.data(), buffer.size()); control_block.number_of_writers.store(score::mw::log::detail::GetMaxNumberOfConcurrentWriters()); score::mw::log::detail::WaitFreeLinearWriter writer{control_block}; - constexpr auto kArbitraryNumberOfBytes{42u}; + constexpr auto kArbitraryNumberOfBytes{42U}; ASSERT_FALSE(writer.Acquire(kArbitraryNumberOfBytes).has_value()); } @@ -211,14 +211,14 @@ TEST(WaitFreeLinearWriter, BufferSizeExceededShouldReturnEmpty) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - constexpr auto kBufferSize = 10u * 10u * 64u * 1024u; + constexpr auto kBufferSize = 10U * 10U * 64U * 1024U; std::vector buffer(kBufferSize); score::mw::log::detail::LinearControlBlock control_block{}; control_block.data = score::cpp::span(buffer.data(), buffer.size()); control_block.acquired_index.store(static_cast(control_block.data.size())); score::mw::log::detail::WaitFreeLinearWriter writer{control_block}; - constexpr auto kArbitraryNumberOfBytes{42u}; + constexpr auto kArbitraryNumberOfBytes{42U}; ASSERT_FALSE(writer.Acquire(kArbitraryNumberOfBytes).has_value()); } @@ -230,14 +230,14 @@ TEST(WaitFreeLinearWriter, BufferSizeExceededUpperLimitShouldReturnEmpty) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - constexpr auto kBufferSize = 10u * 10u * 64u * 1024u; + constexpr auto kBufferSize = 10U * 10U * 64U * 1024U; std::vector buffer(kBufferSize); score::mw::log::detail::LinearControlBlock control_block{}; control_block.data = score::cpp::span(buffer.data(), buffer.size()); control_block.acquired_index.store(score::mw::log::detail::GetMaxLinearBufferCapacityBytes()); score::mw::log::detail::WaitFreeLinearWriter writer{control_block}; - constexpr auto kArbitraryNumberOfBytes{42u}; + constexpr auto kArbitraryNumberOfBytes{42U}; ASSERT_FALSE(writer.Acquire(kArbitraryNumberOfBytes).has_value()); } @@ -251,7 +251,7 @@ TEST(WaitFreeLinearWriter, FailedAcquireShouldTerminateBuffer) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - constexpr auto kBufferSize = score::mw::log::detail::GetLengthOffsetBytes() * 2u; + constexpr auto kBufferSize = score::mw::log::detail::GetLengthOffsetBytes() * 2U; std::vector buffer(kBufferSize); score::mw::log::detail::LinearControlBlock control_block{}; control_block.data = score::cpp::span(buffer.data(), buffer.size()); @@ -264,7 +264,7 @@ TEST(WaitFreeLinearWriter, FailedAcquireShouldTerminateBuffer) // thread tries to reserve it. if (i++ == 0) { - auto acquire_result = writer_callback.Acquire(0u); + auto acquire_result = writer_callback.Acquire(0U); if (acquire_result.has_value() == false) { std::abort(); @@ -301,7 +301,7 @@ TEST(WaitFreeLinearWriter, FailedAcquireWithNoFreeSpaceShouldNotTerminateBuffer) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - constexpr auto kBufferSize = score::mw::log::detail::GetLengthOffsetBytes() * 2u; + constexpr auto kBufferSize = score::mw::log::detail::GetLengthOffsetBytes() * 2U; std::vector buffer(kBufferSize); score::mw::log::detail::LinearControlBlock control_block{}; control_block.data = score::cpp::span(buffer.data(), buffer.size()); @@ -349,7 +349,7 @@ TEST(WaitFreeLinearWriter, AcquireMoreThanMaximumShouldFail) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - constexpr auto kBufferSize = score::mw::log::detail::GetLengthOffsetBytes() * 2u; + constexpr auto kBufferSize = score::mw::log::detail::GetLengthOffsetBytes() * 2U; std::vector buffer(kBufferSize); score::mw::log::detail::LinearControlBlock control_block{}; control_block.data = score::cpp::span(buffer.data(), buffer.size()); diff --git a/score/mw/log/legacy_non_verbose_api/tracing_test.cpp b/score/mw/log/legacy_non_verbose_api/tracing_test.cpp index d12c424..c9db3c0 100644 --- a/score/mw/log/legacy_non_verbose_api/tracing_test.cpp +++ b/score/mw/log/legacy_non_verbose_api/tracing_test.cpp @@ -121,13 +121,13 @@ class LoggerFixture : public ::testing::Test const auto slot = unit_.ReserveSlot().value(); auto&& log_record = unit_.GetLogRecord(slot); - auto& log_entry = log_record.getLogEntry(); + auto& log_entry = log_record.GetLogEntry(); log_entry.app_id = LoggingIdentifier{app_id}; log_entry.ctx_id = LoggingIdentifier{context_id}; log_entry.log_level = log_level; log_entry.num_of_args = 5; - log_record.getVerbosePayload().Put("xyz xyz", 7); + log_record.GetVerbosePayload().Put("xyz xyz", 7); unit_.FlushSlot(slot); From ea944d0f45a06f3fa41cc72443ef679b0055c277 Mon Sep 17 00:00:00 2001 From: Xavier Bonaventura Date: Wed, 18 Feb 2026 18:45:20 +0100 Subject: [PATCH 05/12] mw: Explicitly load rules_cc and rules_python load If we want to make sure that the rules C++ and Python loaded are the version we defined and not the one in Bazel, we need to explicitly add the load statement. This also becomes mandatory in Bazel 9. These changes have been done automatically with buildifier fix after adding native-cc and native-py. GIT_ORIGIN_SPP_REV_ID: c820f1811d8c6d42332706badb1e1a8a6f9b2dbc --- score/mw/log/detail/utils/signal_handling/BUILD | 2 ++ score/mw/log/flags/BUILD | 1 + score/mw/log/test/fake_recorder/BUILD | 1 + score/mw/log/test/fake_recorder_environment/BUILD | 1 + 4 files changed, 5 insertions(+) diff --git a/score/mw/log/detail/utils/signal_handling/BUILD b/score/mw/log/detail/utils/signal_handling/BUILD index 56c9e17..ebd60d6 100644 --- a/score/mw/log/detail/utils/signal_handling/BUILD +++ b/score/mw/log/detail/utils/signal_handling/BUILD @@ -1,3 +1,5 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + # ******************************************************************************* # Copyright (c) 2025 Contributors to the Eclipse Foundation # diff --git a/score/mw/log/flags/BUILD b/score/mw/log/flags/BUILD index 9a4bd59..0adc312 100644 --- a/score/mw/log/flags/BUILD +++ b/score/mw/log/flags/BUILD @@ -12,6 +12,7 @@ # ******************************************************************************* load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") +load("@rules_cc//cc:defs.bzl", "cc_library") bool_flag( name = "KRemote_Logging", diff --git a/score/mw/log/test/fake_recorder/BUILD b/score/mw/log/test/fake_recorder/BUILD index 353eeaa..8dc3270 100644 --- a/score/mw/log/test/fake_recorder/BUILD +++ b/score/mw/log/test/fake_recorder/BUILD @@ -11,6 +11,7 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* +load("@rules_cc//cc:defs.bzl", "cc_library") load("@score_baselibs//score/language/safecpp:toolchain_features.bzl", "COMPILER_WARNING_FEATURES") cc_library( diff --git a/score/mw/log/test/fake_recorder_environment/BUILD b/score/mw/log/test/fake_recorder_environment/BUILD index 24b4d09..83dc2d8 100644 --- a/score/mw/log/test/fake_recorder_environment/BUILD +++ b/score/mw/log/test/fake_recorder_environment/BUILD @@ -11,6 +11,7 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* +load("@rules_cc//cc:defs.bzl", "cc_library") load("@score_baselibs//score/language/safecpp:toolchain_features.bzl", "COMPILER_WARNING_FEATURES") cc_library( From 7737c4df2d6afed7432079c131d15bcccd7795f1 Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Wed, 11 Feb 2026 09:06:30 +0100 Subject: [PATCH 06/12] Add extra clang-tidy checks for platform/aas/mw/log BUILD GIT_ORIGIN_SPP_REV_ID: 1b4f6756ba4c1fc71667d7190bec17a68c23383b --- score/mw/log/detail/common/composite_recorder_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/score/mw/log/detail/common/composite_recorder_test.cpp b/score/mw/log/detail/common/composite_recorder_test.cpp index 75f6198..70b1c26 100644 --- a/score/mw/log/detail/common/composite_recorder_test.cpp +++ b/score/mw/log/detail/common/composite_recorder_test.cpp @@ -241,7 +241,7 @@ TEST_F(CompositeRecorderFixture, LogInvocationShallBeForwardedToAllAvailableReco EXPECT_CALL(*mock_recorder, LogUint64(recorder_slot, kBin64.value)); EXPECT_CALL(*mock_recorder, - Log_LogRawBuffer(recorder_slot, gLogRawBuffer.data(), static_cast(gLogRawBuffer.size()))); + LogLogRawBuffer(recorder_slot, gLogRawBuffer.data(), static_cast(gLogRawBuffer.size()))); return mock_recorder; }); @@ -289,9 +289,9 @@ TEST_F(CompositeRecorderFixture, LogSlog2MessageAvailableRecorders) SlotHandle recorder_slot{static_cast(recorder)}; EXPECT_CALL( *mock_recorder, - Log_LogSlog2Message(recorder_slot, - static_cast(gLogSlog2Message.GetCode()), - LogStringEquals(static_cast(gLogSlog2Message.GetMessage())))) + LogLogSlog2Message(recorder_slot, + static_cast(gLogSlog2Message.GetCode()), + LogStringEquals(static_cast(gLogSlog2Message.GetMessage())))) .Times(0); return mock_recorder; }); From 0cb3cb18be39554b3d053833a0b3beaf4c724047 Mon Sep 17 00:00:00 2001 From: Andrey Babanin Date: Tue, 24 Feb 2026 15:21:37 +0100 Subject: [PATCH 07/12] fix: move rules_cc inclusions after copyright in mw/log The problem is that buildifier put the rule_cc inclusion in beginning of a file because it assumed that the copyright header is a comment for the next statement (cc_library, test_suite,...) due to a missing empty line in-between. GIT_ORIGIN_SPP_REV_ID: f8420e7798965cd7380b13c2a892378805e6f7b2 --- score/mw/log/custom_recorder_example/BUILD | 4 ++-- score/mw/log/detail/utils/signal_handling/BUILD | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/score/mw/log/custom_recorder_example/BUILD b/score/mw/log/custom_recorder_example/BUILD index f846650..ca92e33 100644 --- a/score/mw/log/custom_recorder_example/BUILD +++ b/score/mw/log/custom_recorder_example/BUILD @@ -1,5 +1,3 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") - # ******************************************************************************* # Copyright (c) 2025 Contributors to the Eclipse Foundation # @@ -12,6 +10,8 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") # # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* + +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") load("@score_baselibs//score/quality/clang_tidy:extra_checks.bzl", "clang_tidy_extra_checks") clang_tidy_extra_checks( diff --git a/score/mw/log/detail/utils/signal_handling/BUILD b/score/mw/log/detail/utils/signal_handling/BUILD index ebd60d6..1d564e8 100644 --- a/score/mw/log/detail/utils/signal_handling/BUILD +++ b/score/mw/log/detail/utils/signal_handling/BUILD @@ -1,5 +1,3 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") - # ******************************************************************************* # Copyright (c) 2025 Contributors to the Eclipse Foundation # @@ -12,6 +10,8 @@ load("@rules_cc//cc:defs.bzl", "cc_library") # # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* + +load("@rules_cc//cc:defs.bzl", "cc_library") load("@score_baselibs//score/quality/clang_tidy:extra_checks.bzl", "clang_tidy_extra_checks") clang_tidy_extra_checks( From 4afdd3ecffd1041bec8d9f5ff3867866e0b9d6c4 Mon Sep 17 00:00:00 2001 From: Mihajlo Katancevic Date: Mon, 23 Feb 2026 23:36:27 +0100 Subject: [PATCH 08/12] Use macros instead of manual suppression GIT_ORIGIN_SPP_REV_ID: b56a619ccccc3fd3fe672d0402be408710c08a1d --- score/datarouter/BUILD | 2 + score/datarouter/include/dlt/dlt_common.h | 75 ++++++++----------- score/datarouter/include/dlt/dlt_headers.h | 30 +------- .../src/unix_domain/unix_domain_common.cpp | 30 ++------ score/mw/log/detail/file_recorder/BUILD | 1 + .../file_recorder/dlt_message_builder_types.h | 37 ++------- 6 files changed, 55 insertions(+), 120 deletions(-) diff --git a/score/datarouter/BUILD b/score/datarouter/BUILD index 94c7ad9..19016be 100644 --- a/score/datarouter/BUILD +++ b/score/datarouter/BUILD @@ -57,6 +57,7 @@ cc_library( "//score/mw/log/detail/common:log_entry_deserialize", "@score_baselibs//score/language/futurecpp", "@score_baselibs//score/os/utils:path", + "@score_baselibs//score/quality/compiler_warnings", ], ) @@ -81,6 +82,7 @@ cc_library( "@score_baselibs//score/language/futurecpp", "@score_baselibs//score/os:socket", "@score_baselibs//score/os/utils:signal", + "@score_baselibs//score/quality/compiler_warnings", ], ) diff --git a/score/datarouter/include/dlt/dlt_common.h b/score/datarouter/include/dlt/dlt_common.h index f800402..0d617e3 100644 --- a/score/datarouter/include/dlt/dlt_common.h +++ b/score/datarouter/include/dlt/dlt_common.h @@ -43,6 +43,8 @@ #include "dlt_protocol.h" #include "dlt_types.h" +#include "score/quality/compiler_warnings/warnings.h" + #if !defined(PACKED) #define PACKED __attribute__((aligned(1), packed)) #endif @@ -81,96 +83,85 @@ */ #define DLT_ID_SIZE 4 -// NOLINTBEGIN(score-banned-preprocessor-directives) see below /** * Suppress compiler warnings related to Wpacked and Wattributes - * because some structures delared with PACKED attribute + * because some structures declared with PACKED attribute * if this attribute has no effect it causes warning */ -#if defined(__INTEL_COMPILER) // ICC warnings not complete -// required due to ICC warnings -// coverity[autosar_cpp14_a16_7_1_violation] -#pragma warning(push) -#elif defined(__GNUC__) -// required due to ICC warnings -// coverity[autosar_cpp14_a16_7_1_violation] -#pragma GCC diagnostic push -// required due to ICC warnings -// coverity[autosar_cpp14_a16_7_1_violation] -#pragma GCC diagnostic ignored "-Wpacked" -// required due to ICC warnings -// coverity[autosar_cpp14_a16_7_1_violation] -#pragma GCC diagnostic ignored "-Wattributes" -#endif -// NOLINTEND(score-banned-preprocessor-directives) + +DISABLE_WARNING_PUSH +DISABLE_WARNING_PACKED +DISABLE_WARNING_ATTRIBUTES // NOLINTBEGIN(modernize-avoid-c-arrays) see below /** - * dlt_common.h header part of GENIVI Project DLT, provide C-style interface and should not be changed by user - * So plain array could not be replaced by modern alternatives + * dlt_common.h header part of GENIVI Project DLT, provide C-style interface and + * should not be changed by user So plain array could not be replaced by modern + * alternatives */ /** - * The structure of the DLT file storage header. This header is used before each stored DLT message. + * The structure of the DLT file storage header. This header is used before each + * stored DLT message. */ typedef struct { - // coverity[autosar_cpp14_a9_6_1_violation] False positive, size is well defined DLT_ID_SIZE -> 4 + // coverity[autosar_cpp14_a9_6_1_violation] False positive, size is well + // defined DLT_ID_SIZE -> 4 char pattern[DLT_ID_SIZE]; /**< This pattern should be DLT0x01 */ uint32_t seconds; /**< seconds since 1.1.1970 */ int32_t microseconds; /**< Microseconds */ - // coverity[autosar_cpp14_a9_6_1_violation] False positive, size is well defined DLT_ID_SIZE -> 4 - char ecu[DLT_ID_SIZE]; /**< The ECU id is added, if it is not already in the DLT message itself */ + // coverity[autosar_cpp14_a9_6_1_violation] False positive, size is well + // defined DLT_ID_SIZE -> 4 + char ecu[DLT_ID_SIZE]; /**< The ECU id is added, if it is not already in the + DLT message itself */ } PACKED DltStorageHeader; /** - * The structure of the DLT standard header. This header is used in each DLT message. + * The structure of the DLT standard header. This header is used in each DLT + * message. */ typedef struct { - uint8_t htyp; /**< This parameter contains several informations, see definitions below */ + uint8_t htyp; /**< This parameter contains several informations, see + definitions below */ uint8_t mcnt; /**< The message counter is increased with each sent DLT message */ uint16_t len; /**< Length of the complete message, without storage header */ } PACKED DltStandardHeader; /** - * The structure of the DLT extra header parameters. Each parameter is sent only if enabled in htyp. + * The structure of the DLT extra header parameters. Each parameter is sent only + * if enabled in htyp. */ typedef struct { - // coverity[autosar_cpp14_a9_6_1_violation] False positive, size is well defined DLT_ID_SIZE -> 4 + // coverity[autosar_cpp14_a9_6_1_violation] False positive, size is well + // defined DLT_ID_SIZE -> 4 char ecu[DLT_ID_SIZE]; /**< ECU id */ uint32_t tmsp; /**< Timestamp since system start in 0.1 milliseconds */ } PACKED DltStandardHeaderExtra; /** - * The structure of the DLT extended header. This header is only sent if enabled in htyp parameter. + * The structure of the DLT extended header. This header is only sent if enabled + * in htyp parameter. */ typedef struct { uint8_t msin; /**< messsage info */ uint8_t noar; /**< number of arguments */ - // coverity[autosar_cpp14_a9_6_1_violation] False positive, size is well defined DLT_ID_SIZE -> 4 + // coverity[autosar_cpp14_a9_6_1_violation] False positive, size is well + // defined DLT_ID_SIZE -> 4 char apid[DLT_ID_SIZE]; /**< application id */ - // coverity[autosar_cpp14_a9_6_1_violation] False positive, size is well defined DLT_ID_SIZE -> 4 + // coverity[autosar_cpp14_a9_6_1_violation] False positive, size is well + // defined DLT_ID_SIZE -> 4 char ctid[DLT_ID_SIZE]; /**< context id */ } PACKED DltExtendedHeader; // NOLINTEND(modernize-avoid-c-arrays) -// NOLINTBEGIN(score-banned-preprocessor-directives) see below /** * Suppress compiler warnings related to Wpacked and Wattributes * because some structures delared with PACKED attribute * if this attribute has no effect it causes warning */ -#if defined(__INTEL_COMPILER) -// required due to ICC warnings -// coverity[autosar_cpp14_a16_7_1_violation] -#pragma warning(pop) -#elif defined(__GNUC__) -// required due to ICC warnings -// coverity[autosar_cpp14_a16_7_1_violation] -#pragma GCC diagnostic pop -#endif -// NOLINTEND(score-banned-preprocessor-directives) +DISABLE_WARNING_POP #endif // SCORE_DATAROUTER_INCLUDE_DLT_DLT_COMMON_H diff --git a/score/datarouter/include/dlt/dlt_headers.h b/score/datarouter/include/dlt/dlt_headers.h index 91f31d4..1e8ffb7 100644 --- a/score/datarouter/include/dlt/dlt_headers.h +++ b/score/datarouter/include/dlt/dlt_headers.h @@ -28,27 +28,14 @@ namespace internal static constexpr uint32_t kDltMessageSize = 65536UL; -// NOLINTBEGIN(score-banned-preprocessor-directives) see below /** * Suppress compiler warnings related to Wpacked and Wattributes * because some structures declared with PACKED attribute * if this attribute has no effect it causes warning */ -#if defined(__INTEL_COMPILER) // ICC warnings not complete -// required due to ICC warnings -// coverity[autosar_cpp14_a16_7_1_violation] -#pragma warning(push) -#elif defined(__GNUC__) -// required due to ICC warnings -// coverity[autosar_cpp14_a16_7_1_violation] -#pragma GCC diagnostic push -// required due to ICC warnings -// coverity[autosar_cpp14_a16_7_1_violation] -#pragma GCC diagnostic ignored "-Wpacked" -// required due to ICC warnings -// coverity[autosar_cpp14_a16_7_1_violation] -#pragma GCC diagnostic ignored "-Wattributes" -#endif +DISABLE_WARNING_PUSH +DISABLE_WARNING_PACKED +DISABLE_WARNING_ATTRIBUTES typedef struct { @@ -64,16 +51,7 @@ typedef struct DltExtendedHeader ext; } PACKED DltVerboseHeader; -#if defined(__INTEL_COMPILER) -// required due to ICC warnings -// coverity[autosar_cpp14_a16_7_1_violation] -#pragma warning(pop) -#elif defined(__GNUC__) -// required due to ICC warnings -// coverity[autosar_cpp14_a16_7_1_violation] -#pragma GCC diagnostic pop -#endif -// NOLINTEND(score-banned-preprocessor-directives) +DISABLE_WARNING_POP inline void ConstructDltStorageHeader(DltStorageHeader& storagehdr, uint32_t secs, int32_t microsecs) { diff --git a/score/datarouter/src/unix_domain/unix_domain_common.cpp b/score/datarouter/src/unix_domain/unix_domain_common.cpp index 7960b5a..be81610 100644 --- a/score/datarouter/src/unix_domain/unix_domain_common.cpp +++ b/score/datarouter/src/unix_domain/unix_domain_common.cpp @@ -15,6 +15,7 @@ #include "score/os/errno.h" #include "score/os/socket.h" #include "score/os/utils/signal.h" +#include "score/quality/compiler_warnings/warnings.h" #include #include @@ -53,21 +54,10 @@ static_assert(kSocketCmsgSpace == CMSG_SPACE(sizeof(int) * 1U), "Invalid constan void CmsgLenSuppressWarnings(struct cmsghdr* cmsg, size_t num_fds) { #ifdef __QNX__ -// NOLINTBEGIN(score-banned-preprocessor-directives) : required due to compiler warning for qnx -/* -Deviation from Rule A16-7-1: -- The #pragma directive shall not be used -Justification: -- required due to compiler warning for qnx -*/ -// coverity[autosar_cpp14_a16_7_1_violation] see above -#pragma GCC diagnostic push -// coverity[autosar_cpp14_a16_7_1_violation] see above -#pragma GCC diagnostic ignored "-Wsign-conversion" + DISABLE_WARNING_PUSH + DISABLE_WARNING_SIGN_CONVERSION cmsg->cmsg_len = static_cast(CMSG_LEN(sizeof(std::int32_t) * num_fds)); -// coverity[autosar_cpp14_a16_7_1_violation] see above -#pragma GCC diagnostic pop -// NOLINTEND(score-banned-preprocessor-directives) + DISABLE_WARNING_POP #else cmsg->cmsg_len = CMSG_LEN(sizeof(std::int32_t) * num_fds); #endif @@ -77,11 +67,9 @@ int32_t* CmsgDataSuppressWarning(struct cmsghdr* cmsg) { int32_t* fdptr = nullptr; #ifdef __QNX__ -// NOLINTBEGIN(score-banned-preprocessor-directives) : required due to compiler warning for qnx -// coverity[autosar_cpp14_a16_7_1_violation] see above -#pragma GCC diagnostic push -// coverity[autosar_cpp14_a16_7_1_violation] see above -#pragma GCC diagnostic ignored "-Wsign-conversion" + DISABLE_WARNING_PUSH + DISABLE_WARNING_SIGN_CONVERSION + /* Deviation from Rule M5-0-15: - Array indexing shall be the only form of pointer arithmetic @@ -94,9 +82,7 @@ int32_t* CmsgDataSuppressWarning(struct cmsghdr* cmsg) // coverity[autosar_cpp14_m5_0_15_violation] // coverity[autosar_cpp14_m5_2_8_violation] fdptr = static_cast(static_cast(CMSG_DATA(cmsg))); -// coverity[autosar_cpp14_a16_7_1_violation] see above -#pragma GCC diagnostic pop -// NOLINTEND(score-banned-preprocessor-directives) + DISABLE_WARNING_POP #else // coverity[autosar_cpp14_m5_0_15_violation] see above // coverity[autosar_cpp14_m5_2_8_violation] see above diff --git a/score/mw/log/detail/file_recorder/BUILD b/score/mw/log/detail/file_recorder/BUILD index 934e124..26c9b06 100644 --- a/score/mw/log/detail/file_recorder/BUILD +++ b/score/mw/log/detail/file_recorder/BUILD @@ -61,6 +61,7 @@ cc_library( "@score_baselibs//score/mw/log/detail/text_recorder:file_output_backend", "@score_baselibs//score/mw/log/detail/text_recorder:message_builder_interface", "@score_baselibs//score/os/utils:high_resolution_steady_clock", + "@score_baselibs//score/quality/compiler_warnings", "@score_baselibs//score/static_reflection_with_serialization/serialization", ], ) diff --git a/score/mw/log/detail/file_recorder/dlt_message_builder_types.h b/score/mw/log/detail/file_recorder/dlt_message_builder_types.h index 94d729a..cad9732 100644 --- a/score/mw/log/detail/file_recorder/dlt_message_builder_types.h +++ b/score/mw/log/detail/file_recorder/dlt_message_builder_types.h @@ -13,6 +13,8 @@ #ifndef SCORE_MW_LOG_DETAIL_FILE_RECORDER_DLT_MESSAGE_BUILDER_TYPES_H #define SCORE_MW_LOG_DETAIL_FILE_RECORDER_DLT_MESSAGE_BUILDER_TYPES_H +#include "score/quality/compiler_warnings/warnings.h" + #include #include #include @@ -75,26 +77,11 @@ constexpr std::size_t kDltStorageHeaderSize = 16UL; constexpr std::size_t kMaxDltHeaderSize = 512UL; -// NOLINTBEGIN(score-banned-preprocessor-directives) needed to use PACKED attribute // needed to use PACKED attribute as GNU extension -// coverity[autosar_cpp14_a16_0_1_violation] -#if defined(__GNUC__) -// needed to use PACKED attribute -// coverity[autosar_cpp14_a16_7_1_violation] -// coverity[autosar_cpp14_a16_0_1_violation] -#pragma GCC diagnostic push -// needed to use PACKED attribute -// coverity[autosar_cpp14_a16_7_1_violation] -// coverity[autosar_cpp14_a16_0_1_violation] -#pragma GCC diagnostic ignored "-Wpacked" -// needed to use PACKED attribute -// coverity[autosar_cpp14_a16_7_1_violation] -// coverity[autosar_cpp14_a16_0_1_violation] -#pragma GCC diagnostic ignored "-Wattributes" -// needed to use PACKED attribute as GNU extension -// coverity[autosar_cpp14_a16_0_1_violation] -#endif -// NOLINTEND(score-banned-preprocessor-directives) needed to use PACKED attribute + +DISABLE_WARNING_PUSH +DISABLE_WARNING_PACKED +DISABLE_WARNING_ATTRIBUTES /** * The structure of the DLT standard header. This header is used in each DLT message. @@ -148,17 +135,7 @@ struct DltVerboseHeader } PACKED; // needed to use PACKED attribute as GNU extension -// coverity[autosar_cpp14_a16_0_1_violation] -#if defined(__GNUC__) -// NOLINTBEGIN(score-banned-preprocessor-directives) needed to use PACKED attribute -// needed to use PACKED attribute -// coverity[autosar_cpp14_a16_7_1_violation] -// coverity[autosar_cpp14_a16_0_1_violation] -#pragma GCC diagnostic pop -// NOLINTEND(score-banned-preprocessor-directives) needed to use PACKED attribute -// needed to use PACKED attribute as GNU extension -// coverity[autosar_cpp14_a16_0_1_violation] -#endif +DISABLE_WARNING_POP } // namespace detail } // namespace log From 1f09cf65b52e369ad95a6215f4950bcf41cd22a8 Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Wed, 25 Feb 2026 16:37:20 +0100 Subject: [PATCH 09/12] Fix ODR violation in socketserverUT - Either the real or mock UdpStreamOutput should be linked into socketserverUT otherwise this leads to layout mismatch and heap corruption as seen in InitLogChannels - Fix clang_tidy_extra_checks for stub code parts GIT_ORIGIN_SPP_REV_ID: 1a9198cf43559e29c1bfba7af1b22d7132e70d3d --- score/datarouter/BUILD | 14 +++++++--- .../dynamic_config_stub/stub_config_session.h | 6 ++-- .../file_transfer_handler_factory_stub.h | 2 +- .../ut_logging/test_stub_config_session.cpp | 28 +++++++++---------- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/score/datarouter/BUILD b/score/datarouter/BUILD index 19016be..1a2b8b9 100644 --- a/score/datarouter/BUILD +++ b/score/datarouter/BUILD @@ -524,7 +524,7 @@ cc_library( "//conditions:default": ["//score/datarouter/src/persistency/stub_persistent_dictionary:stub_persistent_dictionary_factory"], }) + select({ "//score/datarouter/build_configuration_flags:config_file_transfer": [ - "//score/datarouter/src/file_transfer/file_transfer_impl:file_transfer_stream_handler", + ft_dep, ], "//conditions:default": [ "//score/datarouter/src/file_transfer/file_transfer_stub:file_transfer_stream_handler_stub", @@ -552,7 +552,7 @@ cc_library( ], }), ) - for name, ara_fact_dep, nv_dep, nv_stub_dep, dc_dep, dc_stub_dep, test_only in [ + for name, ara_fact_dep, nv_dep, nv_stub_dep, dc_dep, dc_stub_dep, ft_dep, test_only in [ ( "", "//score/datarouter/src/persistency/ara_per_persistent_dictionary:ara_per_persistent_dictionary_factory", @@ -560,6 +560,7 @@ cc_library( "//score/datarouter/src/dlt/nonverbose_dlt_stub:nonverbose_dlt_handler_stub", "//score/datarouter/src/configuration/dynamic_config/dynamic_config_impl:dynamic_config_session", "//score/datarouter/src/configuration/dynamic_config/dynamic_config_stub:config_session_stub", + "//score/datarouter/src/file_transfer/file_transfer_impl:file_transfer_stream_handler", False, ), ( @@ -569,6 +570,7 @@ cc_library( "//score/datarouter/src/dlt/nonverbose_dlt_stub:nonverbose_dlt_handler_stub_testing", "//score/datarouter/src/configuration/dynamic_config/dynamic_config_impl:dynamic_config_session_testing", "//score/datarouter/src/configuration/dynamic_config/dynamic_config_stub:config_session_stub_testing", + "//score/datarouter/src/file_transfer/file_transfer_impl:file_transfer_stream_handler_testing", True, ), ] @@ -814,7 +816,7 @@ cc_library( deps = [ ":datarouter_feature_config_testing", ":datarouter_lib", - ":dltserver", + ":dltserver_testing", ":persistentlogconfig", ":socketserver_config_lib_testing", "@score_baselibs//score/mw/log/configuration:nvconfigfactory", @@ -939,10 +941,14 @@ cc_library( ], features = COMPILER_WARNING_FEATURES, strip_include_prefix = "mocks", - visibility = ["//score/datarouter/test:__subpackages__"], + visibility = [ + "//score/datarouter/src/file_transfer:__subpackages__", + "//score/datarouter/test:__subpackages__", + ], deps = [ ":dltserver_common", "@googletest//:gtest_main", + "@score_baselibs//score/os:socket", ], ) diff --git a/score/datarouter/src/configuration/dynamic_config/dynamic_config_stub/stub_config_session.h b/score/datarouter/src/configuration/dynamic_config/dynamic_config_stub/stub_config_session.h index 29669cd..49eac59 100644 --- a/score/datarouter/src/configuration/dynamic_config/dynamic_config_stub/stub_config_session.h +++ b/score/datarouter/src/configuration/dynamic_config/dynamic_config_stub/stub_config_session.h @@ -32,12 +32,12 @@ class StubConfigSession : public score::logging::ISession StubConfigSession(Handle&&, Handler&&) { } - bool tick() override + bool Tick() override { return true; } - void on_command(const std::string&) override {} - void on_closed_by_peer() override {} + void OnCommand(const std::string&) override {} + void OnClosedByPeer() override {} }; } // namespace daemon diff --git a/score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_handler_factory_stub.h b/score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_handler_factory_stub.h index c2b4fec..746f149 100644 --- a/score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_handler_factory_stub.h +++ b/score/datarouter/src/file_transfer/file_transfer_stub/file_transfer_handler_factory_stub.h @@ -52,7 +52,7 @@ class StubFileTransferHandlerFactory : public FileTransferHandlerFactory createConcreteHandler() + std::unique_ptr CreateConcreteHandler() { return std::make_unique(mock_output_); } diff --git a/score/datarouter/test/ut/ut_logging/test_stub_config_session.cpp b/score/datarouter/test/ut/ut_logging/test_stub_config_session.cpp index 67d4d3b..d97701d 100644 --- a/score/datarouter/test/ut/ut_logging/test_stub_config_session.cpp +++ b/score/datarouter/test/ut/ut_logging/test_stub_config_session.cpp @@ -86,7 +86,7 @@ TEST_F(StubConfigSessionUT, Tick_ReturnsTrue) score::logging::daemon::StubConfigSession session(std::move(handle), handler); // Act - bool result = session.tick(); + bool result = session.Tick(); // Assert EXPECT_TRUE(result); @@ -103,9 +103,9 @@ TEST_F(StubConfigSessionUT, OnCommand_DoesNothing) // Act & Assert - Should not throw or crash EXPECT_NO_THROW({ - session.on_command("test command"); - session.on_command(""); - session.on_command("another command"); + session.OnCommand("test command"); + session.OnCommand(""); + session.OnCommand("another command"); }); } @@ -120,8 +120,8 @@ TEST_F(StubConfigSessionUT, OnClosedByPeer_DoesNothing) // Act & Assert - Should not throw or crash EXPECT_NO_THROW({ - session.on_closed_by_peer(); - session.on_closed_by_peer(); // Can be called multiple times + session.OnClosedByPeer(); + session.OnClosedByPeer(); // Can be called multiple times }); } @@ -139,9 +139,9 @@ TEST_F(StubConfigSessionUT, IsSessionInterface) // Assert - Should be able to call interface methods EXPECT_NO_THROW({ - EXPECT_TRUE(session->tick()); - session->on_command("test"); - session->on_closed_by_peer(); + EXPECT_TRUE(session->Tick()); + session->OnCommand("test"); + session->OnClosedByPeer(); }); } @@ -177,7 +177,7 @@ TEST_F(StubConfigSessionFactoryUT, CreateConcreteSession_ReturnsValidSession) // Assert ASSERT_NE(session, nullptr); - EXPECT_TRUE(session->tick()); + EXPECT_TRUE(session->Tick()); } TEST_F(StubConfigSessionFactoryUT, CreateConfigSession_ReturnsValidSession) @@ -194,7 +194,7 @@ TEST_F(StubConfigSessionFactoryUT, CreateConfigSession_ReturnsValidSession) // Assert ASSERT_NE(session, nullptr); - EXPECT_TRUE(session->tick()); + EXPECT_TRUE(session->Tick()); } TEST_F(StubConfigSessionFactoryUT, CreateConfigSession_WorksWithDifferentHandlerTypes) @@ -243,10 +243,10 @@ TEST_F(StubConfigSessionFactoryUT, MultipleSessionCreation) for (const auto& session : sessions) { ASSERT_NE(session, nullptr); - EXPECT_TRUE(session->tick()); + EXPECT_TRUE(session->Tick()); EXPECT_NO_THROW({ - session->on_command("test"); - session->on_closed_by_peer(); + session->OnCommand("test"); + session->OnClosedByPeer(); }); } } From 203ecdce9339e312a91b1715044a2544da55d592 Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Wed, 14 Jan 2026 11:26:50 +0100 Subject: [PATCH 10/12] pas: Refactor DltLogServer diag job tests Remove session-based parser/callback tests for SET_LOG_CHANNEL_THRESHOLD, SET_MESSAGING_FILTERING_STATE, and SET_DEFAULT_LOG_LEVEL. Add behavior-focused direct-call tests to verify threshold filtering, filtering toggle behavior, and default log level behavior. Tested: bazel test --config=spp_host_gcc //platform/aas/pas/logging/test/ut/ut_logging:dltserverUT bazel test --config=arm64-qnx-unit-tests //platform/aas/pas/logging/test/ut/ut_logging:dltserverUT_microvm_qnx_5 GIT_ORIGIN_SPP_REV_ID: 657d932afb5b3a78581969bd99d717795cb60877 --- .../test/ut/ut_logging/test_dltserver.cpp | 254 ++++++++++++------ 1 file changed, 169 insertions(+), 85 deletions(-) diff --git a/score/datarouter/test/ut/ut_logging/test_dltserver.cpp b/score/datarouter/test/ut/ut_logging/test_dltserver.cpp index a5f390c..1895141 100644 --- a/score/datarouter/test/ut/ut_logging/test_dltserver.cpp +++ b/score/datarouter/test/ut/ut_logging/test_dltserver.cpp @@ -302,58 +302,6 @@ TEST(ResetToDefaultTest, ResetToDefaultCommandChannelsSizeTooBigNoReadCallback) EXPECT_OK_OR_NOOP(response); } -TEST_F(DltServerCreatedWithConfigFixture, SetDefaultLogLevelWrongCommandExpectReadCallback) -{ - EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); - EXPECT_CALL(write_callback, Call(_)).Times(0); - - DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); - - std::string response{}; - auto session = dlt_server.NewConfigSession( - score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - - session->OnCommand(std::string(kCommandSize, config::kSetDefaultLogLevel)); - - EXPECT_ERR_OR_NOOP(response); -} - -TEST_F(DltServerCreatedWithConfigFixture, SetDefaultLogLevelCommandExpectReadCallback) -{ - EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); - EXPECT_CALL(write_callback, Call(_)).Times(0); - - DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); - - std::string response{}; - auto session = dlt_server.NewConfigSession( - score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - - std::array command_buffer{config::kSetDefaultLogLevel, 1}; - const std::string command{command_buffer.begin(), command_buffer.end()}; - session->OnCommand(command); - - EXPECT_OK_OR_NOOP(response); -} - -TEST_F(DltServerCreatedWithConfigFixture, SetDefaultLogLevelCommandReadLevelErrorExpectReadCallback) -{ - EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); - EXPECT_CALL(write_callback, Call(_)).Times(0); - - DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); - - std::string response{}; - auto session = dlt_server.NewConfigSession( - score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - - std::array command_buffer{config::kSetDefaultLogLevel, 7}; - const std::string command{command_buffer.begin(), command_buffer.end()}; - session->OnCommand(command); - - EXPECT_ERR_OR_NOOP(response); -} - TEST_F(DltServerCreatedWithConfigFixture, SetTraceStateCommandExpectReadCallback) { EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); @@ -598,7 +546,7 @@ TEST_F(DltServerCreatedWithConfigFixture, SetDltOutputEnableCommandCallbackEnabl EXPECT_OK_OR_NOOP(response); } -TEST_F(DltServerCreatedWithConfigFixture, SetMessagingFilteringStateWrongCommandExpectReadCallback) +TEST_F(DltServerCreatedWithConfigFixture, SetDltOutputEnableCommandWrongSizeExpectError) { EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); EXPECT_CALL(write_callback, Call(_)).Times(0); @@ -609,12 +557,13 @@ TEST_F(DltServerCreatedWithConfigFixture, SetMessagingFilteringStateWrongCommand auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - session->OnCommand(std::string(kCommandSize, config::kSetMessagingFilteringState)); + // Send command with wrong size (only command byte, missing enable/disable parameter) + session->OnCommand(std::string(kCommandSize, config::kSetDltOutputEnable)); EXPECT_ERR_OR_NOOP(response); } -TEST_F(DltServerCreatedWithConfigFixture, SetMessagingFilteringStateCommandExpectReadCallback) +TEST_F(DltServerCreatedWithConfigFixture, SetDefaultLogLevelCommandExpectReadCallback) { EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); EXPECT_CALL(write_callback, Call(_)).Times(0); @@ -625,72 +574,119 @@ TEST_F(DltServerCreatedWithConfigFixture, SetMessagingFilteringStateCommandExpec auto session = dlt_server.NewConfigSession( score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); - std::array command_buffer{config::kSetMessagingFilteringState, 1}; + std::array command_buffer{config::kSetDefaultLogLevel, 1}; const std::string command{command_buffer.begin(), command_buffer.end()}; session->OnCommand(command); EXPECT_OK_OR_NOOP(response); } -TEST_F(DltServerCreatedWithConfigFixture, SetLogLevelBehaviorIncreaseThresholdAllowsVerbose) +TEST_F(DltServerCreatedWithConfigFixture, SetDefaultLogLevelCommandReadLevelErrorExpectReadCallback) +{ + EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); + EXPECT_CALL(write_callback, Call(_)).Times(0); + + DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); + + std::string response{}; + auto session = dlt_server.NewConfigSession( + score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); + + std::array command_buffer{config::kSetDefaultLogLevel, 7}; + const std::string command{command_buffer.begin(), command_buffer.end()}; + session->OnCommand(command); + + EXPECT_ERR_OR_NOOP(response); +} + +TEST_F(DltServerCreatedWithConfigFixture, SetDefaultLogLevelBehaviorAffectsNewContexts) { - // Load persistent config (initial thresholds from sConfig.messageThresholds: APP0/CTX0 => kOff) EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); EXPECT_CALL(write_callback, Call(_)).Times(0); - // Use test subclass to access sendVerbose score::logging::dltserver::DltLogServer::DltLogServerTest dlt_server( s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true, std::move(log_sender_mock)); - const score::mw::log::detail::LoggingIdentifier app_id{"APP0"}; - const score::mw::log::detail::LoggingIdentifier ctx_id{"CTX0"}; + // Change default log level to kInfo. + const auto resp = dlt_server.SetDefaultLogLevel(score::mw::log::LogLevel::kInfo); + EXPECT_EQ(resp.size(), 1U); + EXPECT_EQ(resp[0], static_cast(config::kRetOk)); + + // Use a NEW1/CTX1 pair that is not present in the s_config.message_thresholds mapping. + const score::mw::log::detail::LoggingIdentifier new_app_id{"NEW1"}; + const score::mw::log::detail::LoggingIdentifier new_ctx_id{"CTX1"}; + const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection verbose_entry{ - app_id, ctx_id, {}, 0, score::mw::log::LogLevel::kVerbose}; + new_app_id, new_ctx_id, {}, 0, score::mw::log::LogLevel::kVerbose}; + const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection info_entry{ + new_app_id, new_ctx_id, {}, 0, score::mw::log::LogLevel::kInfo}; - // Initially threshold for APP0/CTX0 is kOff, so verbose should be filtered out. + // With default set to kInfo, verbose must be filtered. EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(0); dlt_server.SendVerbose(100U, verbose_entry); ::testing::Mock::VerifyAndClearExpectations(log_sender_mock_raw_ptr); - // Increase threshold to kVerbose for APP0/CTX0 using direct API - const ThresholdT new_threshold{LoglevelT{score::mw::log::LogLevel::kVerbose}}; - const auto resp = dlt_server.SetLogLevel(DltidT{"APP0"}, DltidT{"CTX0"}, new_threshold); - // Response always one byte RET_OK - EXPECT_EQ(resp[0], static_cast(config::kRetOk)); + // Info should be forwarded. + EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(1); + dlt_server.SendVerbose(100U, info_entry); +} - // Now verbose should pass filtering and be forwarded once per assigned channel (DFLT + CORE) -> 2 calls. - EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(2); - dlt_server.SendVerbose(100U, verbose_entry); +TEST_F(DltServerCreatedWithConfigFixture, SetMessagingFilteringStateCommandExpectReadCallback) +{ + EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); + EXPECT_CALL(write_callback, Call(_)).Times(0); + + DltLogServer dlt_server(s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true); + + std::string response{}; + auto session = dlt_server.NewConfigSession( + score::platform::datarouter::ConfigSessionHandleType{0, nullptr, std::reference_wrapper{response}}); + + std::array command_buffer{config::kSetMessagingFilteringState, 1}; + const std::string command{command_buffer.begin(), command_buffer.end()}; + session->OnCommand(command); + + EXPECT_OK_OR_NOOP(response); } -TEST_F(DltServerCreatedWithConfigFixture, SetLogLevelBehaviorResetToDefaultBlocksVerboseAgain) +TEST_F(DltServerCreatedWithConfigFixture, SetMessagingFilteringStateBehaviorBypassesThresholds) { EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); EXPECT_CALL(write_callback, Call(_)).Times(0); + // Start with filtering enabled (default in s_config). score::logging::dltserver::DltLogServer::DltLogServerTest dlt_server( s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true, std::move(log_sender_mock)); + // Set CORE threshold to kInfo so it would normally block verbose. + const auto resp_threshold = dlt_server.SetLogChannelThreshold(DltidT{"CORE"}, score::mw::log::LogLevel::kInfo); + EXPECT_EQ(resp_threshold[0], static_cast(config::kRetOk)); + const score::mw::log::detail::LoggingIdentifier app_id{"APP0"}; - const score::mw::log::detail::LoggingIdentifier ctx_id{"CTX0"}; + const score::mw::log::detail::LoggingIdentifier core_ctx_id{"CORE"}; const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection verbose_entry{ - app_id, ctx_id, {}, 0, score::mw::log::LogLevel::kVerbose}; + app_id, core_ctx_id, {}, 0, score::mw::log::LogLevel::kVerbose}; - // Raise threshold first so verbose is forwarded - const ThresholdT raise_threshold{LoglevelT{score::mw::log::LogLevel::kVerbose}}; - const auto resp_raise = dlt_server.SetLogLevel(DltidT{"APP0"}, DltidT{"CTX0"}, raise_threshold); - EXPECT_EQ(resp_raise[0], static_cast(config::kRetOk)); - // With raise_threshold, verbose accepted and forwarded for both assigned channels -> 2 calls. - EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(2); + // With filtering enabled, verbose should be filtered. + EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(0); dlt_server.SendVerbose(100U, verbose_entry); ::testing::Mock::VerifyAndClearExpectations(log_sender_mock_raw_ptr); - // Now reset to default (ThresholdCmd::UseDefault removes specific mapping) - const ThresholdT reset_threshold{ThresholdCmd::kUseDefault}; - const auto resp_reset = dlt_server.SetLogLevel(DltidT{"APP0"}, DltidT{"CTX0"}, reset_threshold); - EXPECT_EQ(resp_reset[0], static_cast(config::kRetOk)); + // Disable messaging filtering: thresholds should be bypassed and verbose should be forwarded. + const auto resp_disable = dlt_server.SetMessagingFilteringState(false); + EXPECT_EQ(resp_disable.size(), 1U); + EXPECT_EQ(resp_disable[0], static_cast(config::kRetOk)); + + // When filtering is disabled, verbose is forwarded. + EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(1); + dlt_server.SendVerbose(100U, verbose_entry); + ::testing::Mock::VerifyAndClearExpectations(log_sender_mock_raw_ptr); + + // Re-enable filtering: verbose should be filtered again. + const auto resp_enable = dlt_server.SetMessagingFilteringState(true); + EXPECT_EQ(resp_enable.size(), 1U); + EXPECT_EQ(resp_enable[0], static_cast(config::kRetOk)); - // With default threshold kOff, verbose must be filtered again EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(0); dlt_server.SendVerbose(100U, verbose_entry); } @@ -747,6 +743,94 @@ TEST_F(DltServerCreatedWithConfigFixture, SetLogChannelThresholdChannelFoundComm EXPECT_OK_OR_NOOP(response); } +TEST_F(DltServerCreatedWithConfigFixture, SetLogChannelThresholdBehaviorFiltersLowerLevels) +{ + EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); + EXPECT_CALL(write_callback, Call(_)).Times(0); + + score::logging::dltserver::DltLogServer::DltLogServerTest dlt_server( + s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true, std::move(log_sender_mock)); + + // Set CORE channel threshold to kInfo. + const auto resp = dlt_server.SetLogChannelThreshold(DltidT{"CORE"}, score::mw::log::LogLevel::kInfo); + EXPECT_EQ(resp.size(), 1U); + EXPECT_EQ(resp[0], static_cast(config::kRetOk)); + + // Route against a known mapping that is already used elsewhere in this file: + // APP0/CTX0 is assigned to the CORE channel in the fixture config. + const score::mw::log::detail::LoggingIdentifier app_id{"APP0"}; + const score::mw::log::detail::LoggingIdentifier ctx_id{"CTX0"}; + + const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection verbose_entry{ + app_id, ctx_id, {}, 0, score::mw::log::LogLevel::kVerbose}; + // With the threshold raised to kInfo, verbose must be filtered. + EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(0); + dlt_server.SendVerbose(100U, verbose_entry); +} + +TEST_F(DltServerCreatedWithConfigFixture, SetLogLevelBehaviorIncreaseThresholdAllowsVerbose) +{ + // Load persistent config (initial thresholds from s_config.message_thresholds: APP0/CTX0 => kOff) + EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); + EXPECT_CALL(write_callback, Call(_)).Times(0); + + // Use test subclass to access SendVerbose + score::logging::dltserver::DltLogServer::DltLogServerTest dlt_server( + s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true, std::move(log_sender_mock)); + + const score::mw::log::detail::LoggingIdentifier app_id{"APP0"}; + const score::mw::log::detail::LoggingIdentifier ctx_id{"CTX0"}; + const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection verbose_entry{ + app_id, ctx_id, {}, 0, score::mw::log::LogLevel::kVerbose}; + + // Initially threshold for APP0/CTX0 is kOff, so verbose should be filtered out. + EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(0); + dlt_server.SendVerbose(100U, verbose_entry); + ::testing::Mock::VerifyAndClearExpectations(log_sender_mock_raw_ptr); + + // Increase threshold to kVerbose for APP0/CTX0 using direct API + const ThresholdT new_threshold{LoglevelT{score::mw::log::LogLevel::kVerbose}}; + const auto resp = dlt_server.SetLogLevel(DltidT{"APP0"}, DltidT{"CTX0"}, new_threshold); + // Response always one byte kRetOk + EXPECT_EQ(resp[0], static_cast(config::kRetOk)); + + // Now verbose should pass filtering and be forwarded once per assigned channel (DFLT + CORE) -> 2 calls. + EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(2); + dlt_server.SendVerbose(100U, verbose_entry); +} + +TEST_F(DltServerCreatedWithConfigFixture, SetLogLevelBehaviorResetToDefaultBlocksVerboseAgain) +{ + EXPECT_CALL(read_callback, Call()).Times(1).WillOnce(Return(p_config)); + EXPECT_CALL(write_callback, Call(_)).Times(0); + + score::logging::dltserver::DltLogServer::DltLogServerTest dlt_server( + s_config, read_callback.AsStdFunction(), write_callback.AsStdFunction(), true, std::move(log_sender_mock)); + + const score::mw::log::detail::LoggingIdentifier app_id{"APP0"}; + const score::mw::log::detail::LoggingIdentifier ctx_id{"CTX0"}; + const score::mw::log::detail::log_entry_deserialization::LogEntryDeserializationReflection verbose_entry{ + app_id, ctx_id, {}, 0, score::mw::log::LogLevel::kVerbose}; + + // Raise threshold first so verbose is forwarded + const ThresholdT raise_threshold{LoglevelT{score::mw::log::LogLevel::kVerbose}}; + const auto resp_raise = dlt_server.SetLogLevel(DltidT{"APP0"}, DltidT{"CTX0"}, raise_threshold); + EXPECT_EQ(resp_raise[0], static_cast(config::kRetOk)); + // With raise_threshold, verbose accepted and forwarded for both assigned channels -> 2 calls. + EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(2); + dlt_server.SendVerbose(100U, verbose_entry); + ::testing::Mock::VerifyAndClearExpectations(log_sender_mock_raw_ptr); + + // Now reset to default (ThresholdCmd::UseDefault removes specific mapping) + const ThresholdT reset_threshold{ThresholdCmd::kUseDefault}; + const auto resp_reset = dlt_server.SetLogLevel(DltidT{"APP0"}, DltidT{"CTX0"}, reset_threshold); + EXPECT_EQ(resp_reset[0], static_cast(config::kRetOk)); + + // With default threshold kOff, verbose must be filtered again + EXPECT_CALL(*log_sender_mock_raw_ptr, SendVerbose(_, _, _)).Times(0); + dlt_server.SendVerbose(100U, verbose_entry); +} + TEST(DltServerTest, ExtractIdValidInputDataExpectValidResult) { const std::string input_message{"asdAPP012345678zxccvb86545"}; From 3baeaf99e1e7ab9f15f2d9ce6e94040808f19b4b Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Fri, 27 Feb 2026 10:10:16 +0100 Subject: [PATCH 11/12] Fix new line that the copyright header checker misses out GIT_ORIGIN_SPP_REV_ID: 6a14ce49ce93029ecf9882f5aaecafe29be846cf --- score/datarouter/include/daemon/i_diagnostic_job_parser.h | 1 - 1 file changed, 1 deletion(-) diff --git a/score/datarouter/include/daemon/i_diagnostic_job_parser.h b/score/datarouter/include/daemon/i_diagnostic_job_parser.h index 900b5b2..7f08411 100644 --- a/score/datarouter/include/daemon/i_diagnostic_job_parser.h +++ b/score/datarouter/include/daemon/i_diagnostic_job_parser.h @@ -1,4 +1,3 @@ - /******************************************************************************** * Copyright (c) 2025 Contributors to the Eclipse Foundation * From 3baf953b799b444fc430ad37a4722ef035a4e99f Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Mon, 2 Mar 2026 09:23:42 +0100 Subject: [PATCH 12/12] Bumps baselibs - Required for migrating changes due to extra_clang_tidy_fixes --- MODULE.bazel | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MODULE.bazel b/MODULE.bazel index 0b7aa25..3d731ac 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -94,6 +94,12 @@ use_repo(python) bazel_dep(name = "googletest", version = "1.17.0.bcr.1") bazel_dep(name = "rapidjson", version = "1.1.0") bazel_dep(name = "score_baselibs", version = "0.2.4") +git_override( + module_name = "score_baselibs", + commit = "4b67ce1929575801405c77f7e3c79ab36156a976", + remote = "https://github.com/eclipse-score/baselibs.git", +) + bazel_dep(name = "score_communication", version = "0.1.2") git_override( module_name = "score_communication",