From 2fbd70a088e20672985da92a3dfcd29743bc3cc0 Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Wed, 4 Feb 2026 18:03:03 +0100 Subject: [PATCH 01/29] Adds commit_message component that scrubs the commit Issue id GIT_ORIGIN_SPP_REV_ID: 027d974df77ead0b650e002101e61363753e2e16 --- score/datarouter/BUILD | 26 +++++---- .../build_configuration_flags/BUILD | 12 ++--- score/datarouter/daemon_communication/BUILD | 4 +- .../dlt_filetransfer_trigger_lib/BUILD | 6 +-- .../config_session_factory/BUILD | 2 +- .../config_session_stub/BUILD | 6 +-- .../dynamic_configuration/i_session/BUILD | 2 +- score/datarouter/error/BUILD | 2 +- .../include/daemon/i_diagnostic_job_parser.h | 1 + score/datarouter/model/BUILD | 25 +++++++++ score/datarouter/model/datarouter.fcdl | 7 +++ score/datarouter/model/interface/BUILD | 25 +++++++++ .../model/interface/Persistency.fdepl | 22 ++++++++ .../model/interface/Persistency.fidl | 13 +++++ score/datarouter/network/BUILD | 2 +- score/datarouter/nonverbose_dlt_stub/BUILD | 10 ++-- score/datarouter/src/file_transfer/BUILD | 2 +- .../file_transfer/file_transfer_stub/BUILD | 14 ++--- score/datarouter/src/persistency/BUILD | 6 +-- .../stub_persistent_dictionary/BUILD | 4 +- score/datarouter/src/persistent_logging/BUILD | 2 +- .../persistent_logging_stub/BUILD | 4 +- score/datarouter/test/BUILD | 2 +- score/datarouter/test/ut/BUILD | 2 +- score/datarouter/test/ut/etc/BUILD | 2 +- score/datarouter/test/ut/ut_logging/BUILD | 54 +++++++++---------- score/mw/log/detail/common/BUILD | 2 +- score/mw/log/detail/data_router/BUILD | 2 +- .../detail/data_router/shared_memory/BUILD | 2 +- score/mw/log/legacy_non_verbose_api/BUILD | 4 +- 30 files changed, 179 insertions(+), 88 deletions(-) create mode 100644 score/datarouter/model/BUILD create mode 100644 score/datarouter/model/datarouter.fcdl create mode 100644 score/datarouter/model/interface/BUILD create mode 100644 score/datarouter/model/interface/Persistency.fdepl create mode 100644 score/datarouter/model/interface/Persistency.fidl diff --git a/score/datarouter/BUILD b/score/datarouter/BUILD index f3a52c8..5de0093 100644 --- a/score/datarouter/BUILD +++ b/score/datarouter/BUILD @@ -322,7 +322,7 @@ cc_library( ], visibility = [ "//platform/aas/pas/datarouterconf:__subpackages__", - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], ) @@ -335,11 +335,11 @@ filegroup( "etc/persistent-logging.json", ], visibility = [ - "//ecu/xpad/xpad-shared/config/common/pas/datarouter:__subpackages__", + "//pqr/abc/abc-lmn/config/common/pas/datarouter:__subpackages__", "//score/datarouter/test:__subpackages__", "//platform/aas/tools/itf:__subpackages__", "//platform/aas/tools/sctf:__subpackages__", - # "@ddad//ecu/xpad/xpad-shared/config/common/pas/datarouter:__subpackages__", + # "@xyz//pqr/abc/abc-lmn/config/common/pas/datarouter:__subpackages__", ], ) @@ -369,7 +369,7 @@ cc_library( ], features = COMPILER_WARNING_FEATURES, visibility = [ - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], deps = [ ":log", @@ -429,7 +429,7 @@ cc_library( ], features = COMPILER_WARNING_FEATURES, visibility = [ - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], deps = [ ":datarouter_types", @@ -502,7 +502,7 @@ cc_library( }), strip_include_prefix = "include", visibility = [ - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], deps = select({ "//score/datarouter/build_configuration_flags:config_persistent_configuration": [ @@ -677,7 +677,7 @@ cc_library( features = COMPILER_WARNING_FEATURES, strip_include_prefix = "include", visibility = [ - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], deps = [ ":dltprotocol", @@ -708,13 +708,13 @@ cc_library( ":dltserver_common", ":persistentlogconfig", ":socketserver_config_helpers", - "//score/datarouter:datarouter_types", "//score/datarouter/error:logging_error", "//score/datarouter/src/persistency:interface", "@rapidjson", "@score_baselibs//score/language/futurecpp", "@score_baselibs//score/static_reflection_with_serialization/serialization", "@score_baselibs//score/static_reflection_with_serialization/visitor", + "@score_logging//score/datarouter:datarouter_types", ], ) @@ -737,13 +737,13 @@ cc_library( ":datarouter_testing", ":dltserver_common", ":persistentlogconfig", - "//score/datarouter:datarouter_types", "//score/datarouter/error:logging_error", "//score/datarouter/src/persistency:mock", "@rapidjson", "@score_baselibs//score/language/futurecpp", "@score_baselibs//score/static_reflection_with_serialization/serialization", "@score_baselibs//score/static_reflection_with_serialization/visitor", + "@score_logging//score/datarouter:datarouter_types", ], ) @@ -755,7 +755,6 @@ cc_library( hdrs = [ "include/daemon/socketserver.h", ], - # TODO: will be reworked in Ticket-207823 features = COMPILER_WARNING_FEATURES, local_defines = select({ "//score/datarouter/build_configuration_flags:config_persistent_logging": ["PERSISTENT_LOGGING"], @@ -763,8 +762,8 @@ cc_library( }), strip_include_prefix = "include", visibility = [ - "//score/datarouter:__pkg__", "//score/datarouter/test:__subpackages__", + "@score_logging//score/datarouter:__pkg__", ], deps = [ ":datarouter_feature_config", @@ -790,7 +789,6 @@ cc_library( hdrs = [ "include/daemon/socketserver.h", ], - # TODO: will be reworked in Ticket-207823 features = COMPILER_WARNING_FEATURES, local_defines = select({ "//score/datarouter/build_configuration_flags:config_persistent_logging": ["PERSISTENT_LOGGING"], @@ -891,7 +889,7 @@ cc_library( ], features = COMPILER_WARNING_FEATURES, strip_include_prefix = "include", - visibility = ["//score/datarouter:__subpackages__"], + visibility = ["@score_logging//score/datarouter:__subpackages__"], deps = [ ":dltserver_common", "//score/datarouter/network:vlan", @@ -1016,7 +1014,7 @@ cc_library( features = COMPILER_WARNING_FEATURES, strip_include_prefix = "include", visibility = [ - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], deps = [ # It's being conflicted with the real udp_stream_output target that used diff --git a/score/datarouter/build_configuration_flags/BUILD b/score/datarouter/build_configuration_flags/BUILD index 08a775d..c3ef71e 100644 --- a/score/datarouter/build_configuration_flags/BUILD +++ b/score/datarouter/build_configuration_flags/BUILD @@ -25,7 +25,7 @@ config_setting( }, visibility = [ "//platform/aas/test/pas/datarouterconf:__subpackages__", - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], ) @@ -37,7 +37,7 @@ bool_flag( config_setting( name = "config_persistent_configuration", flag_values = {":persistent_config_feature_enabled": "True"}, - visibility = ["//score/datarouter:__subpackages__"], + visibility = ["@score_logging//score/datarouter:__subpackages__"], ) bool_flag( @@ -51,7 +51,7 @@ config_setting( ":enable_nonverbose_dlt": "True", }, visibility = [ - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], ) @@ -66,7 +66,7 @@ config_setting( ":enable_dynamic_configuration_in_datarouter": "True", }, visibility = [ - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], ) @@ -81,7 +81,7 @@ config_setting( ":file_transfer": "True", }, visibility = [ - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], ) @@ -96,7 +96,7 @@ config_setting( ":enable_thin_network_sender": "False", }, visibility = [ - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], ) diff --git a/score/datarouter/daemon_communication/BUILD b/score/datarouter/daemon_communication/BUILD index e66e9ba..8ccadbb 100644 --- a/score/datarouter/daemon_communication/BUILD +++ b/score/datarouter/daemon_communication/BUILD @@ -32,7 +32,7 @@ cc_library( "session_handle_interface.h", ], features = COMPILER_WARNING_FEATURES, - visibility = ["//score/datarouter:__subpackages__"], + visibility = ["@score_logging//score/datarouter:__subpackages__"], ) cc_library( @@ -43,7 +43,7 @@ cc_library( ], features = COMPILER_WARNING_FEATURES, visibility = [ - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], deps = [ "@googletest//:gtest", diff --git a/score/datarouter/dlt_filetransfer_trigger_lib/BUILD b/score/datarouter/dlt_filetransfer_trigger_lib/BUILD index 5e3eb57..72af8fe 100644 --- a/score/datarouter/dlt_filetransfer_trigger_lib/BUILD +++ b/score/datarouter/dlt_filetransfer_trigger_lib/BUILD @@ -47,7 +47,7 @@ cc_library( ], deps = [ "filetransfer_message_types", - "//score/datarouter:log", + "@score_logging//score/datarouter:log", ], ) @@ -61,11 +61,11 @@ cc_library( visibility = [ "//platform/aas/pas/crash_handler:__subpackages__", "//platform/aas/pas/datarouterconf/src/filetransfer:__subpackages__", - "//score/datarouter:__subpackages__", "//score/mw/log/legacy_non_verbose_api:__pkg__", + "@score_logging//score/datarouter:__subpackages__", ], deps = [ - "//score/datarouter:dltprotocol", + "@score_logging//score/datarouter:dltprotocol", ], ) diff --git a/score/datarouter/dynamic_configuration/config_session_factory/BUILD b/score/datarouter/dynamic_configuration/config_session_factory/BUILD index b9a1343..c0a9ad6 100644 --- a/score/datarouter/dynamic_configuration/config_session_factory/BUILD +++ b/score/datarouter/dynamic_configuration/config_session_factory/BUILD @@ -36,7 +36,7 @@ clang_tidy_extra_checks( features = COMPILER_WARNING_FEATURES, strip_include_prefix = ".", visibility = [ - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], deps = deps, ) diff --git a/score/datarouter/dynamic_configuration/config_session_stub/BUILD b/score/datarouter/dynamic_configuration/config_session_stub/BUILD index 1c1848c..e0753fc 100644 --- a/score/datarouter/dynamic_configuration/config_session_stub/BUILD +++ b/score/datarouter/dynamic_configuration/config_session_stub/BUILD @@ -45,8 +45,8 @@ clang_tidy_extra_checks( "", False, [ - "//score/datarouter:__pkg__", - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__pkg__", + "@score_logging//score/datarouter:__subpackages__", ], [ "//score/datarouter/dynamic_configuration/config_session_factory", @@ -57,7 +57,7 @@ clang_tidy_extra_checks( "_testing", True, [ - "//score/datarouter:__pkg__", + "@score_logging//score/datarouter:__pkg__", "//score/datarouter/test:__subpackages__", ], [ diff --git a/score/datarouter/dynamic_configuration/i_session/BUILD b/score/datarouter/dynamic_configuration/i_session/BUILD index c6450ed..50ea6cc 100644 --- a/score/datarouter/dynamic_configuration/i_session/BUILD +++ b/score/datarouter/dynamic_configuration/i_session/BUILD @@ -34,6 +34,6 @@ cc_library( features = COMPILER_WARNING_FEATURES, strip_include_prefix = ".", visibility = [ - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], ) diff --git a/score/datarouter/error/BUILD b/score/datarouter/error/BUILD index 9fd0a03..058312f 100644 --- a/score/datarouter/error/BUILD +++ b/score/datarouter/error/BUILD @@ -35,7 +35,7 @@ cc_library( "error.h", ], features = COMPILER_WARNING_FEATURES, - visibility = ["//score/datarouter:__subpackages__"], + visibility = ["@score_logging//score/datarouter:__subpackages__"], deps = [ "@score_baselibs//score/memory:string_literal", "@score_baselibs//score/result", diff --git a/score/datarouter/include/daemon/i_diagnostic_job_parser.h b/score/datarouter/include/daemon/i_diagnostic_job_parser.h index 29ee5c2..58f5c81 100644 --- a/score/datarouter/include/daemon/i_diagnostic_job_parser.h +++ b/score/datarouter/include/daemon/i_diagnostic_job_parser.h @@ -1,3 +1,4 @@ + /******************************************************************************** * Copyright (c) 2025 Contributors to the Eclipse Foundation * diff --git a/score/datarouter/model/BUILD b/score/datarouter/model/BUILD new file mode 100644 index 0000000..698c6ff --- /dev/null +++ b/score/datarouter/model/BUILD @@ -0,0 +1,25 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +filegroup( + name = "model", + srcs = [ + "datarouter.fcdl", + "//platform/aas/intc/lifecycle_state_machine/adaptive_model/interfaces:machinefgstate_interface", + "//score/datarouter/model/interface:persistency", + ], + visibility = [ + "//pqr/abc/abc-lmn/config/common/pas/datarouter:__subpackages__", + # "@xyz//pqr/abc/abc-lmn/config/common/pas/datarouter:__subpackages__", + ], +) diff --git a/score/datarouter/model/datarouter.fcdl b/score/datarouter/model/datarouter.fcdl new file mode 100644 index 0000000..63c7489 --- /dev/null +++ b/score/datarouter/model/datarouter.fcdl @@ -0,0 +1,7 @@ +package bmw.platform.datarouter + +import bmw.platform.datarouter.PortInterfaces.* from "interface/Persistency.fidl" + +service component datarouter { + provides PersistencyNvmblockInterface as PersistencyNvmblockPPort +} diff --git a/score/datarouter/model/interface/BUILD b/score/datarouter/model/interface/BUILD new file mode 100644 index 0000000..b0c6849 --- /dev/null +++ b/score/datarouter/model/interface/BUILD @@ -0,0 +1,25 @@ +# ******************************************************************************* +# 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 +# ******************************************************************************* + +filegroup( + name = "persistency", + srcs = [ + "Persistency.fdepl", + "Persistency.fidl", + "//platform/aas/tools/franca/deployment_specifications:persistency", + ], + visibility = [ + "//platform/aas/test/bazel:__pkg__", + "//score/datarouter/model:__pkg__", + ], +) diff --git a/score/datarouter/model/interface/Persistency.fdepl b/score/datarouter/model/interface/Persistency.fdepl new file mode 100644 index 0000000..26d1cfa --- /dev/null +++ b/score/datarouter/model/interface/Persistency.fdepl @@ -0,0 +1,22 @@ +package bmw.platform.datarouter.PortInterfaces + +import "platform:/resource/AASModel/platform/aas/tools/franca/deployment_specifications/persistency_deployment_spec.fdepl" + +import "Persistency.fidl" + +define persistency for interface bmw.platform.datarouter.PortInterfaces.PersistencyNvmblockInterface as persistencyNvmblockDepl { + UpdateStrategy = KeepExisting + Redundancy = None + + attribute dataRouter { + UpdateStrategy = Overwrite + } + + attribute dltConfig { + UpdateStrategy = Overwrite + } + + attribute dltOutputEnabled { + UpdateStrategy = Overwrite + } +} diff --git a/score/datarouter/model/interface/Persistency.fidl b/score/datarouter/model/interface/Persistency.fidl new file mode 100644 index 0000000..d8eb00a --- /dev/null +++ b/score/datarouter/model/interface/Persistency.fidl @@ -0,0 +1,13 @@ +package bmw.platform.datarouter.PortInterfaces + +interface PersistencyNvmblockInterface +{ + version { + major 1 + minor 0 + } + + attribute String dataRouter + attribute String dltConfig + attribute String dltOutputEnabled +} diff --git a/score/datarouter/network/BUILD b/score/datarouter/network/BUILD index 6128587..053c4aa 100644 --- a/score/datarouter/network/BUILD +++ b/score/datarouter/network/BUILD @@ -39,7 +39,7 @@ cc_library( "additional_warnings", "strict_warnings", ], - visibility = ["//score/datarouter:__pkg__"], + visibility = ["@score_logging//score/datarouter:__pkg__"], deps = select({ "//score/datarouter/build_configuration_flags:enable_local_vlan": [":vlan_local"], "//conditions:default": [":vlan_local"], diff --git a/score/datarouter/nonverbose_dlt_stub/BUILD b/score/datarouter/nonverbose_dlt_stub/BUILD index 5ae03b5..170c4f5 100644 --- a/score/datarouter/nonverbose_dlt_stub/BUILD +++ b/score/datarouter/nonverbose_dlt_stub/BUILD @@ -36,26 +36,26 @@ clang_tidy_extra_checks( features = COMPILER_WARNING_FEATURES, strip_include_prefix = ".", visibility = [ - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], deps = [ - "//score/datarouter:log", - "//score/datarouter:logparser", "@score_baselibs//score/mw/log/configuration:nvconfig", + "@score_logging//score/datarouter:log", + "@score_logging//score/datarouter:logparser", ] + dep, ) for name, dep, test_only in [ ( "", [ - "//score/datarouter:dlt_log_channel_lib", + "@score_logging//score/datarouter:dlt_log_channel_lib", ], False, ), ( "_testing", [ - "//score/datarouter:dlt_log_channel_lib_testing", + "@score_logging//score/datarouter:dlt_log_channel_lib_testing", ], True, ), diff --git a/score/datarouter/src/file_transfer/BUILD b/score/datarouter/src/file_transfer/BUILD index 178608a..3315720 100644 --- a/score/datarouter/src/file_transfer/BUILD +++ b/score/datarouter/src/file_transfer/BUILD @@ -37,6 +37,6 @@ cc_library( "//score/datarouter/test:__subpackages__", ], deps = [ - "//score/datarouter:logparser", + "@score_logging//score/datarouter:logparser", ], ) diff --git a/score/datarouter/src/file_transfer/file_transfer_stub/BUILD b/score/datarouter/src/file_transfer/file_transfer_stub/BUILD index d550980..cd2c614 100644 --- a/score/datarouter/src/file_transfer/file_transfer_stub/BUILD +++ b/score/datarouter/src/file_transfer/file_transfer_stub/BUILD @@ -21,13 +21,13 @@ cc_library( ], features = COMPILER_WARNING_FEATURES, visibility = [ - "//score/datarouter:__pkg__", "//score/datarouter/test:__subpackages__", + "@score_logging//score/datarouter:__pkg__", ], deps = [ ":file_transfer_stream_handler_stub", - "//score/datarouter:logparser", "//score/datarouter/src/file_transfer:file_transfer_handler_factory", + "@score_logging//score/datarouter:logparser", ], ) @@ -38,13 +38,13 @@ cc_library( ], features = COMPILER_WARNING_FEATURES, visibility = [ - "//score/datarouter:__pkg__", + "@score_logging//score/datarouter:__pkg__", ], deps = [ - "//score/datarouter:dltprotocol", - "//score/datarouter:dltserver_common", - "//score/datarouter:log", - "//score/datarouter:logparser", "@score_baselibs//score/language/futurecpp", + "@score_logging//score/datarouter:dltprotocol", + "@score_logging//score/datarouter:dltserver_common", + "@score_logging//score/datarouter:log", + "@score_logging//score/datarouter:logparser", ], ) diff --git a/score/datarouter/src/persistency/BUILD b/score/datarouter/src/persistency/BUILD index 17ad2f0..78d2059 100644 --- a/score/datarouter/src/persistency/BUILD +++ b/score/datarouter/src/persistency/BUILD @@ -30,7 +30,7 @@ cc_library( name = "interface", hdrs = ["i_persistent_dictionary.h"], features = COMPILER_WARNING_FEATURES, - visibility = ["//score/datarouter:__subpackages__"], + visibility = ["@score_logging//score/datarouter:__subpackages__"], ) cc_library( @@ -39,7 +39,7 @@ cc_library( "persistent_dictionary_factory.hpp", ], features = COMPILER_WARNING_FEATURES, - visibility = ["//score/datarouter:__subpackages__"], + visibility = ["@score_logging//score/datarouter:__subpackages__"], deps = [ ":interface", ], @@ -52,7 +52,7 @@ cc_library( "mock_persistent_dictionary.h", ], features = COMPILER_WARNING_FEATURES, - visibility = ["//score/datarouter:__subpackages__"], + visibility = ["@score_logging//score/datarouter:__subpackages__"], deps = [ ":interface", "@googletest//:gtest", diff --git a/score/datarouter/src/persistency/stub_persistent_dictionary/BUILD b/score/datarouter/src/persistency/stub_persistent_dictionary/BUILD index 93e0d74..09a3029 100644 --- a/score/datarouter/src/persistency/stub_persistent_dictionary/BUILD +++ b/score/datarouter/src/persistency/stub_persistent_dictionary/BUILD @@ -23,7 +23,7 @@ cc_library( "stub_persistent_dictionary.h", ], features = COMPILER_WARNING_FEATURES, - visibility = ["//score/datarouter:__subpackages__"], + visibility = ["@score_logging//score/datarouter:__subpackages__"], deps = [ "//score/datarouter/src/persistency:interface", ], @@ -37,7 +37,7 @@ cc_library( hdrs = [ "stub_persistent_dictionary_factory.h", ], - visibility = ["//score/datarouter:__subpackages__"], + visibility = ["@score_logging//score/datarouter:__subpackages__"], deps = [ ":stub", "//score/datarouter/src/persistency:persistency_factory", diff --git a/score/datarouter/src/persistent_logging/BUILD b/score/datarouter/src/persistent_logging/BUILD index 7811b88..05d9a6a 100644 --- a/score/datarouter/src/persistent_logging/BUILD +++ b/score/datarouter/src/persistent_logging/BUILD @@ -32,7 +32,7 @@ cc_library( ], visibility = ["//score/datarouter/src/persistent_logging:__subpackages__"], deps = [ - "//score/datarouter:logparser", + "@score_logging//score/datarouter:logparser", ], ) diff --git a/score/datarouter/src/persistent_logging/persistent_logging_stub/BUILD b/score/datarouter/src/persistent_logging/persistent_logging_stub/BUILD index a66bf6e..a4c7d1b 100644 --- a/score/datarouter/src/persistent_logging/persistent_logging_stub/BUILD +++ b/score/datarouter/src/persistent_logging/persistent_logging_stub/BUILD @@ -23,10 +23,10 @@ cc_library( "stub_sysedr_factory.h", "stub_sysedr_handler.h", ], - visibility = ["//score/datarouter:__subpackages__"], + visibility = ["@score_logging//score/datarouter:__subpackages__"], deps = [ - "//score/datarouter:log", "//score/datarouter/src/persistent_logging:sysedr_factory", "//score/datarouter/src/persistent_logging:sysedr_handler_interface", + "@score_logging//score/datarouter:log", ], ) diff --git a/score/datarouter/test/BUILD b/score/datarouter/test/BUILD index dfcc468..a7e6d5a 100644 --- a/score/datarouter/test/BUILD +++ b/score/datarouter/test/BUILD @@ -34,7 +34,7 @@ test_suite( tests = [ "//score/datarouter/test/ut:unit_tests", ], - visibility = ["//score/datarouter:__pkg__"], + visibility = ["@score_logging//score/datarouter:__pkg__"], ) py_unittest_qnx_test( diff --git a/score/datarouter/test/ut/BUILD b/score/datarouter/test/ut/BUILD index 2a59c9b..a2b9c6c 100644 --- a/score/datarouter/test/ut/BUILD +++ b/score/datarouter/test/ut/BUILD @@ -22,7 +22,7 @@ test_suite( tests = [ "//score/datarouter/test/ut/ut_logging:unit_tests", ], - visibility = ["//score/datarouter:__pkg__"], + visibility = ["@score_logging//score/datarouter:__pkg__"], ) py_unittest_qnx_test( diff --git a/score/datarouter/test/ut/etc/BUILD b/score/datarouter/test/ut/etc/BUILD index b2fa745..098ef88 100644 --- a/score/datarouter/test/ut/etc/BUILD +++ b/score/datarouter/test/ut/etc/BUILD @@ -24,7 +24,7 @@ filegroup( ], visibility = [ "//platform/aas/pas/datarouterconf:__subpackages__", - "//score/datarouter:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], ) diff --git a/score/datarouter/test/ut/ut_logging/BUILD b/score/datarouter/test/ut/ut_logging/BUILD index 0f92458..e852d21 100644 --- a/score/datarouter/test/ut/ut_logging/BUILD +++ b/score/datarouter/test/ut/ut_logging/BUILD @@ -44,7 +44,7 @@ test_suite( ":unix_domain_server_test", ":utility_test", ], - visibility = ["//score/datarouter:__pkg__"], + visibility = ["@score_logging//score/datarouter:__pkg__"], ) cc_test( @@ -60,9 +60,9 @@ cc_test( ], tags = ["unit"], deps = [ - "//score/datarouter:log_entry_deserialization", "@googletest//:gtest_main", "@score_baselibs//score/static_reflection_with_serialization/serialization", + "@score_logging//score/datarouter:log_entry_deserialization", ], ) @@ -79,8 +79,8 @@ cc_test( ], tags = ["unit"], deps = [ - "//score/datarouter:logchannel_utility", "@googletest//:gtest_main", + "@score_logging//score/datarouter:logchannel_utility", ], ) @@ -92,9 +92,9 @@ cc_test( features = FEAT_COMPILER_WARNINGS_AS_ERRORS, tags = ["unit"], deps = [ - "//score/datarouter:logparser_testing", "@googletest//:gtest_main", "@score_baselibs//score/mw/log/configuration:nvconfig_mock", + "@score_logging//score/datarouter:logparser_testing", ], ) @@ -122,8 +122,8 @@ cc_test( features = FEAT_COMPILER_WARNINGS_AS_ERRORS, tags = ["unit"], deps = [ - "//score/datarouter:dltprotocol", "@googletest//:gtest_main", + "@score_logging//score/datarouter:dltprotocol", ], ) @@ -151,9 +151,9 @@ cc_test( features = FEAT_COMPILER_WARNINGS_AS_ERRORS, tags = ["unit"], deps = [ - "//score/datarouter:datarouter_feature_config", "//score/datarouter/src/file_transfer:file_transfer_handler_factory", "@googletest//:gtest_main", + "@score_logging//score/datarouter:datarouter_feature_config", ] + select({ "//score/datarouter/build_configuration_flags:config_file_transfer": [ "//score/datarouter/src/file_transfer/file_transfer_impl:file_transfer_stream_handler_factory", @@ -197,9 +197,9 @@ cc_test( features = FEAT_COMPILER_WARNINGS_AS_ERRORS, tags = ["unit"], deps = [ - "//score/datarouter:dltserver_testing", - "//score/datarouter:log", "@googletest//:gtest_main", + "@score_logging//score/datarouter:dltserver_testing", + "@score_logging//score/datarouter:log", ], ) @@ -225,10 +225,10 @@ cc_test( # It's being conflicted with the real udp_stream_output target that used # by earlier targets here. "dltserver_testing" shall be at the first. # buildifier off - "//score/datarouter:dltserver_testing", + "@score_logging//score/datarouter:dltserver_testing", # buildifier on - "//score/datarouter:log", - "//score/datarouter:datarouter_feature_config_testing", + "@score_logging//score/datarouter:log", + "@score_logging//score/datarouter:datarouter_feature_config_testing", "//score/datarouter/dlt_filetransfer_trigger_lib", "@googletest//:gtest_main", ], @@ -242,9 +242,9 @@ cc_test( features = FEAT_COMPILER_WARNINGS_AS_ERRORS, tags = ["unit"], deps = [ - "//score/datarouter:datarouter_options", - "//score/datarouter:log", "@googletest//:gtest_main", + "@score_logging//score/datarouter:datarouter_options", + "@score_logging//score/datarouter:log", ], ) @@ -256,9 +256,9 @@ cc_test( features = FEAT_COMPILER_WARNINGS_AS_ERRORS, tags = ["unit"], deps = [ - "//score/datarouter:datarouter_app", - "//score/datarouter:log", "@googletest//:gtest_main", + "@score_logging//score/datarouter:datarouter_app", + "@score_logging//score/datarouter:log", ], ) @@ -273,9 +273,9 @@ cc_test( features = FEAT_COMPILER_WARNINGS_AS_ERRORS, tags = ["unit"], deps = [ - "//score/datarouter:log", - "//score/datarouter:persistentlogconfig", "@googletest//:gtest_main", + "@score_logging//score/datarouter:log", + "@score_logging//score/datarouter:persistentlogconfig", ], ) @@ -291,10 +291,10 @@ cc_test( features = FEAT_COMPILER_WARNINGS_AS_ERRORS, tags = ["unit"], deps = [ - "//score/datarouter:log", - "//score/datarouter:socketserver_config_lib_testing", "//score/datarouter/src/persistency/stub_persistent_dictionary:stub", "@googletest//:gtest_main", + "@score_logging//score/datarouter:log", + "@score_logging//score/datarouter:socketserver_config_lib_testing", ], ) @@ -309,12 +309,12 @@ cc_test( features = FEAT_COMPILER_WARNINGS_AS_ERRORS, tags = ["unit"], deps = [ - "//score/datarouter:datarouter_socketserver_testing", "//score/datarouter/src/persistency:mock", "@googletest//:gtest_main", "@score_baselibs//score/mw/log/configuration:nvconfig_mock", "@score_baselibs//score/os/mocklib:pthread_mock", "@score_baselibs//score/os/mocklib:unistd_mock", + "@score_logging//score/datarouter:datarouter_socketserver_testing", ], ) @@ -326,12 +326,12 @@ cc_test( features = FEAT_COMPILER_WARNINGS_AS_ERRORS, tags = ["unit"], deps = [ - "//score/datarouter:message_passing_server", "//score/datarouter/daemon_communication:mock", "@googletest//:gtest_main", "@score_baselibs//score/os/mocklib:pthread_mock", "@score_baselibs//score/os/mocklib:unistd_mock", "@score_communication//score/message_passing:mock", + "@score_logging//score/datarouter:message_passing_server", ], ) @@ -343,9 +343,9 @@ cc_test( features = FEAT_COMPILER_WARNINGS_AS_ERRORS, tags = ["unit"], deps = [ - "//score/datarouter:udp_stream_output", "@googletest//:gtest_main", "@score_baselibs//score/os/mocklib:socket_mock", + "@score_logging//score/datarouter:udp_stream_output", ], ) @@ -357,12 +357,12 @@ cc_test( features = FEAT_COMPILER_WARNINGS_AS_ERRORS, tags = ["unit"], deps = [ - "//score/datarouter:unixdomain_server", "@googletest//:gtest_main", "@score_baselibs//score/os/mocklib:pthread_mock", "@score_baselibs//score/os/mocklib:socket_mock", "@score_baselibs//score/os/mocklib:sys_poll_mock", "@score_baselibs//score/os/utils/mocklib:signal_mock", + "@score_logging//score/datarouter:unixdomain_server", ], ) @@ -382,9 +382,9 @@ cc_test( "@googletest//:gtest_main", ], "//conditions:default": [ - "//score/datarouter:datarouter_feature_config_testing", "//score/datarouter/dynamic_configuration/config_session_stub:config_session_stub_testing", "@googletest//:gtest_main", + "@score_logging//score/datarouter:datarouter_feature_config_testing", ], }), ) @@ -401,10 +401,10 @@ cc_test( # It's being conflicted with the real udp_stream_output target that used # by earlier targets here. "udpoutput_mock" shall be at the first. # buildifier off - "//score/datarouter:udpoutput_mock", + "@score_logging//score/datarouter:udpoutput_mock", # buildifier on - "//score/datarouter:datarouter_feature_config_testing", - "//score/datarouter:dltserver_testing", + "@score_logging//score/datarouter:datarouter_feature_config_testing", + "@score_logging//score/datarouter:dltserver_testing", # "//score/datarouter/dynamic_configuration/dynamic_config_session:dynamic_config_session_testing", "//score/datarouter/dynamic_configuration/config_session_stub:config_session_stub_testing", "@googletest//:gtest_main", diff --git a/score/mw/log/detail/common/BUILD b/score/mw/log/detail/common/BUILD index 2262c5b..7623334 100644 --- a/score/mw/log/detail/common/BUILD +++ b/score/mw/log/detail/common/BUILD @@ -99,8 +99,8 @@ cc_library( srcs = ["log_entry_deserialize.h"], features = COMPILER_WARNING_FEATURES, visibility = [ - "//score/datarouter:__pkg__", "//score/datarouter/test:__subpackages__", + "@score_logging//score/datarouter:__pkg__", ], deps = [ "@score_baselibs//score/mw/log:shared_types", diff --git a/score/mw/log/detail/data_router/BUILD b/score/mw/log/detail/data_router/BUILD index 1aad812..3247f9c 100644 --- a/score/mw/log/detail/data_router/BUILD +++ b/score/mw/log/detail/data_router/BUILD @@ -162,9 +162,9 @@ cc_library( features = COMPILER_WARNING_FEATURES, tags = ["FFI"], visibility = [ - "//score/datarouter:__pkg__", "//score/datarouter/test:__subpackages__", "//score/mw/log/detail/slog:__pkg__", + "@score_logging//score/datarouter:__pkg__", ], deps = [ "@score_baselibs//score/mw/log/detail:logging_identifier", diff --git a/score/mw/log/detail/data_router/shared_memory/BUILD b/score/mw/log/detail/data_router/shared_memory/BUILD index 4aabf5e..55dd458 100644 --- a/score/mw/log/detail/data_router/shared_memory/BUILD +++ b/score/mw/log/detail/data_router/shared_memory/BUILD @@ -84,9 +84,9 @@ cc_library( ], tags = ["FFI"], visibility = [ - "//score/datarouter:__subpackages__", "//score/mw/log/detail/data_router:__subpackages__", "//score/mw/log/legacy_non_verbose_api:__subpackages__", + "@score_logging//score/datarouter:__subpackages__", ], deps = [ ":common", diff --git a/score/mw/log/legacy_non_verbose_api/BUILD b/score/mw/log/legacy_non_verbose_api/BUILD index 3635582..29eb21e 100644 --- a/score/mw/log/legacy_non_verbose_api/BUILD +++ b/score/mw/log/legacy_non_verbose_api/BUILD @@ -23,12 +23,11 @@ cc_library( tags = ["FFI"], visibility = [ "//platform/aas/ara/log:__subpackages__", - "//score/datarouter:__pkg__", "//score/mw/log:__subpackages__", "@score_baselibs//score/mw/log:__subpackages__", + "@score_logging//score/datarouter:__pkg__", ], deps = [ - "//score/datarouter:libtracing_legacy_public_headers", "//score/mw/log/detail/data_router/shared_memory:writer", "@score_baselibs//score/language/futurecpp", "@score_baselibs//score/mw/log:frontend", @@ -37,6 +36,7 @@ cc_library( "@score_baselibs//score/mw/log/configuration:nvconfigfactory", "@score_baselibs//score/mw/log/detail/wait_free_stack", "@score_baselibs//score/static_reflection_with_serialization/serialization", + "@score_logging//score/datarouter:libtracing_legacy_public_headers", ], ) From 8791cc24d406ed6f936c72065294e351d33f2ff8 Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Sun, 1 Feb 2026 12:33:17 +0100 Subject: [PATCH 02/29] Enable extra clang_tidy checks for the following folders: - platform/aas/mw/log/log_ext - platform/aas/mw/log/custom_recorder_example - platform/aas/mw/log/configuration GIT_ORIGIN_SPP_REV_ID: 72c0feca4c16fd2f6a32e38d700e0e407b0152a4 --- score/datarouter/src/logparser/logparser.cpp | 2 +- .../test/ut/ut_logging/test_socketserver.cpp | 4 ++-- score/mw/log/custom_recorder_example/BUILD | 14 +++++++++++++- .../custom_recorder_factory_impl.h | 6 +++--- .../custom_recorder_example/custom_recorder_impl.h | 6 +++--- score/mw/log/custom_recorder_example/main.cpp | 2 +- score/mw/log/legacy_non_verbose_api/tracing.cpp | 2 +- score/mw/log/legacy_non_verbose_api/tracing.h | 2 +- 8 files changed, 25 insertions(+), 13 deletions(-) diff --git a/score/datarouter/src/logparser/logparser.cpp b/score/datarouter/src/logparser/logparser.cpp index f18542a..b036645 100644 --- a/score/datarouter/src/logparser/logparser.cpp +++ b/score/datarouter/src/logparser/logparser.cpp @@ -102,7 +102,7 @@ void LogParser::add_incoming_type(const bufsize_t map_index, const std::string& 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}}; + IndexParser indexParser{TypeInfo{nv_config_.GetDltMsgDesc(typeName), map_index, params, typeName, ecuId, appId}}; const auto ith_range = handle_request_map.equal_range(typeName); for (auto ith = ith_range.first; ith != ith_range.second; ++ith) { diff --git a/score/datarouter/test/ut/ut_logging/test_socketserver.cpp b/score/datarouter/test/ut/ut_logging/test_socketserver.cpp index 43f123a..52cad95 100644 --- a/score/datarouter/test/ut/ut_logging/test_socketserver.cpp +++ b/score/datarouter/test/ut/ut_logging/test_socketserver.cpp @@ -317,7 +317,7 @@ TEST_F(SocketServerRemainingFunctionsTest, LoadNvConfigSuccessPath) // Verify that we got a valid config by checking for a known type from test-class-id.json // The test data contains "score::logging::PersistentLogFileEvent" - const auto* descriptor = nv_config.getDltMsgDesc("score::logging::PersistentLogFileEvent"); + const auto* descriptor = nv_config.GetDltMsgDesc("score::logging::PersistentLogFileEvent"); EXPECT_NE(nullptr, descriptor); // Should find the entry } @@ -336,7 +336,7 @@ TEST_F(SocketServerRemainingFunctionsTest, LoadNvConfigErrorPath) auto nv_config = SocketServer::LoadNvConfig(logger, "/nonexistent/path/class-id.json"); // Verify that we got an empty config by checking for any type - const auto* descriptor = nv_config.getDltMsgDesc("score::logging::PersistentLogFileEvent"); + const auto* descriptor = nv_config.GetDltMsgDesc("score::logging::PersistentLogFileEvent"); EXPECT_EQ(nullptr, descriptor); // Empty config returns nullptr for all queries } diff --git a/score/mw/log/custom_recorder_example/BUILD b/score/mw/log/custom_recorder_example/BUILD index 3cf90f0..f846650 100644 --- a/score/mw/log/custom_recorder_example/BUILD +++ b/score/mw/log/custom_recorder_example/BUILD @@ -1,3 +1,5 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") + # ******************************************************************************* # Copyright (c) 2025 Contributors to the Eclipse Foundation # @@ -10,8 +12,18 @@ # # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* +load("@score_baselibs//score/quality/clang_tidy:extra_checks.bzl", "clang_tidy_extra_checks") -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") +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 = "custom_recorder_example", diff --git a/score/mw/log/custom_recorder_example/custom_recorder_factory_impl.h b/score/mw/log/custom_recorder_example/custom_recorder_factory_impl.h index e4b12de..e4a7060 100644 --- a/score/mw/log/custom_recorder_example/custom_recorder_factory_impl.h +++ b/score/mw/log/custom_recorder_example/custom_recorder_factory_impl.h @@ -10,8 +10,8 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_EXAMPLE_CUSTOM_RECORDER_FACTORY_IMPL_H -#define SCORE_MW_LOG_EXAMPLE_CUSTOM_RECORDER_FACTORY_IMPL_H +#ifndef SCORE_MW_LOG_CUSTOM_RECORDER_EXAMPLE_CUSTOM_RECORDER_FACTORY_IMPL_H +#define SCORE_MW_LOG_CUSTOM_RECORDER_EXAMPLE_CUSTOM_RECORDER_FACTORY_IMPL_H #include "score/mw/log/detail/log_recorder_factory.hpp" @@ -37,4 +37,4 @@ class CustomRecorderFactoryImpl : public score::mw::log::detail::LogRecorderFact } // namespace specific } // namespace user -#endif // SCORE_MW_LOG_EXAMPLE_CUSTOM_RECORDER_FACTORY_IMPL_H +#endif // SCORE_MW_LOG_CUSTOM_RECORDER_EXAMPLE_CUSTOM_RECORDER_FACTORY_IMPL_H diff --git a/score/mw/log/custom_recorder_example/custom_recorder_impl.h b/score/mw/log/custom_recorder_example/custom_recorder_impl.h index f6b45b7..75ff2b3 100644 --- a/score/mw/log/custom_recorder_example/custom_recorder_impl.h +++ b/score/mw/log/custom_recorder_example/custom_recorder_impl.h @@ -10,8 +10,8 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_CUSTOM_RECORDER_IMPL_H -#define SCORE_MW_LOG_CUSTOM_RECORDER_IMPL_H +#ifndef SCORE_MW_LOG_CUSTOM_RECORDER_EXAMPLE_CUSTOM_RECORDER_IMPL_H +#define SCORE_MW_LOG_CUSTOM_RECORDER_EXAMPLE_CUSTOM_RECORDER_IMPL_H #include "score/mw/log/recorder.h" @@ -69,4 +69,4 @@ class CustomRecorderImpl final : public score::mw::log::Recorder } // namespace specific } // namespace user -#endif // SCORE_MW_LOG_CUSTOM_RECORDER_IMPL_H +#endif // SCORE_MW_LOG_CUSTOM_RECORDER_EXAMPLE_CUSTOM_RECORDER_IMPL_H diff --git a/score/mw/log/custom_recorder_example/main.cpp b/score/mw/log/custom_recorder_example/main.cpp index 91d6abb..3c3070e 100644 --- a/score/mw/log/custom_recorder_example/main.cpp +++ b/score/mw/log/custom_recorder_example/main.cpp @@ -13,7 +13,7 @@ #include "score/mw/log/logging.h" -int main(void) +int main() { score::mw::log::LogInfo("TEST") << "welcome to mw::log"; } diff --git a/score/mw/log/legacy_non_verbose_api/tracing.cpp b/score/mw/log/legacy_non_verbose_api/tracing.cpp index a0b4178..e090736 100644 --- a/score/mw/log/legacy_non_verbose_api/tracing.cpp +++ b/score/mw/log/legacy_non_verbose_api/tracing.cpp @@ -71,7 +71,7 @@ logger::logger(const score::cpp::optional logger::GetLevelForContext(const std::string& name) const noexcept { - const score::mw::log::config::NvMsgDescriptor* const msg_desc = nvconfig_.getDltMsgDesc(name); + const score::mw::log::config::NvMsgDescriptor* const msg_desc = nvconfig_.GetDltMsgDesc(name); if (msg_desc != nullptr) { const auto ctxId = msg_desc->GetCtxId(); diff --git a/score/mw/log/legacy_non_verbose_api/tracing.h b/score/mw/log/legacy_non_verbose_api/tracing.h index bef29bd..3e60d84 100644 --- a/score/mw/log/legacy_non_verbose_api/tracing.h +++ b/score/mw/log/legacy_non_verbose_api/tracing.h @@ -123,7 +123,7 @@ class logger { auto log_level = LogLevel::kInfo; const score::mw::log::config::NvMsgDescriptor* const msg_desc = - nvconfig_.getDltMsgDesc(::score::common::visitor::struct_visitable::name()); + nvconfig_.GetDltMsgDesc(::score::common::visitor::struct_visitable::name()); if (msg_desc != nullptr) { auto message_descriptor_log_level = msg_desc->GetLogLevel(); From c570e28fe8596c00397368784948c29250ec5c4b Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Sun, 1 Feb 2026 15:02:07 +0100 Subject: [PATCH 03/29] Enable extra clang_tidy checks for the following folders: - platform/aas/mw/log/detail/file_recorder - platform/aas/mw/log/detail/text_recorder GIT_ORIGIN_SPP_REV_ID: f750de78591cc42c642b58bf0402d052c792789a --- score/mw/log/detail/file_recorder/BUILD | 12 +++++++++++ .../file_recorder/dlt_message_builder.cpp | 20 +++++++++---------- .../file_recorder/dlt_message_builder.h | 6 +++--- .../dlt_message_builder_test.cpp | 5 +---- .../file_recorder/dlt_message_builder_types.h | 6 +++--- .../log/detail/file_recorder/file_recorder.h | 6 +++--- .../file_recorder/file_recorder_factory.h | 6 +++--- .../file_recorder_factory_test.cpp | 4 ++-- .../file_recorder/file_recorder_test.cpp | 10 +++++----- score/mw/log/detail/file_recorder/svp_time.h | 6 +++--- 10 files changed, 45 insertions(+), 36 deletions(-) diff --git a/score/mw/log/detail/file_recorder/BUILD b/score/mw/log/detail/file_recorder/BUILD index 91f6c15..934e124 100644 --- a/score/mw/log/detail/file_recorder/BUILD +++ b/score/mw/log/detail/file_recorder/BUILD @@ -13,6 +13,18 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load("@score_baselibs//:bazel/unit_tests.bzl", "cc_unit_test_suites_for_host_and_qnx") +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", + ], +) COMPILER_WARNING_FEATURES = [ "treat_warnings_as_errors", 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 2fd6794..ee224b2 100644 --- a/score/mw/log/detail/file_recorder/dlt_message_builder.cpp +++ b/score/mw/log/detail/file_recorder/dlt_message_builder.cpp @@ -151,9 +151,9 @@ void ConstructDltStandardHeaderTypes(DltStandardHeader& standard, standard.len = htons(msg_size); } -using timestamp_t = score::os::HighResolutionSteadyClock::time_point; -using systime_t = std::chrono::system_clock::time_point; -using dlt_duration_t = std::chrono::duration>; +using TimestampT = score::os::HighResolutionSteadyClock::time_point; +using SystimeT = std::chrono::system_clock::time_point; +using DltDurationT = std::chrono::duration>; DltMessageBuilder::DltMessageBuilder(const std::string_view ecu_id) noexcept : IMessageBuilder(), @@ -169,16 +169,16 @@ void DltMessageBuilder::SetNextMessage(LogRecord& log_record) noexcept log_record_ = log_record; const auto& entry = log_record.getLogEntry(); - const auto time_stamp = timestamp_t::clock::now().time_since_epoch(); - const auto time_epoch = systime_t::clock::now().time_since_epoch(); + const auto time_stamp = TimestampT::clock::now().time_since_epoch(); + const auto time_epoch = SystimeT::clock::now().time_since_epoch(); - using secs_u32 = std::chrono::duration>; - const std::uint32_t seconds = std::chrono::duration_cast(time_epoch).count(); + using SecsU32 = std::chrono::duration>; + const std::uint32_t seconds = std::chrono::duration_cast(time_epoch).count(); const auto secs_remainder = time_epoch - std::chrono::seconds(seconds); - using microsecs_i32 = std::chrono::duration; - const std::int32_t microsecs = std::chrono::duration_cast(secs_remainder).count(); - const std::uint32_t timestamp = std::chrono::duration_cast(time_stamp).count(); + using MicrosecsI32 = std::chrono::duration; + const std::int32_t microsecs = std::chrono::duration_cast(secs_remainder).count(); + const std::uint32_t timestamp = std::chrono::duration_cast(time_stamp).count(); /* Deviation from AUTOSAR C++14 Rule A4-7-1 diff --git a/score/mw/log/detail/file_recorder/dlt_message_builder.h b/score/mw/log/detail/file_recorder/dlt_message_builder.h index 1465a40..61495d2 100644 --- a/score/mw/log/detail/file_recorder/dlt_message_builder.h +++ b/score/mw/log/detail/file_recorder/dlt_message_builder.h @@ -10,8 +10,8 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_DLT_MESSAGE_BUILDER_H_ -#define SCORE_MW_LOG_DETAIL_DLT_MESSAGE_BUILDER_H_ +#ifndef SCORE_MW_LOG_DETAIL_FILE_RECORDER_DLT_MESSAGE_BUILDER_H +#define SCORE_MW_LOG_DETAIL_FILE_RECORDER_DLT_MESSAGE_BUILDER_H #include "score/mw/log/detail/file_recorder/dlt_message_builder_types.h" #include "score/mw/log/detail/text_recorder/imessage_builder.h" @@ -61,4 +61,4 @@ class DltMessageBuilder : public IMessageBuilder } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_DLT_MESSAGE_BUILDER_H_ +#endif // SCORE_MW_LOG_DETAIL_FILE_RECORDER_DLT_MESSAGE_BUILDER_H 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 4ec5c36..f948019 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 @@ -29,12 +29,9 @@ namespace detail namespace { -using ::testing::_; -using ::testing::HasSubstr; -using ::testing::MatchesRegex; using ::testing::StrEq; -const std::map levels = { +const std::map kLevels = { {0, "off"}, {1, "fatal"}, {2, "error"}, 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 79da03f..94d729a 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 @@ -10,8 +10,8 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_DLT_MESSAGE_BUILDER_TYPES_H_ -#define SCORE_MW_LOG_DETAIL_DLT_MESSAGE_BUILDER_TYPES_H_ +#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 #include @@ -165,4 +165,4 @@ struct DltVerboseHeader } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_DLT_MESSAGE_BUILDER_TYPES_H_ +#endif // SCORE_MW_LOG_DETAIL_FILE_RECORDER_DLT_MESSAGE_BUILDER_TYPES_H diff --git a/score/mw/log/detail/file_recorder/file_recorder.h b/score/mw/log/detail/file_recorder/file_recorder.h index 18421c0..9683806 100644 --- a/score/mw/log/detail/file_recorder/file_recorder.h +++ b/score/mw/log/detail/file_recorder/file_recorder.h @@ -10,8 +10,8 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_FILE_RECORDER_H -#define SCORE_MW_LOG_DETAIL_FILE_RECORDER_H +#ifndef SCORE_MW_LOG_DETAIL_FILE_RECORDER_FILE_RECORDER_H +#define SCORE_MW_LOG_DETAIL_FILE_RECORDER_FILE_RECORDER_H #include "score/mw/log/configuration/configuration.h" #include "score/mw/log/detail/backend.h" @@ -75,4 +75,4 @@ class FileRecorder final : public Recorder } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_FILE_RECORDER_H +#endif // SCORE_MW_LOG_DETAIL_FILE_RECORDER_FILE_RECORDER_H diff --git a/score/mw/log/detail/file_recorder/file_recorder_factory.h b/score/mw/log/detail/file_recorder/file_recorder_factory.h index 7136338..adaf68e 100644 --- a/score/mw/log/detail/file_recorder/file_recorder_factory.h +++ b/score/mw/log/detail/file_recorder/file_recorder_factory.h @@ -10,8 +10,8 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_FILE_RECORDER_FACTORY_H -#define SCORE_MW_LOG_DETAIL_FILE_RECORDER_FACTORY_H +#ifndef SCORE_MW_LOG_DETAIL_FILE_RECORDER_FILE_RECORDER_FACTORY_H +#define SCORE_MW_LOG_DETAIL_FILE_RECORDER_FILE_RECORDER_FACTORY_H #include "score/os/fcntl.h" #include "score/mw/log/detail/error.h" @@ -49,4 +49,4 @@ class FileRecorderFactory : public LogRecorderFactory } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_FILE_RECORDER_FACTORY_H +#endif // SCORE_MW_LOG_DETAIL_FILE_RECORDER_FILE_RECORDER_FACTORY_H diff --git a/score/mw/log/detail/file_recorder/file_recorder_factory_test.cpp b/score/mw/log/detail/file_recorder/file_recorder_factory_test.cpp index 8380b1e..3056598 100644 --- a/score/mw/log/detail/file_recorder/file_recorder_factory_test.cpp +++ b/score/mw/log/detail/file_recorder/file_recorder_factory_test.cpp @@ -63,7 +63,7 @@ TEST_F(FileRecorderFactoryConfigFixture, FileConfigurionShallCallFileCreationAnd RecordProperty("DerivationTechnique", "Analysis of requirements"); auto fcntl_mock = score::cpp::pmr::make_unique(memory_resource_); - auto fcntl_mock_raw_ptr = fcntl_mock.get(); + auto* fcntl_mock_raw_ptr = fcntl_mock.get(); std::int32_t file_descriptor = 3; const score::os::Fcntl::Open open_flags = @@ -83,7 +83,7 @@ TEST_F(FileRecorderFactoryConfigFixture, FileConfigurionShallCallFileCreationAnd TEST_F(FileRecorderFactoryConfigFixture, CreateFileLoggingBackendFalied) { auto fcntl_mock = score::cpp::pmr::make_unique(memory_resource_); - auto fcntl_mock_raw_ptr = fcntl_mock.get(); + auto* fcntl_mock_raw_ptr = fcntl_mock.get(); EXPECT_CALL(*fcntl_mock_raw_ptr, open(_, _, _)) .Times(1) 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 7d67abf..bb2ca93 100644 --- a/score/mw/log/detail/file_recorder/file_recorder_test.cpp +++ b/score/mw/log/detail/file_recorder/file_recorder_test.cpp @@ -160,9 +160,9 @@ TEST_F(FileRecorderFixture, TooManyArgumentsWillYieldTruncatedLog) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - constexpr std::size_t type_info_byte_size_according_to_specification = 4; + constexpr std::size_t kTypeInfoByteSizeAccordingToSpecification = 4; const std::size_t number_of_arguments = log_record_.getLogEntry().payload.capacity() / - (type_info_byte_size_according_to_specification + sizeof(std::uint32_t)); + (kTypeInfoByteSizeAccordingToSpecification + sizeof(std::uint32_t)); for (std::size_t i = 0; i < number_of_arguments + 5; ++i) { recorder_->Log(SlotHandle{}, std::uint32_t{}); @@ -447,14 +447,14 @@ TEST(FileRecorderTests, FileRecorderShouldClearSlotOnStart) auto recorder = std::make_unique(config, std::move(backend)); // Simulate the case that a slot already contains data from a previous message. - constexpr auto context = "ctx0"; - recorder->StartRecord(context, kActiveLogLevel); + constexpr auto kContext = "ctx0"; + recorder->StartRecord(kContext, kActiveLogLevel); const auto payload = std::string_view{"Hello world"}; recorder->Log(SlotHandle{}, payload); recorder->StopRecord(SlotHandle{}); // Expect that the previous data is cleared. - recorder->StartRecord(context, kActiveLogLevel); + recorder->StartRecord(kContext, kActiveLogLevel); EXPECT_EQ(log_record.getVerbosePayload().GetSpan().size(), 0); EXPECT_EQ(log_record.getLogEntry().num_of_args, 0); } diff --git a/score/mw/log/detail/file_recorder/svp_time.h b/score/mw/log/detail/file_recorder/svp_time.h index 6df7637..1b240dd 100644 --- a/score/mw/log/detail/file_recorder/svp_time.h +++ b/score/mw/log/detail/file_recorder/svp_time.h @@ -10,8 +10,8 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef MW_LOG_DETAILS_SVP_TIME_H_ -#define MW_LOG_DETAILS_SVP_TIME_H_ +#ifndef SCORE_MW_LOG_DETAIL_FILE_RECORDER_SVP_TIME_H +#define SCORE_MW_LOG_DETAIL_FILE_RECORDER_SVP_TIME_H #include @@ -36,4 +36,4 @@ struct SVPTime } // namespace mw } // namespace score -#endif // MW_LOG_DETAILS_SVP_TIME_H_ +#endif // SCORE_MW_LOG_DETAIL_FILE_RECORDER_SVP_TIME_H From b10117a238ca46997feb6161ae30051b61328acc Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Sun, 1 Feb 2026 14:22:48 +0100 Subject: [PATCH 04/29] Enable extra clang_tidy checks for the following folders: - platform/aas/mw/log/detail/common - platform/aas/mw/log/detail/utils/signal_handling - platform/aas/mw/log/test GIT_ORIGIN_SPP_REV_ID: 2185a4b87fb9a0941e396933b71b94b6532bddef --- score/mw/log/detail/common/BUILD | 12 + .../log/detail/common/composite_recorder.cpp | 2 +- .../detail/common/composite_recorder_test.cpp | 17 +- score/mw/log/detail/common/dlt_format.cpp | 84 +-- .../mw/log/detail/common/dlt_format_test.cpp | 516 +++++++++--------- score/mw/log/detail/common/helper_functions.h | 4 +- .../detail/common/helper_functions_test.cpp | 12 +- .../log/detail/common/istatistics_reporter.h | 6 +- .../detail/common/recorder_factory_test.cpp | 7 +- score/mw/log/detail/common/runtime_test.cpp | 10 +- .../log/detail/common/statistics_reporter.h | 6 +- .../common/statistics_reporter_test.cpp | 46 +- .../mw/log/detail/utils/signal_handling/BUILD | 12 + .../utils/signal_handling/signal_handling.h | 6 +- .../console_logging_environment.h | 6 +- .../test/console_logging_environment/main.cpp | 2 +- .../log/test/fake_recorder/fake_recorder.cpp | 8 +- .../register_fake_recorder_environment.cpp | 2 +- 18 files changed, 389 insertions(+), 369 deletions(-) diff --git a/score/mw/log/detail/common/BUILD b/score/mw/log/detail/common/BUILD index 7623334..10f953e 100644 --- a/score/mw/log/detail/common/BUILD +++ b/score/mw/log/detail/common/BUILD @@ -13,6 +13,18 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load("@score_baselibs//:bazel/unit_tests.bzl", "cc_unit_test_suites_for_host_and_qnx") +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", + ], +) COMPILER_WARNING_FEATURES = [ "treat_warnings_as_errors", diff --git a/score/mw/log/detail/common/composite_recorder.cpp b/score/mw/log/detail/common/composite_recorder.cpp index 36ea0cb..b0adde5 100644 --- a/score/mw/log/detail/common/composite_recorder.cpp +++ b/score/mw/log/detail/common/composite_recorder.cpp @@ -48,7 +48,7 @@ void ForEachRecorder(const std::vector>& recorders, for (auto it = recorders.begin(); it < recorders.end(); it++) { const auto index = static_cast(std::distance(begin, it)); - callback(*it->get(), SlotHandle::RecorderIdentifier{index}); + callback(**it, SlotHandle::RecorderIdentifier{index}); } } diff --git a/score/mw/log/detail/common/composite_recorder_test.cpp b/score/mw/log/detail/common/composite_recorder_test.cpp index a6c013e..75f6198 100644 --- a/score/mw/log/detail/common/composite_recorder_test.cpp +++ b/score/mw/log/detail/common/composite_recorder_test.cpp @@ -66,8 +66,8 @@ const LogBin16 kBin16{kUint16 - 2}; const LogBin32 kBin32{kUint32 - 2}; const LogBin64 kBin64{kUint64 - 2}; -LogRawBuffer log_raw_buffer{nullptr, 0}; -LogSlog2Message log_Slog2Message{1, "Hello World"}; +LogRawBuffer gLogRawBuffer{nullptr, 0}; +LogSlog2Message gLogSlog2Message{1, "Hello World"}; MATCHER_P(LogStringEquals, expected, "matches LogString objects") { @@ -240,9 +240,8 @@ TEST_F(CompositeRecorderFixture, LogInvocationShallBeForwardedToAllAvailableReco EXPECT_CALL(*mock_recorder, LogUint32(recorder_slot, kBin32.value)); EXPECT_CALL(*mock_recorder, LogUint64(recorder_slot, kBin64.value)); - EXPECT_CALL( - *mock_recorder, - Log_LogRawBuffer(recorder_slot, log_raw_buffer.data(), static_cast(log_raw_buffer.size()))); + EXPECT_CALL(*mock_recorder, + Log_LogRawBuffer(recorder_slot, gLogRawBuffer.data(), static_cast(gLogRawBuffer.size()))); return mock_recorder; }); @@ -273,7 +272,7 @@ TEST_F(CompositeRecorderFixture, LogInvocationShallBeForwardedToAllAvailableReco composite_recorder.Log(slot.value(), kBin32); composite_recorder.Log(slot.value(), kBin64); - composite_recorder.Log(slot.value(), log_raw_buffer); + composite_recorder.Log(slot.value(), gLogRawBuffer); } TEST_F(CompositeRecorderFixture, LogSlog2MessageAvailableRecorders) @@ -291,8 +290,8 @@ TEST_F(CompositeRecorderFixture, LogSlog2MessageAvailableRecorders) EXPECT_CALL( *mock_recorder, Log_LogSlog2Message(recorder_slot, - static_cast(log_Slog2Message.GetCode()), - LogStringEquals(static_cast(log_Slog2Message.GetMessage())))) + static_cast(gLogSlog2Message.GetCode()), + LogStringEquals(static_cast(gLogSlog2Message.GetMessage())))) .Times(0); return mock_recorder; }); @@ -300,7 +299,7 @@ TEST_F(CompositeRecorderFixture, LogSlog2MessageAvailableRecorders) const auto slot = composite_recorder.StartRecord(kContext, kLogLevel); ASSERT_TRUE(slot.has_value()); - composite_recorder.Log(slot.value(), log_Slog2Message); + composite_recorder.Log(slot.value(), gLogSlog2Message); } TEST_F(CompositeRecorderFixture, LogShallBeEnabledIfAtLeastOneRecorderIsEnabled) diff --git a/score/mw/log/detail/common/dlt_format.cpp b/score/mw/log/detail/common/dlt_format.cpp index a625805..188e698 100644 --- a/score/mw/log/detail/common/dlt_format.cpp +++ b/score/mw/log/detail/common/dlt_format.cpp @@ -87,12 +87,12 @@ class TypeInfo } // \Requirement PRS_Dlt_00625 - constexpr static std::uint32_t TYPE_BOOL_BIT = 4U; - constexpr static std::uint32_t TYPE_SIGNED_BIT = 5U; - constexpr static std::uint32_t TYPE_UNSIGNED_BIT = 6U; - constexpr static std::uint32_t TYPE_FLOAT_BIT = 7U; - constexpr static std::uint32_t TYPE_STRING_BIT = 9U; - constexpr static std::uint32_t TYPE_RAW_BIT = 10U; + constexpr static std::uint32_t kTypeBoolBit = 4U; + constexpr static std::uint32_t kTypeSignedBit = 5U; + constexpr static std::uint32_t kTypeUnsignedBit = 6U; + constexpr static std::uint32_t kTypeFloatBit = 7U; + constexpr static std::uint32_t kTypeStringBit = 9U; + constexpr static std::uint32_t kTypeRawBit = 10U; // \Requirement PRS_Dlt_00354 score::cpp::optional Set(const TypeLength length) @@ -106,8 +106,8 @@ class TypeInfo // \Requirement PRS_Dlt_00183, PRS_Dlt_00367 score::cpp::optional Set(const StringEncoding encoding) noexcept { - const auto is_type_string_bit_set = score::platform::CheckBit(underlying_type_, TYPE_STRING_BIT); - const auto is_trace_info_bit_set = score::platform::CheckBit(underlying_type_, TRACE_INFO_BIT); + const auto is_type_string_bit_set = score::platform::CheckBit(underlying_type_, kTypeStringBit); + const auto is_trace_info_bit_set = score::platform::CheckBit(underlying_type_, kTraceInfoBit); // LCOV_EXCL_START : can't achieve the other conditions because can't control the "underlying_type_" value. if ((is_type_string_bit_set || is_trace_info_bit_set) == false) { @@ -117,15 +117,15 @@ class TypeInfo static_assert(std::is_same::type, std::uint32_t>::value, "Mismatching underlying type. Cast not valid."); - underlying_type_ |= (static_cast(encoding) << STRING_ENCODING_START); + underlying_type_ |= (static_cast(encoding) << kStringEncodingStart); return *this; } // \Requirement PRS_Dlt_00782, PRS_Dlt_00783 score::cpp::optional Set(const score::mw::log::detail::IntegerRepresentation encoding) noexcept { - const auto is_type_unsigned_bit_set = score::platform::CheckBit(underlying_type_, TYPE_UNSIGNED_BIT); - const auto is_type_signed_bit_set = score::platform::CheckBit(underlying_type_, TYPE_SIGNED_BIT); + const auto is_type_unsigned_bit_set = score::platform::CheckBit(underlying_type_, kTypeUnsignedBit); + const auto is_type_signed_bit_set = score::platform::CheckBit(underlying_type_, kTypeSignedBit); // LCOV_EXCL_START : can't achieve the other conditions because can't control the "underlying_type_" value. if ((is_type_unsigned_bit_set || is_type_signed_bit_set) == false) { @@ -146,7 +146,7 @@ class TypeInfo static_assert( std::is_same::type, std::uint8_t>::value, "Mismatching underlying type. Cast not valid."); - underlying_type_ |= (static_cast(encoding) << INTEGER_ENCODING_START); + underlying_type_ |= (static_cast(encoding) << kIntegerEncodingStart); return *this; } @@ -157,10 +157,10 @@ class TypeInfo // \Requirement PRS_Dlt_00625 // constexpr static auto VARIABLE_INFO_BIT = 11U; not supported in our implementation // constexpr static auto FIXED_POINT_BIT = 12U; not supported in our implementation - constexpr static std::size_t TRACE_INFO_BIT{13UL}; - constexpr static auto STRING_ENCODING_START = 15U; + constexpr static std::size_t kTraceInfoBit{13UL}; + constexpr static auto kStringEncodingStart = 15U; // \Requirement PRS_Dlt_00782 - constexpr static auto INTEGER_ENCODING_START = 15U; + constexpr static auto kIntegerEncodingStart = 15U; }; template @@ -343,7 +343,7 @@ namespace detail AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const bool data) noexcept { // \Requirement PRS_Dlt_00139 - TypeInfo type_info(TypeInfo::TYPE_BOOL_BIT); + TypeInfo type_info(TypeInfo::kTypeBoolBit); // 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) { @@ -362,113 +362,113 @@ AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const std::uint8_t data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_UNSIGNED_BIT, TypeLength::k8Bit); + return LogData(payload, data, repr, TypeInfo::kTypeUnsignedBit, TypeLength::k8Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const std::uint16_t data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_UNSIGNED_BIT, TypeLength::k16Bit); + return LogData(payload, data, repr, TypeInfo::kTypeUnsignedBit, TypeLength::k16Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const std::uint32_t data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_UNSIGNED_BIT, TypeLength::k32Bit); + return LogData(payload, data, repr, TypeInfo::kTypeUnsignedBit, TypeLength::k32Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const std::uint64_t data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_UNSIGNED_BIT, TypeLength::k64Bit); + return LogData(payload, data, repr, TypeInfo::kTypeUnsignedBit, TypeLength::k64Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const std::int8_t data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_SIGNED_BIT, TypeLength::k8Bit); + return LogData(payload, data, repr, TypeInfo::kTypeSignedBit, TypeLength::k8Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const std::int16_t data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_SIGNED_BIT, TypeLength::k16Bit); + return LogData(payload, data, repr, TypeInfo::kTypeSignedBit, TypeLength::k16Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const std::int32_t data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_SIGNED_BIT, TypeLength::k32Bit); + return LogData(payload, data, repr, TypeInfo::kTypeSignedBit, TypeLength::k32Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const std::int64_t data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_SIGNED_BIT, TypeLength::k64Bit); + return LogData(payload, data, repr, TypeInfo::kTypeSignedBit, TypeLength::k64Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const LogHex8 data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_UNSIGNED_BIT, TypeLength::k8Bit); + return LogData(payload, data, repr, TypeInfo::kTypeUnsignedBit, TypeLength::k8Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const LogHex16 data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_UNSIGNED_BIT, TypeLength::k16Bit); + return LogData(payload, data, repr, TypeInfo::kTypeUnsignedBit, TypeLength::k16Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const LogHex32 data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_UNSIGNED_BIT, TypeLength::k32Bit); + return LogData(payload, data, repr, TypeInfo::kTypeUnsignedBit, TypeLength::k32Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const LogHex64 data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_UNSIGNED_BIT, TypeLength::k64Bit); + return LogData(payload, data, repr, TypeInfo::kTypeUnsignedBit, TypeLength::k64Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const LogBin8 data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_UNSIGNED_BIT, TypeLength::k8Bit); + return LogData(payload, data, repr, TypeInfo::kTypeUnsignedBit, TypeLength::k8Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const LogBin16 data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_UNSIGNED_BIT, TypeLength::k16Bit); + return LogData(payload, data, repr, TypeInfo::kTypeUnsignedBit, TypeLength::k16Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const LogBin32 data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_UNSIGNED_BIT, TypeLength::k32Bit); + return LogData(payload, data, repr, TypeInfo::kTypeUnsignedBit, TypeLength::k32Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const LogBin64 data, const IntegerRepresentation repr) noexcept { - return LogData(payload, data, repr, TypeInfo::TYPE_UNSIGNED_BIT, TypeLength::k64Bit); + return LogData(payload, data, repr, TypeInfo::kTypeUnsignedBit, TypeLength::k64Bit); } AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const float data) noexcept { // \Requirement PRS_Dlt_00390, PRS_Dlt_00145 - TypeInfo type_info(TypeInfo::TYPE_FLOAT_BIT); + TypeInfo type_info(TypeInfo::kTypeFloatBit); // 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) { @@ -483,7 +483,7 @@ AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const float data) noex AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const double data) noexcept { // \Requirement PRS_Dlt_00386, PRS_Dlt_00356 - TypeInfo type_info(TypeInfo::TYPE_FLOAT_BIT); + TypeInfo type_info(TypeInfo::kTypeFloatBit); // 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) { @@ -498,7 +498,7 @@ AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const double data) noe AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const std::string_view data) noexcept { // \Requirement PRS_Dlt_00420, PRS_Dlt_00155 - TypeInfo type_info(TypeInfo::TYPE_STRING_BIT); + TypeInfo type_info(TypeInfo::kTypeStringBit); // 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) { @@ -519,16 +519,16 @@ AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const std::string_view // including the DLT headers. // Number of bytes needed for the header needed before the payload. - constexpr std::uint64_t header_size = sizeof(type_info) + sizeof(std::uint16_t); + constexpr std::uint64_t kHeaderSize = sizeof(type_info) + sizeof(std::uint16_t); - if (payload.RemainingCapacity() <= header_size) + if (payload.RemainingCapacity() <= kHeaderSize) { // No space left in buffer for payload. return AddArgumentResult::NotAdded; } // Now figure out how many bytes we can store for the string (including null terminator). - const auto capacity_after_header = payload.RemainingCapacity() - header_size; + const auto capacity_after_header = payload.RemainingCapacity() - kHeaderSize; // Clamp that capacity to what fits in a 16-bit length field. // This is our max "string length including null". @@ -541,7 +541,7 @@ AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const std::string_view AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const LogRawBuffer data) noexcept { // \Requirement PRS_Dlt_00625 - const auto type_info = TypeInfo(TypeInfo::TYPE_RAW_BIT); + const auto type_info = TypeInfo(TypeInfo::kTypeRawBit); // \Requirement PRS_Dlt_00160, PRS_Dlt_00374 // The string payload shall be assembled as follows: @@ -554,16 +554,16 @@ AddArgumentResult DLTFormat::Log(VerbosePayload& payload, const LogRawBuffer dat // including the DLT headers. // Number of bytes needed for the header needed before the payload. - constexpr std::size_t header_size = sizeof(type_info) + sizeof(std::uint16_t); + constexpr std::size_t kHeaderSize = sizeof(type_info) + sizeof(std::uint16_t); - if (payload.RemainingCapacity() <= header_size) + if (payload.RemainingCapacity() <= kHeaderSize) { // No space left in buffer for payload. return AddArgumentResult::NotAdded; } // Calculate how many bytes can remain for the raw buffer after the header. - const auto capacity_after_header = payload.RemainingCapacity() - header_size; + const auto capacity_after_header = payload.RemainingCapacity() - kHeaderSize; // Clamp that to fit in uint16_t. const auto max_length = helper::ClampTo(capacity_after_header); diff --git a/score/mw/log/detail/common/dlt_format_test.cpp b/score/mw/log/detail/common/dlt_format_test.cpp index 060e894..27ae59e 100644 --- a/score/mw/log/detail/common/dlt_format_test.cpp +++ b/score/mw/log/detail/common/dlt_format_test.cpp @@ -28,10 +28,10 @@ namespace class DLTFormatFixture : public ::testing::Test { public: - ByteVector buffer_{}; - VerbosePayload payload_{100, buffer_}; - ByteVector size_two_buffer_{}; - VerbosePayload size_two_payload_{2, size_two_buffer_}; + ByteVector buffer{}; + VerbosePayload payload{100, buffer}; + ByteVector size_two_buffer{}; + VerbosePayload size_two_payload{2, size_two_buffer}; }; TEST_F(DLTFormatFixture, TypeInfomrationForBoolean) @@ -43,12 +43,12 @@ TEST_F(DLTFormatFixture, TypeInfomrationForBoolean) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, true); + DLTFormat::Log(payload, true); - ASSERT_EQ(buffer_.at(0), '\x11'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x00'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x11'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x00'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, BooleanValueTrueCorrectlyTransformed) @@ -60,9 +60,9 @@ TEST_F(DLTFormatFixture, BooleanValueTrueCorrectlyTransformed) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, true); + DLTFormat::Log(payload, true); - ASSERT_EQ(buffer_.at(4), '\x01'); + ASSERT_EQ(buffer.at(4), '\x01'); } TEST_F(DLTFormatFixture, BooleanValueFalseCorrectlyTransformed) @@ -74,9 +74,9 @@ TEST_F(DLTFormatFixture, BooleanValueFalseCorrectlyTransformed) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, false); + DLTFormat::Log(payload, false); - ASSERT_EQ(buffer_.at(4), '\x00'); + ASSERT_EQ(buffer.at(4), '\x00'); } TEST_F(DLTFormatFixture, TypeInfomrationForUint8) @@ -88,12 +88,12 @@ TEST_F(DLTFormatFixture, TypeInfomrationForUint8) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint8_t{42U}); + DLTFormat::Log(payload, std::uint8_t{42U}); - ASSERT_EQ(buffer_.at(0), '\x41'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x00'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x41'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x00'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, Uint8ValueTrueCorrectlyTransformed) @@ -105,9 +105,9 @@ TEST_F(DLTFormatFixture, Uint8ValueTrueCorrectlyTransformed) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint8_t{0x42}); + DLTFormat::Log(payload, std::uint8_t{0x42}); - ASSERT_EQ(buffer_.at(4), '\x42'); + ASSERT_EQ(buffer.at(4), '\x42'); } TEST_F(DLTFormatFixture, TypeIsNotStoredIfNotWholePayloadFitsIntoBuffer) @@ -120,14 +120,14 @@ TEST_F(DLTFormatFixture, TypeIsNotStoredIfNotWholePayloadFitsIntoBuffer) RecordProperty("DerivationTechnique", "Analysis of requirements"); // Given a buffer that is to small to fit TypeInformation + Payload - ByteVector buffer{}; - VerbosePayload payload{3, buffer}; + ByteVector small_buffer{}; + VerbosePayload small_payload{3, small_buffer}; // When Logging the type - DLTFormat::Log(payload, std::uint8_t{42U}); + DLTFormat::Log(small_payload, std::uint8_t{42U}); // Then nothing is stored in the buffer (since it would have overflowed) - ASSERT_EQ(buffer.size(), 0U); + ASSERT_EQ(small_buffer.size(), 0U); } TEST_F(DLTFormatFixture, TypeInfomrationForUint16) @@ -139,12 +139,12 @@ TEST_F(DLTFormatFixture, TypeInfomrationForUint16) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint16_t{0xABCD}); + DLTFormat::Log(payload, std::uint16_t{0xABCD}); - ASSERT_EQ(buffer_.at(0), '\x42'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x00'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x42'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x00'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, Uint16ValueTrueCorrectlyTransformed) @@ -156,10 +156,10 @@ TEST_F(DLTFormatFixture, Uint16ValueTrueCorrectlyTransformed) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint16_t{0x42AB}); + DLTFormat::Log(payload, std::uint16_t{0x42AB}); - ASSERT_EQ(buffer_.at(4), '\xAB'); - ASSERT_EQ(buffer_.at(5), '\x42'); + ASSERT_EQ(buffer.at(4), '\xAB'); + ASSERT_EQ(buffer.at(5), '\x42'); } TEST_F(DLTFormatFixture, TypeInfomrationForUint32) @@ -171,12 +171,12 @@ TEST_F(DLTFormatFixture, TypeInfomrationForUint32) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint32_t{0xABCDEF00}); + DLTFormat::Log(payload, std::uint32_t{0xABCDEF00}); - ASSERT_EQ(buffer_.at(0), '\x43'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x00'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x43'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x00'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, Uint32ValueTrueCorrectlyTransformed) @@ -188,12 +188,12 @@ TEST_F(DLTFormatFixture, Uint32ValueTrueCorrectlyTransformed) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint32_t{0x42ABCDEF}); + DLTFormat::Log(payload, std::uint32_t{0x42ABCDEF}); - ASSERT_EQ(buffer_.at(4), '\xEF'); - ASSERT_EQ(buffer_.at(5), '\xCD'); - ASSERT_EQ(buffer_.at(6), '\xAB'); - ASSERT_EQ(buffer_.at(7), '\x42'); + ASSERT_EQ(buffer.at(4), '\xEF'); + ASSERT_EQ(buffer.at(5), '\xCD'); + ASSERT_EQ(buffer.at(6), '\xAB'); + ASSERT_EQ(buffer.at(7), '\x42'); } TEST_F(DLTFormatFixture, TypeInfomrationForUint64) @@ -205,12 +205,12 @@ TEST_F(DLTFormatFixture, TypeInfomrationForUint64) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint64_t{0xABCDEF00ABCDEF00}); + DLTFormat::Log(payload, std::uint64_t{0xABCDEF00ABCDEF00}); - ASSERT_EQ(buffer_.at(0), '\x44'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x00'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x44'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x00'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, Uint64ValueTrueCorrectlyTransformed) @@ -222,16 +222,16 @@ TEST_F(DLTFormatFixture, Uint64ValueTrueCorrectlyTransformed) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint64_t{0x42ABCDEF01020304}); + DLTFormat::Log(payload, std::uint64_t{0x42ABCDEF01020304}); - ASSERT_EQ(buffer_.at(4), '\x04'); - ASSERT_EQ(buffer_.at(5), '\x03'); - ASSERT_EQ(buffer_.at(6), '\x02'); - ASSERT_EQ(buffer_.at(7), '\x01'); - ASSERT_EQ(buffer_.at(8), '\xEF'); - ASSERT_EQ(buffer_.at(9), '\xCD'); - ASSERT_EQ(buffer_.at(10), '\xAB'); - ASSERT_EQ(buffer_.at(11), '\x42'); + ASSERT_EQ(buffer.at(4), '\x04'); + ASSERT_EQ(buffer.at(5), '\x03'); + ASSERT_EQ(buffer.at(6), '\x02'); + ASSERT_EQ(buffer.at(7), '\x01'); + ASSERT_EQ(buffer.at(8), '\xEF'); + ASSERT_EQ(buffer.at(9), '\xCD'); + ASSERT_EQ(buffer.at(10), '\xAB'); + ASSERT_EQ(buffer.at(11), '\x42'); } TEST_F(DLTFormatFixture, TypeInformationForInt8) @@ -243,12 +243,12 @@ TEST_F(DLTFormatFixture, TypeInformationForInt8) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::int8_t{-42}); + DLTFormat::Log(payload, std::int8_t{-42}); - ASSERT_EQ(buffer_.at(0), '\x21'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x00'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x21'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x00'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, Int8ValueTrueCorrectlyTransformed) @@ -260,9 +260,9 @@ TEST_F(DLTFormatFixture, Int8ValueTrueCorrectlyTransformed) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::int8_t{-42}); + DLTFormat::Log(payload, std::int8_t{-42}); - ASSERT_EQ(buffer_.at(4), '\xd6'); + ASSERT_EQ(buffer.at(4), '\xd6'); } TEST_F(DLTFormatFixture, TypeInformationForInt16) @@ -274,12 +274,12 @@ TEST_F(DLTFormatFixture, TypeInformationForInt16) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::int16_t{-32768}); + DLTFormat::Log(payload, std::int16_t{-32768}); - ASSERT_EQ(buffer_.at(0), '\x22'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x00'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x22'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x00'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, Int16ValueTrueCorrectlyTransformed) @@ -291,10 +291,10 @@ TEST_F(DLTFormatFixture, Int16ValueTrueCorrectlyTransformed) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::int16_t{-32768}); + DLTFormat::Log(payload, std::int16_t{-32768}); - ASSERT_EQ(buffer_.at(4), '\x00'); - ASSERT_EQ(buffer_.at(5), '\x80'); + ASSERT_EQ(buffer.at(4), '\x00'); + ASSERT_EQ(buffer.at(5), '\x80'); } TEST_F(DLTFormatFixture, TypeInformationForInt32) @@ -306,12 +306,12 @@ TEST_F(DLTFormatFixture, TypeInformationForInt32) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::int32_t{-2147483648}); + DLTFormat::Log(payload, std::int32_t{-2147483648}); - ASSERT_EQ(buffer_.at(0), '\x23'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x00'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x23'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x00'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, Int32ValueTrueCorrectlyTransformed) @@ -323,12 +323,12 @@ TEST_F(DLTFormatFixture, Int32ValueTrueCorrectlyTransformed) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::int32_t{-2147483648}); + DLTFormat::Log(payload, std::int32_t{-2147483648}); - ASSERT_EQ(buffer_.at(4), '\x00'); - ASSERT_EQ(buffer_.at(5), '\x00'); - ASSERT_EQ(buffer_.at(6), '\x00'); - ASSERT_EQ(buffer_.at(7), '\x80'); + ASSERT_EQ(buffer.at(4), '\x00'); + ASSERT_EQ(buffer.at(5), '\x00'); + ASSERT_EQ(buffer.at(6), '\x00'); + ASSERT_EQ(buffer.at(7), '\x80'); } TEST_F(DLTFormatFixture, TypeInformationForInt64) @@ -340,12 +340,12 @@ TEST_F(DLTFormatFixture, TypeInformationForInt64) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::numeric_limits::min()); + DLTFormat::Log(payload, std::numeric_limits::min()); - ASSERT_EQ(buffer_.at(0), '\x24'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x00'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x24'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x00'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, Int64ValueTrueCorrectlyTransformed) @@ -357,16 +357,16 @@ TEST_F(DLTFormatFixture, Int64ValueTrueCorrectlyTransformed) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::numeric_limits::min()); + DLTFormat::Log(payload, std::numeric_limits::min()); - ASSERT_EQ(buffer_.at(4), '\x00'); - ASSERT_EQ(buffer_.at(5), '\x00'); - ASSERT_EQ(buffer_.at(6), '\x00'); - ASSERT_EQ(buffer_.at(7), '\x00'); - ASSERT_EQ(buffer_.at(8), '\x00'); - ASSERT_EQ(buffer_.at(9), '\x00'); - ASSERT_EQ(buffer_.at(10), '\x00'); - ASSERT_EQ(buffer_.at(11), '\x80'); + ASSERT_EQ(buffer.at(4), '\x00'); + ASSERT_EQ(buffer.at(5), '\x00'); + ASSERT_EQ(buffer.at(6), '\x00'); + ASSERT_EQ(buffer.at(7), '\x00'); + ASSERT_EQ(buffer.at(8), '\x00'); + ASSERT_EQ(buffer.at(9), '\x00'); + ASSERT_EQ(buffer.at(10), '\x00'); + ASSERT_EQ(buffer.at(11), '\x80'); } TEST_F(DLTFormatFixture, TypeInformationForFloat) @@ -378,12 +378,12 @@ TEST_F(DLTFormatFixture, TypeInformationForFloat) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, float{1.0f}); + DLTFormat::Log(payload, float{1.0F}); - ASSERT_EQ(buffer_.at(0), '\x83'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x00'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x83'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x00'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, FloatValueCorrectlyTransformed) @@ -395,12 +395,12 @@ TEST_F(DLTFormatFixture, FloatValueCorrectlyTransformed) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, float{1.0f}); + DLTFormat::Log(payload, float{1.0F}); - ASSERT_EQ(buffer_.at(4), '\x00'); - ASSERT_EQ(buffer_.at(5), '\x00'); - ASSERT_EQ(buffer_.at(6), '\x80'); - ASSERT_EQ(buffer_.at(7), '\x3F'); + ASSERT_EQ(buffer.at(4), '\x00'); + ASSERT_EQ(buffer.at(5), '\x00'); + ASSERT_EQ(buffer.at(6), '\x80'); + ASSERT_EQ(buffer.at(7), '\x3F'); } TEST_F(DLTFormatFixture, TypeInformationForDouble) @@ -412,12 +412,12 @@ TEST_F(DLTFormatFixture, TypeInformationForDouble) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, double{1.0}); + DLTFormat::Log(payload, double{1.0}); - ASSERT_EQ(buffer_.at(0), '\x84'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x00'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x84'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x00'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, DoubleValueCorrectlyTransformed) @@ -429,16 +429,16 @@ TEST_F(DLTFormatFixture, DoubleValueCorrectlyTransformed) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, double{1.0}); + DLTFormat::Log(payload, double{1.0}); - ASSERT_EQ(buffer_.at(4), '\x00'); - ASSERT_EQ(buffer_.at(5), '\x00'); - ASSERT_EQ(buffer_.at(6), '\x00'); - ASSERT_EQ(buffer_.at(7), '\x00'); - ASSERT_EQ(buffer_.at(8), '\x00'); - ASSERT_EQ(buffer_.at(9), '\x00'); - ASSERT_EQ(buffer_.at(10), '\xF0'); - ASSERT_EQ(buffer_.at(11), '\x3F'); + ASSERT_EQ(buffer.at(4), '\x00'); + ASSERT_EQ(buffer.at(5), '\x00'); + ASSERT_EQ(buffer.at(6), '\x00'); + ASSERT_EQ(buffer.at(7), '\x00'); + ASSERT_EQ(buffer.at(8), '\x00'); + ASSERT_EQ(buffer.at(9), '\x00'); + ASSERT_EQ(buffer.at(10), '\xF0'); + ASSERT_EQ(buffer.at(11), '\x3F'); } TEST_F(DLTFormatFixture, TypeInformationForString) @@ -450,12 +450,12 @@ TEST_F(DLTFormatFixture, TypeInformationForString) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::string_view{"Hello World"}); + DLTFormat::Log(payload, std::string_view{"Hello World"}); - ASSERT_EQ(buffer_.at(0), '\x00'); - ASSERT_EQ(buffer_.at(1), '\x82'); - ASSERT_EQ(buffer_.at(2), '\x00'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x00'); + ASSERT_EQ(buffer.at(1), '\x82'); + ASSERT_EQ(buffer.at(2), '\x00'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, StringValueCorrectlyTransformed) @@ -467,25 +467,25 @@ TEST_F(DLTFormatFixture, StringValueCorrectlyTransformed) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::string_view{"Hello World"}); + DLTFormat::Log(payload, std::string_view{"Hello World"}); // Length - ASSERT_EQ(buffer_.at(4), '\x0C'); - ASSERT_EQ(buffer_.at(5), '\x00'); + ASSERT_EQ(buffer.at(4), '\x0C'); + ASSERT_EQ(buffer.at(5), '\x00'); // String - ASSERT_EQ(buffer_.at(6), 'H'); - ASSERT_EQ(buffer_.at(7), 'e'); - ASSERT_EQ(buffer_.at(8), 'l'); - ASSERT_EQ(buffer_.at(9), 'l'); - ASSERT_EQ(buffer_.at(10), 'o'); - ASSERT_EQ(buffer_.at(11), ' '); - ASSERT_EQ(buffer_.at(12), 'W'); - ASSERT_EQ(buffer_.at(13), 'o'); - ASSERT_EQ(buffer_.at(14), 'r'); - ASSERT_EQ(buffer_.at(15), 'l'); - ASSERT_EQ(buffer_.at(16), 'd'); - ASSERT_EQ(buffer_.at(17), '\x00'); + ASSERT_EQ(buffer.at(6), 'H'); + ASSERT_EQ(buffer.at(7), 'e'); + ASSERT_EQ(buffer.at(8), 'l'); + ASSERT_EQ(buffer.at(9), 'l'); + ASSERT_EQ(buffer.at(10), 'o'); + ASSERT_EQ(buffer.at(11), ' '); + ASSERT_EQ(buffer.at(12), 'W'); + ASSERT_EQ(buffer.at(13), 'o'); + ASSERT_EQ(buffer.at(14), 'r'); + ASSERT_EQ(buffer.at(15), 'l'); + ASSERT_EQ(buffer.at(16), 'd'); + ASSERT_EQ(buffer.at(17), '\x00'); } TEST_F(DLTFormatFixture, StringValueDoesNotFitNullTermination) @@ -497,23 +497,23 @@ TEST_F(DLTFormatFixture, StringValueDoesNotFitNullTermination) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - buffer_.clear(); - buffer_.shrink_to_fit(); - buffer_.reserve(17); - DLTFormat::Log(payload_, std::string_view{"Hello World"}); + buffer.clear(); + buffer.shrink_to_fit(); + buffer.reserve(17); + DLTFormat::Log(payload, std::string_view{"Hello World"}); // String - ASSERT_EQ(buffer_.at(6), 'H'); - ASSERT_EQ(buffer_.at(7), 'e'); - ASSERT_EQ(buffer_.at(8), 'l'); - ASSERT_EQ(buffer_.at(9), 'l'); - ASSERT_EQ(buffer_.at(10), 'o'); - ASSERT_EQ(buffer_.at(11), ' '); - ASSERT_EQ(buffer_.at(12), 'W'); - ASSERT_EQ(buffer_.at(13), 'o'); - ASSERT_EQ(buffer_.at(14), 'r'); - ASSERT_EQ(buffer_.at(15), 'l'); - ASSERT_EQ(buffer_.at(16), '\x00'); + ASSERT_EQ(buffer.at(6), 'H'); + ASSERT_EQ(buffer.at(7), 'e'); + ASSERT_EQ(buffer.at(8), 'l'); + ASSERT_EQ(buffer.at(9), 'l'); + ASSERT_EQ(buffer.at(10), 'o'); + ASSERT_EQ(buffer.at(11), ' '); + ASSERT_EQ(buffer.at(12), 'W'); + ASSERT_EQ(buffer.at(13), 'o'); + ASSERT_EQ(buffer.at(14), 'r'); + ASSERT_EQ(buffer.at(15), 'l'); + ASSERT_EQ(buffer.at(16), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationForUint8InHex) @@ -526,12 +526,12 @@ TEST_F(DLTFormatFixture, TypeInformationForUint8InHex) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint8_t{42U}, score::mw::log::detail::IntegerRepresentation::kHex); + DLTFormat::Log(payload, std::uint8_t{42U}, score::mw::log::detail::IntegerRepresentation::kHex); - ASSERT_EQ(buffer_.at(0), '\x41'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x41'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationForHex8InHex) @@ -543,12 +543,12 @@ TEST_F(DLTFormatFixture, TypeInformationForHex8InHex) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, LogHex8{0xFF}, score::mw::log::detail::IntegerRepresentation::kHex); + DLTFormat::Log(payload, LogHex8{0xFF}, score::mw::log::detail::IntegerRepresentation::kHex); - ASSERT_EQ(buffer_.at(0), '\x41'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x41'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationForHex16InHex) @@ -560,12 +560,12 @@ TEST_F(DLTFormatFixture, TypeInformationForHex16InHex) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, LogHex16{0xFFFF}, score::mw::log::detail::IntegerRepresentation::kHex); + DLTFormat::Log(payload, LogHex16{0xFFFF}, score::mw::log::detail::IntegerRepresentation::kHex); - ASSERT_EQ(buffer_.at(0), '\x42'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x42'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationForHex32InHex) @@ -577,12 +577,12 @@ TEST_F(DLTFormatFixture, TypeInformationForHex32InHex) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, LogHex32{0xFFFFFF}, score::mw::log::detail::IntegerRepresentation::kHex); + DLTFormat::Log(payload, LogHex32{0xFFFFFF}, score::mw::log::detail::IntegerRepresentation::kHex); - ASSERT_EQ(buffer_.at(0), '\x43'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x43'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationForHex64InHex) @@ -594,12 +594,12 @@ TEST_F(DLTFormatFixture, TypeInformationForHex64InHex) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, LogHex64{0xFFFFFFFF}, score::mw::log::detail::IntegerRepresentation::kHex); + DLTFormat::Log(payload, LogHex64{0xFFFFFFFF}, score::mw::log::detail::IntegerRepresentation::kHex); - ASSERT_EQ(buffer_.at(0), '\x44'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x44'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationForBin8InBin) @@ -611,12 +611,12 @@ TEST_F(DLTFormatFixture, TypeInformationForBin8InBin) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, LogBin8{0xFF}, score::mw::log::detail::IntegerRepresentation::kBinary); + DLTFormat::Log(payload, LogBin8{0xFF}, score::mw::log::detail::IntegerRepresentation::kBinary); - ASSERT_EQ(buffer_.at(0), '\x41'); - ASSERT_EQ(buffer_.at(1), '\x80'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x41'); + ASSERT_EQ(buffer.at(1), '\x80'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationForBin16InBin) @@ -628,12 +628,12 @@ TEST_F(DLTFormatFixture, TypeInformationForBin16InBin) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, LogBin16{0xFFFF}, score::mw::log::detail::IntegerRepresentation::kBinary); + DLTFormat::Log(payload, LogBin16{0xFFFF}, score::mw::log::detail::IntegerRepresentation::kBinary); - ASSERT_EQ(buffer_.at(0), '\x42'); - ASSERT_EQ(buffer_.at(1), '\x80'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x42'); + ASSERT_EQ(buffer.at(1), '\x80'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationForBin32InBin) @@ -645,12 +645,12 @@ TEST_F(DLTFormatFixture, TypeInformationForBin32InBin) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, LogBin32{0xFFFFFF}, score::mw::log::detail::IntegerRepresentation::kBinary); + DLTFormat::Log(payload, LogBin32{0xFFFFFF}, score::mw::log::detail::IntegerRepresentation::kBinary); - ASSERT_EQ(buffer_.at(0), '\x43'); - ASSERT_EQ(buffer_.at(1), '\x80'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x43'); + ASSERT_EQ(buffer.at(1), '\x80'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationForBin64InBin) @@ -662,12 +662,12 @@ TEST_F(DLTFormatFixture, TypeInformationForBin64InBin) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, LogBin64{0xFFFFFFFF}, score::mw::log::detail::IntegerRepresentation::kBinary); + DLTFormat::Log(payload, LogBin64{0xFFFFFFFF}, score::mw::log::detail::IntegerRepresentation::kBinary); - ASSERT_EQ(buffer_.at(0), '\x44'); - ASSERT_EQ(buffer_.at(1), '\x80'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x44'); + ASSERT_EQ(buffer.at(1), '\x80'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationForUint16InHex) @@ -680,12 +680,12 @@ TEST_F(DLTFormatFixture, TypeInformationForUint16InHex) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint16_t{0xABCD}, score::mw::log::detail::IntegerRepresentation::kHex); + DLTFormat::Log(payload, std::uint16_t{0xABCD}, score::mw::log::detail::IntegerRepresentation::kHex); - ASSERT_EQ(buffer_.at(0), '\x42'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x42'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationForUint32InHex) @@ -698,12 +698,12 @@ TEST_F(DLTFormatFixture, TypeInformationForUint32InHex) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint32_t{0xABCDEF00}, score::mw::log::detail::IntegerRepresentation::kHex); + DLTFormat::Log(payload, std::uint32_t{0xABCDEF00}, score::mw::log::detail::IntegerRepresentation::kHex); - ASSERT_EQ(buffer_.at(0), '\x43'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x43'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationForUint64InHex) @@ -716,12 +716,12 @@ TEST_F(DLTFormatFixture, TypeInformationForUint64InHex) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint64_t{0xABCDEF00ABCDEF00}, score::mw::log::detail::IntegerRepresentation::kHex); + DLTFormat::Log(payload, std::uint64_t{0xABCDEF00ABCDEF00}, score::mw::log::detail::IntegerRepresentation::kHex); - ASSERT_EQ(buffer_.at(0), '\x44'); - ASSERT_EQ(buffer_.at(1), '\x00'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x44'); + ASSERT_EQ(buffer.at(1), '\x00'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationUInt8InBinary) @@ -734,12 +734,12 @@ TEST_F(DLTFormatFixture, TypeInformationUInt8InBinary) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint8_t{42U}, score::mw::log::detail::IntegerRepresentation::kBinary); + DLTFormat::Log(payload, std::uint8_t{42U}, score::mw::log::detail::IntegerRepresentation::kBinary); - ASSERT_EQ(buffer_.at(0), '\x41'); - ASSERT_EQ(buffer_.at(1), '\x80'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x41'); + ASSERT_EQ(buffer.at(1), '\x80'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationUint16InBinary) @@ -752,12 +752,12 @@ TEST_F(DLTFormatFixture, TypeInformationUint16InBinary) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint16_t{0xABCD}, score::mw::log::detail::IntegerRepresentation::kBinary); + DLTFormat::Log(payload, std::uint16_t{0xABCD}, score::mw::log::detail::IntegerRepresentation::kBinary); - ASSERT_EQ(buffer_.at(0), '\x42'); - ASSERT_EQ(buffer_.at(1), '\x80'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x42'); + ASSERT_EQ(buffer.at(1), '\x80'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationUint32InBinary) @@ -770,12 +770,12 @@ TEST_F(DLTFormatFixture, TypeInformationUint32InBinary) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint32_t{0xABCDEF00}, score::mw::log::detail::IntegerRepresentation::kBinary); + DLTFormat::Log(payload, std::uint32_t{0xABCDEF00}, score::mw::log::detail::IntegerRepresentation::kBinary); - ASSERT_EQ(buffer_.at(0), '\x43'); - ASSERT_EQ(buffer_.at(1), '\x80'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x43'); + ASSERT_EQ(buffer.at(1), '\x80'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationUint64InBinary) @@ -788,12 +788,12 @@ TEST_F(DLTFormatFixture, TypeInformationUint64InBinary) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - DLTFormat::Log(payload_, std::uint64_t{0xABCDEF00ABCDEF00}, score::mw::log::detail::IntegerRepresentation::kBinary); + DLTFormat::Log(payload, std::uint64_t{0xABCDEF00ABCDEF00}, score::mw::log::detail::IntegerRepresentation::kBinary); - ASSERT_EQ(buffer_.at(0), '\x44'); - ASSERT_EQ(buffer_.at(1), '\x80'); - ASSERT_EQ(buffer_.at(2), '\x01'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x44'); + ASSERT_EQ(buffer.at(1), '\x80'); + ASSERT_EQ(buffer.at(2), '\x01'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, TypeInformationForRaw) @@ -806,12 +806,12 @@ TEST_F(DLTFormatFixture, TypeInformationForRaw) RecordProperty("DerivationTechnique", "Analysis of requirements"); std::vector data{{1, 2, 3}}; - DLTFormat::Log(payload_, LogRawBuffer{data.data(), 3}); + DLTFormat::Log(payload, LogRawBuffer{data.data(), 3}); - ASSERT_EQ(buffer_.at(0), '\x00'); - ASSERT_EQ(buffer_.at(1), '\x04'); - ASSERT_EQ(buffer_.at(2), '\x00'); - ASSERT_EQ(buffer_.at(3), '\x00'); + ASSERT_EQ(buffer.at(0), '\x00'); + ASSERT_EQ(buffer.at(1), '\x04'); + ASSERT_EQ(buffer.at(2), '\x00'); + ASSERT_EQ(buffer.at(3), '\x00'); } TEST_F(DLTFormatFixture, RawValueCorrectlyTransformed) @@ -824,16 +824,16 @@ TEST_F(DLTFormatFixture, RawValueCorrectlyTransformed) RecordProperty("DerivationTechnique", "Analysis of requirements"); std::vector data{{1, 2, 3}}; - DLTFormat::Log(payload_, LogRawBuffer{data.data(), 3}); + DLTFormat::Log(payload, LogRawBuffer{data.data(), 3}); // Length - ASSERT_EQ(buffer_.at(4), '\x03'); - ASSERT_EQ(buffer_.at(5), '\x00'); + ASSERT_EQ(buffer.at(4), '\x03'); + ASSERT_EQ(buffer.at(5), '\x00'); // Data - ASSERT_EQ(buffer_.at(6), 1); - ASSERT_EQ(buffer_.at(7), 2); - ASSERT_EQ(buffer_.at(8), 3); + ASSERT_EQ(buffer.at(6), 1); + ASSERT_EQ(buffer.at(7), 2); + ASSERT_EQ(buffer.at(8), 3); } TEST_F(DLTFormatFixture, RawValueDoesNotFitWhole) @@ -845,19 +845,19 @@ TEST_F(DLTFormatFixture, RawValueDoesNotFitWhole) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - buffer_.clear(); - buffer_.shrink_to_fit(); - buffer_.reserve(4 + 2 + 2); + buffer.clear(); + buffer.shrink_to_fit(); + buffer.reserve(4 + 2 + 2); std::vector data{{1, 2, 3}}; - DLTFormat::Log(payload_, LogRawBuffer{data.data(), 3}); + DLTFormat::Log(payload, LogRawBuffer{data.data(), 3}); // Length - ASSERT_EQ(buffer_.at(4), '\x02'); - ASSERT_EQ(buffer_.at(5), '\x00'); + ASSERT_EQ(buffer.at(4), '\x02'); + ASSERT_EQ(buffer.at(5), '\x00'); // String - ASSERT_EQ(buffer_.at(6), 1); - ASSERT_EQ(buffer_.at(7), 2); + ASSERT_EQ(buffer.at(6), 1); + ASSERT_EQ(buffer.at(7), 2); } TEST_F(DLTFormatFixture, RawValueDoesNotFitAny) @@ -869,14 +869,14 @@ TEST_F(DLTFormatFixture, RawValueDoesNotFitAny) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - buffer_.clear(); - buffer_.shrink_to_fit(); - buffer_.reserve(4 + 2); + buffer.clear(); + buffer.shrink_to_fit(); + buffer.reserve(4 + 2); std::vector data{{1, 2, 3}}; - DLTFormat::Log(payload_, LogRawBuffer{data.data(), 3}); + DLTFormat::Log(payload, LogRawBuffer{data.data(), 3}); // Length is zero - ASSERT_EQ(buffer_.size(), 0); + ASSERT_EQ(buffer.size(), 0); } } // namespace diff --git a/score/mw/log/detail/common/helper_functions.h b/score/mw/log/detail/common/helper_functions.h index c4b2b48..5cc65ef 100644 --- a/score/mw/log/detail/common/helper_functions.h +++ b/score/mw/log/detail/common/helper_functions.h @@ -62,9 +62,9 @@ inline constexpr Target ClampTo(Source value) noexcept inline std::uint16_t ClampAddNullTerminator(std::uint16_t length) noexcept { - constexpr auto max_u16 = std::numeric_limits::max(); + constexpr auto kMaxU16 = std::numeric_limits::max(); // If there's room for a null terminator, add one; otherwise, stick to the max. - return (length < max_u16) ? static_cast(length + 1U) : length; + return (length < kMaxU16) ? static_cast(length + 1U) : length; } } // namespace helper diff --git a/score/mw/log/detail/common/helper_functions_test.cpp b/score/mw/log/detail/common/helper_functions_test.cpp index 1d0f770..c5c761a 100644 --- a/score/mw/log/detail/common/helper_functions_test.cpp +++ b/score/mw/log/detail/common/helper_functions_test.cpp @@ -42,17 +42,17 @@ TEST(SumTest, SumOverflow) TEST(ClampAddNullTerminatorTest, ClampAddNullTerminatorNoOverFlow) { std::uint16_t v1 = 1U; - constexpr std::uint16_t expected_value = 2U; + constexpr std::uint16_t kExpectedValue = 2U; std::size_t result1 = ClampAddNullTerminator(v1); - EXPECT_EQ(result1, expected_value); + EXPECT_EQ(result1, kExpectedValue); } TEST(ClampAddNullTerminatorTest, ClampAddNullTerminatorOverFlow) { std::uint16_t v1 = std::numeric_limits::max(); - constexpr std::uint16_t expected_value = std::numeric_limits::max(); + constexpr std::uint16_t kExpectedValue = std::numeric_limits::max(); std::size_t result1 = ClampAddNullTerminator(v1); - EXPECT_EQ(result1, expected_value); + EXPECT_EQ(result1, kExpectedValue); } TEST(ClampTest, ClampSourceOverflow) @@ -63,8 +63,8 @@ TEST(ClampTest, ClampSourceOverflow) static_assert(std::numeric_limits::max() > std::numeric_limits::max(), "SourceType type must be greater than TargetType"); - constexpr SourceType source = std::numeric_limits::max(); - const auto result = helper::ClampTo(source); + constexpr SourceType kSource = std::numeric_limits::max(); + const auto result = helper::ClampTo(kSource); EXPECT_EQ(result, std::numeric_limits::max()); } diff --git a/score/mw/log/detail/common/istatistics_reporter.h b/score/mw/log/detail/common/istatistics_reporter.h index 593a8a1..8658d59 100644 --- a/score/mw/log/detail/common/istatistics_reporter.h +++ b/score/mw/log/detail/common/istatistics_reporter.h @@ -10,8 +10,8 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_COMMON_DATA_ROUTER_ISTATISTICS_REPORTER_H -#define SCORE_MW_LOG_DETAIL_COMMON_DATA_ROUTER_ISTATISTICS_REPORTER_H +#ifndef SCORE_MW_LOG_DETAIL_COMMON_ISTATISTICS_REPORTER_H +#define SCORE_MW_LOG_DETAIL_COMMON_ISTATISTICS_REPORTER_H #include "score/mw/log/recorder.h" @@ -59,4 +59,4 @@ class IStatisticsReporter } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_COMMON_DATA_ROUTER_ISTATISTICS_REPORTER_H +#endif // SCORE_MW_LOG_DETAIL_COMMON_ISTATISTICS_REPORTER_H diff --git a/score/mw/log/detail/common/recorder_factory_test.cpp b/score/mw/log/detail/common/recorder_factory_test.cpp index cc71d1a..b6433a3 100644 --- a/score/mw/log/detail/common/recorder_factory_test.cpp +++ b/score/mw/log/detail/common/recorder_factory_test.cpp @@ -35,9 +35,6 @@ namespace detail namespace { -using ::testing::_; -using ::testing::Return; - template bool IsRecorderOfType(const std::unique_ptr& recorder) noexcept { @@ -275,9 +272,9 @@ TEST_F(RecorderFactoryConfigFixture, OutOfRangeLogModeShallReturnEmptyRecorder) RecordProperty("DerivationTechnique", "Analysis of requirements"); // selected number should not be listed in LogMode enum definition - const LogMode outOfRangeLogMode = static_cast(240); + const LogMode out_of_range_log_mode = static_cast(240); - SetConfigurationWithLogMode({outOfRangeLogMode}); + SetConfigurationWithLogMode({out_of_range_log_mode}); auto recorder = CreateFromConfiguration(); EXPECT_TRUE(IsRecorderOfType(recorder)); } diff --git a/score/mw/log/detail/common/runtime_test.cpp b/score/mw/log/detail/common/runtime_test.cpp index eba317c..294d525 100644 --- a/score/mw/log/detail/common/runtime_test.cpp +++ b/score/mw/log/detail/common/runtime_test.cpp @@ -41,7 +41,7 @@ bool IsRecorderOfType(const Recorder& recorder) noexcept class RuntimeFixture : public ::testing::Test { public: - RecorderMock recorder_mock_{}; + RecorderMock recorder_mock{}; }; TEST_F(RuntimeFixture, CanSetALoggingBackend) @@ -54,7 +54,7 @@ TEST_F(RuntimeFixture, CanSetALoggingBackend) // Given an empty process // When setting the recorder for e.g. testing purposes - Runtime::SetRecorder(&recorder_mock_); + Runtime::SetRecorder(&recorder_mock); // Then no exception happens (API test) } @@ -67,11 +67,11 @@ TEST_F(RuntimeFixture, CanRetrieveSetRecorder) RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); // Given the recorder was already set - Runtime::SetRecorder(&recorder_mock_); + Runtime::SetRecorder(&recorder_mock); // When trying to read the current recorder // Then it is the one that was previously stored - EXPECT_EQ(&recorder_mock_, &Runtime::GetRecorder()); + EXPECT_EQ(&recorder_mock, &Runtime::GetRecorder()); } TEST_F(RuntimeFixture, CanRetrieveFallbackRecorder) @@ -99,7 +99,7 @@ TEST_F(RuntimeFixture, DefaultRecorderShallBeReturned) RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); // Given the unset recorder: - Runtime::SetRecorder(&recorder_mock_); + Runtime::SetRecorder(&recorder_mock); auto& recorder = Runtime::GetRecorder(); Runtime::SetRecorder(nullptr); diff --git a/score/mw/log/detail/common/statistics_reporter.h b/score/mw/log/detail/common/statistics_reporter.h index 58d1584..7adff6f 100644 --- a/score/mw/log/detail/common/statistics_reporter.h +++ b/score/mw/log/detail/common/statistics_reporter.h @@ -10,8 +10,8 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_COMMON_DATA_ROUTER_STATISTICS_REPORTER_H -#define SCORE_MW_LOG_DETAIL_COMMON_DATA_ROUTER_STATISTICS_REPORTER_H +#ifndef SCORE_MW_LOG_DETAIL_COMMON_STATISTICS_REPORTER_H +#define SCORE_MW_LOG_DETAIL_COMMON_STATISTICS_REPORTER_H #include "score/mw/log/recorder.h" @@ -58,4 +58,4 @@ class StatisticsReporter final : public IStatisticsReporter } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_COMMON_DATA_ROUTER_STATISTICS_REPORTER_H +#endif // SCORE_MW_LOG_DETAIL_COMMON_STATISTICS_REPORTER_H diff --git a/score/mw/log/detail/common/statistics_reporter_test.cpp b/score/mw/log/detail/common/statistics_reporter_test.cpp index dea7c23..9a1ef0a 100644 --- a/score/mw/log/detail/common/statistics_reporter_test.cpp +++ b/score/mw/log/detail/common/statistics_reporter_test.cpp @@ -44,7 +44,7 @@ struct StatisticsReporterFixture : public ::testing::Test { void ExpectNoReport() { - EXPECT_CALL(recorder_mock_, StartRecord(_, _)).Times(0); + EXPECT_CALL(recorder_mock, StartRecord(_, _)).Times(0); } void ExpectReport(const std::size_t expected_no_slot_available_counter, @@ -52,16 +52,16 @@ struct StatisticsReporterFixture : public ::testing::Test const LogLevel expected_log_level) { InSequence in_sequence{}; - EXPECT_CALL(recorder_mock_, StartRecord(_, expected_log_level)).Times(1).WillOnce(Return(kSlot)); - EXPECT_CALL(recorder_mock_, LogUint64(kSlot, kNumberOfSlots)); - EXPECT_CALL(recorder_mock_, LogUint64(kSlot, kSlotSizeBytes)); - EXPECT_CALL(recorder_mock_, LogUint64(kSlot, expected_no_slot_available_counter)); - EXPECT_CALL(recorder_mock_, LogUint64(kSlot, expected_message_too_long_counter)); - EXPECT_CALL(recorder_mock_, StopRecord(kSlot)).Times(1); + EXPECT_CALL(recorder_mock, StartRecord(_, expected_log_level)).Times(1).WillOnce(Return(kSlot)); + EXPECT_CALL(recorder_mock, LogUint64(kSlot, kNumberOfSlots)); + EXPECT_CALL(recorder_mock, LogUint64(kSlot, kSlotSizeBytes)); + EXPECT_CALL(recorder_mock, LogUint64(kSlot, expected_no_slot_available_counter)); + EXPECT_CALL(recorder_mock, LogUint64(kSlot, expected_message_too_long_counter)); + EXPECT_CALL(recorder_mock, StopRecord(kSlot)).Times(1); } - RecorderMock recorder_mock_{}; - StatisticsReporter unit_{recorder_mock_, kReportInterval, kNumberOfSlots, kSlotSizeBytes}; + RecorderMock recorder_mock{}; + StatisticsReporter unit{recorder_mock, kReportInterval, kNumberOfSlots, kSlotSizeBytes}; }; TEST_F(StatisticsReporterFixture, UpdateShallReportIfOverDue) @@ -75,7 +75,7 @@ TEST_F(StatisticsReporterFixture, UpdateShallReportIfOverDue) const std::size_t expected_no_slot_available_counter = 0; const std::size_t expected_message_too_long_counter = 0; ExpectReport(expected_no_slot_available_counter, expected_message_too_long_counter, kZeroErrorsLogLevel); - unit_.Update(kOverdueTime); + unit.Update(kOverdueTime); } TEST_F(StatisticsReporterFixture, UpdateShallReportWarningIfOverDueAndErrors) @@ -90,11 +90,11 @@ TEST_F(StatisticsReporterFixture, UpdateShallReportWarningIfOverDueAndErrors) const std::size_t expected_message_too_long_counter = 1; ExpectReport(expected_no_slot_available_counter, expected_message_too_long_counter, kNonZeroErrorsLogLevel); - unit_.IncrementNoSlotAvailable(); - unit_.IncrementNoSlotAvailable(); - unit_.IncrementMessageTooLong(); + unit.IncrementNoSlotAvailable(); + unit.IncrementNoSlotAvailable(); + unit.IncrementMessageTooLong(); - unit_.Update(kOverdueTime); + unit.Update(kOverdueTime); } TEST_F(StatisticsReporterFixture, UpdateShallReportWarningMessageIsTooooLong) @@ -105,10 +105,10 @@ TEST_F(StatisticsReporterFixture, UpdateShallReportWarningMessageIsTooooLong) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - EXPECT_CALL(recorder_mock_, StopRecord(kSlot)).Times(0); + EXPECT_CALL(recorder_mock, StopRecord(kSlot)).Times(0); - unit_.IncrementMessageTooLong(); - unit_.Update(kOverdueTime); + unit.IncrementMessageTooLong(); + unit.Update(kOverdueTime); } TEST_F(StatisticsReporterFixture, UpdateShallGiveUpIfNotYetTimeToReport) @@ -122,9 +122,9 @@ TEST_F(StatisticsReporterFixture, UpdateShallGiveUpIfNotYetTimeToReport) RecordProperty("DerivationTechnique", "Analysis of requirements"); InSequence in_sequence{}; - EXPECT_CALL(recorder_mock_, StartRecord(_, _)).Times(0); + EXPECT_CALL(recorder_mock, StartRecord(_, _)).Times(0); - unit_.Update(kInitialTime); + unit.Update(kInitialTime); } TEST_F(StatisticsReporterFixture, UpdateShallGiveUpIfAlreadyReporting) @@ -136,13 +136,13 @@ TEST_F(StatisticsReporterFixture, UpdateShallGiveUpIfAlreadyReporting) RecordProperty("DerivationTechnique", "Analysis of requirements"); InSequence in_sequence{}; - EXPECT_CALL(recorder_mock_, StartRecord(_, _)).Times(1).WillOnce([this](auto, auto) { - EXPECT_CALL(recorder_mock_, StartRecord(_, _)).Times(0); - unit_.Update(kOverdueTime); + EXPECT_CALL(recorder_mock, StartRecord(_, _)).Times(1).WillOnce([this](auto, auto) { + EXPECT_CALL(recorder_mock, StartRecord(_, _)).Times(0); + unit.Update(kOverdueTime); return kSlot; }); - unit_.Update(kOverdueTime); + unit.Update(kOverdueTime); } } // namespace diff --git a/score/mw/log/detail/utils/signal_handling/BUILD b/score/mw/log/detail/utils/signal_handling/BUILD index 43d75fe..56c9e17 100644 --- a/score/mw/log/detail/utils/signal_handling/BUILD +++ b/score/mw/log/detail/utils/signal_handling/BUILD @@ -10,6 +10,18 @@ # # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* +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", + ], +) COMPILER_WARNING_FEATURES = [ "treat_warnings_as_errors", diff --git a/score/mw/log/detail/utils/signal_handling/signal_handling.h b/score/mw/log/detail/utils/signal_handling/signal_handling.h index f53276a..5f84aef 100644 --- a/score/mw/log/detail/utils/signal_handling/signal_handling.h +++ b/score/mw/log/detail/utils/signal_handling/signal_handling.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_UTILS_SIGNAL_HANDLING_SIGNAL_HANDLING_H_ -#define SCORE_MW_LOG_DETAIL_UTILS_SIGNAL_HANDLING_SIGNAL_HANDLING_H_ +#ifndef SCORE_MW_LOG_DETAIL_UTILS_SIGNAL_HANDLING_SIGNAL_HANDLING_H +#define SCORE_MW_LOG_DETAIL_UTILS_SIGNAL_HANDLING_SIGNAL_HANDLING_H #include "score/os/utils/signal.h" @@ -55,4 +55,4 @@ class SignalHandling } // namespace score::mw::log::detail -#endif // SCORE_MW_LOG_DETAIL_UTILS_SIGNAL_HANDLING_SIGNAL_HANDLING_H_ +#endif // SCORE_MW_LOG_DETAIL_UTILS_SIGNAL_HANDLING_SIGNAL_HANDLING_H diff --git a/score/mw/log/test/console_logging_environment/console_logging_environment.h b/score/mw/log/test/console_logging_environment/console_logging_environment.h index ccf4b97..8ec5e3d 100644 --- a/score/mw/log/test/console_logging_environment/console_logging_environment.h +++ b/score/mw/log/test/console_logging_environment/console_logging_environment.h @@ -10,8 +10,8 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_CONSOLE_LOGGING_ENVIRONMENT_H -#define SCORE_MW_LOG_CONSOLE_LOGGING_ENVIRONMENT_H +#ifndef SCORE_MW_LOG_TEST_CONSOLE_LOGGING_ENVIRONMENT_CONSOLE_LOGGING_ENVIRONMENT_H +#define SCORE_MW_LOG_TEST_CONSOLE_LOGGING_ENVIRONMENT_CONSOLE_LOGGING_ENVIRONMENT_H #include "gtest/gtest.h" @@ -39,4 +39,4 @@ class ConsoleLoggingEnvironment : public ::testing::Environment } // namespace mw } // namespace score -#endif +#endif // SCORE_MW_LOG_TEST_CONSOLE_LOGGING_ENVIRONMENT_CONSOLE_LOGGING_ENVIRONMENT_H diff --git a/score/mw/log/test/console_logging_environment/main.cpp b/score/mw/log/test/console_logging_environment/main.cpp index 147d83f..aa04578 100644 --- a/score/mw/log/test/console_logging_environment/main.cpp +++ b/score/mw/log/test/console_logging_environment/main.cpp @@ -20,7 +20,7 @@ int main(int argc, char** argv) ::testing::InitGoogleTest(&argc, argv); // Googletest will delete all registered global environments and thus we must use new() here. - auto console_log_environment = new score::mw::log::ConsoleLoggingEnvironment(); + auto* console_log_environment = new score::mw::log::ConsoleLoggingEnvironment(); AddGlobalTestEnvironment(console_log_environment); return RUN_ALL_TESTS(); diff --git a/score/mw/log/test/fake_recorder/fake_recorder.cpp b/score/mw/log/test/fake_recorder/fake_recorder.cpp index e4f49ac..b76df03 100644 --- a/score/mw/log/test/fake_recorder/fake_recorder.cpp +++ b/score/mw/log/test/fake_recorder/fake_recorder.cpp @@ -28,13 +28,13 @@ namespace test { namespace { -std::mutex g_stdout_mutex; +std::mutex gStdoutMutex; /// Convert unsigned integer to binary string using std::bitset -template +template std::string ToBinaryString(std::uint64_t value) { - return "0b" + std::bitset(value).to_string(); + return "0b" + std::bitset(value).to_string(); } } // namespace @@ -234,7 +234,7 @@ void FakeRecorder::FlushSlot(const SlotHandle& slot) noexcept } { - std::lock_guard out_lock(g_stdout_mutex); + std::lock_guard out_lock(gStdoutMutex); std::fwrite(msg.c_str(), 1U, msg.size(), stdout); std::fwrite("\n", 1U, 1U, stdout); std::fflush(stdout); diff --git a/score/mw/log/test/fake_recorder_environment/register_fake_recorder_environment.cpp b/score/mw/log/test/fake_recorder_environment/register_fake_recorder_environment.cpp index 64a668f..de524d8 100644 --- a/score/mw/log/test/fake_recorder_environment/register_fake_recorder_environment.cpp +++ b/score/mw/log/test/fake_recorder_environment/register_fake_recorder_environment.cpp @@ -25,6 +25,6 @@ struct AutoRegisterFakeRecorderEnvironment } }; -static AutoRegisterFakeRecorderEnvironment auto_register_instance; +AutoRegisterFakeRecorderEnvironment gAutoRegisterInstance; } // namespace From 67fbc7d5d3a2eef236ca4c08ca4ba5785f53f823 Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Tue, 6 Jan 2026 14:15:07 +0530 Subject: [PATCH 05/29] Restructured non-verbose dlt code GIT_ORIGIN_SPP_REV_ID: 89ff20567f9f90be5ea603bbacc5d4b6b0a0d1be --- score/datarouter/BUILD | 20 +++--- .../applications/datarouter_feature_config.h | 4 +- .../src/dlt/nonverbose_dlt_impl/BUILD | 65 +++++++++++++++++++ .../nonverbose_dlt_impl/nonverbose_dlt.cpp | 42 ++++++++++++ .../dlt/nonverbose_dlt_impl/nonverbose_dlt.h | 59 +++++++++++++++++ .../{ => src/dlt}/nonverbose_dlt_stub/BUILD | 0 .../nonverbose_dlt_stub/stub_nonverbose_dlt.h | 0 .../test/ut/ut_logging/test_nonverbosedlt.cpp | 2 +- 8 files changed, 179 insertions(+), 13 deletions(-) create mode 100644 score/datarouter/src/dlt/nonverbose_dlt_impl/BUILD create mode 100644 score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.cpp create mode 100644 score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h rename score/datarouter/{ => src/dlt}/nonverbose_dlt_stub/BUILD (100%) rename score/datarouter/{ => src/dlt}/nonverbose_dlt_stub/stub_nonverbose_dlt.h (100%) diff --git a/score/datarouter/BUILD b/score/datarouter/BUILD index 5de0093..ba1ef49 100644 --- a/score/datarouter/BUILD +++ b/score/datarouter/BUILD @@ -164,8 +164,8 @@ cc_library( features = COMPILER_WARNING_FEATURES, strip_include_prefix = "include", visibility = [ - "//score/datarouter/nonverbose_dlt:__pkg__", - "//score/datarouter/nonverbose_dlt_stub:__pkg__", + "//score/datarouter/src/dlt/nonverbose_dlt_impl:__pkg__", + "//score/datarouter/src/dlt/nonverbose_dlt_stub:__pkg__", "//score/datarouter/src/file_transfer:__subpackages__", "//score/datarouter/src/persistent_logging:__pkg__", "//score/datarouter/src/persistent_logging/persistent_logging:__pkg__", @@ -187,8 +187,8 @@ cc_library( features = COMPILER_WARNING_FEATURES, strip_include_prefix = "include", visibility = [ - "//score/datarouter/nonverbose_dlt:__pkg__", - "//score/datarouter/nonverbose_dlt_stub:__pkg__", + "//score/datarouter/src/dlt/nonverbose_dlt_impl:__pkg__", + "//score/datarouter/src/dlt/nonverbose_dlt_stub:__pkg__", "//score/datarouter/src/file_transfer:__subpackages__", "//score/datarouter/src/persistent_logging:__pkg__", "//score/datarouter/src/persistent_logging/persistent_logging:__pkg__", @@ -543,8 +543,8 @@ cc_library( ( "", "//score/datarouter/src/persistency/ara_per_persistent_dictionary:ara_per_persistent_dictionary_factory", - "//score/datarouter/nonverbose_dlt:nonverbose_dlt_handler", - "//score/datarouter/nonverbose_dlt_stub:nonverbose_dlt_handler_stub", + "//score/datarouter/src/dlt/nonverbose_dlt_impl:nonverbose_dlt_handler", + "//score/datarouter/src/dlt/nonverbose_dlt_stub:nonverbose_dlt_handler_stub", "//score/datarouter/dynamic_configuration/dynamic_config_session:dynamic_config_session", "//score/datarouter/dynamic_configuration/config_session_stub:config_session_stub", False, @@ -552,8 +552,8 @@ cc_library( ( "_testing", "//score/datarouter/src/persistency/ara_per_persistent_dictionary:ara_per_persistent_dictionary_factory_testing", - "//score/datarouter/nonverbose_dlt:nonverbose_dlt_handler_testing", - "//score/datarouter/nonverbose_dlt_stub:nonverbose_dlt_handler_stub_testing", + "//score/datarouter/src/dlt/nonverbose_dlt_impl:nonverbose_dlt_handler_testing", + "//score/datarouter/src/dlt/nonverbose_dlt_stub:nonverbose_dlt_handler_stub_testing", "//score/datarouter/dynamic_configuration/dynamic_config_session:dynamic_config_session_testing", "//score/datarouter/dynamic_configuration/config_session_stub:config_session_stub_testing", True, @@ -619,8 +619,8 @@ cc_library( features = COMPILER_WARNING_FEATURES, strip_include_prefix = "include", visibility = [ - "//score/datarouter/nonverbose_dlt:__pkg__", - "//score/datarouter/nonverbose_dlt_stub:__pkg__", + "//score/datarouter/src/dlt/nonverbose_dlt_impl:__pkg__", + "//score/datarouter/src/dlt/nonverbose_dlt_stub:__pkg__", ], deps = [ ":dltserver_common", diff --git a/score/datarouter/include/applications/datarouter_feature_config.h b/score/datarouter/include/applications/datarouter_feature_config.h index 0799ce2..d968285 100644 --- a/score/datarouter/include/applications/datarouter_feature_config.h +++ b/score/datarouter/include/applications/datarouter_feature_config.h @@ -24,9 +24,9 @@ #endif #if defined(NON_VERBOSE_DLT) -#include "score/datarouter/nonverbose_dlt/nonverbose_dlt.h" +#include "score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h" #else -#include "score/datarouter/nonverbose_dlt_stub/stub_nonverbose_dlt.h" +#include "score/datarouter/src/dlt/nonverbose_dlt_stub/stub_nonverbose_dlt.h" #endif #if defined(DYNAMIC_CONFIGURATION_IN_DATAROUTER) diff --git a/score/datarouter/src/dlt/nonverbose_dlt_impl/BUILD b/score/datarouter/src/dlt/nonverbose_dlt_impl/BUILD new file mode 100644 index 0000000..707285e --- /dev/null +++ b/score/datarouter/src/dlt/nonverbose_dlt_impl/BUILD @@ -0,0 +1,65 @@ +# ******************************************************************************* +# 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 = "nonverbose_dlt_handler" + name, + testonly = test_only, + srcs = [ + "nonverbose_dlt.cpp", + ], + hdrs = [ + "nonverbose_dlt.h", + ], + features = COMPILER_WARNING_FEATURES, + strip_include_prefix = ".", + visibility = [ + "@score_logging//score/datarouter:__subpackages__", + ], + deps = [ + "@score_baselibs//score/mw/log/configuration:nvconfig", + "@score_logging//score/datarouter:log", + "@score_logging//score/datarouter:logparser", + ] + dep, + ) + for name, dep, test_only in [ + ( + "", + [ + "@score_logging//score/datarouter:dlt_log_channel_lib", + ], + False, + ), + ( + "_testing", + [ + "@score_logging//score/datarouter:dlt_log_channel_lib_testing", + ], + True, + ), + ] +] diff --git a/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.cpp b/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.cpp new file mode 100644 index 0000000..2dc4d17 --- /dev/null +++ b/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.cpp @@ -0,0 +1,42 @@ +/******************************************************************************** + * 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 + ********************************************************************************/ + +#include "nonverbose_dlt.h" + +#include + +namespace score +{ +namespace logging +{ +namespace dltserver +{ + +DltNonverboseHandler::DltNonverboseHandler(IOutput& output) + : LogParser::AnyHandler(), logger_(score::mw::log::CreateLogger("NvL", "Nonverbose logging")), output_(output) +{ +} + +void DltNonverboseHandler::handle(const TypeInfo& type_info, timestamp_t timestamp, const char* data, bufsize_t size) +{ + if (type_info.nvMsgDesc != 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); + } +} + +} // namespace dltserver +} // namespace logging +} // namespace score diff --git a/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h b/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h new file mode 100644 index 0000000..e6772b0 --- /dev/null +++ b/score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h @@ -0,0 +1,59 @@ +/******************************************************************************** + * 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 SCORE_PAS_LOGGING_NONVERBOSE_DLT_NONVERBOSE_DLT_H +#define SCORE_PAS_LOGGING_NONVERBOSE_DLT_NONVERBOSE_DLT_H + +#include "logparser/logparser.h" +#include "score/mw/log/configuration/nvconfig.h" +#include "score/mw/log/logger.h" + +#include "daemon/dlt_log_channel.h" + +namespace score +{ +namespace logging +{ +namespace dltserver +{ + +class DltNonverboseHandler : public LogParser::AnyHandler +{ + public: + class IOutput + { + public: + virtual void SendNonVerbose(const score::mw::log::config::NvMsgDescriptor& desc, + uint32_t tmsp, + const void* data, + size_t size) = 0; + + protected: + ~IOutput() = default; + }; + explicit DltNonverboseHandler(IOutput& output); + + virtual void handle(const TypeInfo& type_info, timestamp_t timestamp, const char* data, bufsize_t size) override; + + private: + score::mw::log::Logger& logger_; + IOutput& output_; + + bool InitNonverboseMode(); +}; + +} // namespace dltserver +} // namespace logging +} // namespace score + +#endif // SCORE_PAS_LOGGING_NONVERBOSE_DLT_NONVERBOSE_DLT_H diff --git a/score/datarouter/nonverbose_dlt_stub/BUILD b/score/datarouter/src/dlt/nonverbose_dlt_stub/BUILD similarity index 100% rename from score/datarouter/nonverbose_dlt_stub/BUILD rename to score/datarouter/src/dlt/nonverbose_dlt_stub/BUILD diff --git a/score/datarouter/nonverbose_dlt_stub/stub_nonverbose_dlt.h b/score/datarouter/src/dlt/nonverbose_dlt_stub/stub_nonverbose_dlt.h similarity index 100% rename from score/datarouter/nonverbose_dlt_stub/stub_nonverbose_dlt.h rename to score/datarouter/src/dlt/nonverbose_dlt_stub/stub_nonverbose_dlt.h diff --git a/score/datarouter/test/ut/ut_logging/test_nonverbosedlt.cpp b/score/datarouter/test/ut/ut_logging/test_nonverbosedlt.cpp index ea0c2f3..e531f70 100644 --- a/score/datarouter/test/ut/ut_logging/test_nonverbosedlt.cpp +++ b/score/datarouter/test/ut/ut_logging/test_nonverbosedlt.cpp @@ -13,7 +13,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "score/datarouter/nonverbose_dlt/nonverbose_dlt.h" +#include "score/datarouter/src/dlt/nonverbose_dlt_impl/nonverbose_dlt.h" using namespace ::testing; using namespace score::logging::dltserver; From 71f6aeb7a092a00fcddcc7c401d73222a76b2b9c Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Sun, 8 Feb 2026 16:22:51 +0100 Subject: [PATCH 06/29] Fix AUTOSAR C++14 A12-1-1 violations in SharedMemoryReader constructors Replace empty brace initialization with explicit initialization: - linear_reader_: Use std::nullopt instead of {} - acquired_data_: Use std::nullopt instead of {} - number_of_acquired_bytes_: Use 0U instead of {} This ensures all member variables are explicitly initialized as required by AUTOSAR C++14 A12-1-1. GIT_ORIGIN_SPP_REV_ID: 1ee88a7b95c5cc269f57efa48e4506da7b2ac17a --- .../data_router/shared_memory/shared_memory_reader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/score/mw/log/detail/data_router/shared_memory/shared_memory_reader.cpp b/score/mw/log/detail/data_router/shared_memory/shared_memory_reader.cpp index f197bbb..bb7bc67 100644 --- a/score/mw/log/detail/data_router/shared_memory/shared_memory_reader.cpp +++ b/score/mw/log/detail/data_router/shared_memory/shared_memory_reader.cpp @@ -131,9 +131,9 @@ SharedMemoryReader::SharedMemoryReader(const SharedData& shared_data, UnmapCallback unmap_callback) noexcept : shared_data_{shared_data}, unmap_callback_{std::move(unmap_callback)}, - linear_reader_{}, - acquired_data_{}, - number_of_acquired_bytes_{}, + linear_reader_{std::nullopt}, + acquired_data_{std::nullopt}, + number_of_acquired_bytes_{0U}, finished_reading_after_detach_{false}, buffer_expected_to_read_next_{shared_data.control_block.switch_count_points_active_for_writing.load()}, is_writer_detached_{false}, @@ -148,7 +148,7 @@ SharedMemoryReader::SharedMemoryReader(SharedMemoryReader&& other) noexcept acquired_data_{other.acquired_data_}, number_of_acquired_bytes_{other.number_of_acquired_bytes_}, finished_reading_after_detach_{other.finished_reading_after_detach_}, - buffer_expected_to_read_next_(other.buffer_expected_to_read_next_), + buffer_expected_to_read_next_{other.buffer_expected_to_read_next_}, is_writer_detached_{other.is_writer_detached_}, alternating_read_only_reader_{std::move(other.alternating_read_only_reader_)} { From 5ebae544f7a41bb9ebbf36abba1130715febb1d8 Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Sun, 8 Feb 2026 18:16:48 +0100 Subject: [PATCH 07/29] Fix AUTOSAR C++14 M5-2-10 violations in DataRouter Separate increment operators from other expressions: - Line 287: Extract member variable before incrementing - Line 550: Store lock result before incrementing member AUTOSAR M5-2-10 prohibits mixing increment/decrement operators with other operators in an expression. GIT_ORIGIN_SPP_REV_ID: 1db0f836de7d0932f285900bbff883835dc9951b --- score/datarouter/datarouter/data_router.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/score/datarouter/datarouter/data_router.cpp b/score/datarouter/datarouter/data_router.cpp index b36b405..de8ec25 100644 --- a/score/datarouter/datarouter/data_router.cpp +++ b/score/datarouter/datarouter/data_router.cpp @@ -284,7 +284,8 @@ void DataRouter::SourceSession::processAndRouteLogMessages(uint64_t& message_cou } else { - cmd->ticks_without_write++; + auto& ticks = cmd->ticks_without_write; + ++ticks; } } else @@ -547,7 +548,9 @@ bool DataRouter::SourceSession::request_acquire() if (acquire_result) { - ++(stats_data_.lock()->count_acquire_requests); + auto stats = stats_data_.lock(); + auto& count_ref = stats->count_acquire_requests; + ++count_ref; } return acquire_result; From dee972bf358eb51de09f1023e8331afe0193ad7e Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Sun, 8 Feb 2026 20:32:35 +0100 Subject: [PATCH 08/29] Fix AUTOSAR C++14 A5-1-4 violations in SocketServer Replace reference capture with pointer capture in lambdas to avoid capturing reference that could outlive the lambda object. Changed from [&persistent_dictionary] to [pd_ptr] where pd_ptr is a raw pointer obtained from persistent_dictionary.get(). This satisfies AUTOSAR A5-1-4 by capturing by value instead of by reference. GIT_ORIGIN_SPP_REV_ID: a69c9c5f304d26d4dc328f065ece0a369712e03e --- score/datarouter/src/daemon/socketserver.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/score/datarouter/src/daemon/socketserver.cpp b/score/datarouter/src/daemon/socketserver.cpp index 2083e5d..b52a548 100644 --- a/score/datarouter/src/daemon/socketserver.cpp +++ b/score/datarouter/src/daemon/socketserver.cpp @@ -103,11 +103,12 @@ SocketServer::PersistentStorageHandlers SocketServer::InitializePersistentStorag { PersistentStorageHandlers handlers; - handlers.load_dlt = [&persistent_dictionary]() { - return readDlt(*persistent_dictionary); + auto* pd_ptr = persistent_dictionary.get(); + handlers.load_dlt = [pd_ptr]() { + return readDlt(*pd_ptr); }; - handlers.store_dlt = [&persistent_dictionary](const score::logging::dltserver::PersistentConfig& config) { - writeDlt(config, *persistent_dictionary); + handlers.store_dlt = [pd_ptr](const score::logging::dltserver::PersistentConfig& config) { + writeDlt(config, *pd_ptr); }; handlers.is_dlt_enabled = readDltEnabled(*persistent_dictionary); From f82e60124cce4a285287e99fe7f9cf59f3504065 Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Sun, 8 Feb 2026 20:42:13 +0100 Subject: [PATCH 09/29] Fix AUTOSAR C++14 violations in MessagePassingServer Fix A7-1-2 violations (lines 127, 133, 543): - Change const to constexpr for compile-time constants - service_protocol_config: const -> constexpr - server_config: const -> constexpr - message array: const -> constexpr Fix A5-1-4 violations (lines 165-166): - Replace lambda capturing 'this' with explicit pointer captures - disconnect_callback: Capture mutex_ and pid_session_map_ as pointers - This avoids capturing the whole object by reference GIT_ORIGIN_SPP_REV_ID: f4c2302447fefb498c911301351fcf71869517d1 --- .../src/daemon/message_passing_server.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/score/datarouter/src/daemon/message_passing_server.cpp b/score/datarouter/src/daemon/message_passing_server.cpp index 8e0e8df..bf96c6c 100644 --- a/score/datarouter/src/daemon/message_passing_server.cpp +++ b/score/datarouter/src/daemon/message_passing_server.cpp @@ -124,35 +124,35 @@ MessagePassingServer::MessagePassingServer(MessagePassingServer::SessionFactory std::cerr << "setname_np: " << ret_pthread.error() << std::endl; } - const score::message_passing::ServiceProtocolConfig service_protocol_config{ + constexpr score::message_passing::ServiceProtocolConfig service_protocol_config{ MessagePassingConfig::kDatarouterReceiverIdentifier, MessagePassingConfig::kMaxMessageSize, MessagePassingConfig::kMaxReplySize, MessagePassingConfig::kMaxNotifySize}; - const score::message_passing::IServerFactory::ServerConfig server_config{MessagePassingConfig::kMaxReceiverQueueSize, - MessagePassingConfig::kPreAllocConnections, - MessagePassingConfig::kMaxQueuedNotifies}; + constexpr score::message_passing::IServerFactory::ServerConfig server_config{MessagePassingConfig::kMaxReceiverQueueSize, + MessagePassingConfig::kPreAllocConnections, + MessagePassingConfig::kMaxQueuedNotifies}; receiver_ = server_factory_->Create(service_protocol_config, server_config); auto connect_callback = [](score::message_passing::IServerConnection& connection) noexcept -> std::uintptr_t { const pid_t client_pid = connection.GetClientIdentity().pid; return static_cast(client_pid); }; - auto disconnect_callback = [this](score::message_passing::IServerConnection& connection) noexcept { - std::unique_lock lock(mutex_); - const auto found = pid_session_map_.find(connection.GetClientIdentity().pid); - if (found != pid_session_map_.end()) + auto disconnect_callback = [mutex_ptr = &mutex_, pid_session_map_ptr = &pid_session_map_](score::message_passing::IServerConnection& connection) noexcept { + std::unique_lock lock(*mutex_ptr); + const auto found = pid_session_map_ptr->find(connection.GetClientIdentity().pid); + if (found != pid_session_map_ptr->end()) { SessionWrapper& wrapper = found->second; wrapper.to_force_finish_ = true; found->second.enqueue_for_delete_while_locked(true); } }; - auto received_send_message_callback = [this](score::message_passing::IServerConnection& connection, + auto received_send_message_callback = [this_ptr = this](score::message_passing::IServerConnection& connection, const score::cpp::span message) noexcept -> score::cpp::blank { const pid_t client_pid = connection.GetClientIdentity().pid; - this->MessageCallback(message, client_pid); + this_ptr->MessageCallback(message, client_pid); return {}; }; auto received_send_message_with_reply_callback = @@ -540,7 +540,7 @@ bool MessagePassingServer::SessionHandle::AcquireRequest() const { return false; } - const std::array message{score::cpp::to_underlying(DatarouterMessageIdentifier::kAcquireRequest)}; + constexpr std::array message{score::cpp::to_underlying(DatarouterMessageIdentifier::kAcquireRequest)}; auto ret = sender_->Send(message); if (!ret) { From e59fdf1d17b07a7052cf2b5a1e7bf357f7ada1ff Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Sun, 8 Feb 2026 20:46:30 +0100 Subject: [PATCH 10/29] Fix AUTOSAR C++14 A12-1-1 violation in LogParser Change handlers_ initialization from empty braces to parentheses in IndexParser constructor to comply with AUTOSAR rule A12-1-1 which requires explicit initialization. GIT_ORIGIN_SPP_REV_ID: 3aa46e970c434b4b63c1bd8078ae760865559837 --- score/datarouter/include/logparser/logparser.h | 2 +- .../src/daemon/message_passing_server.cpp | 15 +++++++++------ score/datarouter/src/logparser/logparser.cpp | 11 ++++++++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/score/datarouter/include/logparser/logparser.h b/score/datarouter/include/logparser/logparser.h index 02eb7f5..15eeb85 100644 --- a/score/datarouter/include/logparser/logparser.h +++ b/score/datarouter/include/logparser/logparser.h @@ -89,7 +89,7 @@ class LogParser : public ILogParser public: TypeInfo info_; - explicit IndexParser(TypeInfo info) : info_{info}, handlers_{} {} + explicit IndexParser(TypeInfo info) : info_{info}, handlers_() {} void add_handler(const HandleRequestMap::value_type& request); void remove_handler(const HandleRequestMap::value_type& request); diff --git a/score/datarouter/src/daemon/message_passing_server.cpp b/score/datarouter/src/daemon/message_passing_server.cpp index bf96c6c..225ad42 100644 --- a/score/datarouter/src/daemon/message_passing_server.cpp +++ b/score/datarouter/src/daemon/message_passing_server.cpp @@ -130,16 +130,18 @@ MessagePassingServer::MessagePassingServer(MessagePassingServer::SessionFactory MessagePassingConfig::kMaxReplySize, MessagePassingConfig::kMaxNotifySize}; - constexpr score::message_passing::IServerFactory::ServerConfig server_config{MessagePassingConfig::kMaxReceiverQueueSize, - MessagePassingConfig::kPreAllocConnections, - MessagePassingConfig::kMaxQueuedNotifies}; + constexpr score::message_passing::IServerFactory::ServerConfig server_config{ + MessagePassingConfig::kMaxReceiverQueueSize, + MessagePassingConfig::kPreAllocConnections, + MessagePassingConfig::kMaxQueuedNotifies}; receiver_ = server_factory_->Create(service_protocol_config, server_config); auto connect_callback = [](score::message_passing::IServerConnection& connection) noexcept -> std::uintptr_t { const pid_t client_pid = connection.GetClientIdentity().pid; return static_cast(client_pid); }; - auto disconnect_callback = [mutex_ptr = &mutex_, pid_session_map_ptr = &pid_session_map_](score::message_passing::IServerConnection& connection) noexcept { + auto disconnect_callback = [mutex_ptr = &mutex_, pid_session_map_ptr = &pid_session_map_]( + score::message_passing::IServerConnection& connection) noexcept { std::unique_lock lock(*mutex_ptr); const auto found = pid_session_map_ptr->find(connection.GetClientIdentity().pid); if (found != pid_session_map_ptr->end()) @@ -149,8 +151,9 @@ MessagePassingServer::MessagePassingServer(MessagePassingServer::SessionFactory found->second.enqueue_for_delete_while_locked(true); } }; - auto received_send_message_callback = [this_ptr = this](score::message_passing::IServerConnection& connection, - const score::cpp::span message) noexcept -> score::cpp::blank { + auto received_send_message_callback = [this_ptr = this]( + score::message_passing::IServerConnection& connection, + const score::cpp::span message) noexcept -> score::cpp::blank { const pid_t client_pid = connection.GetClientIdentity().pid; this_ptr->MessageCallback(message, client_pid); return {}; diff --git a/score/datarouter/src/logparser/logparser.cpp b/score/datarouter/src/logparser/logparser.cpp index b036645..d46385f 100644 --- a/score/datarouter/src/logparser/logparser.cpp +++ b/score/datarouter/src/logparser/logparser.cpp @@ -59,7 +59,16 @@ namespace platform namespace internal { -LogParser::LogParser(const score::mw::log::INvConfig& nv_config) : nv_config_(nv_config) {} +LogParser::LogParser(const score::mw::log::INvConfig& nv_config) + : ILogParser(), + 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) { From 12583ac74940a5c8614cebaa2f56ce74ec0dffff Mon Sep 17 00:00:00 2001 From: Nikita Belenkiy Date: Fri, 6 Feb 2026 19:04:28 +0100 Subject: [PATCH 11/29] lib/message_passing: provide OS-agnostic interface GIT_ORIGIN_SPP_REV_ID: 442c2a22862435d1f6fc0d0cfb2813a5aa6b1fa4 --- .../datarouter/include/daemon/socketserver.h | 20 ++-------- .../message_passing_factory_impl.h | 37 +++---------------- 2 files changed, 9 insertions(+), 48 deletions(-) diff --git a/score/datarouter/include/daemon/socketserver.h b/score/datarouter/include/daemon/socketserver.h index dce4823..23a6e3a 100644 --- a/score/datarouter/include/daemon/socketserver.h +++ b/score/datarouter/include/daemon/socketserver.h @@ -52,15 +52,8 @@ class Pthread; } // namespace os } // namespace score -#ifdef __QNX__ -#include "score/message_passing/qnx_dispatch/qnx_dispatch_client_factory.h" -#include "score/message_passing/qnx_dispatch/qnx_dispatch_engine.h" -#include "score/message_passing/qnx_dispatch/qnx_dispatch_server_factory.h" -#else -#include "score/message_passing/unix_domain/unix_domain_client_factory.h" -#include "score/message_passing/unix_domain/unix_domain_engine.h" -#include "score/message_passing/unix_domain/unix_domain_server_factory.h" -#endif +#include "score/message_passing/client_factory.h" +#include "score/message_passing/server_factory.h" namespace score { @@ -69,13 +62,8 @@ namespace platform namespace datarouter { -#ifdef __QNX__ -using ServerFactory = score::message_passing::QnxDispatchServerFactory; -using ClientFactory = score::message_passing::QnxDispatchClientFactory; -#else -using ServerFactory = score::message_passing::UnixDomainServerFactory; -using ClientFactory = score::message_passing::UnixDomainClientFactory; -#endif +using ServerFactory = score::message_passing::ServerFactory; +using ClientFactory = score::message_passing::ClientFactory; class SocketServer { diff --git a/score/mw/log/detail/data_router/message_passing_factory_impl.h b/score/mw/log/detail/data_router/message_passing_factory_impl.h index bddcc0d..4b0142b 100644 --- a/score/mw/log/detail/data_router/message_passing_factory_impl.h +++ b/score/mw/log/detail/data_router/message_passing_factory_impl.h @@ -16,19 +16,10 @@ #include "score/mw/log/detail/data_router/message_passing_factory.h" -#include "score/message_passing/i_client_factory.h" -#include "score/message_passing/i_server_factory.h" -#include +#include "score/message_passing/client_factory.h" +#include "score/message_passing/server_factory.h" -#ifdef __QNX__ -#include "score/message_passing/qnx_dispatch/qnx_dispatch_client_factory.h" -#include "score/message_passing/qnx_dispatch/qnx_dispatch_engine.h" -#include "score/message_passing/qnx_dispatch/qnx_dispatch_server_factory.h" -#else -#include "score/message_passing/unix_domain/unix_domain_client_factory.h" -#include "score/message_passing/unix_domain/unix_domain_engine.h" -#include "score/message_passing/unix_domain/unix_domain_server_factory.h" -#endif +#include namespace score { @@ -39,26 +30,8 @@ namespace log namespace detail { -/* - Deviation from Rule A16-0-1: - - Rule A16-0-1 (required, implementation, automated) - The pre-processor shall only be used for unconditional and conditional file - inclusion and include guards, and using the following directives: (1) #ifndef, - #ifdef, (3) #if, (4) #if defined, (5) #elif, (6) #else, (7) #define, (8) #endif, (9) - #include. - Justification: - - Feature Flag to enable/disable Logging Modes in Production SW. - */ -// coverity[autosar_cpp14_a16_0_1_violation] see above -#ifdef __QNX__ -using ServerFactory = score::message_passing::QnxDispatchServerFactory; -using ClientFactory = score::message_passing::QnxDispatchClientFactory; -// coverity[autosar_cpp14_a16_0_1_violation] see above -#else -using ServerFactory = score::message_passing::UnixDomainServerFactory; -using ClientFactory = score::message_passing::UnixDomainClientFactory; -// coverity[autosar_cpp14_a16_0_1_violation] see above -#endif +using ServerFactory = score::message_passing::ServerFactory; +using ClientFactory = score::message_passing::ClientFactory; class MessagePassingFactoryImpl : public MessagePassingFactory { From 3ce156ac2f7a77e97788a378514f78071411b342 Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Sun, 1 Feb 2026 15:34:38 +0100 Subject: [PATCH 12/29] Enable extra clang_tidy checks for the following folders: - platform/aas/log/detail/data_router - platfrom/aas/log/detail/slog GIT_ORIGIN_SPP_REV_ID: 69715ec571edc7532b27dcae16e879b6c10b04cf --- score/mw/log/detail/data_router/BUILD | 12 + .../data_router/data_router_backend.cpp | 6 +- .../data_router/data_router_backend_test.cpp | 179 +++++++------- .../data_router/data_router_message_client.h | 6 +- .../data_router_message_client_backend.h | 6 +- .../data_router_message_client_factory.h | 6 +- .../data_router_message_client_factory_impl.h | 6 +- .../data_router_message_client_factory_mock.h | 6 +- ...ata_router_message_client_factory_test.cpp | 15 +- .../data_router_message_client_identifiers.h | 6 +- .../data_router_message_client_impl.cpp | 6 +- .../data_router_message_client_impl.h | 6 +- .../data_router_message_client_mock.h | 6 +- .../data_router_message_client_test.cpp | 57 +++-- .../data_router_message_client_utils.cpp | 6 +- .../data_router_message_client_utils.h | 6 +- .../detail/data_router/data_router_messages.h | 6 +- .../data_router/data_router_messages_test.cpp | 30 +-- .../data_router/data_router_recorder.cpp | 34 +-- .../detail/data_router/data_router_recorder.h | 6 +- .../data_router/data_router_recorder_test.cpp | 16 +- .../data_router/message_passing_factory.h | 2 +- .../message_passing_factory_impl.h | 2 +- .../message_passing_factory_mock.h | 2 +- .../message_passing_factory_test.cpp | 4 +- .../data_router/remote_dlt_recorder_factory.h | 6 +- .../remote_dlt_recorder_factory_test.cpp | 3 - .../data_router/shared_memory/common.cpp | 2 +- .../detail/data_router/shared_memory/common.h | 6 +- .../shared_memory/i_shared_memory_reader.h | 6 +- .../shared_memory/reader_factory.h | 6 +- .../shared_memory/reader_factory_impl.cpp | 12 +- .../shared_memory/reader_factory_impl.h | 6 +- .../shared_memory/reader_factory_test.cpp | 108 ++++----- .../shared_memory/shared_memory_reader.cpp | 8 +- .../shared_memory/shared_memory_reader.h | 6 +- .../shared_memory_reader_test.cpp | 226 +++++++++--------- .../shared_memory/shared_memory_writer.h | 20 +- .../shared_memory_writer_test.cpp | 120 +++++----- .../shared_memory/writer_factory.cpp | 52 ++-- .../shared_memory/writer_factory.h | 8 +- .../shared_memory/writer_factory_test.cpp | 208 ++++++++-------- score/mw/log/detail/slog/BUILD | 12 + score/mw/log/detail/slog/slog_backend.cpp | 16 +- .../log/detail/slog/slog_recorder_factory.cpp | 4 +- .../log/detail/slog/slog_recorder_factory.h | 6 +- 46 files changed, 644 insertions(+), 634 deletions(-) diff --git a/score/mw/log/detail/data_router/BUILD b/score/mw/log/detail/data_router/BUILD index 3247f9c..eb727b3 100644 --- a/score/mw/log/detail/data_router/BUILD +++ b/score/mw/log/detail/data_router/BUILD @@ -14,6 +14,18 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load("@score_baselibs//:bazel/unit_tests.bzl", "cc_unit_test_suites_for_host_and_qnx") 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 = "data_router_backend", 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 4340478..b26212a 100644 --- a/score/mw/log/detail/data_router/data_router_backend.cpp +++ b/score/mw/log/detail/data_router/data_router_backend.cpp @@ -31,10 +31,10 @@ namespace detail namespace { -static std::size_t CheckForMaxCapacity(const std::size_t capacity) noexcept +std::size_t CheckForMaxCapacity(const std::size_t capacity) noexcept { - const auto isWithinMaxCapacity = (capacity <= std::numeric_limits::max()); - if (isWithinMaxCapacity) + const auto is_within_max_capacity = (capacity <= std::numeric_limits::max()); + if (is_within_max_capacity) { return capacity; } 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 62946d6..1bf2d67 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 @@ -41,24 +41,23 @@ namespace { using ::testing::_; -using ::testing::AnyNumber; using ::testing::Return; using ::testing::StrEq; -static constexpr pid_t kPid{0x314}; -static constexpr std::int32_t kArbitratyUid = 21880012; -static constexpr std::int32_t kFileDescriptor = 0x31; // arbitrary file descriptor number -static constexpr std::int32_t kFdNumber = 17; -static constexpr auto kSharedSize = 64UL; -static constexpr auto kOpenReadFlagsDynamic = +constexpr pid_t kPid{0x314}; +constexpr std::int32_t kArbitratyUid = 21880012; +constexpr std::int32_t kFileDescriptor = 0x31; // arbitrary file descriptor number +constexpr std::int32_t kFdNumber = 17; +constexpr auto kSharedSize = 64UL; +constexpr auto kOpenReadFlagsDynamic = score::os::Fcntl::Open::kReadWrite | score::os::Fcntl::Open::kExclusive | score::os::Fcntl::Open::kCloseOnExec; -static constexpr auto kOpenReadFlags = kOpenReadFlagsDynamic | score::os::Fcntl::Open::kCreate; -static constexpr auto kOpenModeFlags = +constexpr auto kOpenReadFlags = kOpenReadFlagsDynamic | score::os::Fcntl::Open::kCreate; +constexpr auto kOpenModeFlags = score::os::Stat::Mode::kReadUser | score::os::Stat::Mode::kReadGroup | score::os::Stat::Mode::kReadOthers; constexpr auto kAlignRequirement = std::alignment_of::value; const char kDynamicFileName[] = "/tmp/logging-XXXXXX.shmem"; -const std::string GetStaticSharedMemoryFileName() noexcept +std::string GetStaticSharedMemoryFileName() noexcept { std::stringstream ss; ss << "/tmp/logging.NONE." << kArbitratyUid << ".shmem"; @@ -76,7 +75,7 @@ struct DatarouterMessageClientStub : DatarouterMessageClient WriterFactory::OsalInstances CreateSharedMemoryWriterFactoryMockResources() { WriterFactory::OsalInstances osal; - auto memory_resource = score::cpp::pmr::get_default_resource(); + auto* memory_resource = score::cpp::pmr::get_default_resource(); osal.fcntl_osal = score::cpp::pmr::make_unique(memory_resource); osal.unistd = score::cpp::pmr::make_unique(memory_resource); osal.mman = score::cpp::pmr::make_unique(memory_resource); @@ -128,35 +127,35 @@ class DataRouterBackendFixture : public ::testing::Test, public ::testing::WithP shared_data_.control_block.control_block_odd.data}; reader_ = std::make_unique(shared_data_, std::move(read_only_reader), []() noexcept {}); - config_.SetDynamicDatarouterIdentifiers(false); - logger_ = std::make_unique( - config_, score::mw::log::NvConfigFactory::CreateEmpty(), std::move(writer_)); + config.SetDynamicDatarouterIdentifiers(false); + logger = std::make_unique( + config, score::mw::log::NvConfigFactory::CreateEmpty(), std::move(writer_)); - ::score::platform::logger::InjectTestInstance(logger_.get()); + ::score::platform::logger::InjectTestInstance(logger.get()); CreateSharedMemoryWriterFactory(); - map_address_ = buffer_.data(); + map_address = buffer.data(); - ON_CALL(*stdlib_mock_raw_ptr_, mkstemps(_, _)).WillByDefault(Return(kFdNumber)); + ON_CALL(*stdlib_mock_raw_ptr, mkstemps(_, _)).WillByDefault(Return(kFdNumber)); - ON_CALL(*unistd_mock_raw_ptr_, ftruncate(kFileDescriptor, _)) + ON_CALL(*unistd_mock_raw_ptr, ftruncate(kFileDescriptor, _)) .WillByDefault(Return(score::cpp::expected_blank{})); - ON_CALL(*stat_mock_raw_ptr_, chmod(_, _)).WillByDefault(Return(score::cpp::expected_blank{})); + ON_CALL(*stat_mock_raw_ptr, chmod(_, _)).WillByDefault(Return(score::cpp::expected_blank{})); - ON_CALL(*unistd_mock_raw_ptr_, getuid()).WillByDefault(Return(kArbitratyUid)); + ON_CALL(*unistd_mock_raw_ptr, getuid()).WillByDefault(Return(kArbitratyUid)); - ON_CALL(*mman_mock_raw_ptr_, + ON_CALL(*mman_mock_raw_ptr, mmap(nullptr, _, score::os::Mman::Protection::kRead | score::os::Mman::Protection::kWrite, score::os::Mman::Map::kShared, kFileDescriptor, 0)) - .WillByDefault(Return(score::cpp::expected{map_address_})); + .WillByDefault(Return(score::cpp::expected{map_address})); - ON_CALL(*unistd_mock_raw_ptr_, getpid()).WillByDefault(Return(kPid)); + ON_CALL(*unistd_mock_raw_ptr, getpid()).WillByDefault(Return(kPid)); } void TearDown() override @@ -164,25 +163,25 @@ class DataRouterBackendFixture : public ::testing::Test, public ::testing::WithP ::score::platform::logger::InjectTestInstance(nullptr); } - void SimulateLogging(const std::string& context_id, const LogLevel logLevel = LogLevel::kError) + void SimulateLogging(const std::string& context_id, const LogLevel log_level = LogLevel::kError) { - SimulateLogging(logLevel, context_id); + SimulateLogging(log_level, context_id); } void CreateSharedMemoryWriterFactory() { - auto memory_resource = score::cpp::pmr::get_default_resource(); + auto* memory_resource = score::cpp::pmr::get_default_resource(); auto fcntl_mock = score::cpp::pmr::make_unique(memory_resource); auto unistd_mock = score::cpp::pmr::make_unique(memory_resource); auto mman_mock = score::cpp::pmr::make_unique(memory_resource); auto stat_mock = score::cpp::pmr::make_unique(memory_resource); auto stdlib_mock = score::cpp::pmr::make_unique(memory_resource); - fcntl_mock_raw_ptr_ = fcntl_mock.get(); - mman_mock_raw_ptr_ = mman_mock.get(); - unistd_mock_raw_ptr_ = unistd_mock.get(); - stat_mock_raw_ptr_ = stat_mock.get(); - stdlib_mock_raw_ptr_ = stdlib_mock.get(); + fcntl_mock_raw_ptr = fcntl_mock.get(); + mman_mock_raw_ptr = mman_mock.get(); + unistd_mock_raw_ptr = unistd_mock.get(); + stat_mock_raw_ptr = stat_mock.get(); + stdlib_mock_raw_ptr = stdlib_mock.get(); WriterFactory::OsalInstances osal; osal.fcntl_osal = std::move(fcntl_mock); @@ -191,53 +190,53 @@ class DataRouterBackendFixture : public ::testing::Test, public ::testing::WithP osal.stat_osal = std::move(stat_mock); osal.stdlib = std::move(stdlib_mock); - writer_factory_ = WriterFactory{std::move(osal)}; + writer_factory = WriterFactory{std::move(osal)}; } - void SimulateLogging(const LogLevel logLevel = LogLevel::kError, + void SimulateLogging(const LogLevel log_level = LogLevel::kError, const std::string& context_id = "DFLT", const std::string& app_id = "TEST") { const auto slot = unit_.ReserveSlot().value(); - auto&& logRecord = unit_.GetLogRecord(slot); - auto& log_entry = logRecord.getLogEntry(); + auto&& log_record = unit_.GetLogRecord(slot); + auto& log_entry = log_record.getLogEntry(); log_entry.app_id = LoggingIdentifier{app_id}; log_entry.ctx_id = LoggingIdentifier{context_id}; - log_entry.log_level = logLevel; + log_entry.log_level = log_level; log_entry.num_of_args = 5; - logRecord.getVerbosePayload().Put("ABC DEF", 7); + log_record.getVerbosePayload().Put("ABC DEF", 7); unit_.FlushSlot(slot); - const auto acquire_result = logger_->GetSharedMemoryWriter().ReadAcquire(); - config_ = logger_->get_config(); + const auto acquire_result = logger->GetSharedMemoryWriter().ReadAcquire(); + config = logger->get_config(); reader_->NotifyAcquisitionSetReader(acquire_result); reader_->Read([](const TypeRegistration&) noexcept {}, [this](const SharedMemoryRecord& record) { std::ignore = SerializeNs::deserialize( - record.payload.data(), GetDataSizeAsLength(record.payload), header_); + record.payload.data(), GetDataSizeAsLength(record.payload), header); }); } - LogEntry header_{}; - std::unique_ptr logger_{}; - Configuration config_{}; + LogEntry header{}; + std::unique_ptr logger{}; + Configuration config{}; // Mocks needed for dependency injection into SharedMemoryWriter: - score::os::FcntlMock* fcntl_mock_raw_ptr_; - score::os::UnistdMock* unistd_mock_raw_ptr_; - score::os::StatMock* stat_mock_raw_ptr_; - score::os::StdlibMock* stdlib_mock_raw_ptr_; - score::os::MmanMock* mman_mock_raw_ptr_; + score::os::FcntlMock* fcntl_mock_raw_ptr; + score::os::UnistdMock* unistd_mock_raw_ptr; + score::os::StatMock* stat_mock_raw_ptr; + score::os::StdlibMock* stdlib_mock_raw_ptr; + score::os::MmanMock* mman_mock_raw_ptr; - score::mw::log::detail::WriterFactory writer_factory_{{}}; - std::array buffer_; - void* map_address_; + score::mw::log::detail::WriterFactory writer_factory{{}}; + std::array buffer; + void* map_address; private: SharedData shared_data_{}; @@ -251,7 +250,7 @@ class DataRouterBackendFixture : public ::testing::Test, public ::testing::WithP DataRouterBackend unit_{std::uint8_t{255UL}, LogRecord{}, message_client_factory_, - config_, + config, WriterFactory{CreateSharedMemoryWriterFactoryMockResources()}}; }; @@ -265,7 +264,7 @@ TEST_F(DataRouterBackendFixture, AppIDSetCorrectly) SimulateLogging(); const auto app_id = LoggingIdentifier{"TEST"}; - EXPECT_EQ(header_.app_id, app_id); + EXPECT_EQ(header.app_id, app_id); } TEST_F(DataRouterBackendFixture, ToSmallAppIdSetCorrectlyWithZeroPadding) @@ -278,7 +277,7 @@ TEST_F(DataRouterBackendFixture, ToSmallAppIdSetCorrectlyWithZeroPadding) SimulateLogging(LogLevel::kError, "DFLT", "TES"); const auto test = LoggingIdentifier{"TES"}; - EXPECT_EQ(header_.app_id, test); + EXPECT_EQ(header.app_id, test); } TEST_F(DataRouterBackendFixture, ContextIdSetCorrectly) @@ -291,7 +290,7 @@ TEST_F(DataRouterBackendFixture, ContextIdSetCorrectly) SimulateLogging(); const auto ctx = LoggingIdentifier{"DFLT"}; - EXPECT_EQ(header_.ctx_id, ctx); + EXPECT_EQ(header.ctx_id, ctx); } TEST_F(DataRouterBackendFixture, ToSmallCtxSetCorrectlyWithZeroPadding) @@ -304,7 +303,7 @@ TEST_F(DataRouterBackendFixture, ToSmallCtxSetCorrectlyWithZeroPadding) SimulateLogging("DFL"); const auto ctx = LoggingIdentifier{"DFL"}; - EXPECT_EQ(header_.ctx_id, ctx); + EXPECT_EQ(header.ctx_id, ctx); } TEST_P(DataRouterBackendFixture, LogLevelSetCorrectly) @@ -318,7 +317,7 @@ TEST_P(DataRouterBackendFixture, LogLevelSetCorrectly) SimulateLogging(GetParam()); - EXPECT_EQ(header_.log_level, GetParam()); + EXPECT_EQ(header.log_level, GetParam()); } INSTANTIATE_TEST_SUITE_P(LogLevelSetCorrectly, @@ -416,7 +415,7 @@ TEST_F(DataRouterBackendFixture, NumberOfArgsSetCorrectly) SimulateLogging(); - EXPECT_EQ(header_.num_of_args, 5UL); + EXPECT_EQ(header.num_of_args, 5UL); } TEST_F(DataRouterBackendFixture, PayloadSetCorrectly) @@ -431,7 +430,7 @@ TEST_F(DataRouterBackendFixture, PayloadSetCorrectly) ByteVector payload{'A', 'B', 'C', ' ', 'D', 'E', 'F'}; // Payload content - EXPECT_EQ(header_.payload, payload); + EXPECT_EQ(header.payload, payload); } TEST(DataRouterBackendTests, CheckSizeValid) @@ -441,16 +440,16 @@ TEST(DataRouterBackendTests, CheckSizeValid) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Analysis of boundary values"); - const std::size_t kMaxSlotsSize = 255UL; + const std::size_t k_max_slots_size = 255UL; DatarouterMessageClientStubFactory message_client_factory; // Give the try to allocate one more then possible number of slots - const Configuration config_{}; + const Configuration config{}; WriterFactory writer_factory{CreateSharedMemoryWriterFactoryMockResources()}; DataRouterBackend datarouter_backend{ - kMaxSlotsSize + 1, LogRecord{}, message_client_factory, config_, std::move(writer_factory)}; + k_max_slots_size + 1, LogRecord{}, message_client_factory, config, std::move(writer_factory)}; // Given depleted allocator: - for (std::size_t i = 0; i < kMaxSlotsSize; i++) + for (std::size_t i = 0; i < k_max_slots_size; i++) { const auto& slot = datarouter_backend.ReserveSlot(); EXPECT_TRUE(slot.has_value()); @@ -469,17 +468,17 @@ TEST(DataRouterBackendTests, WhenAllPossibleSlotsUsedFailToAllocateMore) RecordProperty("DerivationTechnique", "Analysis of boundary values"); // Given maksimum allocation size: - const std::uint8_t kMaxSlotsSize = 255UL; + const std::uint8_t k_max_slots_size = 255UL; DatarouterMessageClientStubFactory message_client_factory{}; - const Configuration config_{}; - DataRouterBackend datarouter_backend(kMaxSlotsSize, + const Configuration config{}; + DataRouterBackend datarouter_backend(k_max_slots_size, LogRecord{}, message_client_factory, - config_, + config, WriterFactory{CreateSharedMemoryWriterFactoryMockResources()}); // Given depleted allocator: - for (std::size_t i = 0; i < kMaxSlotsSize; i++) + for (std::size_t i = 0; i < k_max_slots_size; i++) { const auto& slot = datarouter_backend.ReserveSlot(); EXPECT_TRUE(slot.has_value()); @@ -497,10 +496,10 @@ TEST_F(DataRouterBackendFixture, WhenSafeIpcIsTrueMessageClientIsCreated) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - const std::uint8_t kMaxSlotsSize = 255UL; + const std::uint8_t k_max_slots_size = 255UL; DatarouterMessageClientFactoryMock message_client_factory{}; - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(GetStaticSharedMemoryFileName()), kOpenReadFlags, kOpenModeFlags)) + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(GetStaticSharedMemoryFileName()), kOpenReadFlags, kOpenModeFlags)) .WillOnce(Return(score::cpp::expected{kFileDescriptor})); EXPECT_CALL(message_client_factory, CreateOnce(_, _)) @@ -509,7 +508,7 @@ TEST_F(DataRouterBackendFixture, WhenSafeIpcIsTrueMessageClientIsCreated) }); DataRouterBackend datarouter_backend( - kMaxSlotsSize, LogRecord{}, message_client_factory, config_, std::move(writer_factory_)); + k_max_slots_size, LogRecord{}, message_client_factory, config, std::move(writer_factory)); } TEST_F(DataRouterBackendFixture, WhenIdentifierIsNotDynamicUidShallBeUsed) @@ -519,10 +518,10 @@ TEST_F(DataRouterBackendFixture, WhenIdentifierIsNotDynamicUidShallBeUsed) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - const std::uint8_t kSlotsSize = 16UL; + const std::uint8_t k_slots_size = 16UL; DatarouterMessageClientFactoryMock message_client_factory{}; - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(GetStaticSharedMemoryFileName()), kOpenReadFlags, kOpenModeFlags)) + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(GetStaticSharedMemoryFileName()), kOpenReadFlags, kOpenModeFlags)) .WillOnce(Return(score::cpp::expected{kFileDescriptor})); EXPECT_CALL(message_client_factory, CreateOnce(_, _)) @@ -531,7 +530,7 @@ TEST_F(DataRouterBackendFixture, WhenIdentifierIsNotDynamicUidShallBeUsed) }); DataRouterBackend datarouter_backend( - kSlotsSize, LogRecord{}, message_client_factory, config_, std::move(writer_factory_)); + k_slots_size, LogRecord{}, message_client_factory, config, std::move(writer_factory)); } TEST_F(DataRouterBackendFixture, ConstructWithDynamicIdentifier) @@ -541,11 +540,11 @@ TEST_F(DataRouterBackendFixture, ConstructWithDynamicIdentifier) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - const std::uint8_t kMaxSlotsSize = 255UL; + const std::uint8_t k_max_slots_size = 255UL; DatarouterMessageClientFactoryMock message_client_factory{}; - config_.SetDynamicDatarouterIdentifiers(true); + config.SetDynamicDatarouterIdentifiers(true); - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(kDynamicFileName), kOpenReadFlagsDynamic, kOpenModeFlags)) + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(kDynamicFileName), kOpenReadFlagsDynamic, kOpenModeFlags)) .WillOnce(Return(score::cpp::expected{kFileDescriptor})); EXPECT_CALL(message_client_factory, CreateOnce(_, _)) @@ -553,19 +552,19 @@ TEST_F(DataRouterBackendFixture, ConstructWithDynamicIdentifier) return std::make_unique(); }); - EXPECT_CALL(*unistd_mock_raw_ptr_, getuid()).Times(0); + EXPECT_CALL(*unistd_mock_raw_ptr, getuid()).Times(0); DataRouterBackend datarouter_backend( - kMaxSlotsSize, LogRecord{}, message_client_factory, config_, std::move(writer_factory_)); + k_max_slots_size, LogRecord{}, message_client_factory, config, std::move(writer_factory)); } TEST_F(DataRouterBackendFixture, ConstructWithDynamicIdentifierAndChmodSuccess) { - const std::uint8_t kMaxSlotsSize = 255UL; + const std::uint8_t k_max_slots_size = 255UL; DatarouterMessageClientFactoryMock message_client_factory{}; - config_.SetDynamicDatarouterIdentifiers(true); + config.SetDynamicDatarouterIdentifiers(true); - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(kDynamicFileName), kOpenReadFlagsDynamic, kOpenModeFlags)) + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(kDynamicFileName), kOpenReadFlagsDynamic, kOpenModeFlags)) .WillOnce(Return(score::cpp::expected{kFileDescriptor})); EXPECT_CALL(message_client_factory, CreateOnce(_, _)) @@ -573,10 +572,10 @@ TEST_F(DataRouterBackendFixture, ConstructWithDynamicIdentifierAndChmodSuccess) return std::make_unique(); }); - EXPECT_CALL(*unistd_mock_raw_ptr_, getuid()).Times(0); + EXPECT_CALL(*unistd_mock_raw_ptr, getuid()).Times(0); DataRouterBackend datarouter_backend( - kMaxSlotsSize, LogRecord{}, message_client_factory, config_, std::move(writer_factory_)); + k_max_slots_size, LogRecord{}, message_client_factory, config, std::move(writer_factory)); } TEST_F(DataRouterBackendFixture, DataRouterBackEndConstructedWithEmptyIdentifierWhenMkstempFail) @@ -586,24 +585,24 @@ TEST_F(DataRouterBackendFixture, DataRouterBackEndConstructedWithEmptyIdentifier RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - config_.SetDynamicDatarouterIdentifiers(true); + config.SetDynamicDatarouterIdentifiers(true); - const std::uint8_t kMaxSlotsSize = 255UL; + const std::uint8_t k_max_slots_size = 255UL; DatarouterMessageClientFactoryMock message_client_factory{}; - EXPECT_CALL(*stdlib_mock_raw_ptr_, mkstemps(_, _)) + EXPECT_CALL(*stdlib_mock_raw_ptr, mkstemps(_, _)) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno()))); - EXPECT_CALL(*stat_mock_raw_ptr_, chmod(_, _)) + EXPECT_CALL(*stat_mock_raw_ptr, chmod(_, _)) .Times(2) .WillRepeatedly(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno()))); EXPECT_CALL(message_client_factory, CreateOnce(_, _)).Times(0); - EXPECT_CALL(*unistd_mock_raw_ptr_, getuid()).Times(0); + EXPECT_CALL(*unistd_mock_raw_ptr, getuid()).Times(0); DataRouterBackend datarouter_backend( - kMaxSlotsSize, LogRecord{}, message_client_factory, config_, std::move(writer_factory_)); + k_max_slots_size, LogRecord{}, message_client_factory, config, std::move(writer_factory)); } } // namespace diff --git a/score/mw/log/detail/data_router/data_router_message_client.h b/score/mw/log/detail/data_router/data_router_message_client.h index f36698f..5804892 100644 --- a/score/mw/log/detail/data_router/data_router_message_client.h +++ b/score/mw/log/detail/data_router/data_router_message_client.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_H -#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_H +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_H namespace score { @@ -49,4 +49,4 @@ class DatarouterMessageClient } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_H +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_H diff --git a/score/mw/log/detail/data_router/data_router_message_client_backend.h b/score/mw/log/detail/data_router/data_router_message_client_backend.h index 04934e3..a576b5a 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_backend.h +++ b/score/mw/log/detail/data_router/data_router_message_client_backend.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef MW_LOG_DETAILS_DATA_ROUTER_MESSAGE_CLIENT_BACKEND_H_ -#define MW_LOG_DETAILS_DATA_ROUTER_MESSAGE_CLIENT_BACKEND_H_ +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_BACKEND_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_BACKEND_H #include "score/mw/log/detail/data_router/message_passing_factory.h" #include "score/mw/log/detail/data_router/shared_memory/shared_memory_writer.h" @@ -53,4 +53,4 @@ class MsgClientBackend } // namespace mw } // namespace score -#endif // MW_LOG_DETAILS_DATA_ROUTER_MESSAGE_CLIENT_BACKEND_H_ +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_BACKEND_H diff --git a/score/mw/log/detail/data_router/data_router_message_client_factory.h b/score/mw/log/detail/data_router/data_router_message_client_factory.h index ef50cbd..bb96f32 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_factory.h +++ b/score/mw/log/detail/data_router/data_router_message_client_factory.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_H -#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_H +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_H #include "score/mw/log/detail/data_router/data_router_message_client.h" #include "score/mw/log/detail/data_router/shared_memory/writer_factory.h" @@ -52,4 +52,4 @@ class DatarouterMessageClientFactory } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_H +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_H diff --git a/score/mw/log/detail/data_router/data_router_message_client_factory_impl.h b/score/mw/log/detail/data_router/data_router_message_client_factory_impl.h index ce21f46..9d14bb7 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_factory_impl.h +++ b/score/mw/log/detail/data_router/data_router_message_client_factory_impl.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_IMPL_H -#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_IMPL_H +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_IMPL_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_IMPL_H #include "score/mw/log/configuration/configuration.h" #include "score/mw/log/detail/data_router/data_router_message_client_factory.h" @@ -52,4 +52,4 @@ class DatarouterMessageClientFactoryImpl : public DatarouterMessageClientFactory } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_H +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_IMPL_H diff --git a/score/mw/log/detail/data_router/data_router_message_client_factory_mock.h b/score/mw/log/detail/data_router/data_router_message_client_factory_mock.h index f8ce610..cf2fa3f 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_factory_mock.h +++ b/score/mw/log/detail/data_router/data_router_message_client_factory_mock.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_MOCK_H -#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_MOCK_H +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_MOCK_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_MOCK_H #include "score/mw/log/detail/data_router/data_router_message_client_factory.h" @@ -41,4 +41,4 @@ class DatarouterMessageClientFactoryMock : public DatarouterMessageClientFactory } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_H +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_FACTORY_MOCK_H diff --git a/score/mw/log/detail/data_router/data_router_message_client_factory_test.cpp b/score/mw/log/detail/data_router/data_router_message_client_factory_test.cpp index bcc634c..fc7564e 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_factory_test.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_factory_test.cpp @@ -35,12 +35,7 @@ namespace detail namespace { -using ::testing::_; -using ::testing::ByMove; -using ::testing::Eq; -using ::testing::Matcher; using ::testing::Return; -using ::testing::ReturnRef; using ::testing::StrEq; const auto kMwsrFileName = ""; @@ -53,7 +48,7 @@ class DatarouterMessageClientFactoryFixture : public ::testing::Test public: void SetUp() override { - auto memory_resource = score::cpp::pmr::get_default_resource(); + auto* memory_resource = score::cpp::pmr::get_default_resource(); auto unistd_mock = score::cpp::pmr::make_unique>(memory_resource); auto pthread_mock = score::cpp::pmr::make_unique>(memory_resource); auto signal_mock = score::cpp::pmr::make_unique>(memory_resource); @@ -64,7 +59,7 @@ class DatarouterMessageClientFactoryFixture : public ::testing::Test auto message_passing_factory = std::make_unique>(); message_passing_factory_ = message_passing_factory.get(); factory_ = std::make_unique( - config, + config_, std::move(message_passing_factory), MsgClientUtils{std::move(unistd_mock), std::move(pthread_mock), std::move(signal_mock)}); } @@ -101,7 +96,7 @@ class DatarouterMessageClientFactoryFixture : public ::testing::Test std::unique_ptr client_; testing::StrictMock* message_passing_factory_; std::unique_ptr factory_; - const score::mw::log::detail::Configuration config{}; + const score::mw::log::detail::Configuration config_{}; }; TEST_F(DatarouterMessageClientFactoryFixture, CreateOnceShouldReturnClientWithExpectedValues) @@ -113,12 +108,12 @@ TEST_F(DatarouterMessageClientFactoryFixture, CreateOnceShouldReturnClientWithEx auto client = CreateClientWithFactory(); - auto client_impl = dynamic_cast(client.get()); + auto* client_impl = dynamic_cast(client.get()); // Using the getters check that the factory provided the expected values to the constructor. EXPECT_EQ(client_impl->GetReceiverIdentifier(), kClientReceiverIdentifier); - EXPECT_EQ(client_impl->GetAppid(), LoggingIdentifier{config.GetAppId()}); + EXPECT_EQ(client_impl->GetAppid(), LoggingIdentifier{config_.GetAppId()}); EXPECT_EQ(client_impl->GetThisProcessPid(), kThisProcessPid); EXPECT_EQ(client_impl->GetWriterFileName(), kMwsrFileName); } diff --git a/score/mw/log/detail/data_router/data_router_message_client_identifiers.h b/score/mw/log/detail/data_router/data_router_message_client_identifiers.h index c416af5..16c4d9c 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_identifiers.h +++ b/score/mw/log/detail/data_router/data_router_message_client_identifiers.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef MW_LOG_DETAILS_DATA_ROUTER_MESSAGE_CLIENT_IDENTIFIERS_H_ -#define MW_LOG_DETAILS_DATA_ROUTER_MESSAGE_CLIENT_IDENTIFIERS_H_ +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_IDENTIFIERS_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_IDENTIFIERS_H #include "score/mw/log/detail/logging_identifier.h" #include @@ -55,4 +55,4 @@ class MsgClientIdentifiers } // namespace mw } // namespace score -#endif // MW_LOG_DETAILS_DATA_ROUTER_MESSAGE_CLIENT_IDENTIFIERS_H_ +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_IDENTIFIERS_H diff --git a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp index 9692312..7b6f7f3 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp @@ -33,8 +33,6 @@ namespace log namespace detail { -using std::chrono_literals::operator"" ms; - DatarouterMessageClientImpl::DatarouterMessageClientImpl(const MsgClientIdentifiers& ids, MsgClientBackend backend, MsgClientUtils utils, @@ -312,12 +310,12 @@ void DatarouterMessageClientImpl::Shutdown() noexcept score::cpp::expected_blank DatarouterMessageClientImpl::CreateSender() noexcept { - const score::message_passing::ServiceProtocolConfig& protocol_config{ + const score::message_passing::ServiceProtocolConfig protocol_config{ MessagePassingConfig::kDatarouterReceiverIdentifier, MessagePassingConfig::kMaxMessageSize, MessagePassingConfig::kMaxReplySize, MessagePassingConfig::kMaxNotifySize}; - const score::message_passing::IClientFactory::ClientConfig& client_config{0, 10, false, true, false}; + const score::message_passing::IClientFactory::ClientConfig client_config{0, 10, false, true, false}; sender_ = message_passing_factory_->CreateClient(protocol_config, client_config); if (sender_ == nullptr) diff --git a/score/mw/log/detail/data_router/data_router_message_client_impl.h b/score/mw/log/detail/data_router/data_router_message_client_impl.h index 6d8ba66..5109ed2 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_impl.h +++ b/score/mw/log/detail/data_router/data_router_message_client_impl.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_IMPL_H -#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_IMPL_H +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_IMPL_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_IMPL_H #include "score/expected.hpp" #include "score/jthread.hpp" @@ -145,4 +145,4 @@ class DatarouterMessageClientImpl : public DatarouterMessageClient } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_H +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_IMPL_H diff --git a/score/mw/log/detail/data_router/data_router_message_client_mock.h b/score/mw/log/detail/data_router/data_router_message_client_mock.h index 97c9b59..565693c 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_mock.h +++ b/score/mw/log/detail/data_router/data_router_message_client_mock.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_MOCK_H -#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_MOCK_H +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_MOCK_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_MOCK_H #include "score/mw/log/detail/data_router/data_router_message_client.h" @@ -39,4 +39,4 @@ class DatarouterMessageClientMock : public DatarouterMessageClient } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_MOCK_H +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_MOCK_H diff --git a/score/mw/log/detail/data_router/data_router_message_client_test.cpp b/score/mw/log/detail/data_router/data_router_message_client_test.cpp index 250830e..ecf335c 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_test.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_test.cpp @@ -38,12 +38,9 @@ namespace { using ::testing::_; -using ::testing::An; using ::testing::ByMove; -using ::testing::Eq; using ::testing::Matcher; using ::testing::Return; -using ::testing::ReturnRef; using ::testing::StrEq; MATCHER_P(CompareServiceProtocol, expected, "") @@ -84,10 +81,10 @@ const auto kMwsrFileName = "/tmp" + kClientReceiverIdentifier + ".shmem"; const auto kAppid = LoggingIdentifier{"TeAp"}; const uid_t kUid = 1234; const auto kDynamicDataRouterIdentifiers = true; -const pid_t kThisProcessPid = 99u; +const pid_t kThisProcessPid = 99U; constexpr pthread_t kThreadId = 42; constexpr auto kLoggerThreadName = "logger"; -constexpr uid_t datarouter_dummy_uid = 111; +constexpr uid_t kDatarouterDummyUid = 111; constexpr std::uint32_t kMaxSendBytes{17U}; constexpr std::uint32_t kMaxNumberMessagesInReceiverQueue{0UL}; @@ -96,15 +93,15 @@ class DatarouterMessageClientFixture : public ::testing::Test public: DatarouterMessageClientFixture() = default; - DatarouterMessageClientFixture(const bool dynamicDataRouterIdentifiers) - : dynamicDataRouterIdentifiers_(dynamicDataRouterIdentifiers) + DatarouterMessageClientFixture(const bool dynamic_data_router_identifiers) + : dynamic_data_router_identifiers_(dynamic_data_router_identifiers) { } - DatarouterMessageClientFixture(const std::string mwsrFileName) : mwsrFileName_(mwsrFileName) {} + DatarouterMessageClientFixture(const std::string mwsr_file_name) : mwsr_file_name_(mwsr_file_name) {} void SetUp() override { - auto memory_resource = score::cpp::pmr::get_default_resource(); + auto* memory_resource = score::cpp::pmr::get_default_resource(); auto unistd_mock = score::cpp::pmr::make_unique>(memory_resource); unistd_mock_ = unistd_mock.get(); auto pthread_mock = score::cpp::pmr::make_unique>(memory_resource); @@ -116,11 +113,11 @@ class DatarouterMessageClientFixture : public ::testing::Test client_ = std::make_unique( MsgClientIdentifiers( - kClientReceiverIdentifier, kThisProcessPid, kAppid, static_cast(datarouter_dummy_uid), kUid), + kClientReceiverIdentifier, kThisProcessPid, kAppid, static_cast(kDatarouterDummyUid), kUid), MsgClientBackend(shared_memory_writer_, - mwsrFileName_, + mwsr_file_name_, std::move(message_passing_factory), - dynamicDataRouterIdentifiers_), + dynamic_data_router_identifiers_), MsgClientUtils{std::move(unistd_mock), std::move(pthread_mock), std::move(signal_mock)}, stop_source_); } @@ -157,7 +154,7 @@ class DatarouterMessageClientFixture : public ::testing::Test { auto receiver = score::cpp::pmr::make_unique>( score::cpp::pmr::get_default_resource()); - auto receiver_ptr = receiver.get(); + auto* receiver_ptr = receiver.get(); const score::message_passing::ServiceProtocolConfig service_protocol_config{ kClientReceiverIdentifier, kMaxSendBytes, 0U, 0U}; @@ -214,11 +211,11 @@ class DatarouterMessageClientFixture : public ::testing::Test sender_mock_in_transit_ = score::cpp::pmr::make_unique>( score::cpp::pmr::get_default_resource()); - auto sender_mock = sender_mock_in_transit_.get(); + auto* sender_mock = sender_mock_in_transit_.get(); const score::message_passing::ServiceProtocolConfig service_protocol_config{ kDatarouterReceiverIdentifier, kMaxSendBytes, 0U, 0U}; - const score::message_passing::IClientFactory::ClientConfig& client_config{0, 10, false, true, false}; + const score::message_passing::IClientFactory::ClientConfig client_config{0, 10, false, true, false}; EXPECT_CALL(*message_passing_factory_, CreateClient(CompareServiceProtocol(service_protocol_config), CompareClientConfig(client_config))) @@ -271,7 +268,7 @@ class DatarouterMessageClientFixture : public ::testing::Test void ExpectUnlinkMwsrWriterFile(bool unlink_successful = true) { - EXPECT_CALL(*unistd_mock_, unlink(StrEq(mwsrFileName_))) + EXPECT_CALL(*unistd_mock_, unlink(StrEq(mwsr_file_name_))) .WillOnce([unlink_successful](const char*) -> score::cpp::expected_blank { if (unlink_successful) { @@ -334,18 +331,18 @@ class DatarouterMessageClientFixture : public ::testing::Test score::message_passing::DisconnectCallback* disconnect_callback = nullptr, score::message_passing::MessageCallback* sent_callback = nullptr, score::message_passing::MessageCallback* sent_with_reply_callback = nullptr, - bool blockTerminationSignalPass = true, + bool block_termination_signal_pass = true, bool receiver_start_listening = true) { - std::ignore = blockTerminationSignalPass; // TODO: remove this param - auto receiver = ExpectReceiverCreated(); + std::ignore = block_termination_signal_pass; // TODO: remove this param + auto* receiver = ExpectReceiverCreated(); if (receiver_ptr != nullptr) { *receiver_ptr = receiver; } - if (blockTerminationSignalPass) + if (block_termination_signal_pass) { ExpectBlockTerminationSignalPass(); } @@ -356,7 +353,7 @@ class DatarouterMessageClientFixture : public ::testing::Test ExpectSetLoggerThreadName(); - auto sender = ExpectSenderCreation(state_callback, callback_registered); + auto* sender = ExpectSenderCreation(state_callback, callback_registered); if (sender_ptr != nullptr) { *sender_ptr = sender; @@ -378,16 +375,16 @@ class DatarouterMessageClientFixture : public ::testing::Test .WillOnce([this](score::cpp::span msg) -> score::cpp::expected_blank { EXPECT_EQ(msg.front(), score::cpp::to_underlying(DatarouterMessageIdentifier::kConnect)); std::array random_part; - if (dynamicDataRouterIdentifiers_ && !mwsrFileName_.empty()) + if (dynamic_data_router_identifiers_ && !mwsr_file_name_.empty()) { - memcpy(random_part.data(), &mwsrFileName_.data()[13], random_part.size()); + memcpy(random_part.data(), &mwsr_file_name_[13], random_part.size()); } else { random_part = {}; } - ConnectMessageFromClient expected_msg(kAppid, kUid, dynamicDataRouterIdentifiers_, random_part); + ConnectMessageFromClient expected_msg(kAppid, kUid, dynamic_data_router_identifiers_, random_part); ConnectMessageFromClient received_msg; const auto payload = msg.subspan(1); memcpy(&received_msg, payload.data(), sizeof(ConnectMessageFromClient)); @@ -420,8 +417,8 @@ class DatarouterMessageClientFixture : public ::testing::Test } bool unlink_done_{false}; - bool dynamicDataRouterIdentifiers_{kDynamicDataRouterIdentifiers}; - std::string mwsrFileName_{kMwsrFileName}; + bool dynamic_data_router_identifiers_{kDynamicDataRouterIdentifiers}; + std::string mwsr_file_name_{kMwsrFileName}; score::cpp::pmr::unique_ptr> sender_mock_in_transit_; @@ -462,7 +459,7 @@ TEST_F(DatarouterMessageClientFixture, CreateSenderShouldCreateSenderWithExpecte RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); testing::InSequence order_matters; - auto sender = ExpectSenderCreation(); + auto* sender = ExpectSenderCreation(); ExpectClientDestruction(sender); client_->CreateSender(); } @@ -529,7 +526,7 @@ TEST_F(DatarouterMessageClientFixture, SendConnectMessageShouldSendExpectedPaylo score::message_passing::IClientConnection::StateCallback state_callback; testing::InSequence order_matters; - auto sender = ExpectSenderCreation(&state_callback); + auto* sender = ExpectSenderCreation(&state_callback); ExpectSendConnectMessage(sender); ExpectClientDestruction(sender); @@ -549,7 +546,7 @@ TEST_F(DynamicDataRouterIdentifiersFalseFixture, score::message_passing::IClientConnection::StateCallback state_callback; testing::InSequence order_matters; - auto sender = ExpectSenderCreation(&state_callback); + auto* sender = ExpectSenderCreation(&state_callback); ExpectSendConnectMessage(sender); ExpectClientDestruction(sender); @@ -568,7 +565,7 @@ TEST_F(MwsrFileNameEmptyFixture, SendConnectMessageMwsrFileNameEmptyShouldSendEx score::message_passing::IClientConnection::StateCallback state_callback; testing::InSequence order_matters; - auto sender = ExpectSenderCreation(&state_callback); + auto* sender = ExpectSenderCreation(&state_callback); ExpectSendConnectMessage(sender); ExpectClientDestruction(sender); diff --git a/score/mw/log/detail/data_router/data_router_message_client_utils.cpp b/score/mw/log/detail/data_router/data_router_message_client_utils.cpp index 78241a8..c56ec3f 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_utils.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_utils.cpp @@ -31,17 +31,17 @@ MsgClientUtils::MsgClientUtils(score::cpp::pmr::unique_ptr un score::os::Unistd& MsgClientUtils::GetUnistd() const noexcept { - return *unistd_.get(); + return *unistd_; } score::os::Pthread& MsgClientUtils::GetPthread() const noexcept { - return *pthread_.get(); + return *pthread_; } score::os::Signal& MsgClientUtils::GetSignal() const noexcept { - return *signal_.get(); + return *signal_; } } // namespace detail diff --git a/score/mw/log/detail/data_router/data_router_message_client_utils.h b/score/mw/log/detail/data_router/data_router_message_client_utils.h index d58cc1c..e12624b 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_utils.h +++ b/score/mw/log/detail/data_router/data_router_message_client_utils.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef MW_LOG_DETAILS_DATA_ROUTER_MESSAGE_CLIENT_UTILS_H_ -#define MW_LOG_DETAILS_DATA_ROUTER_MESSAGE_CLIENT_UTILS_H_ +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_UTILS_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_UTILS_H #include "score/os/pthread.h" #include "score/os/unistd.h" @@ -51,4 +51,4 @@ class MsgClientUtils } // namespace mw } // namespace score -#endif // MW_LOG_DETAILS_DATA_ROUTER_MESSAGE_CLIENT_UTILS_H_ +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGE_CLIENT_UTILS_H diff --git a/score/mw/log/detail/data_router/data_router_messages.h b/score/mw/log/detail/data_router/data_router_messages.h index 19fe9c0..d36b733 100644 --- a/score/mw/log/detail/data_router/data_router_messages.h +++ b/score/mw/log/detail/data_router/data_router_messages.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGES_H -#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGES_H +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGES_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGES_H #include "score/mw/log/detail/logging_identifier.h" @@ -106,4 +106,4 @@ class ConnectMessageFromClient } // namespace log } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGES_H +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_MESSAGES_H diff --git a/score/mw/log/detail/data_router/data_router_messages_test.cpp b/score/mw/log/detail/data_router/data_router_messages_test.cpp index 81bfe13..d6c6827 100644 --- a/score/mw/log/detail/data_router/data_router_messages_test.cpp +++ b/score/mw/log/detail/data_router/data_router_messages_test.cpp @@ -33,8 +33,8 @@ const uid_t kUid = 1234; const uid_t kUid2 = 4321; const bool kDynamicDatarouterIdentifiersFalse = false; const bool kDynamicDatarouterIdentifiersTrue = true; -std::array random_part1{"x"}; -std::array random_part2{"y"}; +std::array gRandomPart1{"x"}; +std::array gRandomPart2{"y"}; TEST(DataRouterMessagesTests, EqualOperatorShouldReturnTrueForEqualConnectMessageFromClientInstances) { @@ -45,8 +45,8 @@ TEST(DataRouterMessagesTests, EqualOperatorShouldReturnTrueForEqualConnectMessag RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - ConnectMessageFromClient lhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, random_part1}; - ConnectMessageFromClient rhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, random_part1}; + ConnectMessageFromClient lhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, gRandomPart1}; + ConnectMessageFromClient rhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, gRandomPart1}; EXPECT_EQ(lhs, rhs); } @@ -57,8 +57,8 @@ TEST(DataRouterMessagesTests, EqualOperatorShouldReturnFalseForDifferentAppids) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - ConnectMessageFromClient lhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, random_part1}; - ConnectMessageFromClient rhs{kAppid2, kUid, kDynamicDatarouterIdentifiersFalse, random_part1}; + ConnectMessageFromClient lhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, gRandomPart1}; + ConnectMessageFromClient rhs{kAppid2, kUid, kDynamicDatarouterIdentifiersFalse, gRandomPart1}; EXPECT_NE(lhs, rhs); } @@ -69,8 +69,8 @@ TEST(DataRouterMessagesTests, EqualOperatorShouldReturnFalseForDifferentUids) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - ConnectMessageFromClient lhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, random_part1}; - ConnectMessageFromClient rhs{kAppid, kUid2, kDynamicDatarouterIdentifiersFalse, random_part1}; + ConnectMessageFromClient lhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, gRandomPart1}; + ConnectMessageFromClient rhs{kAppid, kUid2, kDynamicDatarouterIdentifiersFalse, gRandomPart1}; EXPECT_NE(lhs, rhs); } @@ -82,8 +82,8 @@ TEST(DataRouterMessagesTests, EqualOperatorShouldReturnFalseForDifferentDynamicD RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - ConnectMessageFromClient lhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, random_part1}; - ConnectMessageFromClient rhs{kAppid, kUid, kDynamicDatarouterIdentifiersTrue, random_part1}; + ConnectMessageFromClient lhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, gRandomPart1}; + ConnectMessageFromClient rhs{kAppid, kUid, kDynamicDatarouterIdentifiersTrue, gRandomPart1}; EXPECT_NE(lhs, rhs); } @@ -94,8 +94,8 @@ TEST(DataRouterMessagesTests, EqualOperatorShouldReturnFalseForDifferentRandomPa RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - ConnectMessageFromClient lhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, random_part1}; - ConnectMessageFromClient rhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, random_part2}; + ConnectMessageFromClient lhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, gRandomPart1}; + ConnectMessageFromClient rhs{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, gRandomPart2}; EXPECT_NE(lhs, rhs); } @@ -106,7 +106,7 @@ TEST(DataRouterMessagesTests, GetGUIShouldReturnCorrectValue) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - ConnectMessageFromClient message{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, random_part1}; + ConnectMessageFromClient message{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, gRandomPart1}; EXPECT_EQ(message.GetUid(), kUid); @@ -123,7 +123,7 @@ TEST(DataRouterMessagesTests, GetUseDynamicIdentifierShouldReturnCorrectValue) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - ConnectMessageFromClient message{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, random_part1}; + ConnectMessageFromClient message{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, gRandomPart1}; EXPECT_EQ(message.GetUseDynamicIdentifier(), kDynamicDatarouterIdentifiersFalse); @@ -139,7 +139,7 @@ TEST(DataRouterMessagesTests, GetAppIdDynamicIdentifierShouldReturnCorrectValue) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - ConnectMessageFromClient message{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, random_part1}; + ConnectMessageFromClient message{kAppid, kUid, kDynamicDatarouterIdentifiersFalse, gRandomPart1}; EXPECT_EQ(message.GetAppId(), kAppid); 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 adb47b7..0ba1aab 100644 --- a/score/mw/log/detail/data_router/data_router_recorder.cpp +++ b/score/mw/log/detail/data_router/data_router_recorder.cpp @@ -33,24 +33,24 @@ namespace constexpr auto kStatisticsReportInterval = std::chrono::seconds{5}; -void CleanLogRecord(LogRecord& logRecord) noexcept +void CleanLogRecord(LogRecord& log_record) noexcept { - auto& log_entry = logRecord.getLogEntry(); + auto& log_entry = log_record.getLogEntry(); log_entry.num_of_args = 0U; log_entry.payload.clear(); } -void SetContext(LogRecord& logRecord, const std::string_view context_id) noexcept +void SetContext(LogRecord& log_record, const std::string_view context_id) noexcept { - auto& log_entry = logRecord.getLogEntry(); + auto& log_entry = log_record.getLogEntry(); log_entry.ctx_id = LoggingIdentifier{context_id}; } -void SetLogLevel(LogRecord& logRecord, const LogLevel level) noexcept +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."); - logRecord.getLogEntry().log_level = level; + log_record.getLogEntry().log_level = level; } } // namespace @@ -77,11 +77,11 @@ score::cpp::optional DataRouterRecorder::StartRecord(const std::stri if (slot.has_value()) { - auto&& logRecord = backend_->GetLogRecord(*slot); - CleanLogRecord(logRecord); - SetApplicationId(logRecord); - SetContext(logRecord, context_id); - SetLogLevel(logRecord, log_level); + auto&& log_record = backend_->GetLogRecord(*slot); + CleanLogRecord(log_record); + SetApplicationId(log_record); + SetContext(log_record, context_id); + SetLogLevel(log_record, log_level); } else { @@ -99,10 +99,10 @@ void DataRouterRecorder::StopRecord(const SlotHandle& slot) noexcept template void DataRouterRecorder::LogData(const SlotHandle& slot, const T data) noexcept { - auto& logRecord = backend_->GetLogRecord(slot); - DltArgumentCounter counter{logRecord.getLogEntry().num_of_args}; - std::ignore = counter.TryAddArgument([data, &logRecord, this]() noexcept { - const auto result = DLTFormat::Log(logRecord.getVerbosePayload(), data); + auto& log_record = backend_->GetLogRecord(slot); + 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) { this->statistics_reporter_.IncrementMessageTooLong(); @@ -221,9 +221,9 @@ void DataRouterRecorder::Log(const SlotHandle& slot, const LogSlog2Message data) LogData(slot, data.GetMessage()); } -void DataRouterRecorder::SetApplicationId(LogRecord& logRecord) noexcept +void DataRouterRecorder::SetApplicationId(LogRecord& log_record) noexcept { - auto& log_entry = logRecord.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.h b/score/mw/log/detail/data_router/data_router_recorder.h index d8724ed..b6f7326 100644 --- a/score/mw/log/detail/data_router/data_router_recorder.h +++ b/score/mw/log/detail/data_router/data_router_recorder.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_RECORDER_H -#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_RECORDER_H +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_RECORDER_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_RECORDER_H #include "score/mw/log/recorder.h" @@ -95,4 +95,4 @@ class DataRouterRecorder final : public Recorder } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_RECORDER_H +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_DATA_ROUTER_RECORDER_H 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 f11e9cd..f549ecb 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 @@ -134,7 +134,7 @@ class DataRouterRecorderFixture : public ::testing::Test EXPECT_CALL(*backend_, FlushSlot(slot_)); ON_CALL(*backend_, GetLogRecord(slot_)).WillByDefault(ReturnRef(log_record_)); recorder_ = std::make_unique(std::move(backend_), config_); - recorder_->StartRecord(context_id_, logLevel); + recorder_->StartRecord(context_id_, log_level_); } void TearDown() override @@ -144,7 +144,7 @@ class DataRouterRecorderFixture : public ::testing::Test const auto log_entry_app_id = log_entry.app_id.GetStringView(); EXPECT_EQ(config_app_id, log_entry_app_id); EXPECT_EQ(log_entry.ctx_id.GetStringView(), context_id_); - EXPECT_EQ(log_entry.log_level, logLevel); + EXPECT_EQ(log_entry.log_level, log_level_); EXPECT_EQ(log_entry.num_of_args, expected_number_of_arguments_at_teardown_); recorder_->StopRecord(slot_); } @@ -155,7 +155,7 @@ class DataRouterRecorderFixture : public ::testing::Test std::unique_ptr recorder_; SlotHandle slot_{}; LogRecord log_record_{}; - LogLevel logLevel = kActiveLogLevel; + LogLevel log_level_ = kActiveLogLevel; const std::string_view context_id_ = "DFLT"; std::uint8_t expected_number_of_arguments_at_teardown_{1}; }; @@ -167,9 +167,9 @@ TEST_F(DataRouterRecorderFixture, TooManyArgumentsWillYieldTruncatedLog) RecordProperty("Description", "Verifies that too many arguments shall lead to a truncated log."); RecordProperty("TestType", "Interface test"); - constexpr std::size_t type_info_byte_size_according_to_specification = 4; + constexpr std::size_t kTypeInfoByteSizeAccordingToSpecification = 4; const std::size_t number_of_arguments = log_record_.getLogEntry().payload.capacity() / - (type_info_byte_size_according_to_specification + sizeof(std::uint32_t)); + (kTypeInfoByteSizeAccordingToSpecification + sizeof(std::uint32_t)); for (std::size_t i = 0; i < number_of_arguments + 5; ++i) { recorder_->Log(SlotHandle{}, std::uint32_t{}); @@ -434,14 +434,14 @@ TEST(DataRouterRecorderTests, DatarouterRecorderShouldClearSlotOnStart) auto recorder = std::make_unique(std::move(backend), config); // Simulate the case that a slot already contains data from a previous message. - constexpr auto context = "ctx0"; - recorder->StartRecord(context, kActiveLogLevel); + constexpr auto kContext = "ctx0"; + recorder->StartRecord(kContext, kActiveLogLevel); const auto payload = std::string_view{"Hello world"}; recorder->Log(SlotHandle{}, payload); recorder->StopRecord(SlotHandle{}); // Expect that the previous data is cleared. - recorder->StartRecord(context, kActiveLogLevel); + recorder->StartRecord(kContext, kActiveLogLevel); EXPECT_EQ(log_record.getVerbosePayload().GetSpan().size(), 0); EXPECT_EQ(log_record.getLogEntry().num_of_args, 0); } diff --git a/score/mw/log/detail/data_router/message_passing_factory.h b/score/mw/log/detail/data_router/message_passing_factory.h index c14a4aa..c1a8f8f 100644 --- a/score/mw/log/detail/data_router/message_passing_factory.h +++ b/score/mw/log/detail/data_router/message_passing_factory.h @@ -57,4 +57,4 @@ class MessagePassingFactory } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_H +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_PASSING_FACTORY_H diff --git a/score/mw/log/detail/data_router/message_passing_factory_impl.h b/score/mw/log/detail/data_router/message_passing_factory_impl.h index 4b0142b..4b899e0 100644 --- a/score/mw/log/detail/data_router/message_passing_factory_impl.h +++ b/score/mw/log/detail/data_router/message_passing_factory_impl.h @@ -56,4 +56,4 @@ class MessagePassingFactoryImpl : public MessagePassingFactory } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_H +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_PASSING_FACTORY_IMPL_H diff --git a/score/mw/log/detail/data_router/message_passing_factory_mock.h b/score/mw/log/detail/data_router/message_passing_factory_mock.h index 748bf13..4dfa0d2 100644 --- a/score/mw/log/detail/data_router/message_passing_factory_mock.h +++ b/score/mw/log/detail/data_router/message_passing_factory_mock.h @@ -48,4 +48,4 @@ class MessagePassingFactoryMock : public MessagePassingFactory } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_CLIENT_H +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_MESSAGE_PASSING_FACTORY_MOCK_H diff --git a/score/mw/log/detail/data_router/message_passing_factory_test.cpp b/score/mw/log/detail/data_router/message_passing_factory_test.cpp index ae4daa8..fc1d720 100644 --- a/score/mw/log/detail/data_router/message_passing_factory_test.cpp +++ b/score/mw/log/detail/data_router/message_passing_factory_test.cpp @@ -55,8 +55,8 @@ TEST(MessagePassingFactoryTests, CreateSenderShouldReturnValue) MessagePassingFactoryImpl factory{}; - const score::message_passing::ServiceProtocolConfig& protocol_config{kIdentifier, 9U, 0U, 0U}; - const score::message_passing::IClientFactory::ClientConfig& client_config{0, 0, false, false, false}; + const score::message_passing::ServiceProtocolConfig protocol_config{kIdentifier, 9U, 0U, 0U}; + const score::message_passing::IClientFactory::ClientConfig client_config{0, 0, false, false, false}; auto sender = factory.CreateClient(protocol_config, client_config); EXPECT_NE(sender, nullptr); diff --git a/score/mw/log/detail/data_router/remote_dlt_recorder_factory.h b/score/mw/log/detail/data_router/remote_dlt_recorder_factory.h index f680a11..086966d 100644 --- a/score/mw/log/detail/data_router/remote_dlt_recorder_factory.h +++ b/score/mw/log/detail/data_router/remote_dlt_recorder_factory.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_REMOTE_DLT_RECORDER_FACTORY_H -#define SCORE_MW_LOG_DETAIL_REMOTE_DLT_RECORDER_FACTORY_H +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_REMOTE_DLT_RECORDER_FACTORY_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_REMOTE_DLT_RECORDER_FACTORY_H #include "score/mw/log/configuration/configuration.h" #include "score/mw/log/detail/log_recorder_factory.hpp" @@ -33,4 +33,4 @@ class RemoteDltRecorderFactory : public LogRecorderFactory bool IsRecorderOfType(const std::unique_ptr& recorder) noexcept { diff --git a/score/mw/log/detail/data_router/shared_memory/common.cpp b/score/mw/log/detail/data_router/shared_memory/common.cpp index 2cc9da0..009993d 100644 --- a/score/mw/log/detail/data_router/shared_memory/common.cpp +++ b/score/mw/log/detail/data_router/shared_memory/common.cpp @@ -34,7 +34,7 @@ std::uint32_t GetExpectedNextAcquiredBlockId(const ReadAcquireResult& acquired) // it wraps around to zero due to the well-defined unsigned integer overflow behavior. // This behavior is intentional and designed to ensure seamless buffer ID cycling. // coverity[autosar_cpp14_a4_7_1_violation] - return acquired.acquired_buffer + 1u; + return acquired.acquired_buffer + 1U; } } // namespace detail diff --git a/score/mw/log/detail/data_router/shared_memory/common.h b/score/mw/log/detail/data_router/shared_memory/common.h index 0bccd2d..31e5b92 100644 --- a/score/mw/log/detail/data_router/shared_memory/common.h +++ b/score/mw/log/detail/data_router/shared_memory/common.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef BMW_MW_LOG_SHARED_MEMORY_COMMON -#define BMW_MW_LOG_SHARED_MEMORY_COMMON +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_COMMON_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_COMMON_H #include "score/os/utils/high_resolution_steady_clock.h" #include "score/mw/log/detail/wait_free_producer_queue/alternating_control_block.h" @@ -100,4 +100,4 @@ constexpr TypeIdentifier GetRegisterTypeToken() } // namespace mw } // namespace score -#endif // BMW_MW_LOG_SHARED_MEMORY_COMMON +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_COMMON_H diff --git a/score/mw/log/detail/data_router/shared_memory/i_shared_memory_reader.h b/score/mw/log/detail/data_router/shared_memory/i_shared_memory_reader.h index 39fe5a7..c0386a4 100644 --- a/score/mw/log/detail/data_router/shared_memory/i_shared_memory_reader.h +++ b/score/mw/log/detail/data_router/shared_memory/i_shared_memory_reader.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef BMW_MW_LOG_WAIT_FREE_I_SHARED_MEMORY_READER -#define BMW_MW_LOG_WAIT_FREE_I_SHARED_MEMORY_READER +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_I_SHARED_MEMORY_READER_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_I_SHARED_MEMORY_READER_H #include "score/mw/log/detail/data_router/shared_memory/common.h" #include "score/mw/log/detail/wait_free_producer_queue/alternating_reader.h" @@ -88,4 +88,4 @@ class ISharedMemoryReader } // namespace mw } // namespace score -#endif // BMW_MW_LOG_WAIT_FREE_I_SHARED_MEMORY_READER +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_I_SHARED_MEMORY_READER_H diff --git a/score/mw/log/detail/data_router/shared_memory/reader_factory.h b/score/mw/log/detail/data_router/shared_memory/reader_factory.h index 107dd58..d678430 100644 --- a/score/mw/log/detail/data_router/shared_memory/reader_factory.h +++ b/score/mw/log/detail/data_router/shared_memory/reader_factory.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef BMW_MW_LOG_SHARED_MEMORY_READER_FACTORY -#define BMW_MW_LOG_SHARED_MEMORY_READER_FACTORY +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_READER_FACTORY_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_READER_FACTORY_H #include "score/mw/log/detail/data_router/shared_memory/shared_memory_reader.h" @@ -54,4 +54,4 @@ class ReaderFactory } // namespace mw } // namespace score -#endif // BMW_MW_LOG_SHARED_MEMORY_READER_FACTORY +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_READER_FACTORY_H diff --git a/score/mw/log/detail/data_router/shared_memory/reader_factory_impl.cpp b/score/mw/log/detail/data_router/shared_memory/reader_factory_impl.cpp index 4cb16b9..95dd689 100644 --- a/score/mw/log/detail/data_router/shared_memory/reader_factory_impl.cpp +++ b/score/mw/log/detail/data_router/shared_memory/reader_factory_impl.cpp @@ -32,7 +32,7 @@ ReaderFactoryImpl::ReaderFactoryImpl(score::cpp::pmr::unique_ptr::difference_type>(offset)); return start_address; } @@ -65,9 +65,9 @@ std::unique_ptr ReaderFactoryImpl::Create(const std::int32_ return nullptr; } - static constexpr void* null_addr = nullptr; + static constexpr void* kNullAddr = nullptr; static constexpr std::int64_t kMmapOffset = 0; - auto mmap_result = mman_->mmap(null_addr, + auto mmap_result = mman_->mmap(kNullAddr, map_size_bytes, score::os::Mman::Protection::kRead, score::os::Mman::Map::kShared, @@ -126,9 +126,9 @@ std::unique_ptr ReaderFactoryImpl::Create(const std::int32_ - casted as Byte to access memory mapped by mmap function. */ // coverity[autosar_cpp14_m5_2_8_violation] - const auto shared_data_addr = static_cast(mmap_result.value()); - const auto buffer1_addr = GetBufferAddress(shared_data_addr, shared_data.linear_buffer_1_offset); - const auto buffer2_addr = GetBufferAddress(shared_data_addr, shared_data.linear_buffer_2_offset); + auto* const shared_data_addr = static_cast(mmap_result.value()); + auto* const buffer1_addr = GetBufferAddress(shared_data_addr, shared_data.linear_buffer_1_offset); + auto* const buffer2_addr = GetBufferAddress(shared_data_addr, shared_data.linear_buffer_2_offset); const score::cpp::span buffer_block_even(buffer1_addr, shared_data.control_block.control_block_even.data.size()); const score::cpp::span buffer_block_odd(buffer2_addr, shared_data.control_block.control_block_odd.data.size()); diff --git a/score/mw/log/detail/data_router/shared_memory/reader_factory_impl.h b/score/mw/log/detail/data_router/shared_memory/reader_factory_impl.h index bcc6c47..f1520a8 100644 --- a/score/mw/log/detail/data_router/shared_memory/reader_factory_impl.h +++ b/score/mw/log/detail/data_router/shared_memory/reader_factory_impl.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef BMW_MW_LOG_SHARED_MEMORY_READER_FACTORY_IMPL -#define BMW_MW_LOG_SHARED_MEMORY_READER_FACTORY_IMPL +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_READER_FACTORY_IMPL_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_READER_FACTORY_IMPL_H #include "score/mw/log/detail/data_router/shared_memory/reader_factory.h" @@ -49,4 +49,4 @@ class ReaderFactoryImpl : public ReaderFactory } // namespace mw } // namespace score -#endif // BMW_MW_LOG_SHARED_MEMORY_READER_FACTORY_IMPL +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_READER_FACTORY_IMPL_H diff --git a/score/mw/log/detail/data_router/shared_memory/reader_factory_test.cpp b/score/mw/log/detail/data_router/shared_memory/reader_factory_test.cpp index 9924707..a3ea050 100644 --- a/score/mw/log/detail/data_router/shared_memory/reader_factory_test.cpp +++ b/score/mw/log/detail/data_router/shared_memory/reader_factory_test.cpp @@ -38,35 +38,35 @@ using ::testing::Return; // Testing: // score::cpp::optional ReaderFactory::Create(const std::int32_t file_handle, const pid_t expected_pid) -static constexpr auto kDefaultRingSize = 1024UL; -static constexpr auto kLinearBufferSize = 1024UL / 2UL; -static constexpr auto kSharedSize = kDefaultRingSize + sizeof(SharedData); -static constexpr int kFileHandle{15}; -static constexpr pid_t kExpectedPid{0x137}; -static constexpr auto kMmapOffset = 0; +constexpr auto kDefaultRingSize = 1024UL; +constexpr auto kLinearBufferSize = 1024UL / 2UL; +constexpr auto kSharedSize = kDefaultRingSize + sizeof(SharedData); +constexpr int kFileHandle{15}; +constexpr pid_t kExpectedPid{0x137}; +constexpr auto kMmapOffset = 0; class ReaderFactoryFixture : public ::testing::Test { public: - ReaderFactoryFixture() : shared_data_(*(::new(&buffer_) SharedData)) + ReaderFactoryFixture() : shared_data(*(::new(&buffer) SharedData)) { - shared_data_.linear_buffer_1_offset = sizeof(SharedData); - shared_data_.linear_buffer_2_offset = sizeof(SharedData) + kLinearBufferSize; - shared_data_.producer_pid = kExpectedPid; + shared_data.linear_buffer_1_offset = sizeof(SharedData); + shared_data.linear_buffer_2_offset = sizeof(SharedData) + kLinearBufferSize; + shared_data.producer_pid = kExpectedPid; } ~ReaderFactoryFixture() { - reinterpret_cast(&buffer_)->~SharedData(); + reinterpret_cast(&buffer)->~SharedData(); } - score::cpp::pmr::memory_resource* memory_resource_ = score::cpp::pmr::get_default_resource(); - score::cpp::pmr::unique_ptr mman_mock_pmr = score::cpp::pmr::make_unique(memory_resource_); - score::cpp::pmr::unique_ptr stat_mock_pmr = score::cpp::pmr::make_unique(memory_resource_); - score::os::MmanMock* mman_mock_ = mman_mock_pmr.get(); - score::os::StatMock* stat_mock_ = stat_mock_pmr.get(); - std::aligned_storage_t buffer_; - SharedData& shared_data_; - ReaderFactoryImpl factory_{std::move(mman_mock_pmr), std::move(stat_mock_pmr)}; + score::cpp::pmr::memory_resource* memory_resource = score::cpp::pmr::get_default_resource(); + score::cpp::pmr::unique_ptr mman_mock_pmr = score::cpp::pmr::make_unique(memory_resource); + score::cpp::pmr::unique_ptr stat_mock_pmr = score::cpp::pmr::make_unique(memory_resource); + score::os::MmanMock* mman_mock = mman_mock_pmr.get(); + score::os::StatMock* stat_mock = stat_mock_pmr.get(); + std::aligned_storage_t buffer; + SharedData& shared_data; + ReaderFactoryImpl factory{std::move(mman_mock_pmr), std::move(stat_mock_pmr)}; }; TEST_F(ReaderFactoryFixture, FailingCallToFstatShallResultInEmptyOptional) @@ -76,13 +76,13 @@ TEST_F(ReaderFactoryFixture, FailingCallToFstatShallResultInEmptyOptional) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - EXPECT_CALL(*stat_mock_, fstat(kFileHandle, _)) + EXPECT_CALL(*stat_mock, fstat(kFileHandle, _)) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EINVAL)))); // We expect mmap not to be called irregardless of arguments - EXPECT_CALL(*mman_mock_, mmap(_, _, _, _, _, _)).Times(0); + EXPECT_CALL(*mman_mock, mmap(_, _, _, _, _, _)).Times(0); - auto result = factory_.Create(kFileHandle, kExpectedPid); + auto result = factory.Create(kFileHandle, kExpectedPid); EXPECT_EQ(result, nullptr); } @@ -93,7 +93,7 @@ TEST_F(ReaderFactoryFixture, FstatInvalidReturnShallResultInEmptyOptional) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - EXPECT_CALL(*stat_mock_, fstat(kFileHandle, _)) + EXPECT_CALL(*stat_mock, fstat(kFileHandle, _)) .WillOnce( ::testing::Invoke([](const auto& /*handle*/, auto& stat_buffer) -> score::cpp::expected_blank { stat_buffer.st_size = -1L; @@ -101,9 +101,9 @@ TEST_F(ReaderFactoryFixture, FstatInvalidReturnShallResultInEmptyOptional) })); // We expect mmap not to be called irregardless of arguments - EXPECT_CALL(*mman_mock_, mmap(_, _, _, _, _, _)).Times(0); + EXPECT_CALL(*mman_mock, mmap(_, _, _, _, _, _)).Times(0); - auto result = factory_.Create(kFileHandle, kExpectedPid); + auto result = factory.Create(kFileHandle, kExpectedPid); EXPECT_FALSE(result); } @@ -115,7 +115,7 @@ TEST_F(ReaderFactoryFixture, FstatReturningSizeTooSmallShallResultInEmptyOptiona RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - EXPECT_CALL(*stat_mock_, fstat(kFileHandle, _)) + EXPECT_CALL(*stat_mock, fstat(kFileHandle, _)) .WillOnce( ::testing::Invoke([](const auto& /*handle*/, auto& stat_buffer) -> score::cpp::expected_blank { static_assert(sizeof(SharedData) > 0UL, "SharedData cannot be zero-sized type"); @@ -124,9 +124,9 @@ TEST_F(ReaderFactoryFixture, FstatReturningSizeTooSmallShallResultInEmptyOptiona })); // We expect mmap not to be called irregardless of arguments - EXPECT_CALL(*mman_mock_, mmap(_, _, _, _, _, _)).Times(0); + EXPECT_CALL(*mman_mock, mmap(_, _, _, _, _, _)).Times(0); - auto result = factory_.Create(kFileHandle, kExpectedPid); + auto result = factory.Create(kFileHandle, kExpectedPid); EXPECT_EQ(result, nullptr); } @@ -137,14 +137,14 @@ TEST_F(ReaderFactoryFixture, MmapFailingShallResultInEmptyOptional) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - EXPECT_CALL(*stat_mock_, fstat(kFileHandle, _)) + EXPECT_CALL(*stat_mock, fstat(kFileHandle, _)) .WillOnce( ::testing::Invoke([](const auto& /*handle*/, auto& stat_buffer) -> score::cpp::expected_blank { stat_buffer.st_size = kSharedSize; return score::cpp::expected_blank{}; })); - EXPECT_CALL(*mman_mock_, + EXPECT_CALL(*mman_mock, mmap(nullptr, kSharedSize, score::os::Mman::Protection::kRead, @@ -153,7 +153,7 @@ TEST_F(ReaderFactoryFixture, MmapFailingShallResultInEmptyOptional) kMmapOffset)) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EINVAL)))); - auto result = factory_.Create(kFileHandle, kExpectedPid); + auto result = factory.Create(kFileHandle, kExpectedPid); EXPECT_EQ(result, nullptr); } @@ -166,27 +166,27 @@ TEST_F(ReaderFactoryFixture, SharedDataMemberPointingOutOfBoundsShallResultInEmp RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - EXPECT_CALL(*stat_mock_, fstat(kFileHandle, _)) + EXPECT_CALL(*stat_mock, fstat(kFileHandle, _)) .WillOnce( ::testing::Invoke([](const auto& /*handle*/, auto& stat_buffer) -> score::cpp::expected_blank { stat_buffer.st_size = kSharedSize; return score::cpp::expected_blank{}; })); - EXPECT_CALL(*mman_mock_, + EXPECT_CALL(*mman_mock, mmap(nullptr, kSharedSize, score::os::Mman::Protection::kRead, score::os::Mman::Map::kShared, kFileHandle, kMmapOffset)) - .WillOnce(Return(score::cpp::expected{&buffer_})); + .WillOnce(Return(score::cpp::expected{&buffer})); - shared_data_.linear_buffer_1_offset = kSharedSize + 1UL; + shared_data.linear_buffer_1_offset = kSharedSize + 1UL; - EXPECT_CALL(*mman_mock_, munmap(_, kSharedSize)).WillOnce(Return(score::cpp::expected_blank{})); + EXPECT_CALL(*mman_mock, munmap(_, kSharedSize)).WillOnce(Return(score::cpp::expected_blank{})); - auto result = factory_.Create(kFileHandle, kExpectedPid); + auto result = factory.Create(kFileHandle, kExpectedPid); EXPECT_EQ(result, nullptr); } @@ -197,27 +197,27 @@ TEST_F(ReaderFactoryFixture, UnexpectedPidShallResultInEmptyOptional) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - EXPECT_CALL(*stat_mock_, fstat(kFileHandle, _)) + EXPECT_CALL(*stat_mock, fstat(kFileHandle, _)) .WillOnce( ::testing::Invoke([](const auto& /*handle*/, auto& stat_buffer) -> score::cpp::expected_blank { stat_buffer.st_size = kSharedSize; return score::cpp::expected_blank{}; })); - EXPECT_CALL(*mman_mock_, + EXPECT_CALL(*mman_mock, mmap(nullptr, kSharedSize, score::os::Mman::Protection::kRead, score::os::Mman::Map::kShared, kFileHandle, kMmapOffset)) - .WillOnce(Return(score::cpp::expected{&buffer_})); + .WillOnce(Return(score::cpp::expected{&buffer})); - shared_data_.producer_pid = 0x1; + shared_data.producer_pid = 0x1; - EXPECT_CALL(*mman_mock_, munmap(_, kSharedSize)).WillOnce(Return(score::cpp::expected_blank{})); + EXPECT_CALL(*mman_mock, munmap(_, kSharedSize)).WillOnce(Return(score::cpp::expected_blank{})); - auto result = factory_.Create(kFileHandle, kExpectedPid); + auto result = factory.Create(kFileHandle, kExpectedPid); EXPECT_EQ(result, nullptr); } @@ -228,29 +228,29 @@ TEST_F(ReaderFactoryFixture, ProperSetupShallResultValidReader) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - EXPECT_CALL(*stat_mock_, fstat(kFileHandle, _)) + EXPECT_CALL(*stat_mock, fstat(kFileHandle, _)) .WillOnce( ::testing::Invoke([](const auto& /*handle*/, auto& stat_buffer) -> score::cpp::expected_blank { stat_buffer.st_size = kSharedSize; return score::cpp::expected_blank{}; })); - EXPECT_CALL(*mman_mock_, + EXPECT_CALL(*mman_mock, mmap(nullptr, kSharedSize, score::os::Mman::Protection::kRead, score::os::Mman::Map::kShared, kFileHandle, kMmapOffset)) - .WillOnce(Return(score::cpp::expected{&buffer_})); + .WillOnce(Return(score::cpp::expected{&buffer})); // Memory shall not be unmapped until Reader is destructed - EXPECT_CALL(*mman_mock_, munmap(_, kSharedSize)).Times(0); + EXPECT_CALL(*mman_mock, munmap(_, kSharedSize)).Times(0); - auto result = factory_.Create(kFileHandle, kExpectedPid); + auto result = factory.Create(kFileHandle, kExpectedPid); EXPECT_NE(result, nullptr); - EXPECT_CALL(*mman_mock_, munmap(_, kSharedSize)).WillOnce(Return(score::cpp::expected_blank{})); + EXPECT_CALL(*mman_mock, munmap(_, kSharedSize)).WillOnce(Return(score::cpp::expected_blank{})); } TEST_F(ReaderFactoryFixture, UnmapFailureShallResultValidReader) @@ -260,26 +260,26 @@ TEST_F(ReaderFactoryFixture, UnmapFailureShallResultValidReader) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - EXPECT_CALL(*stat_mock_, fstat(kFileHandle, _)) + EXPECT_CALL(*stat_mock, fstat(kFileHandle, _)) .WillOnce( ::testing::Invoke([](const auto& /*handle*/, auto& stat_buffer) -> score::cpp::expected_blank { stat_buffer.st_size = kSharedSize; return score::cpp::expected_blank{}; })); - EXPECT_CALL(*mman_mock_, + EXPECT_CALL(*mman_mock, mmap(nullptr, kSharedSize, score::os::Mman::Protection::kRead, score::os::Mman::Map::kShared, kFileHandle, kMmapOffset)) - .WillOnce(Return(score::cpp::expected{&buffer_})); + .WillOnce(Return(score::cpp::expected{&buffer})); - auto result = factory_.Create(kFileHandle, kExpectedPid); + auto result = factory.Create(kFileHandle, kExpectedPid); EXPECT_NE(result, nullptr); - EXPECT_CALL(*mman_mock_, munmap(_, kSharedSize)) + EXPECT_CALL(*mman_mock, munmap(_, kSharedSize)) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EINVAL)))); } diff --git a/score/mw/log/detail/data_router/shared_memory/shared_memory_reader.cpp b/score/mw/log/detail/data_router/shared_memory/shared_memory_reader.cpp index bb7bc67..97a9892 100644 --- a/score/mw/log/detail/data_router/shared_memory/shared_memory_reader.cpp +++ b/score/mw/log/detail/data_router/shared_memory/shared_memory_reader.cpp @@ -87,8 +87,8 @@ Length ReadLinearBuffer(LinearReader& reader, continue; } static_assert(std::is_trivially_copyable_v == true); - const auto kTypeIdSize = sizeof(type_registration.type_id); - const auto type_id_source = payload_span.subspan(0, kTypeIdSize); + const auto k_type_id_size = sizeof(type_registration.type_id); + const auto type_id_source = payload_span.subspan(0, k_type_id_size); auto type_id_destination = /* Deviation from Rule M5-2-8: @@ -99,7 +99,7 @@ Length ReadLinearBuffer(LinearReader& reader, payload_span into object type_registration.type_id. */ // coverity[autosar_cpp14_m5_2_8_violation] - score::cpp::span{static_cast(static_cast(&type_registration.type_id)), kTypeIdSize}; + score::cpp::span{static_cast(static_cast(&type_registration.type_id)), k_type_id_size}; std::ignore = std::copy(type_id_source.cbegin(), type_id_source.cend(), type_id_destination.begin()); // type_id is integer uint16_t and thus is within range of values @@ -271,7 +271,7 @@ std::optional SharedMemoryReader::PeekNumberOfBytesAcquiredInBuffer( const std::uint32_t acquired_buffer_count_id) const noexcept { auto block_id = SelectLinearControlBlockId(acquired_buffer_count_id); - auto& block = SelectLinearControlBlockReference(block_id, shared_data_.control_block); + const auto& block = SelectLinearControlBlockReference(block_id, shared_data_.control_block); return block.acquired_index.load(); } diff --git a/score/mw/log/detail/data_router/shared_memory/shared_memory_reader.h b/score/mw/log/detail/data_router/shared_memory/shared_memory_reader.h index 6282a2e..81142df 100644 --- a/score/mw/log/detail/data_router/shared_memory/shared_memory_reader.h +++ b/score/mw/log/detail/data_router/shared_memory/shared_memory_reader.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef BMW_MW_LOG_SHARED_MEMORY_READER -#define BMW_MW_LOG_SHARED_MEMORY_READER +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_SHARED_MEMORY_READER_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_SHARED_MEMORY_READER_H #include "score/mw/log/detail/data_router/shared_memory/i_shared_memory_reader.h" #include "score/mw/log/detail/wait_free_producer_queue/alternating_reader.h" @@ -98,4 +98,4 @@ class SharedMemoryReader : public ISharedMemoryReader } // namespace mw } // namespace score -#endif // BMW_MW_LOG_SHARED_MEMORY_READER +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_SHARED_MEMORY_READER_H diff --git a/score/mw/log/detail/data_router/shared_memory/shared_memory_reader_test.cpp b/score/mw/log/detail/data_router/shared_memory/shared_memory_reader_test.cpp index 5e3f35a..99ff9ef 100644 --- a/score/mw/log/detail/data_router/shared_memory/shared_memory_reader_test.cpp +++ b/score/mw/log/detail/data_router/shared_memory/shared_memory_reader_test.cpp @@ -33,37 +33,37 @@ namespace using ::testing::_; using ::testing::MockFunction; -static constexpr auto kRingSize = 4UL * 1024UL; -static constexpr std::array test_data_sample{"test data"}; +constexpr auto kRingSize = 4UL * 1024UL; +constexpr std::array kTestDataSample{"test data"}; class SharedMemoryReaderFixture : public ::testing::Test { public: SharedMemoryReaderFixture() - : shared_data_{}, - shared_memory_reader_( - shared_data_, - AlternatingReadOnlyReader{shared_data_.control_block, - score::cpp::span(&stack_based_shared_memory[0][0], kRingSize / 2UL), - score::cpp::span(&stack_based_shared_memory[1][0], kRingSize / 2UL)}, + : shared_data{}, + shared_memory_reader( + shared_data, + AlternatingReadOnlyReader{shared_data.control_block, + score::cpp::span(stack_based_shared_memory[0].data(), kRingSize / 2UL), + score::cpp::span(stack_based_shared_memory[1].data(), kRingSize / 2UL)}, UnmapCallback{}), - shared_memory_writer_(InitializeSharedData(shared_data_), UnmapCallback{}) + shared_memory_writer(InitializeSharedData(shared_data), UnmapCallback{}) { stack_based_shared_memory[0].fill(0x00); stack_based_shared_memory[1].fill(0x00); - shared_data_.linear_buffer_1_offset = sizeof(SharedData); - shared_data_.linear_buffer_2_offset = sizeof(SharedData) + kRingSize / 2UL; + shared_data.linear_buffer_1_offset = sizeof(SharedData); + shared_data.linear_buffer_2_offset = sizeof(SharedData) + kRingSize / 2UL; - shared_data_.control_block.control_block_even.data = - score::cpp::span(&stack_based_shared_memory[0][0], kRingSize / 2UL); - shared_data_.control_block.control_block_odd.data = - score::cpp::span(&stack_based_shared_memory[1][0], kRingSize / 2UL); + shared_data.control_block.control_block_even.data = + score::cpp::span(stack_based_shared_memory[0].data(), kRingSize / 2UL); + shared_data.control_block.control_block_odd.data = + score::cpp::span(stack_based_shared_memory[1].data(), kRingSize / 2UL); } - SharedData shared_data_; - SharedMemoryReader shared_memory_reader_; - SharedMemoryWriter shared_memory_writer_; + SharedData shared_data; + SharedMemoryReader shared_memory_reader; + SharedMemoryWriter shared_memory_writer; std::array stack_based_shared_memory[2]; }; @@ -72,15 +72,15 @@ class TypeInfoTest public: void Copy(const score::cpp::span data) const { - std::memcpy(data.data(), type.data(), type.size()); + std::memcpy(data.data(), type_.data(), type_.size()); } std::size_t size() const { - return sizeof(type); + return sizeof(type_); } private: - const std::array type{"test::int"}; + const std::array type_{"test::int"}; }; TEST_F(SharedMemoryReaderFixture, GetterShallReadSharedDataNumberOfDropsInvalidSize) @@ -92,9 +92,9 @@ TEST_F(SharedMemoryReaderFixture, GetterShallReadSharedDataNumberOfDropsInvalidS RecordProperty("DerivationTechnique", "Analysis of requirements"); static constexpr Length kNumberOfDrops{13UL}; - shared_data_.number_of_drops_invalid_size.store(kNumberOfDrops); + shared_data.number_of_drops_invalid_size.store(kNumberOfDrops); - EXPECT_EQ(kNumberOfDrops, shared_memory_reader_.GetNumberOfDropsWithInvalidSize()); + EXPECT_EQ(kNumberOfDrops, shared_memory_reader.GetNumberOfDropsWithInvalidSize()); } TEST_F(SharedMemoryReaderFixture, GetterShallReadSharedDataNumberOfDropsBufferFull) @@ -106,9 +106,9 @@ TEST_F(SharedMemoryReaderFixture, GetterShallReadSharedDataNumberOfDropsBufferFu RecordProperty("DerivationTechnique", "Analysis of requirements"); static constexpr Length kNumberOfDrops{17UL}; - shared_data_.number_of_drops_buffer_full.store(kNumberOfDrops); + shared_data.number_of_drops_buffer_full.store(kNumberOfDrops); - EXPECT_EQ(kNumberOfDrops, shared_memory_reader_.GetNumberOfDropsWithBufferFull()); + EXPECT_EQ(kNumberOfDrops, shared_memory_reader.GetNumberOfDropsWithBufferFull()); } TEST_F(SharedMemoryReaderFixture, GetterShallReadSharedDataSizeOfDropsBufferFull) @@ -120,9 +120,9 @@ TEST_F(SharedMemoryReaderFixture, GetterShallReadSharedDataSizeOfDropsBufferFull RecordProperty("DerivationTechnique", "Analysis of requirements"); static constexpr Length kSizeOfDrops{2048UL}; - shared_data_.size_of_drops_buffer_full.store(kSizeOfDrops); + shared_data.size_of_drops_buffer_full.store(kSizeOfDrops); - EXPECT_EQ(kSizeOfDrops, shared_memory_reader_.GetSizeOfDropsWithBufferFull()); + EXPECT_EQ(kSizeOfDrops, shared_memory_reader.GetSizeOfDropsWithBufferFull()); } TEST_F(SharedMemoryReaderFixture, RingBufferSizeShallReturnValueBasedOnControlBlock) @@ -133,7 +133,7 @@ TEST_F(SharedMemoryReaderFixture, RingBufferSizeShallReturnValueBasedOnControlBl RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - EXPECT_EQ(kRingSize, shared_memory_reader_.GetRingBufferSizeBytes()); + EXPECT_EQ(kRingSize, shared_memory_reader.GetRingBufferSizeBytes()); } TEST_F(SharedMemoryReaderFixture, UnmapCallbackShallBeCalledWhenDestructing) @@ -151,11 +151,11 @@ TEST_F(SharedMemoryReaderFixture, UnmapCallbackShallBeCalledWhenDestructing) check.Call(); }; - SharedMemoryReader shared_memory_reader( - shared_data_, - AlternatingReadOnlyReader{shared_data_.control_block, - score::cpp::span(&stack_based_shared_memory[0][0], kRingSize / 2UL), - score::cpp::span(&stack_based_shared_memory[1][0], kRingSize / 2UL)}, + SharedMemoryReader reader( + shared_data, + AlternatingReadOnlyReader{shared_data.control_block, + score::cpp::span(stack_based_shared_memory[0].data(), kRingSize / 2UL), + score::cpp::span(stack_based_shared_memory[1].data(), kRingSize / 2UL)}, std::move(callback)); EXPECT_CALL(check, Call()).Times(1); @@ -176,16 +176,16 @@ TEST_F(SharedMemoryReaderFixture, UnmapCallbackShallNotBeCalledWhenMoving) check.Call(); }; - SharedMemoryReader shared_memory_reader( - shared_data_, - AlternatingReadOnlyReader{shared_data_.control_block, - score::cpp::span(&stack_based_shared_memory[0][0], kRingSize / 2UL), - score::cpp::span(&stack_based_shared_memory[1][0], kRingSize / 2UL)}, + SharedMemoryReader reader( + shared_data, + AlternatingReadOnlyReader{shared_data.control_block, + score::cpp::span(stack_based_shared_memory[0].data(), kRingSize / 2UL), + score::cpp::span(stack_based_shared_memory[1].data(), kRingSize / 2UL)}, std::move(callback)); EXPECT_CALL(check, Call()).Times(0); - SharedMemoryReader shared_memory_reader_created_by_move(std::move(shared_memory_reader)); + SharedMemoryReader shared_memory_reader_created_by_move(std::move(reader)); EXPECT_CALL(check, Call()).Times(1); } @@ -199,18 +199,18 @@ TEST_F(SharedMemoryReaderFixture, ReaderNotNotifiedShallNotPerformReads) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const auto type_id = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto type_id = shared_memory_writer.TryRegisterType(TypeInfoTest{}); EXPECT_TRUE(type_id.has_value()); - shared_memory_writer_.AllocAndWrite( + shared_memory_writer.AllocAndWrite( [](auto span) noexcept { - EXPECT_EQ(span.size(), test_data_sample.size()); - std::memcpy(span.data(), test_data_sample.data(), test_data_sample.size()); + EXPECT_EQ(span.size(), kTestDataSample.size()); + std::memcpy(span.data(), kTestDataSample.data(), kTestDataSample.size()); }, type_id.value(), - test_data_sample.size()); + kTestDataSample.size()); - const auto read_acquire_result = shared_memory_writer_.ReadAcquire(); + const auto read_acquire_result = shared_memory_writer.ReadAcquire(); // Skip notification: std::ignore = read_acquire_result; @@ -224,7 +224,7 @@ TEST_F(SharedMemoryReaderFixture, ReaderNotNotifiedShallNotPerformReads) }; // Read without first notifying reader about data acquisiton - shared_memory_reader_.Read(on_new_type, on_new_record); + shared_memory_reader.Read(on_new_type, on_new_record); } TEST_F(SharedMemoryReaderFixture, ReadDetached) @@ -236,28 +236,28 @@ TEST_F(SharedMemoryReaderFixture, ReadDetached) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const auto type_id = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto type_id = shared_memory_writer.TryRegisterType(TypeInfoTest{}); EXPECT_TRUE(type_id.has_value()); - shared_memory_writer_.AllocAndWrite( + shared_memory_writer.AllocAndWrite( [](auto span) noexcept { - EXPECT_EQ(span.size(), test_data_sample.size()); - std::memcpy(span.data(), test_data_sample.data(), test_data_sample.size()); + EXPECT_EQ(span.size(), kTestDataSample.size()); + std::memcpy(span.data(), kTestDataSample.data(), kTestDataSample.size()); }, type_id.value(), - test_data_sample.size()); + kTestDataSample.size()); - shared_memory_writer_.ReadAcquire(); + shared_memory_writer.ReadAcquire(); auto on_new_type = [&](const score::mw::log::detail::TypeRegistration&) noexcept {}; auto on_new_record = [&](const score::mw::log::detail::SharedMemoryRecord&) noexcept {}; // prepare reader to be able to read data before writer detached - shared_memory_reader_.NotifyAcquisitionSetReader(ReadAcquireResult{0}); + shared_memory_reader.NotifyAcquisitionSetReader(ReadAcquireResult{0}); // detach writer and read - shared_data_.writer_detached = true; - EXPECT_TRUE(shared_memory_reader_.Read(on_new_type, on_new_record).has_value()); + shared_data.writer_detached = true; + EXPECT_TRUE(shared_memory_reader.Read(on_new_type, on_new_record).has_value()); } TEST_F(SharedMemoryReaderFixture, ReaderNotifiedShallReturnNulloptWhenNotReleasedByWriters) @@ -269,24 +269,24 @@ TEST_F(SharedMemoryReaderFixture, ReaderNotifiedShallReturnNulloptWhenNotRelease RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const auto type_id = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto type_id = shared_memory_writer.TryRegisterType(TypeInfoTest{}); EXPECT_TRUE(type_id.has_value()); ReadAcquireResult read_acquire_result{}; - shared_memory_writer_.AllocAndWrite( + shared_memory_writer.AllocAndWrite( [this, &read_acquire_result](auto span) noexcept { - EXPECT_EQ(span.size(), test_data_sample.size()); + EXPECT_EQ(span.size(), kTestDataSample.size()); - read_acquire_result = shared_memory_writer_.ReadAcquire(); + read_acquire_result = shared_memory_writer.ReadAcquire(); // Because we are inside the buffer access callback, buffer is not released, thus it is expected that a try // to acquire the buffer is not successful: - EXPECT_EQ(shared_memory_reader_.NotifyAcquisitionSetReader(read_acquire_result), std::nullopt); + EXPECT_EQ(shared_memory_reader.NotifyAcquisitionSetReader(read_acquire_result), std::nullopt); }, type_id.value(), - test_data_sample.size()); + kTestDataSample.size()); // Now that all writers released buffer, expect notification to have a value: - auto result_length = shared_memory_reader_.NotifyAcquisitionSetReader(read_acquire_result); + auto result_length = shared_memory_reader.NotifyAcquisitionSetReader(read_acquire_result); EXPECT_TRUE(result_length.has_value()); } @@ -300,44 +300,44 @@ TEST_F(SharedMemoryReaderFixture, ReaderNotifiedShallAcquireData) auto on_new_type_discard = [&](const score::mw::log::detail::TypeRegistration&) noexcept {}; auto on_new_record_discard = [&](const score::mw::log::detail::SharedMemoryRecord&) noexcept {}; - EXPECT_FALSE(shared_memory_reader_.Read(on_new_type_discard, on_new_record_discard).has_value()); + EXPECT_FALSE(shared_memory_reader.Read(on_new_type_discard, on_new_record_discard).has_value()); - const auto type_id = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto type_id = shared_memory_writer.TryRegisterType(TypeInfoTest{}); - EXPECT_FALSE(shared_memory_reader_.Read(on_new_type_discard, on_new_record_discard).has_value()); + EXPECT_FALSE(shared_memory_reader.Read(on_new_type_discard, on_new_record_discard).has_value()); - shared_memory_writer_.AllocAndWrite( + shared_memory_writer.AllocAndWrite( [](auto span) noexcept { - EXPECT_EQ(span.size(), test_data_sample.size()); - std::memcpy(span.data(), test_data_sample.data(), test_data_sample.size()); + EXPECT_EQ(span.size(), kTestDataSample.size()); + std::memcpy(span.data(), kTestDataSample.data(), kTestDataSample.size()); }, type_id.value(), - test_data_sample.size()); + kTestDataSample.size()); - EXPECT_FALSE(shared_memory_reader_.Read(on_new_type_discard, on_new_record_discard).has_value()); + EXPECT_FALSE(shared_memory_reader.Read(on_new_type_discard, on_new_record_discard).has_value()); // trigger the buffer switch: - const auto read_acquire_result = shared_memory_writer_.ReadAcquire(); + const auto read_acquire_result = shared_memory_writer.ReadAcquire(); // Expect acquired buffer to have non-zero acquired bytes: const auto reading_buffer_peek_result = - shared_memory_reader_.PeekNumberOfBytesAcquiredInBuffer(read_acquire_result.acquired_buffer); + shared_memory_reader.PeekNumberOfBytesAcquiredInBuffer(read_acquire_result.acquired_buffer); EXPECT_TRUE(reading_buffer_peek_result.has_value()); EXPECT_GT(reading_buffer_peek_result.value(), 0UL); // Expect next buffer to have zero acquired bytes: const auto writing_buffer_peek_result = - shared_memory_reader_.PeekNumberOfBytesAcquiredInBuffer(read_acquire_result.acquired_buffer + 1); + shared_memory_reader.PeekNumberOfBytesAcquiredInBuffer(read_acquire_result.acquired_buffer + 1); EXPECT_TRUE(writing_buffer_peek_result.has_value()); EXPECT_EQ(writing_buffer_peek_result.value(), 0UL); // Wait on a block to be released by writers: - while (not shared_memory_reader_.IsBlockReleasedByWriters(read_acquire_result.acquired_buffer)) + while (not shared_memory_reader.IsBlockReleasedByWriters(read_acquire_result.acquired_buffer)) { } - const auto acquired_length = shared_memory_reader_.NotifyAcquisitionSetReader(read_acquire_result); + const auto acquired_length = shared_memory_reader.NotifyAcquisitionSetReader(read_acquire_result); EXPECT_TRUE(acquired_length.has_value()); - EXPECT_GT(acquired_length.value(), test_data_sample.size()); + EXPECT_GT(acquired_length.value(), kTestDataSample.size()); auto on_new_type = [&](const score::mw::log::detail::TypeRegistration& registration) noexcept { EXPECT_EQ(registration.type_id, type_id.value()); @@ -346,12 +346,12 @@ TEST_F(SharedMemoryReaderFixture, ReaderNotifiedShallAcquireData) EXPECT_EQ(record.header.type_identifier, type_id.value()); }; - const auto acquired_result = shared_memory_reader_.Read(on_new_type, on_new_record); + const auto acquired_result = shared_memory_reader.Read(on_new_type, on_new_record); ASSERT_TRUE(acquired_result.has_value()); - EXPECT_LT(test_data_sample.size() + TypeInfoTest{}.size(), acquired_result.value()); + EXPECT_LT(kTestDataSample.size() + TypeInfoTest{}.size(), acquired_result.value()); // Expect that after reader is depleated it should not return any data: - EXPECT_FALSE(shared_memory_reader_.Read(on_new_type_discard, on_new_record_discard).has_value()); + EXPECT_FALSE(shared_memory_reader.Read(on_new_type_discard, on_new_record_discard).has_value()); } TEST_F(SharedMemoryReaderFixture, WriterAcquireShallAllowDataToBeWritten) @@ -362,7 +362,7 @@ TEST_F(SharedMemoryReaderFixture, WriterAcquireShallAllowDataToBeWritten) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const auto type_id = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto type_id = shared_memory_writer.TryRegisterType(TypeInfoTest{}); MockFunction check; UnmapCallback callback = [&check]() noexcept { @@ -370,14 +370,14 @@ TEST_F(SharedMemoryReaderFixture, WriterAcquireShallAllowDataToBeWritten) }; auto write = [&, this]() noexcept { - shared_memory_writer_.AllocAndWrite( + shared_memory_writer.AllocAndWrite( [&](auto span) noexcept { check.Call(); - EXPECT_EQ(span.size(), test_data_sample.size()); - std::memcpy(span.data(), test_data_sample.data(), test_data_sample.size()); + EXPECT_EQ(span.size(), kTestDataSample.size()); + std::memcpy(span.data(), kTestDataSample.data(), kTestDataSample.size()); }, type_id.value(), - test_data_sample.size()); + kTestDataSample.size()); }; EXPECT_CALL(check, Call()).Times(1); @@ -385,13 +385,13 @@ TEST_F(SharedMemoryReaderFixture, WriterAcquireShallAllowDataToBeWritten) write(); // Performs Switch in alternating buffer - const auto read_acquire_result = shared_memory_writer_.ReadAcquire(); + const auto read_acquire_result = shared_memory_writer.ReadAcquire(); EXPECT_CALL(check, Call()).Times(1); write(); - shared_memory_reader_.NotifyAcquisitionSetReader(read_acquire_result); + shared_memory_reader.NotifyAcquisitionSetReader(read_acquire_result); auto on_new_type = [&](const score::mw::log::detail::TypeRegistration& registration) noexcept { EXPECT_EQ(registration.type_id, type_id.value()); @@ -406,16 +406,16 @@ TEST_F(SharedMemoryReaderFixture, WriterAcquireShallAllowDataToBeWritten) EXPECT_CALL(check_record, Call(_)).Times(1); // Read without first notifying reader about data acquisiton - shared_memory_reader_.Read(on_new_type, on_new_record); + shared_memory_reader.Read(on_new_type, on_new_record); // Performs Switch in alternating buffer - const auto read_acquire_second_result = shared_memory_writer_.ReadAcquire(); + const auto read_acquire_second_result = shared_memory_writer.ReadAcquire(); - shared_memory_reader_.NotifyAcquisitionSetReader(read_acquire_second_result); + shared_memory_reader.NotifyAcquisitionSetReader(read_acquire_second_result); EXPECT_CALL(check_record, Call(_)).Times(1); - shared_memory_reader_.Read(on_new_type, on_new_record); + shared_memory_reader.Read(on_new_type, on_new_record); } TEST_F(SharedMemoryReaderFixture, CorruptedHeaderSizeTooSmallShallIgnoreEntry) @@ -426,7 +426,7 @@ TEST_F(SharedMemoryReaderFixture, CorruptedHeaderSizeTooSmallShallIgnoreEntry) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const auto type_id = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto type_id = shared_memory_writer.TryRegisterType(TypeInfoTest{}); MockFunction check; UnmapCallback callback = [&check]() noexcept { @@ -435,7 +435,7 @@ TEST_F(SharedMemoryReaderFixture, CorruptedHeaderSizeTooSmallShallIgnoreEntry) EXPECT_CALL(check, Call()).Times(1); - shared_memory_writer_.AllocAndWrite( + shared_memory_writer.AllocAndWrite( [&](auto span) noexcept { check.Call(); EXPECT_EQ(span.size(), 0UL); @@ -450,9 +450,9 @@ TEST_F(SharedMemoryReaderFixture, CorruptedHeaderSizeTooSmallShallIgnoreEntry) 0UL); // Performs Switch in alternating buffer - const auto read_acquire_result = shared_memory_writer_.ReadAcquire(); + const auto read_acquire_result = shared_memory_writer.ReadAcquire(); - shared_memory_reader_.NotifyAcquisitionSetReader(read_acquire_result); + shared_memory_reader.NotifyAcquisitionSetReader(read_acquire_result); auto on_new_type = [&](const score::mw::log::detail::TypeRegistration& registration) noexcept { EXPECT_EQ(registration.type_id, type_id.value()); @@ -466,7 +466,7 @@ TEST_F(SharedMemoryReaderFixture, CorruptedHeaderSizeTooSmallShallIgnoreEntry) // Do not expect call to broken entry EXPECT_CALL(check_record, Call(_)).Times(0); - shared_memory_reader_.Read(on_new_type, on_new_record); + shared_memory_reader.Read(on_new_type, on_new_record); } TEST_F(SharedMemoryReaderFixture, CorruptedRegistrationHeaderSizeTooSmallShallIgnoreEntry) @@ -482,7 +482,7 @@ TEST_F(SharedMemoryReaderFixture, CorruptedRegistrationHeaderSizeTooSmallShallIg public: void Copy(const score::cpp::span data) const { - std::memcpy(data.data(), type.data(), type.size()); + std::memcpy(data.data(), type_.data(), type_.size()); constexpr auto kHeaderSize = sizeof(BufferEntryHeader); Length overwrite_length_value_hack = kHeaderSize; std::memcpy(data.data() - sizeof(Length) - kHeaderSize - sizeof(TypeIdentifier), @@ -491,14 +491,14 @@ TEST_F(SharedMemoryReaderFixture, CorruptedRegistrationHeaderSizeTooSmallShallIg } std::size_t size() const { - return sizeof(type); + return sizeof(type_); } private: - const std::array type{"test::int"}; + const std::array type_{"test::int"}; }; - const auto type_id = shared_memory_writer_.TryRegisterType(CorruptHeaderTypeInfoTest{}); + const auto type_id = shared_memory_writer.TryRegisterType(CorruptHeaderTypeInfoTest{}); MockFunction check; UnmapCallback callback = [&check]() noexcept { @@ -507,7 +507,7 @@ TEST_F(SharedMemoryReaderFixture, CorruptedRegistrationHeaderSizeTooSmallShallIg EXPECT_CALL(check, Call()).Times(1); - shared_memory_writer_.AllocAndWrite( + shared_memory_writer.AllocAndWrite( [&](auto) noexcept { check.Call(); }, @@ -515,9 +515,9 @@ TEST_F(SharedMemoryReaderFixture, CorruptedRegistrationHeaderSizeTooSmallShallIg 0UL); // Performs Switch in alternating buffer - const auto read_acquire_result = shared_memory_writer_.ReadAcquire(); + const auto read_acquire_result = shared_memory_writer.ReadAcquire(); - shared_memory_reader_.NotifyAcquisitionSetReader(read_acquire_result); + shared_memory_reader.NotifyAcquisitionSetReader(read_acquire_result); auto on_new_type = [&](const score::mw::log::detail::TypeRegistration& registration) noexcept { EXPECT_EQ(registration.type_id, type_id.value()); @@ -531,7 +531,7 @@ TEST_F(SharedMemoryReaderFixture, CorruptedRegistrationHeaderSizeTooSmallShallIg // Do not expect call to broken entry EXPECT_CALL(check_record, Call(_)).Times(0); - shared_memory_reader_.Read(on_new_type, on_new_record); + shared_memory_reader.Read(on_new_type, on_new_record); } TEST_F(SharedMemoryReaderFixture, WriterDetachedShallAllowDataToBeReadWithoutSwitching) @@ -543,7 +543,7 @@ TEST_F(SharedMemoryReaderFixture, WriterDetachedShallAllowDataToBeReadWithoutSwi RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const auto type_id = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto type_id = shared_memory_writer.TryRegisterType(TypeInfoTest{}); MockFunction check; UnmapCallback callback = [&check]() noexcept { @@ -551,14 +551,14 @@ TEST_F(SharedMemoryReaderFixture, WriterDetachedShallAllowDataToBeReadWithoutSwi }; auto write = [&, this]() noexcept { - shared_memory_writer_.AllocAndWrite( + shared_memory_writer.AllocAndWrite( [&](auto span) noexcept { check.Call(); - EXPECT_EQ(span.size(), test_data_sample.size()); - std::memcpy(span.data(), test_data_sample.data(), test_data_sample.size()); + EXPECT_EQ(span.size(), kTestDataSample.size()); + std::memcpy(span.data(), kTestDataSample.data(), kTestDataSample.size()); }, type_id.value(), - test_data_sample.size()); + kTestDataSample.size()); }; EXPECT_CALL(check, Call()).Times(1); @@ -566,13 +566,13 @@ TEST_F(SharedMemoryReaderFixture, WriterDetachedShallAllowDataToBeReadWithoutSwi write(); // Performs Switch in alternating buffer - const auto read_acquire_result = shared_memory_writer_.ReadAcquire(); + const auto read_acquire_result = shared_memory_writer.ReadAcquire(); EXPECT_CALL(check, Call()).Times(1); write(); - shared_memory_reader_.NotifyAcquisitionSetReader(read_acquire_result); + shared_memory_reader.NotifyAcquisitionSetReader(read_acquire_result); auto on_new_type = [&](const score::mw::log::detail::TypeRegistration& registration) noexcept { EXPECT_EQ(registration.type_id, type_id.value()); @@ -587,13 +587,13 @@ TEST_F(SharedMemoryReaderFixture, WriterDetachedShallAllowDataToBeReadWithoutSwi EXPECT_CALL(check_record, Call(_)).Times(2); // Read without first notifying reader about data acquisiton - shared_memory_reader_.Read(on_new_type, on_new_record); + shared_memory_reader.Read(on_new_type, on_new_record); - shared_memory_reader_.ReadDetached(on_new_type, on_new_record); + shared_memory_reader.ReadDetached(on_new_type, on_new_record); // After detaching writer no more calls are expected EXPECT_CALL(check_record, Call(_)).Times(0); - shared_memory_reader_.Read(on_new_type, on_new_record); + shared_memory_reader.Read(on_new_type, on_new_record); } } // namespace } // namespace detail diff --git a/score/mw/log/detail/data_router/shared_memory/shared_memory_writer.h b/score/mw/log/detail/data_router/shared_memory/shared_memory_writer.h index 1cb5e3c..0f46973 100644 --- a/score/mw/log/detail/data_router/shared_memory/shared_memory_writer.h +++ b/score/mw/log/detail/data_router/shared_memory/shared_memory_writer.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef BMW_MW_LOG_SHARED_MEMORY_WRITER -#define BMW_MW_LOG_SHARED_MEMORY_WRITER +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_SHARED_MEMORY_WRITER_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_SHARED_MEMORY_WRITER_H #include "score/mw/log/detail/data_router/shared_memory/common.h" #include "score/mw/log/detail/wait_free_producer_queue/alternating_reader_proxy.h" @@ -54,10 +54,10 @@ class SharedMemoryWriter static constexpr Length GetMaxPayloadSize() { // max size of a dlt-v1 message excluding the header. - constexpr std::uint64_t value = 65500UL; - static_assert(GetMaxAcquireLengthBytes() >= value + sizeof(BufferEntryHeader), + constexpr std::uint64_t kValue = 65500UL; + static_assert(GetMaxAcquireLengthBytes() >= kValue + sizeof(BufferEntryHeader), "must not exceed limits of linear writer"); - return value; + return kValue; } /// \brief Allocates space on buffer and writes data into it. @@ -140,7 +140,7 @@ class SharedMemoryWriter { score::cpp::optional result{}; - constexpr size_type type_identifier_size = sizeof(TypeIdentifier); + constexpr size_type kTypeIdentifierSize = sizeof(TypeIdentifier); const auto type_info_size_pre = info.size(); static_assert(std::is_same::value, "Return type of ::size() method of template parameter has uncompatible type"); @@ -148,7 +148,7 @@ class SharedMemoryWriter // static_cast of a positive value after value has been verified const auto type_info_size = static_cast(type_info_size_pre); // cast to bigger type: - const auto total_size = static_cast(type_identifier_size) + static_cast(type_info_size); + const auto total_size = static_cast(kTypeIdentifierSize) + static_cast(type_info_size); this->AllocAndWrite( TimePoint::clock::now(), @@ -166,10 +166,10 @@ class SharedMemoryWriter // coverity[autosar_cpp14_m5_2_8_violation] const score::cpp::span result_span{static_cast(static_cast(&result)), sizeof(result)}; std::ignore = std::copy_n( - result_span.begin(), static_cast(type_identifier_size), payload_span.begin()); + result_span.begin(), static_cast(kTypeIdentifierSize), payload_span.begin()); // Write type info - const auto type_info_span = payload_span.subspan(type_identifier_size, type_info_size); + const auto type_info_span = payload_span.subspan(kTypeIdentifierSize, type_info_size); info.Copy(type_info_span); }); @@ -207,4 +207,4 @@ class SharedMemoryWriter } // namespace mw } // namespace score -#endif // BMW_MW_LOG_SHARED_MEMORY_WRITER +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_SHARED_MEMORY_WRITER_H diff --git a/score/mw/log/detail/data_router/shared_memory/shared_memory_writer_test.cpp b/score/mw/log/detail/data_router/shared_memory/shared_memory_writer_test.cpp index a5d31c1..0162983 100644 --- a/score/mw/log/detail/data_router/shared_memory/shared_memory_writer_test.cpp +++ b/score/mw/log/detail/data_router/shared_memory/shared_memory_writer_test.cpp @@ -31,45 +31,45 @@ namespace detail namespace { -static constexpr std::array test_data_sample{"test data"}; +constexpr std::array kTestDataSample{"test data"}; -static constexpr auto kNumberOfThreads = 10UL; -static constexpr auto kNumberOfActions = 5UL; -static constexpr auto kNumberOfTests = 50UL; +constexpr auto kNumberOfThreads = 10UL; +constexpr auto kNumberOfActions = 5UL; +constexpr auto kNumberOfTests = 50UL; -static constexpr auto kRingSize = 4UL * 1024UL; +constexpr auto kRingSize = 4UL * 1024UL; class SharedMemoryWriterFixture : public ::testing::Test { public: SharedMemoryWriterFixture() - : shared_data_{}, shared_memory_writer_(InitializeSharedData(shared_data_), UnmapCallback{}) + : shared_data{}, shared_memory_writer(InitializeSharedData(shared_data), UnmapCallback{}) { stack_based_shared_memory[0].fill(0x00); stack_based_shared_memory[1].fill(0x00); - shared_data_.linear_buffer_1_offset = sizeof(SharedData); - shared_data_.linear_buffer_2_offset = sizeof(SharedData) + kRingSize / 2UL; + shared_data.linear_buffer_1_offset = sizeof(SharedData); + shared_data.linear_buffer_2_offset = sizeof(SharedData) + kRingSize / 2UL; - shared_data_.control_block.control_block_even.data = - score::cpp::span(&stack_based_shared_memory[0][0], kRingSize / 2UL); - shared_data_.control_block.control_block_odd.data = - score::cpp::span(&stack_based_shared_memory[1][0], kRingSize / 2UL); + shared_data.control_block.control_block_even.data = + score::cpp::span(stack_based_shared_memory[0].data(), kRingSize / 2UL); + shared_data.control_block.control_block_odd.data = + score::cpp::span(stack_based_shared_memory[1].data(), kRingSize / 2UL); AlternatingReadOnlyReader read_only_reader{ - shared_data_.control_block, - shared_data_.control_block.control_block_even.data, - shared_data_.control_block.control_block_odd.data, + shared_data.control_block, + shared_data.control_block.control_block_even.data, + shared_data.control_block.control_block_odd.data, }; - shared_memory_reader_ = - std::make_unique(shared_data_, std::move(read_only_reader), UnmapCallback{}); + shared_memory_reader = + std::make_unique(shared_data, std::move(read_only_reader), UnmapCallback{}); } - SharedData shared_data_; - std::unique_ptr shared_memory_reader_; + SharedData shared_data; + std::unique_ptr shared_memory_reader; std::array stack_based_shared_memory[2]; - SharedMemoryWriter shared_memory_writer_; + SharedMemoryWriter shared_memory_writer; }; class SharedMemoryWriterOversizedRequestsFixture : public SharedMemoryWriterFixture, @@ -88,15 +88,15 @@ class TypeInfoTest public: void Copy(const score::cpp::span data) const { - std::memcpy(data.data(), type.data(), type.size()); + std::memcpy(data.data(), type_.data(), type_.size()); } std::size_t size() const { - return sizeof(type); + return sizeof(type_); } private: - const std::array type{"test::int"}; + const std::array type_{"test::int"}; }; class TypeInfoTestOversized @@ -105,10 +105,10 @@ class TypeInfoTestOversized void Copy(const score::cpp::span) const {} std::size_t size() const { - constexpr std::size_t type_max = std::numeric_limits::max() + 1UL; - static_assert(type_max > 0 && (std::numeric_limits::max() > type_max), + constexpr std::size_t kTypeMax = std::numeric_limits::max() + 1UL; + static_assert(kTypeMax > 0 && (std::numeric_limits::max() > kTypeMax), "Type requirements not met"); - return type_max; + return kTypeMax; } }; @@ -119,7 +119,7 @@ TEST_F(SharedMemoryWriterFixture, OversizedTypeRegisterShallReturnEmpty) RecordProperty("Description", "If a type info returns an oversized length the type registration shall fail."); RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const auto result = shared_memory_writer_.TryRegisterType(TypeInfoTestOversized{}); + const auto result = shared_memory_writer.TryRegisterType(TypeInfoTestOversized{}); EXPECT_FALSE(result.has_value()); } @@ -131,7 +131,7 @@ TEST_F(SharedMemoryWriterFixture, BasicRegisterShallReturnValue) RecordProperty("Description", "For a valid type the type registration shall succeed."); RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const auto result = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto result = shared_memory_writer.TryRegisterType(TypeInfoTest{}); EXPECT_TRUE(result.has_value()); } @@ -144,8 +144,8 @@ TEST_F(SharedMemoryWriterFixture, RegistrationInSequenceShallYieldUniqueTypes) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const auto result = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); - const auto second_result = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto result = shared_memory_writer.TryRegisterType(TypeInfoTest{}); + const auto second_result = shared_memory_writer.TryRegisterType(TypeInfoTest{}); EXPECT_NE(result, second_result); } @@ -158,12 +158,12 @@ TEST_F(SharedMemoryWriterFixture, ShallHandleOverflowAndNotFail) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const auto first = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto first = shared_memory_writer.TryRegisterType(TypeInfoTest{}); for (auto i = 0UL; i < kRingSize; i++) // much more then it is possible { - const auto result = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto result = shared_memory_writer.TryRegisterType(TypeInfoTest{}); } - const auto result = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto result = shared_memory_writer.TryRegisterType(TypeInfoTest{}); EXPECT_FALSE(result.has_value()); } @@ -175,22 +175,22 @@ TEST_F(SharedMemoryWriterFixture, SingleWriteReadShallBeReadPresentingTheSameVal RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const auto type_id = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto type_id = shared_memory_writer.TryRegisterType(TypeInfoTest{}); Byte* get_buffer_space_address = nullptr; - shared_memory_writer_.AllocAndWrite( + shared_memory_writer.AllocAndWrite( [&get_buffer_space_address](auto span) { - EXPECT_EQ(span.size(), test_data_sample.size()); - std::memcpy(span.data(), test_data_sample.data(), test_data_sample.size()); + EXPECT_EQ(span.size(), kTestDataSample.size()); + std::memcpy(span.data(), kTestDataSample.data(), kTestDataSample.size()); get_buffer_space_address = span.data(); }, type_id.value(), - test_data_sample.size()); + kTestDataSample.size()); - const auto read_acquire_result = shared_memory_writer_.ReadAcquire(); + const auto read_acquire_result = shared_memory_writer.ReadAcquire(); // Datarouter part after acquisition - shared_memory_reader_->NotifyAcquisitionSetReader(read_acquire_result); + shared_memory_reader->NotifyAcquisitionSetReader(read_acquire_result); auto on_new_type = [&](const score::mw::log::detail::TypeRegistration& registration) noexcept { EXPECT_EQ(registration.type_id, type_id.value()); @@ -200,7 +200,7 @@ TEST_F(SharedMemoryWriterFixture, SingleWriteReadShallBeReadPresentingTheSameVal EXPECT_EQ(record.payload.data(), get_buffer_space_address); }; - shared_memory_reader_->Read(on_new_type, on_new_record); + shared_memory_reader->Read(on_new_type, on_new_record); } TEST_P(SharedMemoryWriterOversizedRequestsFixture, WriteWithTooBigRequestShallBeRejected) @@ -211,21 +211,21 @@ TEST_P(SharedMemoryWriterOversizedRequestsFixture, WriteWithTooBigRequestShallBe RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const auto type_id = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto type_id = shared_memory_writer.TryRegisterType(TypeInfoTest{}); const auto oversized = GetParam(); // Expect that there is no data to be written - shared_memory_writer_.AllocAndWrite( + shared_memory_writer.AllocAndWrite( [&](auto) { FAIL(); }, type_id.value(), oversized); - const auto read_acquire_result = shared_memory_writer_.ReadAcquire(); + const auto read_acquire_result = shared_memory_writer.ReadAcquire(); // Datarouter part after acquisition - shared_memory_reader_->NotifyAcquisitionSetReader(read_acquire_result); + shared_memory_reader->NotifyAcquisitionSetReader(read_acquire_result); auto on_new_type = [&](const score::mw::log::detail::TypeRegistration& registration) noexcept { EXPECT_EQ(registration.type_id, type_id.value()); @@ -235,7 +235,7 @@ TEST_P(SharedMemoryWriterOversizedRequestsFixture, WriteWithTooBigRequestShallBe FAIL(); }; - shared_memory_reader_->Read(on_new_type, on_new_record); + shared_memory_reader->Read(on_new_type, on_new_record); } TEST_F(SharedMemoryWriterFixture, MultipleConcurentRegistrationShallBeValidInCount) @@ -255,7 +255,7 @@ TEST_F(SharedMemoryWriterFixture, MultipleConcurentRegistrationShallBeValidInCou threads.at(counter) = std::thread([this]() noexcept { for (auto number = 0UL; number < kNumberOfActions; number++) { - const auto type_id = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto type_id = shared_memory_writer.TryRegisterType(TypeInfoTest{}); } }); } @@ -266,10 +266,10 @@ TEST_F(SharedMemoryWriterFixture, MultipleConcurentRegistrationShallBeValidInCou thread.join(); } - const auto read_acquire_result = shared_memory_writer_.ReadAcquire(); + const auto read_acquire_result = shared_memory_writer.ReadAcquire(); // Datarouter part after acquisition - shared_memory_reader_->NotifyAcquisitionSetReader(read_acquire_result); + shared_memory_reader->NotifyAcquisitionSetReader(read_acquire_result); auto count = 0UL; auto on_new_type = [&count](const score::mw::log::detail::TypeRegistration&) noexcept { @@ -279,7 +279,7 @@ TEST_F(SharedMemoryWriterFixture, MultipleConcurentRegistrationShallBeValidInCou FAIL(); }; - shared_memory_reader_->Read(on_new_type, on_new_record); + shared_memory_reader->Read(on_new_type, on_new_record); EXPECT_EQ(count, kNumberOfThreads * kNumberOfActions); } @@ -296,7 +296,7 @@ TEST_F(SharedMemoryWriterFixture, MultipleConcurrentWritesShallAllBeReceivedVali RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - const auto type_id = shared_memory_writer_.TryRegisterType(TypeInfoTest{}); + const auto type_id = shared_memory_writer.TryRegisterType(TypeInfoTest{}); auto call_write_operations = [this, &type_id]() { // When writing into it from multiple threads @@ -307,13 +307,13 @@ TEST_F(SharedMemoryWriterFixture, MultipleConcurrentWritesShallAllBeReceivedVali threads.at(counter) = std::thread([type_id = type_id.value(), this]() noexcept { for (auto number = 0UL; number < kNumberOfActions; number++) { - shared_memory_writer_.AllocAndWrite( + shared_memory_writer.AllocAndWrite( [](auto span) { - EXPECT_EQ(span.size(), test_data_sample.size()); - std::memcpy(span.data(), test_data_sample.data(), test_data_sample.size()); + EXPECT_EQ(span.size(), kTestDataSample.size()); + std::memcpy(span.data(), kTestDataSample.data(), kTestDataSample.size()); }, type_id, - test_data_sample.size()); + kTestDataSample.size()); } }); } @@ -331,12 +331,12 @@ TEST_F(SharedMemoryWriterFixture, MultipleConcurrentWritesShallAllBeReceivedVali auto count = 0UL; auto on_new_record = [&](const score::mw::log::detail::SharedMemoryRecord& record) noexcept { EXPECT_EQ(record.header.type_identifier, type_id.value()); - EXPECT_EQ(record.payload.size(), test_data_sample.size()); - EXPECT_EQ(0, std::memcmp(record.payload.data(), test_data_sample.data(), test_data_sample.size())); + EXPECT_EQ(record.payload.size(), kTestDataSample.size()); + EXPECT_EQ(0, std::memcmp(record.payload.data(), kTestDataSample.data(), kTestDataSample.size())); count++; }; - shared_memory_reader_->Read(on_new_type, on_new_record); + shared_memory_reader->Read(on_new_type, on_new_record); EXPECT_EQ(count, kNumberOfThreads * kNumberOfActions); }; @@ -344,10 +344,10 @@ TEST_F(SharedMemoryWriterFixture, MultipleConcurrentWritesShallAllBeReceivedVali { // test write/verify multiple times to test double buffering and to detect synchronization issues: call_write_operations(); - const auto read_acquire_result = shared_memory_writer_.ReadAcquire(); + const auto read_acquire_result = shared_memory_writer.ReadAcquire(); // Datarouter part after acquisition - shared_memory_reader_->NotifyAcquisitionSetReader(read_acquire_result); + shared_memory_reader->NotifyAcquisitionSetReader(read_acquire_result); verify_write_operation(); } diff --git a/score/mw/log/detail/data_router/shared_memory/writer_factory.cpp b/score/mw/log/detail/data_router/shared_memory/writer_factory.cpp index 5c72967..c142df0 100644 --- a/score/mw/log/detail/data_router/shared_memory/writer_factory.cpp +++ b/score/mw/log/detail/data_router/shared_memory/writer_factory.cpp @@ -77,35 +77,35 @@ void WriterFactory::UnlinkExistingFile(const std::string& file_name) const noexc score::cpp::optional WriterFactory::OpenAndTruncateFile(const std::size_t buffer_total_size, const std::string& file_name, - const score::os::Fcntl::Open flags) noexcept + const score::os::Fcntl::Open flags) const noexcept { - const score::cpp::span funcSpan(__func__); + const score::cpp::span func_span(__func__); constexpr auto kOpenModeFlags = score::os::Stat::Mode::kReadUser | score::os::Stat::Mode::kReadGroup | score::os::Stat::Mode::kReadOthers; // NOLINTNEXTLINE(score-banned-function) it is among safety headers. const auto open_ret_val = osal_.fcntl_osal->open(file_name.c_str(), flags, kOpenModeFlags); if (open_ret_val.has_value() == false) { - std::cerr << funcSpan.data() << ":open " << file_name << " " << open_ret_val.error().ToString() << '\n'; + std::cerr << func_span.data() << ":open " << file_name << " " << open_ret_val.error().ToString() << '\n'; return {}; } - const int32_t memfd_write_ = open_ret_val.value(); + const int32_t memfd_write = open_ret_val.value(); const auto chmod_ret_val = osal_.stat_osal->chmod(file_name.c_str(), kOpenModeFlags); if (chmod_ret_val.has_value() == false) { - std::cerr << funcSpan.data() << ":chmod " << file_name << " " << chmod_ret_val.error().ToString() << '\n'; + std::cerr << func_span.data() << ":chmod " << file_name << " " << chmod_ret_val.error().ToString() << '\n'; return {}; } - auto ftruncate_ret_val = osal_.unistd->ftruncate(memfd_write_, static_cast(buffer_total_size)); + auto ftruncate_ret_val = osal_.unistd->ftruncate(memfd_write, static_cast(buffer_total_size)); if (ftruncate_ret_val.has_value() == false) { - std::cerr << funcSpan.data() << ":ftruncate " << ftruncate_ret_val.error().ToString() << '\n'; + std::cerr << func_span.data() << ":ftruncate " << ftruncate_ret_val.error().ToString() << '\n'; std::ignore = osal_.unistd->unlink(file_name.c_str()); return {}; } - return memfd_write_; + return memfd_write; } score::cpp::optional WriterFactory::MapSharedMemory(const std::size_t buffer_total_size, @@ -137,8 +137,8 @@ score::cpp::optional WriterFactory::MapSharedMemory(const std::size if (nullptr == mmap_result_.value()) { - const score::cpp::span funcSpan(__func__); - std::cerr << funcSpan.data() << ":mmap result it nullptr\n"; + const score::cpp::span func_span(__func__); + std::cerr << func_span.data() << ":mmap result it nullptr\n"; unmap_callback_(); return {}; } @@ -174,13 +174,13 @@ SharedData* WriterFactory::ConstructSharedData(void* const ring_buffer_address, const std::size_t ring_buffer_size) const noexcept { // NOLINTNEXTLINE(score-no-dynamic-raw-memory) new keyword is intended by design - auto shared_data = new (ring_buffer_address) SharedData(); + auto* shared_data = new (ring_buffer_address) SharedData(); shared_data->producer_pid = osal_.unistd->getpid(); // move pointer to point after shared data structure and only after that cast to void* for further pointer // operations: // Cast used because by design we cast data structures onto memory allocated by mmap - auto iter = shared_data; + auto* iter = shared_data; std::advance(iter, 1); /*moving pointer forward by one SharedData type*/ void* const linear_space = static_cast(iter); @@ -200,7 +200,7 @@ SharedData* WriterFactory::ConstructSharedData(void* const ring_buffer_address, // An object with integer type or pointer to void type shall not be converted to an object with pointer type. // But we need to convert void pointer to bytes for serialization purposes, no out of bounds there // coverity[autosar_cpp14_m5_2_8_violation] - const auto block_1_data = static_cast(linear_space); + auto* const block_1_data = static_cast(linear_space); shared_data->control_block.control_block_even.data = score::cpp::span{block_1_data, linear_buffer_size}; std::ignore = InitializeSharedData(*shared_data); // Initialize buffer switch sides: @@ -211,7 +211,7 @@ SharedData* WriterFactory::ConstructSharedData(void* const ring_buffer_address, // An object with integer type or pointer to void type shall not be converted to an object with pointer type. // But we need to convert void pointer to bytes for serialization purposes, no out of bounds there // coverity[autosar_cpp14_m5_2_8_violation] - auto block_2_data = static_cast(linear_space); + auto* block_2_data = static_cast(linear_space); std::advance(block_2_data, static_cast(half_buffer_size)); @@ -238,16 +238,16 @@ LoggingClientFileNameResult WriterFactory::PrepareFileNameAndUpdateOpenFlags( std::cerr << "mkstemps: Failed to create '" << name_buffer.data() << "' file for app: " << app_id.data() << '\n'; } - constexpr score::os::Stat::Mode permissions = score::os::Stat::Mode::kReadUser | score::os::Stat::Mode::kReadGroup | - score::os::Stat::Mode::kReadOthers | score::os::Stat::Mode::kWriteUser; + constexpr score::os::Stat::Mode kPermissions = score::os::Stat::Mode::kReadUser | score::os::Stat::Mode::kReadGroup | + score::os::Stat::Mode::kReadOthers | score::os::Stat::Mode::kWriteUser; - if ((osal_.stat_osal->chmod(name_buffer.data(), permissions)).has_value() == false) + if ((osal_.stat_osal->chmod(name_buffer.data(), kPermissions)).has_value() == false) { std::cerr << "Unable to apply permissions to: " << name_buffer.data() << '\n'; } result_file_name.file_name = std::string{name_buffer.data(), name_buffer.size() - 1UL}; - auto find_beginning_logging_identifier = std::begin(name_buffer); + auto* find_beginning_logging_identifier = std::begin(name_buffer); static_assert( sizeof(kFileNameDirectoryTemplate) <= static_cast(std::numeric_limits::max() - 1), "size of kFileNameDirectoryTemplate is greater than size of int"); @@ -271,13 +271,13 @@ score::cpp::optional WriterFactory::GetAlignedRingBufferAddress( const std::string& file_name, const score::os::Fcntl::Open file_open_flags) noexcept { - const auto memfd_write_ = OpenAndTruncateFile(total_size, file_name, file_open_flags); - if (memfd_write_.has_value() == false) + const auto memfd_write = OpenAndTruncateFile(total_size, file_name, file_open_flags); + if (memfd_write.has_value() == false) { return {}; } - auto ring_buffer_address = MapSharedMemory(total_size, memfd_write_.value(), file_name); + auto ring_buffer_address = MapSharedMemory(total_size, memfd_write.value(), file_name); if (ring_buffer_address.has_value() == false) { return {}; @@ -305,14 +305,14 @@ score::cpp::optional WriterFactory::Create(const std::size_t score::os::Fcntl::Open::kReadWrite | score::os::Fcntl::Open::kExclusive | score::os::Fcntl::Open::kCloseOnExec; file_attributes_ = PrepareFileNameAndUpdateOpenFlags(flags, dynamic_mode, app_id); - constexpr std::size_t buffer_start_offset = sizeof(SharedData); - if (buffer_start_offset > std::numeric_limits::max() - ring_buffer_size) + constexpr std::size_t kBufferStartOffset = sizeof(SharedData); + if (kBufferStartOffset > std::numeric_limits::max() - ring_buffer_size) { - const score::cpp::span funcSpan(__func__); - std::cerr << "(buffer_start_offset + ring_buffer_size) Overflow happened in function : " << funcSpan.data() + const score::cpp::span func_span(__func__); + std::cerr << "(buffer_start_offset + ring_buffer_size) Overflow happened in function : " << func_span.data() << " in line : " << __LINE__ << "\n"; } - const std::size_t buffer_end_offset = buffer_start_offset + ring_buffer_size; + const std::size_t buffer_end_offset = kBufferStartOffset + ring_buffer_size; const auto total_size = buffer_end_offset; auto ring_buffer_address = GetAlignedRingBufferAddress(total_size, file_attributes_.file_name, flags); diff --git a/score/mw/log/detail/data_router/shared_memory/writer_factory.h b/score/mw/log/detail/data_router/shared_memory/writer_factory.h index 1fcc1ed..8af8c4d 100644 --- a/score/mw/log/detail/data_router/shared_memory/writer_factory.h +++ b/score/mw/log/detail/data_router/shared_memory/writer_factory.h @@ -11,8 +11,8 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef BMW_MW_LOG_SHARED_MEMORY_WRITER_FACTORY -#define BMW_MW_LOG_SHARED_MEMORY_WRITER_FACTORY +#ifndef SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_WRITER_FACTORY_H +#define SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_WRITER_FACTORY_H #include "score/mw/log/detail/data_router/shared_memory/shared_memory_writer.h" @@ -85,7 +85,7 @@ class WriterFactory void UnlinkExistingFile(const std::string& file_name) const noexcept; score::cpp::optional OpenAndTruncateFile(const std::size_t buffer_total_size, const std::string& file_name, - const score::os::Fcntl::Open flags) noexcept; + const score::os::Fcntl::Open flags) const noexcept; score::cpp::optional MapSharedMemory(const std::size_t buffer_total_size, const int32_t memfd_write, const std::string& file_name) noexcept; @@ -109,4 +109,4 @@ class WriterFactory } // namespace mw } // namespace score -#endif +#endif // SCORE_MW_LOG_DETAIL_DATA_ROUTER_SHARED_MEMORY_WRITER_FACTORY_H diff --git a/score/mw/log/detail/data_router/shared_memory/writer_factory_test.cpp b/score/mw/log/detail/data_router/shared_memory/writer_factory_test.cpp index 4c8a4cb..adf64b2 100644 --- a/score/mw/log/detail/data_router/shared_memory/writer_factory_test.cpp +++ b/score/mw/log/detail/data_router/shared_memory/writer_factory_test.cpp @@ -39,19 +39,19 @@ using ::testing::_; using ::testing::Return; using ::testing::StrEq; -static constexpr pid_t kPid{0x314}; -static constexpr std::int32_t kArbitratyUid = 12365432UL; -static constexpr bool kDynamicFalse = false; -static constexpr bool kDynamicTrue = true; -static constexpr auto kDefaultRingSize = 1024UL; -static constexpr auto kSharedSize = kDefaultRingSize + sizeof(SharedData); -static constexpr auto kOverflowSize = std::numeric_limits::max(); -static constexpr std::int32_t kFileDescriptor = 0x1; -static constexpr auto kOpenReadFlags = +constexpr pid_t kPid{0x314}; +constexpr std::int32_t kArbitratyUid = 12365432UL; +constexpr bool kDynamicFalse = false; +constexpr bool kDynamicTrue = true; +constexpr auto kDefaultRingSize = 1024UL; +constexpr auto kSharedSize = kDefaultRingSize + sizeof(SharedData); +constexpr auto kOverflowSize = std::numeric_limits::max(); +constexpr std::int32_t kFileDescriptor = 0x1; +constexpr auto kOpenReadFlags = score::os::Fcntl::Open::kCreate | score::os::Fcntl::Open::kReadWrite | score::os::Fcntl::Open::kExclusive; -static constexpr auto kOpenReadFlagsDynamic = +constexpr auto kOpenReadFlagsDynamic = score::os::Fcntl::Open::kReadWrite | score::os::Fcntl::Open::kExclusive | score::os::Fcntl::Open::kCloseOnExec; -static constexpr auto kOpenModeFlags = +constexpr auto kOpenModeFlags = score::os::Stat::Mode::kReadUser | score::os::Stat::Mode::kReadGroup | score::os::Stat::Mode::kReadOthers; constexpr auto kAlignRequirement = std::alignment_of::value; const char kFileNameDynamic[] = "/tmp/logging-XXXXXX.shmem"; @@ -61,58 +61,58 @@ const std::string& GetSharedMemoryFileName() std::stringstream ss; ss << "/tmp/logging.UTST." << kArbitratyUid << ".shmem"; ss.str(); - static const std::string file_name{ss.str()}; - return file_name; + static const std::string kFileName{ss.str()}; + return kFileName; } class WriterFactoryFixture : public ::testing::Test { public: - WriterFactoryFixture() : shared_memory_file_name_{GetSharedMemoryFileName()} + WriterFactoryFixture() : shared_memory_file_name{GetSharedMemoryFileName()} { - auto memory_resource = score::cpp::pmr::get_default_resource(); + auto* memory_resource = score::cpp::pmr::get_default_resource(); auto fcntl_mock = score::cpp::pmr::make_unique(memory_resource); auto unistd_mock = score::cpp::pmr::make_unique(memory_resource); auto mman_mock = score::cpp::pmr::make_unique(memory_resource); auto stat_mock = score::cpp::pmr::make_unique(memory_resource); auto stdlib_mock = score::cpp::pmr::make_unique(memory_resource); - fcntl_mock_raw_ptr_ = fcntl_mock.get(); - mman_mock_raw_ptr_ = mman_mock.get(); - unistd_mock_raw_ptr_ = unistd_mock.get(); - stat_mock_raw_ptr_ = stat_mock.get(); - stdlib_mock_raw_ptr_ = stdlib_mock.get(); + fcntl_mock_raw_ptr = fcntl_mock.get(); + mman_mock_raw_ptr = mman_mock.get(); + unistd_mock_raw_ptr = unistd_mock.get(); + stat_mock_raw_ptr = stat_mock.get(); + stdlib_mock_raw_ptr = stdlib_mock.get(); - osal_.fcntl_osal = std::move(fcntl_mock); - osal_.unistd = std::move(unistd_mock); - osal_.mman = std::move(mman_mock); - osal_.stdlib = std::move(stdlib_mock); - osal_.stat_osal = std::move(stat_mock); + osal.fcntl_osal = std::move(fcntl_mock); + osal.unistd = std::move(unistd_mock); + osal.mman = std::move(mman_mock); + osal.stdlib = std::move(stdlib_mock); + osal.stat_osal = std::move(stat_mock); - ON_CALL(*unistd_mock_raw_ptr_, getuid()).WillByDefault(Return(kArbitratyUid)); + ON_CALL(*unistd_mock_raw_ptr, getuid()).WillByDefault(Return(kArbitratyUid)); - non_zero_address_ = &buffer_[0]; - map_address_ = &buffer_[0]; + non_zero_address = &buffer[0]; + map_address = &buffer[0]; } ~WriterFactoryFixture() { - non_zero_address_ = nullptr; - map_address_ = nullptr; + non_zero_address = nullptr; + map_address = nullptr; } - score::os::FcntlMock* fcntl_mock_raw_ptr_; - score::os::UnistdMock* unistd_mock_raw_ptr_; - score::os::StatMock* stat_mock_raw_ptr_; - score::os::StdlibMock* stdlib_mock_raw_ptr_; - score::os::MmanMock* mman_mock_raw_ptr_; - WriterFactory::OsalInstances osal_; + score::os::FcntlMock* fcntl_mock_raw_ptr; + score::os::UnistdMock* unistd_mock_raw_ptr; + score::os::StatMock* stat_mock_raw_ptr; + score::os::StdlibMock* stdlib_mock_raw_ptr; + score::os::MmanMock* mman_mock_raw_ptr; + WriterFactory::OsalInstances osal; // Mmap helpers: - Byte buffer_[kSharedSize + kAlignRequirement]; - void* non_zero_address_; - void* map_address_; - std::string shared_memory_file_name_; + Byte buffer[kSharedSize + kAlignRequirement]; + void* non_zero_address; + void* map_address; + std::string shared_memory_file_name; }; TEST(WriterFactory, MissingOsalShallResultInEmptyOptional) @@ -218,21 +218,21 @@ TEST_F(WriterFactoryFixture, WhenTheFileExistsItShallBeUnlinked) RecordProperty("DerivationTechnique", "Analysis of requirements"); RecordProperty("Priority", "3"); - WriterFactory writer(std::move(osal_)); + WriterFactory writer(std::move(osal)); - EXPECT_CALL(*unistd_mock_raw_ptr_, access(StrEq(shared_memory_file_name_), score::os::Unistd::AccessMode::kExists)) + EXPECT_CALL(*unistd_mock_raw_ptr, access(StrEq(shared_memory_file_name), score::os::Unistd::AccessMode::kExists)) .WillOnce(Return(score::cpp::expected_blank{})); - EXPECT_CALL(*unistd_mock_raw_ptr_, unlink(StrEq(shared_memory_file_name_))) + EXPECT_CALL(*unistd_mock_raw_ptr, unlink(StrEq(shared_memory_file_name))) .WillOnce(Return(score::cpp::expected_blank{})); EXPECT_CALL( - *fcntl_mock_raw_ptr_, - open(StrEq(shared_memory_file_name_), kOpenReadFlags | score::os::Fcntl::Open::kCloseOnExec, kOpenModeFlags)) + *fcntl_mock_raw_ptr, + open(StrEq(shared_memory_file_name), kOpenReadFlags | score::os::Fcntl::Open::kCloseOnExec, kOpenModeFlags)) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EINVAL)))); // Expect to exit before a call to next mocking feature - EXPECT_CALL(*unistd_mock_raw_ptr_, ftruncate(_, _)).Times(0); + EXPECT_CALL(*unistd_mock_raw_ptr, ftruncate(_, _)).Times(0); auto result = writer.Create(kDefaultRingSize, kDynamicFalse, "UTST"); EXPECT_FALSE(result.has_value()); @@ -249,21 +249,21 @@ TEST_F(WriterFactoryFixture, WhenTheFileExistsAndCannotBeUnlinkedItShallContinue RecordProperty("DerivationTechnique", "Analysis of requirements"); RecordProperty("Priority", "3"); - WriterFactory writer(std::move(osal_)); + WriterFactory writer(std::move(osal)); - EXPECT_CALL(*unistd_mock_raw_ptr_, access(StrEq(shared_memory_file_name_), score::os::Unistd::AccessMode::kExists)) + EXPECT_CALL(*unistd_mock_raw_ptr, access(StrEq(shared_memory_file_name), score::os::Unistd::AccessMode::kExists)) .WillOnce(Return(score::cpp::expected_blank{})); - EXPECT_CALL(*unistd_mock_raw_ptr_, unlink(StrEq(shared_memory_file_name_))) + EXPECT_CALL(*unistd_mock_raw_ptr, unlink(StrEq(shared_memory_file_name))) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EINVAL)))); EXPECT_CALL( - *fcntl_mock_raw_ptr_, - open(StrEq(shared_memory_file_name_), kOpenReadFlags | score::os::Fcntl::Open::kCloseOnExec, kOpenModeFlags)) + *fcntl_mock_raw_ptr, + open(StrEq(shared_memory_file_name), kOpenReadFlags | score::os::Fcntl::Open::kCloseOnExec, kOpenModeFlags)) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EINVAL)))); // Expect to exit before a call to next mocking feature - EXPECT_CALL(*unistd_mock_raw_ptr_, ftruncate(_, _)).Times(0); + EXPECT_CALL(*unistd_mock_raw_ptr, ftruncate(_, _)).Times(0); auto result = writer.Create(kDefaultRingSize, kDynamicFalse, "UTST"); EXPECT_FALSE(result.has_value()); @@ -278,11 +278,11 @@ TEST_F(WriterFactoryFixture, InDynamicFileExistanceShallNotBeChecked) RecordProperty("DerivationTechnique", "Analysis of requirements"); RecordProperty("Priority", "3"); - WriterFactory writer(std::move(osal_)); + WriterFactory writer(std::move(osal)); - EXPECT_CALL(*unistd_mock_raw_ptr_, access(_, _)).Times(0); + EXPECT_CALL(*unistd_mock_raw_ptr, access(_, _)).Times(0); - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EINVAL)))); auto result = writer.Create(kDefaultRingSize, kDynamicTrue, "UTST"); @@ -298,13 +298,13 @@ TEST_F(WriterFactoryFixture, FailureToOpenFileShallResultInEmptyOptionalResult) RecordProperty("DerivationTechnique", "Analysis of requirements"); RecordProperty("Priority", "3"); - WriterFactory writer(std::move(osal_)); + WriterFactory writer(std::move(osal)); - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EINVAL)))); // Expect to exit before a call to next mocking feature - EXPECT_CALL(*unistd_mock_raw_ptr_, ftruncate(_, _)).Times(0); + EXPECT_CALL(*unistd_mock_raw_ptr, ftruncate(_, _)).Times(0); auto result = writer.Create(kDefaultRingSize, kDynamicTrue, "UTST"); EXPECT_FALSE(result.has_value()); @@ -320,20 +320,20 @@ TEST_F(WriterFactoryFixture, FailureToTruncateFileShallResultInEmptyOptionalResu RecordProperty("DerivationTechnique", "Analysis of requirements"); RecordProperty("Priority", "3"); - WriterFactory writer(std::move(osal_)); + WriterFactory writer(std::move(osal)); - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) .WillOnce(Return(score::cpp::expected{kFileDescriptor})); - EXPECT_CALL(*unistd_mock_raw_ptr_, ftruncate(kFileDescriptor, kSharedSize)) + EXPECT_CALL(*unistd_mock_raw_ptr, ftruncate(kFileDescriptor, kSharedSize)) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EINVAL)))); // Expect unlink to be called before exit - EXPECT_CALL(*unistd_mock_raw_ptr_, unlink(StrEq(kFileNameDynamic))) + EXPECT_CALL(*unistd_mock_raw_ptr, unlink(StrEq(kFileNameDynamic))) .WillOnce(Return(score::cpp::expected_blank{})); // We expect mmap not to be called irregardless of arguments - EXPECT_CALL(*mman_mock_raw_ptr_, mmap(_, _, _, _, _, _)).Times(0); + EXPECT_CALL(*mman_mock_raw_ptr, mmap(_, _, _, _, _, _)).Times(0); auto result = writer.Create(kDefaultRingSize, kDynamicTrue, "UTST"); EXPECT_FALSE(result.has_value()); @@ -349,12 +349,12 @@ TEST_F(WriterFactoryFixture, MakeSureThatOpenCallWillOnlyBeDoneWithCorrectOpenRe RecordProperty("DerivationTechnique", "Analysis of requirements"); RecordProperty("Priority", "3"); - WriterFactory writer(std::move(osal_)); + WriterFactory writer(std::move(osal)); EXPECT_CALL( - *fcntl_mock_raw_ptr_, + *fcntl_mock_raw_ptr, open(StrEq(kFileNameDynamic), score::os::Fcntl::Open::kCreate | score::os::Fcntl::Open::kReadWrite, kOpenModeFlags)) .Times(0); - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)).Times(1); + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)).Times(1); auto result = writer.Create(kDefaultRingSize, kDynamicTrue, "UTST"); } @@ -368,15 +368,15 @@ TEST_F(WriterFactoryFixture, FailureToMapFileShallResultInEmptyOptionalResult) RecordProperty("DerivationTechnique", "Analysis of requirements"); RecordProperty("Priority", "3"); - WriterFactory writer(std::move(osal_)); + WriterFactory writer(std::move(osal)); - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) .WillOnce(Return(score::cpp::expected{kFileDescriptor})); - EXPECT_CALL(*unistd_mock_raw_ptr_, ftruncate(kFileDescriptor, kSharedSize)) + EXPECT_CALL(*unistd_mock_raw_ptr, ftruncate(kFileDescriptor, kSharedSize)) .WillOnce(Return(score::cpp::expected_blank{})); - EXPECT_CALL(*mman_mock_raw_ptr_, + EXPECT_CALL(*mman_mock_raw_ptr, mmap(nullptr, kSharedSize, score::os::Mman::Protection::kRead | score::os::Mman::Protection::kWrite, @@ -386,7 +386,7 @@ TEST_F(WriterFactoryFixture, FailureToMapFileShallResultInEmptyOptionalResult) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EINVAL)))); // Expect unlink to be called before exit - EXPECT_CALL(*unistd_mock_raw_ptr_, unlink(StrEq(kFileNameDynamic))) + EXPECT_CALL(*unistd_mock_raw_ptr, unlink(StrEq(kFileNameDynamic))) .WillOnce(Return(score::cpp::expected_blank{})); auto result = writer.Create(kDefaultRingSize, kDynamicTrue, "UTST"); @@ -403,29 +403,29 @@ TEST_F(WriterFactoryFixture, WhenAllMocksReturnValidShallResultValidOptionalResu RecordProperty("DerivationTechnique", "Analysis of requirements"); RecordProperty("Priority", "3"); - WriterFactory writer(std::move(osal_)); + WriterFactory writer(std::move(osal)); - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) .WillOnce(Return(score::cpp::expected{kFileDescriptor})); - EXPECT_CALL(*unistd_mock_raw_ptr_, ftruncate(kFileDescriptor, kSharedSize)) + EXPECT_CALL(*unistd_mock_raw_ptr, ftruncate(kFileDescriptor, kSharedSize)) .WillOnce(Return(score::cpp::expected_blank{})); - EXPECT_CALL(*mman_mock_raw_ptr_, + EXPECT_CALL(*mman_mock_raw_ptr, mmap(nullptr, kSharedSize, score::os::Mman::Protection::kRead | score::os::Mman::Protection::kWrite, score::os::Mman::Map::kShared, kFileDescriptor, 0)) - .WillOnce(Return(score::cpp::expected{map_address_})); + .WillOnce(Return(score::cpp::expected{map_address})); - EXPECT_CALL(*unistd_mock_raw_ptr_, getpid()).WillOnce(Return(kPid)); + EXPECT_CALL(*unistd_mock_raw_ptr, getpid()).WillOnce(Return(kPid)); const auto result = writer.Create(kDefaultRingSize, kDynamicTrue, "UTST"); EXPECT_TRUE(result.has_value()); - EXPECT_CALL(*mman_mock_raw_ptr_, munmap(_, kSharedSize)).WillOnce(Return(score::cpp::expected_blank{})); + EXPECT_CALL(*mman_mock_raw_ptr, munmap(_, kSharedSize)).WillOnce(Return(score::cpp::expected_blank{})); } TEST_F(WriterFactoryFixture, WhenMmapIsValidAndUnmmapIsFailingItShallPrintCerrMessage) @@ -437,29 +437,29 @@ TEST_F(WriterFactoryFixture, WhenMmapIsValidAndUnmmapIsFailingItShallPrintCerrMe RecordProperty("DerivationTechnique", "Analysis of requirements"); RecordProperty("Priority", "3"); - WriterFactory writer(std::move(osal_)); + WriterFactory writer(std::move(osal)); - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) .WillOnce(Return(score::cpp::expected{kFileDescriptor})); - EXPECT_CALL(*unistd_mock_raw_ptr_, ftruncate(kFileDescriptor, kSharedSize)) + EXPECT_CALL(*unistd_mock_raw_ptr, ftruncate(kFileDescriptor, kSharedSize)) .WillOnce(Return(score::cpp::expected_blank{})); - EXPECT_CALL(*mman_mock_raw_ptr_, + EXPECT_CALL(*mman_mock_raw_ptr, mmap(nullptr, kSharedSize, score::os::Mman::Protection::kRead | score::os::Mman::Protection::kWrite, score::os::Mman::Map::kShared, kFileDescriptor, 0)) - .WillOnce(Return(score::cpp::expected{map_address_})); + .WillOnce(Return(score::cpp::expected{map_address})); - EXPECT_CALL(*unistd_mock_raw_ptr_, getpid()).WillOnce(Return(kPid)); + EXPECT_CALL(*unistd_mock_raw_ptr, getpid()).WillOnce(Return(kPid)); const auto result = writer.Create(kDefaultRingSize, kDynamicTrue, "UTST"); EXPECT_TRUE(result.has_value()); - EXPECT_CALL(*mman_mock_raw_ptr_, munmap(_, kSharedSize)) + EXPECT_CALL(*mman_mock_raw_ptr, munmap(_, kSharedSize)) .WillOnce(Return(score::cpp::make_unexpected(score::os::Error::createFromErrno(EINVAL)))); } @@ -474,15 +474,15 @@ TEST_F(WriterFactoryFixture, MmapReturnsNullptrValueShallCallUnmapAndReturnEmpty RecordProperty("DerivationTechnique", "Analysis of requirements"); RecordProperty("Priority", "3"); - WriterFactory writer(std::move(osal_)); + WriterFactory writer(std::move(osal)); - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) .WillOnce(Return(score::cpp::expected{kFileDescriptor})); - EXPECT_CALL(*unistd_mock_raw_ptr_, ftruncate(kFileDescriptor, kSharedSize)) + EXPECT_CALL(*unistd_mock_raw_ptr, ftruncate(kFileDescriptor, kSharedSize)) .WillOnce(Return(score::cpp::expected_blank{})); - EXPECT_CALL(*mman_mock_raw_ptr_, + EXPECT_CALL(*mman_mock_raw_ptr, mmap(nullptr, kSharedSize, score::os::Mman::Protection::kRead | score::os::Mman::Protection::kWrite, @@ -491,9 +491,9 @@ TEST_F(WriterFactoryFixture, MmapReturnsNullptrValueShallCallUnmapAndReturnEmpty 0)) .WillOnce(Return(score::cpp::expected{nullptr})); - EXPECT_CALL(*unistd_mock_raw_ptr_, getpid()).Times(0); + EXPECT_CALL(*unistd_mock_raw_ptr, getpid()).Times(0); - EXPECT_CALL(*mman_mock_raw_ptr_, munmap(_, kSharedSize)).WillOnce(Return(score::cpp::expected_blank{})); + EXPECT_CALL(*mman_mock_raw_ptr, munmap(_, kSharedSize)).WillOnce(Return(score::cpp::expected_blank{})); const auto result = writer.Create(kDefaultRingSize, kDynamicTrue, "UTST"); EXPECT_FALSE(result.has_value()); @@ -522,17 +522,17 @@ TEST_F(WriterFactoryFixture, MmapReturingImproperAlignedMemoryShallCallUnmapAndR RecordProperty("DerivationTechnique", "Analysis of requirements"); RecordProperty("Priority", "3"); - WriterFactory writer(std::move(osal_)); + WriterFactory writer(std::move(osal)); - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) .WillOnce(Return(score::cpp::expected{kFileDescriptor})); - EXPECT_CALL(*unistd_mock_raw_ptr_, ftruncate(kFileDescriptor, kSharedSize)) + EXPECT_CALL(*unistd_mock_raw_ptr, ftruncate(kFileDescriptor, kSharedSize)) .WillOnce(Return(score::cpp::expected_blank{})); - Byte* improper_alignment_address = GetImproperAlignment(map_address_); + Byte* improper_alignment_address = GetImproperAlignment(map_address); - EXPECT_CALL(*mman_mock_raw_ptr_, + EXPECT_CALL(*mman_mock_raw_ptr, mmap(nullptr, kSharedSize, score::os::Mman::Protection::kRead | score::os::Mman::Protection::kWrite, @@ -541,9 +541,9 @@ TEST_F(WriterFactoryFixture, MmapReturingImproperAlignedMemoryShallCallUnmapAndR 0)) .WillOnce(Return(score::cpp::expected{improper_alignment_address})); - EXPECT_CALL(*unistd_mock_raw_ptr_, getpid()).Times(0); + EXPECT_CALL(*unistd_mock_raw_ptr, getpid()).Times(0); - EXPECT_CALL(*mman_mock_raw_ptr_, munmap(_, kSharedSize)).WillOnce(Return(score::cpp::expected_blank{})); + EXPECT_CALL(*mman_mock_raw_ptr, munmap(_, kSharedSize)).WillOnce(Return(score::cpp::expected_blank{})); const auto result = writer.Create(kDefaultRingSize, kDynamicTrue, "UTST"); EXPECT_FALSE(result.has_value()); @@ -554,18 +554,18 @@ TEST_F(WriterFactoryFixture, UnexpectedBufferSizeWithOverflowShallMakeCerrOutput // Tests behavior when ring buffer size causes integer overflow during total size calculation. // Expected size is sizeof(SharedData) which contains const std::size_t expected_shared_data_size = 143; - WriterFactory writer(std::move(osal_)); + WriterFactory writer(std::move(osal)); // Step 1: Open shared memory file succeeds - EXPECT_CALL(*fcntl_mock_raw_ptr_, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) + EXPECT_CALL(*fcntl_mock_raw_ptr, open(StrEq(kFileNameDynamic), kOpenReadFlagsDynamic, kOpenModeFlags)) .WillOnce(Return(score::cpp::expected{kFileDescriptor})); // Step 2: Truncate file to expected size (overflow clamped to SharedData size) - EXPECT_CALL(*unistd_mock_raw_ptr_, ftruncate(kFileDescriptor, expected_shared_data_size)) + EXPECT_CALL(*unistd_mock_raw_ptr, ftruncate(kFileDescriptor, expected_shared_data_size)) .WillOnce(Return(score::cpp::expected_blank{})); // Step 3: Memory mapping fails (returns nullptr) - EXPECT_CALL(*mman_mock_raw_ptr_, + EXPECT_CALL(*mman_mock_raw_ptr, mmap(nullptr, expected_shared_data_size, score::os::Mman::Protection::kRead | score::os::Mman::Protection::kWrite, @@ -575,10 +575,10 @@ TEST_F(WriterFactoryFixture, UnexpectedBufferSizeWithOverflowShallMakeCerrOutput .WillOnce(Return(score::cpp::expected{nullptr})); // Step 4: getpid should not be called due to mmap failure - EXPECT_CALL(*unistd_mock_raw_ptr_, getpid()).Times(0); + EXPECT_CALL(*unistd_mock_raw_ptr, getpid()).Times(0); // Step 5: Cleanup - unmap is called during error handling - EXPECT_CALL(*mman_mock_raw_ptr_, munmap(_, expected_shared_data_size)) + EXPECT_CALL(*mman_mock_raw_ptr, munmap(_, expected_shared_data_size)) .WillOnce(Return(score::cpp::expected_blank{})); // Verify: Create fails and returns empty optional diff --git a/score/mw/log/detail/slog/BUILD b/score/mw/log/detail/slog/BUILD index 5db838c..818f345 100644 --- a/score/mw/log/detail/slog/BUILD +++ b/score/mw/log/detail/slog/BUILD @@ -12,9 +12,21 @@ # ******************************************************************************* load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") +load("@score_baselibs//score/quality/clang_tidy:extra_checks.bzl", "clang_tidy_extra_checks") load("@score_baselibs//third_party/itf:py_unittest_qnx_test.bzl", "py_unittest_qnx_test") load("//:score/mw/common_features.bzl", "COMPILER_WARNING_FEATURES") +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 = "slog_backend", srcs = [ diff --git a/score/mw/log/detail/slog/slog_backend.cpp b/score/mw/log/detail/slog/slog_backend.cpp index a90c48a..ba60880 100644 --- a/score/mw/log/detail/slog/slog_backend.cpp +++ b/score/mw/log/detail/slog/slog_backend.cpp @@ -30,8 +30,8 @@ namespace detail namespace { -constexpr auto SLOG_BUFFER_DEFAULT = 0; -constexpr auto SLOG_VERBOSITY_DEFAULT = SLOG2_DEBUG2; +constexpr auto kSlogBufferDefault = 0; +constexpr auto kSlogVerbosityDefault = SLOG2_DEBUG2; std::size_t CheckTheMaxCapacity(const std::size_t capacity) noexcept { @@ -114,7 +114,7 @@ SlogBackend::SlogBackend( slog_buffer_config_{}, slog2_instance_{std::move(slog2_instance)} { - Init(static_cast(SLOG_VERBOSITY_DEFAULT)); + Init(static_cast(kSlogVerbosityDefault)); } score::cpp::optional SlogBackend::ReserveSlot() noexcept @@ -149,14 +149,14 @@ void SlogBackend::FlushSlot(const SlotHandle& slot) noexcept auto& log_entry = buffer_.GetUnderlyingBufferFor(static_cast(slot.GetSlotOfSelectedRecorder())).getLogEntry(); - constexpr std::size_t max_id_length{4U}; + constexpr std::size_t kMaxIdLength{4U}; // Cast appid length to int32 without overflow. - const std::int32_t app_id_length = static_cast(std::min(max_id_length, app_id_.size())); + const std::int32_t app_id_length = static_cast(std::min(kMaxIdLength, app_id_.size())); // Cast context length to int32 without overflow. const std::int32_t ctx_id_length = - static_cast(std::min(max_id_length, log_entry.ctx_id.GetStringView().size())); + static_cast(std::min(kMaxIdLength, log_entry.ctx_id.GetStringView().size())); // Cast payload size to int32_t without overflow. const std::int32_t payload_length = static_cast( @@ -194,8 +194,8 @@ void SlogBackend::Init(const std::uint8_t verbosity) noexcept slog_buffer_config_.num_buffers = 1; slog_buffer_config_.buffer_set_name = app_id_.c_str(); slog_buffer_config_.verbosity_level = verbosity; - slog_buffer_config_.buffer_config[SLOG_BUFFER_DEFAULT].buffer_name = app_id_.c_str(); - slog_buffer_config_.buffer_config[SLOG_BUFFER_DEFAULT].num_pages = 16; // 16*4kB = 64kB + slog_buffer_config_.buffer_config[kSlogBufferDefault].buffer_name = app_id_.c_str(); + slog_buffer_config_.buffer_config[kSlogBufferDefault].num_pages = 16; // 16*4kB = 64kB const auto result = slog2_instance_->slog2_register(&slog_buffer_config_, &slog_buffer_, 0U); if (result.has_value() == false) diff --git a/score/mw/log/detail/slog/slog_recorder_factory.cpp b/score/mw/log/detail/slog/slog_recorder_factory.cpp index 47d41a5..abc07ef 100644 --- a/score/mw/log/detail/slog/slog_recorder_factory.cpp +++ b/score/mw/log/detail/slog/slog_recorder_factory.cpp @@ -24,8 +24,8 @@ std::unique_ptr SlogRecorderFactory::CreateConcreteLogRecorder(const C score::cpp::pmr::memory_resource* memory_resource) { auto backend = CreateSystemBackend(config, memory_resource); // LCOV_EXCL_LINE : no branches to test - constexpr bool check_log_level_for_console = false; - return std::make_unique(config, std::move(backend), check_log_level_for_console); + constexpr bool kCheckLogLevelForConsole = false; + return std::make_unique(config, std::move(backend), kCheckLogLevelForConsole); } std::unique_ptr SlogRecorderFactory::CreateSystemBackend(const Configuration& config, diff --git a/score/mw/log/detail/slog/slog_recorder_factory.h b/score/mw/log/detail/slog/slog_recorder_factory.h index 25111a7..e42245a 100644 --- a/score/mw/log/detail/slog/slog_recorder_factory.h +++ b/score/mw/log/detail/slog/slog_recorder_factory.h @@ -10,8 +10,8 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#ifndef SCORE_MW_LOG_DETAIL_SLOG_RECORDER_FACTORY_H -#define SCORE_MW_LOG_DETAIL_SLOG_RECORDER_FACTORY_H +#ifndef SCORE_MW_LOG_DETAIL_SLOG_SLOG_RECORDER_FACTORY_H +#define SCORE_MW_LOG_DETAIL_SLOG_SLOG_RECORDER_FACTORY_H #include "score/mw/log/detail/log_recorder_factory.hpp" #include "score/mw/log/detail/slog/slog_backend.h" @@ -41,4 +41,4 @@ class SlogRecorderFactory : public LogRecorderFactory } // namespace mw } // namespace score -#endif // SCORE_MW_LOG_DETAIL_SLOG_RECORDER_FACTORY_H +#endif // SCORE_MW_LOG_DETAIL_SLOG_SLOG_RECORDER_FACTORY_H From 556522d4a25b0829566e4381d95cd4cbdb0479f3 Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Mon, 2 Feb 2026 10:06:04 +0100 Subject: [PATCH 13/29] Enable extra clang_tidy checks for the following folders: - platform/aas/mw/log/legacy_non_verbose_api GIT_ORIGIN_SPP_REV_ID: b64c30942376baf38fb4ec2900b41eade0549689 --- .../data_router/data_router_backend.cpp | 14 +- .../data_router/data_router_backend_test.cpp | 10 +- ...ata_router_message_client_factory_impl.cpp | 2 +- score/mw/log/legacy_non_verbose_api/BUILD | 12 ++ .../mw/log/legacy_non_verbose_api/tracing.cpp | 38 ++--- score/mw/log/legacy_non_verbose_api/tracing.h | 140 ++++++++-------- .../legacy_non_verbose_api/tracing_test.cpp | 154 +++++++++--------- 7 files changed, 188 insertions(+), 182 deletions(-) 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 b26212a..98659f7 100644 --- a/score/mw/log/detail/data_router/data_router_backend.cpp +++ b/score/mw/log/detail/data_router/data_router_backend.cpp @@ -62,7 +62,7 @@ DataRouterBackend::DataRouterBackend(const std::size_t number_of_slots, if (writer.has_value()) { // Required to retrieve and update the Configuration across - std::ignore = ::score::platform::logger::instance(config, {}, std::move(writer.value())); + std::ignore = ::score::platform::Logger::Instance(config, {}, std::move(writer.value())); message_client_ = message_client_factory.CreateOnce(writer_factory.GetIdentifier(), writer_factory.GetFileName()); message_client_->Run(); @@ -102,22 +102,22 @@ void DataRouterBackend::FlushSlot(const SlotHandle& slot) noexcept switch (log_entry.log_level) { case LogLevel::kVerbose: - TRACE_VERBOSE(log_entry); + TraceVerbose(log_entry); break; case LogLevel::kDebug: - TRACE_DEBUG(log_entry); + TraceDebug(log_entry); break; case LogLevel::kInfo: - TRACE_INFO(log_entry); + TraceInfo(log_entry); break; case LogLevel::kWarn: - TRACE_WARN(log_entry); + TraceWarn(log_entry); break; case LogLevel::kError: - TRACE_ERROR(log_entry); + TraceError(log_entry); break; case LogLevel::kFatal: - TRACE_FATAL(log_entry); + TraceFatal(log_entry); break; case LogLevel::kOff: default: 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 1bf2d67..ad4f5ce 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 @@ -128,10 +128,10 @@ class DataRouterBackendFixture : public ::testing::Test, public ::testing::WithP reader_ = std::make_unique(shared_data_, std::move(read_only_reader), []() noexcept {}); config.SetDynamicDatarouterIdentifiers(false); - logger = std::make_unique( + logger = std::make_unique( config, score::mw::log::NvConfigFactory::CreateEmpty(), std::move(writer_)); - ::score::platform::logger::InjectTestInstance(logger.get()); + ::score::platform::Logger::InjectTestInstance(logger.get()); CreateSharedMemoryWriterFactory(); @@ -160,7 +160,7 @@ class DataRouterBackendFixture : public ::testing::Test, public ::testing::WithP void TearDown() override { - ::score::platform::logger::InjectTestInstance(nullptr); + ::score::platform::Logger::InjectTestInstance(nullptr); } void SimulateLogging(const std::string& context_id, const LogLevel log_level = LogLevel::kError) @@ -212,7 +212,7 @@ class DataRouterBackendFixture : public ::testing::Test, public ::testing::WithP unit_.FlushSlot(slot); const auto acquire_result = logger->GetSharedMemoryWriter().ReadAcquire(); - config = logger->get_config(); + config = logger->GetConfig(); reader_->NotifyAcquisitionSetReader(acquire_result); @@ -224,7 +224,7 @@ class DataRouterBackendFixture : public ::testing::Test, public ::testing::WithP } LogEntry header{}; - std::unique_ptr logger{}; + std::unique_ptr logger{}; Configuration config{}; // Mocks needed for dependency injection into SharedMemoryWriter: diff --git a/score/mw/log/detail/data_router/data_router_message_client_factory_impl.cpp b/score/mw/log/detail/data_router/data_router_message_client_factory_impl.cpp index b21bd66..f4842aa 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_factory_impl.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_factory_impl.cpp @@ -72,7 +72,7 @@ std::unique_ptr DatarouterMessageClientFactoryImpl::Cre // coverity[autosar_cpp14_a4_7_1_violation] static_cast(config_.GetDataRouterUid()), uid), - MsgClientBackend(score::platform::logger::instance().GetSharedMemoryWriter(), + MsgClientBackend(score::platform::Logger::Instance().GetSharedMemoryWriter(), mwsr_file_name, std::move(message_passing_factory_), config_.GetDynamicDatarouterIdentifiers()), diff --git a/score/mw/log/legacy_non_verbose_api/BUILD b/score/mw/log/legacy_non_verbose_api/BUILD index 29eb21e..1e363d8 100644 --- a/score/mw/log/legacy_non_verbose_api/BUILD +++ b/score/mw/log/legacy_non_verbose_api/BUILD @@ -14,6 +14,18 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load("@score_baselibs//:bazel/unit_tests.bzl", "cc_unit_test_suites_for_host_and_qnx") 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 = "legacy_non_verbose_api", diff --git a/score/mw/log/legacy_non_verbose_api/tracing.cpp b/score/mw/log/legacy_non_verbose_api/tracing.cpp index e090736..fafcd0a 100644 --- a/score/mw/log/legacy_non_verbose_api/tracing.cpp +++ b/score/mw/log/legacy_non_verbose_api/tracing.cpp @@ -33,7 +33,7 @@ exception is covered by SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD() macro and function so suppressing this warning */ // coverity[autosar_cpp14_a15_5_3_violation] -logger::logger(const score::cpp::optional& config, +Logger::Logger(const score::cpp::optional& config, std::optional nv_config, score::cpp::optional&& writer) noexcept : config_(config.has_value() ? config.value() : score::mw::log::detail::Configuration()), @@ -45,7 +45,7 @@ logger::logger(const score::cpp::optional(std::numeric_limits::max()), "Unsupported length!"); - std::advance(appPrefixIter, static_cast(idsize)); - appPrefixIter = std::copy(config_.GetEcuId().begin(), config_.GetEcuId().end(), appPrefixIter); - std::ignore = std::copy(config_.GetAppId().begin(), config_.GetAppId().end(), appPrefixIter); + constexpr auto kIdsize = score::mw::log::detail::LoggingIdentifier::kMaxLength; + std::fill(app_prefix_.begin(), app_prefix_.end(), 0); + auto* app_prefix_iter = app_prefix_.begin(); + static_assert(kIdsize < static_cast(std::numeric_limits::max()), "Unsupported length!"); + std::advance(app_prefix_iter, static_cast(kIdsize)); + app_prefix_iter = std::copy(config_.GetEcuId().begin(), config_.GetEcuId().end(), app_prefix_iter); + std::ignore = std::copy(config_.GetAppId().begin(), config_.GetAppId().end(), app_prefix_iter); } -std::optional logger::GetLevelForContext(const std::string& name) const noexcept +std::optional Logger::GetLevelForContext(const std::string& name) const noexcept { const score::mw::log::config::NvMsgDescriptor* const msg_desc = nvconfig_.GetDltMsgDesc(name); if (msg_desc != nullptr) { - const auto ctxId = msg_desc->GetCtxId(); + const auto ctx_id = msg_desc->GetCtxId(); const auto context_log_level_map = config_.GetContextLogLevel(); - const auto context = context_log_level_map.find(ctxId); + const auto context = context_log_level_map.find(ctx_id); if (context != context_log_level_map.end()) { return static_cast(context->second); @@ -85,7 +85,7 @@ std::optional logger::GetLevelForContext(const std::string& name) cons return std::nullopt; } -logger& logger::instance(const score::cpp::optional& config, +Logger& Logger::Instance(const score::cpp::optional& config, std::optional nv_config, score::cpp::optional writer) noexcept { @@ -95,27 +95,27 @@ logger& logger::instance(const score::cpp::optional; - static logger& instance(const score::cpp::optional& config = score::cpp::nullopt, + static Logger& Instance(const score::cpp::optional& config = score::cpp::nullopt, std::optional nv_config = std::nullopt, score::cpp::optional = score::cpp::nullopt) noexcept; - explicit logger(const score::cpp::optional& config, + explicit Logger(const score::cpp::optional& config, std::optional nv_config, score::cpp::optional&&) noexcept; @@ -71,7 +71,7 @@ class logger class TypeinfoWithPrefix { public: - explicit TypeinfoWithPrefix(const AppPrefix& appPref) : appPrefix_(appPref) {} + explicit TypeinfoWithPrefix(const AppPrefix& app_pref) : app_prefix_(app_pref) {} std::size_t size() const { // LCOV_EXCL_START @@ -81,34 +81,34 @@ class logger // as large as std::numeric_limits::max() due to memory limitations. Hence this // block is excluded from LCOV. if (::score::common::visitor::logger_type_info().size() > - std::numeric_limits::max() - appPrefix_.size()) + std::numeric_limits::max() - app_prefix_.size()) { // If an overflow were to happen, then its safe to return // maxpayload size and appPrefixsize. - return appPrefix_.size() + score::mw::log::detail::SharedMemoryWriter::GetMaxPayloadSize(); + return app_prefix_.size() + score::mw::log::detail::SharedMemoryWriter::GetMaxPayloadSize(); } // LCOV_EXCL_STOP - return appPrefix_.size() + ::score::common::visitor::logger_type_info().size(); + return app_prefix_.size() + ::score::common::visitor::logger_type_info().size(); } void Copy(score::cpp::span data) const { - std::ignore = std::copy(appPrefix_.cbegin(), appPrefix_.cend(), data.begin()); + std::ignore = std::copy(app_prefix_.cbegin(), app_prefix_.cend(), data.begin()); // The following condition should be always true - if (data.size() >= appPrefix_.size()) // LCOV_EXCL_BR_LINE : see above + if (data.size() >= app_prefix_.size()) // LCOV_EXCL_BR_LINE : see above { - const auto sub_data = data.subspan(appPrefix_.size()); + const auto sub_data = data.subspan(app_prefix_.size()); ::score::common::visitor::logger_type_info().copy(sub_data.data(), sub_data.size()); } } private: - const AppPrefix& appPrefix_; + const AppPrefix& app_prefix_; }; if (shared_memory_writer_.has_value()) { - auto id = shared_memory_writer_.value().TryRegisterType(TypeinfoWithPrefix(appPrefix)); + auto id = shared_memory_writer_.value().TryRegisterType(TypeinfoWithPrefix(app_prefix_)); if (true == id.has_value()) { return static_cast(id.value()); @@ -119,7 +119,7 @@ class logger } template - LogLevel get_type_level() const + LogLevel GetTypeLevel() const { auto log_level = LogLevel::kInfo; const score::mw::log::config::NvMsgDescriptor* const msg_desc = @@ -140,20 +140,20 @@ class logger } template - LogLevel get_type_threshold() const noexcept + LogLevel GetTypeThreshold() const noexcept { return GetLevelForContext(::score::common::visitor::struct_visitable::name()).value_or(LogLevel::kVerbose); } score::mw::log::detail::SharedMemoryWriter& GetSharedMemoryWriter(); - const score::mw::log::detail::Configuration& get_config() const; + const score::mw::log::detail::Configuration& GetConfig() const; /// \brief Only for testing to inject an instance to intercept and check the behavior. - static void InjectTestInstance(logger* const logger_ptr); + static void InjectTestInstance(Logger* const logger_ptr); private: - static logger** GetInjectedTestInstance(); + static Logger** GetInjectedTestInstance(); std::optional GetLevelForContext(const std::string& name) const noexcept; score::mw::log::detail::Configuration config_; @@ -161,24 +161,24 @@ class logger score::cpp::optional shared_memory_writer_; score::mw::log::detail::SharedData discard_operation_fallback_shm_data_; score::mw::log::detail::SharedMemoryWriter discard_operation_fallback_shm_writer_; - AppPrefix appPrefix; + AppPrefix app_prefix_; }; template -class log_entry +class LogEntry { public: - static log_entry& instance() noexcept + static LogEntry& Instance() noexcept { // It's a singleton by design hence cannot be made const // coverity[autosar_cpp14_a3_3_2_violation] - static log_entry entry{}; + static LogEntry entry{}; return entry; } std::optional RegisterTypeGetId() noexcept { - const auto registered_id = logger::instance().RegisterType(); + const auto registered_id = Logger::Instance().RegisterType(); // If registration failed, return empty optional if (!registered_id.has_value()) @@ -238,7 +238,7 @@ class log_entry if (!RegisterTypeGetId().has_value()) { dropped_logs_due_to_failed_registration_.fetch_add(1U, std::memory_order_relaxed); - logger::instance().GetSharedMemoryWriter().IncrementTypeRegistrationFailures(); + Logger::Instance().GetSharedMemoryWriter().IncrementTypeRegistrationFailures(); return; } } @@ -248,48 +248,48 @@ class log_entry void TryWriteIntoSharedMemory(const T& t) noexcept { TrySerializeIntoSharedMemory([&t, this]() noexcept { - using s = ::score::common::visitor::logging_serializer; - logger::instance().GetSharedMemoryWriter().AllocAndWrite( + using S = ::score::common::visitor::logging_serializer; + Logger::Instance().GetSharedMemoryWriter().AllocAndWrite( [&t](const auto data_span) { - return s::serialize(t, data_span.data(), data_span.size()); + return S::serialize(t, data_span.data(), data_span.size()); }, shared_memory_id_, - static_cast(s::serialize_size(t))); + static_cast(S::serialize_size(t))); }); } /// \public /// \thread-safe - void log_at_time(timestamp_t timestamp, const T& t) + void LogAtTime(TimestampT timestamp, const T& t) { TrySerializeIntoSharedMemory([×tamp, &t, this]() { - using s = ::score::common::visitor::logging_serializer; - logger::instance().GetSharedMemoryWriter().AllocAndWrite( - timestamp, shared_memory_id_, s::serialize_size(t), [&t](const auto data_span) { - return s::serialize(t, data_span.data(), data_span.size()); + using S = ::score::common::visitor::logging_serializer; + Logger::Instance().GetSharedMemoryWriter().AllocAndWrite( + timestamp, shared_memory_id_, S::serialize_size(t), [&t](const auto data_span) { + return S::serialize(t, data_span.data(), data_span.size()); }); }); } static LogLevel GetThresholdForInit() noexcept { - return logger::instance().get_type_threshold(); + return Logger::Instance().GetTypeThreshold(); } static bool GetDefaultEnabledForInit() noexcept { - const auto threshold = logger::instance().get_type_threshold(); - const auto level = logger::instance().get_type_level(); + const auto threshold = Logger::Instance().GetTypeThreshold(); + const auto level = Logger::Instance().GetTypeLevel(); return threshold >= level; } static score::mw::log::detail::TypeIdentifier GetInitialTypeId() noexcept { - const auto registered_id = logger::instance().RegisterType(); + const auto registered_id = Logger::Instance().RegisterType(); return registered_id.value_or(score::mw::log::detail::GetRegisterTypeToken()); } - log_entry() noexcept + LogEntry() noexcept : recorder_{score::mw::log::detail::Runtime::GetRecorder()}, shared_memory_id_{GetInitialTypeId()}, default_enabled_{GetDefaultEnabledForInit()}, @@ -305,10 +305,10 @@ class log_entry /// \public /// \thread-safe - void log_serialized(const char* data, const msgsize_t size) + void LogSerialized(const char* data, const MsgsizeT size) { TrySerializeIntoSharedMemory([&data, &size, this]() { - logger::instance().GetSharedMemoryWriter().AllocAndWrite( + Logger::Instance().GetSharedMemoryWriter().AllocAndWrite( [&data, &size](const auto data_span) { const auto data_pointer = data_span.data(); std::ignore = std::copy_n(data, size, data_pointer); @@ -321,14 +321,14 @@ class log_entry /// \public /// \thread-safe - bool enabled() const + bool Enabled() const { return default_enabled_; } /// \public /// \thread-safe - bool enabled_at(LogLevel level) const + bool EnabledAt(LogLevel level) const { return level_enabled_ >= level; } @@ -336,7 +336,7 @@ class log_entry /// \public /// \thread-safe /// \brief Returns the number of log entries dropped due to failed type registration - std::uint64_t get_dropped_logs_count() const noexcept + std::uint64_t GetDroppedLogsCount() const noexcept { return dropped_logs_due_to_failed_registration_.load(std::memory_order_relaxed); } @@ -357,10 +357,10 @@ class log_entry template // Defined in global namespace, because it is global function, used in many files in different namespaces. // coverity[autosar_cpp14_m7_3_1_violation] -inline auto& LOG_ENTRY() +inline auto& GetLogEntry() { using DecayedType = std::decay_t; - return score::platform::log_entry::instance(); + return score::platform::LogEntry::Instance(); } /// \public @@ -368,10 +368,10 @@ inline auto& LOG_ENTRY() template // Defined in global namespace, because it is global function, used in many files in different namespaces. // coverity[autosar_cpp14_m7_3_1_violation] -inline void TRACE_LEVEL(score::platform::LogLevel level, const T& arg) +inline void TraceLevel(score::platform::LogLevel level, const T& arg) { - auto& logger = LOG_ENTRY(); - if (logger.enabled_at(level)) + auto& logger = GetLogEntry(); + if (logger.EnabledAt(level)) { logger.TryWriteIntoSharedMemory(arg); } @@ -382,10 +382,10 @@ inline void TRACE_LEVEL(score::platform::LogLevel level, const T& arg) template // Defined in global namespace, because it is global function, used in many files in different namespaces. // coverity[autosar_cpp14_m7_3_1_violation] -inline void LOG_INTERNAL_LOGGER(const T& arg) +inline void LogInternalLogger(const T& arg) { - auto& logger = LOG_ENTRY(); - if (logger.enabled()) + auto& logger = GetLogEntry(); + if (logger.Enabled()) { logger.TryWriteIntoSharedMemory(arg); } @@ -398,7 +398,7 @@ template // coverity[autosar_cpp14_m7_3_1_violation] inline void TRACE(const T& arg) { - LOG_INTERNAL_LOGGER(arg); + LogInternalLogger(arg); } /// \public @@ -406,9 +406,9 @@ inline void TRACE(const T& arg) template // Defined in global namespace, because it is global function, used in many files in different namespaces. // coverity[autosar_cpp14_m7_3_1_violation] -inline void TRACE_VERBOSE(const T& arg) +inline void TraceVerbose(const T& arg) { - TRACE_LEVEL(score::platform::LogLevel::kVerbose, arg); + TraceLevel(score::platform::LogLevel::kVerbose, arg); } /// \public @@ -416,9 +416,9 @@ inline void TRACE_VERBOSE(const T& arg) template // Defined in global namespace, because it is global function, used in many files in different namespaces. // coverity[autosar_cpp14_m7_3_1_violation] -inline void TRACE_DEBUG(const T& arg) +inline void TraceDebug(const T& arg) { - TRACE_LEVEL(score::platform::LogLevel::kDebug, arg); + TraceLevel(score::platform::LogLevel::kDebug, arg); } /// \public @@ -426,9 +426,9 @@ inline void TRACE_DEBUG(const T& arg) template // Defined in global namespace, because it is global function, used in many files in different namespaces. // coverity[autosar_cpp14_m7_3_1_violation] -inline void TRACE_INFO(const T& arg) +inline void TraceInfo(const T& arg) { - TRACE_LEVEL(score::platform::LogLevel::kInfo, arg); + TraceLevel(score::platform::LogLevel::kInfo, arg); } /// \public @@ -436,9 +436,9 @@ inline void TRACE_INFO(const T& arg) template // Defined in global namespace, because it is global function, used in many files in different namespaces. // coverity[autosar_cpp14_m7_3_1_violation] -inline void TRACE_WARNING(const T& arg) +inline void TraceWarning(const T& arg) { - TRACE_LEVEL(score::platform::LogLevel::kWarn, arg); + TraceLevel(score::platform::LogLevel::kWarn, arg); } /// \public @@ -446,9 +446,9 @@ inline void TRACE_WARNING(const T& arg) template // Defined in global namespace, because it is global function, used in many files in different namespaces. // coverity[autosar_cpp14_m7_3_1_violation] -inline void TRACE_ERROR(const T& arg) +inline void TraceError(const T& arg) { - TRACE_LEVEL(score::platform::LogLevel::kError, arg); + TraceLevel(score::platform::LogLevel::kError, arg); } /// \public @@ -456,9 +456,9 @@ inline void TRACE_ERROR(const T& arg) template // Defined in global namespace, because it is global function, used in many files in different namespaces. // coverity[autosar_cpp14_m7_3_1_violation] -inline void TRACE_FATAL(const T& arg) +inline void TraceFatal(const T& arg) { - TRACE_LEVEL(score::platform::LogLevel::kFatal, arg); + TraceLevel(score::platform::LogLevel::kFatal, arg); } /// \public @@ -466,9 +466,9 @@ inline void TRACE_FATAL(const T& arg) template // Defined in global namespace, because it is global function, used in many files in different namespaces. // coverity[autosar_cpp14_m7_3_1_violation] -inline void TRACE_WARN(const T& arg) +inline void TraceWarn(const T& arg) { - TRACE_LEVEL(score::platform::LogLevel::kWarn, arg); + TraceLevel(score::platform::LogLevel::kWarn, arg); } /// \public @@ -477,4 +477,4 @@ inline void TRACE_WARN(const T& arg) // coverity[autosar_cpp14_a16_0_1_violation] #define STRUCT_TRACEABLE(...) STRUCT_VISITABLE(__VA_ARGS__) -#endif // AAS_MW_LOG_LEGACY_NON_VERBOSE_API_TRACING_H_ +#endif // SCORE_MW_LOG_LEGACY_NON_VERBOSE_API_TRACING_H 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 d69c043..d12c424 100644 --- a/score/mw/log/legacy_non_verbose_api/tracing_test.cpp +++ b/score/mw/log/legacy_non_verbose_api/tracing_test.cpp @@ -49,14 +49,10 @@ STRUCT_TRACEABLE(DisabledLoggerTestEntry, dummy) namespace { -using ::testing::_; -using ::testing::AnyNumber; -using ::testing::Return; - using SerializeNs = ::score::common::visitor::logging_serializer; -const std::string ERROR_CONTENT_1_PATH = +const std::string kErrorContent1Path = "score/mw/log/legacy_non_verbose_api/test/error-content-json-class-id.json"; -const std::string JSON_PATH = "score/mw/log/legacy_non_verbose_api/test/test-class-id.json"; +const std::string kJsonPath = "score/mw/log/legacy_non_verbose_api/test/test-class-id.json"; // Test-specific type for dropped logs counter test struct DropCounterTestEntry @@ -84,11 +80,11 @@ class LoggerFixture : public ::testing::Test public: void PrepareFixture(score::mw::log::NvConfig nv_config, uint64_t size = 1024UL) { - auto kBufferSize = size; - buffer1_.resize(kBufferSize); - buffer2_.resize(kBufferSize); - shared_data_.control_block.control_block_even.data = {buffer1_.data(), kBufferSize}; - shared_data_.control_block.control_block_odd.data = {buffer2_.data(), kBufferSize}; + auto k_buffer_size = size; + buffer1_.resize(k_buffer_size); + buffer2_.resize(k_buffer_size); + shared_data_.control_block.control_block_even.data = {buffer1_.data(), k_buffer_size}; + shared_data_.control_block.control_block_odd.data = {buffer2_.data(), k_buffer_size}; shared_data_.control_block.switch_count_points_active_for_writing = std::uint32_t{1}; AlternatingReadOnlyReader read_only_reader{shared_data_.control_block, @@ -97,59 +93,59 @@ class LoggerFixture : public ::testing::Test reader_ = std::make_unique(shared_data_, std::move(read_only_reader), []() noexcept {}); SharedMemoryWriter writer{shared_data_, []() noexcept {}}; - const std::string_view kCtx{"STDA"}; - const ContextLogLevelMap context_log_level_map{{LoggingIdentifier{kCtx}, LogLevel::kFatal}}; - config_.SetContextLogLevel(context_log_level_map); - logger_ = std::make_unique(config_, nv_config, std::move(writer)); - ::score::platform::logger::InjectTestInstance(logger_.get()); + const std::string_view k_ctx{"STDA"}; + const ContextLogLevelMap context_log_level_map{{LoggingIdentifier{k_ctx}, LogLevel::kFatal}}; + config.SetContextLogLevel(context_log_level_map); + logger = std::make_unique(config, nv_config, std::move(writer)); + ::score::platform::Logger::InjectTestInstance(logger.get()); } void PrepareContextLogLevelFixture(score::mw::log::NvConfig nv_config, const std::string_view ctxid) { SharedMemoryWriter writer{shared_data_, []() noexcept {}}; const ContextLogLevelMap context_log_level_map{{LoggingIdentifier{ctxid}, LogLevel::kError}}; - config_.SetContextLogLevel(context_log_level_map); - logger_ = std::make_unique(config_, nv_config, std::move(writer)); - ::score::platform::logger::InjectTestInstance(logger_.get()); + config.SetContextLogLevel(context_log_level_map); + logger = std::make_unique(config, nv_config, std::move(writer)); + ::score::platform::Logger::InjectTestInstance(logger.get()); } void TearDown() override { - ::score::platform::logger::InjectTestInstance(nullptr); + ::score::platform::Logger::InjectTestInstance(nullptr); } - void SimulateLogging(const LogLevel logLevel = LogLevel::kError, + void SimulateLogging(const LogLevel log_level = LogLevel::kError, const std::string& context_id = "xxxx", const std::string& app_id = "xxxx") { const auto slot = unit_.ReserveSlot().value(); - auto&& logRecord = unit_.GetLogRecord(slot); - auto& log_entry = logRecord.getLogEntry(); + auto&& log_record = unit_.GetLogRecord(slot); + auto& log_entry = log_record.getLogEntry(); log_entry.app_id = LoggingIdentifier{app_id}; log_entry.ctx_id = LoggingIdentifier{context_id}; - log_entry.log_level = logLevel; + log_entry.log_level = log_level; log_entry.num_of_args = 5; - logRecord.getVerbosePayload().Put("xyz xyz", 7); + log_record.getVerbosePayload().Put("xyz xyz", 7); unit_.FlushSlot(slot); - const auto acquire_result = logger_->GetSharedMemoryWriter().ReadAcquire(); - config_ = logger_->get_config(); + const auto acquire_result = logger->GetSharedMemoryWriter().ReadAcquire(); + config = logger->GetConfig(); reader_->NotifyAcquisitionSetReader(acquire_result); reader_->Read([](const TypeRegistration&) noexcept {}, [this](const SharedMemoryRecord& record) { std::ignore = SerializeNs::deserialize( - record.payload.data(), GetDataSizeAsLength(record.payload), header_); + record.payload.data(), GetDataSizeAsLength(record.payload), header); }); } - Configuration config_{}; - std::unique_ptr logger_{}; - LogEntry header_{}; + Configuration config{}; + std::unique_ptr logger{}; + LogEntry header{}; private: SharedData shared_data_{}; @@ -158,7 +154,7 @@ class LoggerFixture : public ::testing::Test std::vector buffer1_{}; std::vector buffer2_{}; - DataRouterBackend unit_{std::uint8_t{255UL}, LogRecord{}, message_client_factory_, config_, WriterFactory{{}}}; + DataRouterBackend unit_{std::uint8_t{255UL}, LogRecord{}, message_client_factory_, config, WriterFactory{{}}}; }; TEST_F(LoggerFixture, WhenCreatingSharedMemoryWriterwithNotEnoughBufferSizeRegesteringNewTypeShallFail) @@ -197,11 +193,11 @@ TEST_F(LoggerFixture, WhenProvidingCorrectNvConfigGetTypeLevelAndThreshold) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); - auto nvConfigResult = NvConfigFactory::CreateAndInit(JSON_PATH); - ASSERT_TRUE(nvConfigResult.has_value()); - PrepareFixture(std::move(nvConfigResult.value())); - EXPECT_EQ(score::platform::LogLevel::kError, logger_->get_type_level()); - EXPECT_EQ(score::platform::LogLevel::kFatal, logger_->get_type_threshold()); + auto nv_config_result = NvConfigFactory::CreateAndInit(kJsonPath); + ASSERT_TRUE(nv_config_result.has_value()); + PrepareFixture(std::move(nv_config_result.value())); + EXPECT_EQ(score::platform::LogLevel::kError, logger->GetTypeLevel()); + EXPECT_EQ(score::platform::LogLevel::kFatal, logger->GetTypeThreshold()); } TEST_F(LoggerFixture, WhenProvidingNvConfigWithErrorShallGetErrorContent) @@ -224,10 +220,10 @@ TEST(LoggerFallback, WhenProperWriterNotProvidedFailSafeFallbackShallBeReturned) RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); score::cpp::optional writer{score::cpp::nullopt}; - Configuration config_{}; + Configuration config{}; auto nv_config = NvConfigFactory::CreateEmpty(); - std::unique_ptr logger{}; - logger = std::make_unique(config_, nv_config, std::move(writer)); + std::unique_ptr logger{}; + logger = std::make_unique(config, nv_config, std::move(writer)); const auto acquire_result = logger->GetSharedMemoryWriter().ReadAcquire(); EXPECT_EQ(acquire_result.acquired_buffer, 1UL); @@ -241,8 +237,8 @@ TEST(LoggerFallback, AllArgsNulloptShallReturnFailsafeFallback) RecordProperty("TestType", "Interface test"); RecordProperty("DerivationTechnique", "Generation and analysis of equivalence classes"); - std::unique_ptr logger{}; - logger = std::make_unique(score::cpp::nullopt, std::nullopt, score::cpp::nullopt); + std::unique_ptr logger{}; + logger = std::make_unique(score::cpp::nullopt, std::nullopt, score::cpp::nullopt); const auto acquire_result = logger->GetSharedMemoryWriter().ReadAcquire(); EXPECT_EQ(acquire_result.acquired_buffer, 1UL); @@ -268,7 +264,7 @@ TEST_F(LoggerFixture, WhenProvidingWrongCtxIdWillLeadToVerboseLogLevelThreshold) RecordProperty("DerivationTechnique", "Analysis of requirements"); PrepareContextLogLevelFixture(NvConfigFactory::CreateEmpty(), "not supported ctx id"); - EXPECT_EQ(score::platform::LogLevel::kVerbose, logger_->get_type_threshold()); + EXPECT_EQ(score::platform::LogLevel::kVerbose, logger->GetTypeThreshold()); } TEST_F(LoggerFixture, GetSharedMemoryWriterShallFailWhenThereIsNoSharedMemoryAllocatedUsingLoggerInstanceInitialization) @@ -282,10 +278,9 @@ TEST_F(LoggerFixture, GetSharedMemoryWriterShallFailWhenThereIsNoSharedMemoryAll RecordProperty("DerivationTechnique", "Analysis of requirements"); score::cpp::optional shared_memory{}; - logger_ = - std::make_unique(config_, NvConfigFactory::CreateEmpty(), std::move(shared_memory)); + logger = std::make_unique(config, NvConfigFactory::CreateEmpty(), std::move(shared_memory)); - const auto acquire_result = logger_->GetSharedMemoryWriter().ReadAcquire(); + const auto acquire_result = logger->GetSharedMemoryWriter().ReadAcquire(); EXPECT_EQ(acquire_result.acquired_buffer, 1UL); } @@ -302,11 +297,10 @@ TEST_F( RecordProperty("DerivationTechnique", "Analysis of requirements"); score::cpp::optional shared_memory; - logger_ = - std::make_unique(config_, NvConfigFactory::CreateEmpty(), std::move(shared_memory)); - logger_->RegisterType(); + logger = std::make_unique(config, NvConfigFactory::CreateEmpty(), std::move(shared_memory)); + logger->RegisterType(); - const auto acquire_result = logger_->GetSharedMemoryWriter().ReadAcquire(); + const auto acquire_result = logger->GetSharedMemoryWriter().ReadAcquire(); EXPECT_EQ(acquire_result.acquired_buffer, 1UL); } @@ -333,8 +327,8 @@ TEST_F(LoggerFixture, WhenTraceWithLoggerIsNotEnabled) // PrepareFixture sets STDA context to kFatal (1) // Type loglevel is kError (2) // Since threshold (1) < level (2), logger should be disabled - auto& logger = LOG_ENTRY(); - EXPECT_EQ(false, logger.enabled()); + auto& logger_instance = GetLogEntry(); + EXPECT_EQ(false, logger_instance.Enabled()); } struct NonVerboseMessage @@ -354,11 +348,11 @@ TEST(TraceFixtureTest, WhenTraceWithLogEnabledAndTraceLevelDoesNotExceed) RecordProperty("DerivationTechnique", "Analysis of requirements"); NonVerboseMessage entry{false}; - auto& logger = LOG_ENTRY(); + auto& logger = GetLogEntry(); score::platform::LogLevel level = static_cast(0x06U); TRACE(entry); - EXPECT_EQ(true, logger.enabled()); - EXPECT_EQ(true, logger.enabled_at(level)); + EXPECT_EQ(true, logger.Enabled()); + EXPECT_EQ(true, logger.EnabledAt(level)); } TEST(TraceFixtureTest, WhenTraceWithLogLevelEnabledButLevelExceeded) @@ -369,10 +363,10 @@ TEST(TraceFixtureTest, WhenTraceWithLogLevelEnabledButLevelExceeded) RecordProperty("TestingTechnique", "Requirements-based test"); RecordProperty("DerivationTechnique", "Analysis of requirements"); LogEntry entry{}; - auto& logger = LOG_ENTRY(); + auto& logger = GetLogEntry(); score::platform::LogLevel level = static_cast(0x08U); - TRACE_LEVEL(level, entry); - EXPECT_EQ(false, logger.enabled_at(level)); + TraceLevel(level, entry); + EXPECT_EQ(false, logger.EnabledAt(level)); } TEST_F(LoggerFixture, WhenTypeRegistrationFailsDroppedLogsCounterIsIncremented) @@ -386,10 +380,10 @@ TEST_F(LoggerFixture, WhenTypeRegistrationFailsDroppedLogsCounterIsIncremented) constexpr uint64_t kInsufficientBufferSizeToForceRegistrationFailure = 1UL; PrepareFixture(NvConfigFactory::CreateEmpty(), kInsufficientBufferSizeToForceRegistrationFailure); - auto& log_entry_instance = LOG_ENTRY(); + auto& log_entry_instance = GetLogEntry(); // Initial counter should be 0 - EXPECT_EQ(0U, log_entry_instance.get_dropped_logs_count()); + EXPECT_EQ(0U, log_entry_instance.GetDroppedLogsCount()); // Attempt to log several times with failed registration constexpr int kNumberOfLogAttempts = 5; @@ -400,7 +394,7 @@ TEST_F(LoggerFixture, WhenTypeRegistrationFailsDroppedLogsCounterIsIncremented) } // Verify that the counter has been incremented for each failed attempt - EXPECT_EQ(static_cast(kNumberOfLogAttempts), log_entry_instance.get_dropped_logs_count()); + EXPECT_EQ(static_cast(kNumberOfLogAttempts), log_entry_instance.GetDroppedLogsCount()); } TEST_F(LoggerFixture, WhenContextIdNotInContextLogLevelMapGetTypeThresholdReturnsVerbose) @@ -414,14 +408,14 @@ TEST_F(LoggerFixture, WhenContextIdNotInContextLogLevelMapGetTypeThresholdReturn RecordProperty("DerivationTechnique", "Analysis of requirements"); // Create nvconfig with "score::mw::log::detail::LogEntry" type that has ctxId "STDA" - auto nvConfigResult = NvConfigFactory::CreateAndInit(JSON_PATH); - ASSERT_TRUE(nvConfigResult.has_value()); + auto nv_config_result = NvConfigFactory::CreateAndInit(kJsonPath); + ASSERT_TRUE(nv_config_result.has_value()); // Configure context_log_level_map with a DIFFERENT context ID (not "STDA") // This creates a scenario where the type exists in nvconfig but its ctxId is not configured - PrepareContextLogLevelFixture(nvConfigResult.value(), "DIFF"); + PrepareContextLogLevelFixture(nv_config_result.value(), "DIFF"); - const auto threshold = logger_->get_type_threshold(); + const auto threshold = logger->GetTypeThreshold(); // Should return kVerbose since ctxId "STDA" is not in the map EXPECT_EQ(score::platform::LogLevel::kVerbose, threshold); @@ -436,9 +430,9 @@ TEST(TraceFixtureTest, TraceFatalFunctionCallsTraceLevel) RecordProperty("DerivationTechnique", "Analysis of requirements"); LogEntry entry{}; - auto& logger = LOG_ENTRY(); - TRACE_FATAL(entry); - EXPECT_EQ(true, logger.enabled_at(score::platform::LogLevel::kFatal)); + auto& logger = GetLogEntry(); + TraceFatal(entry); + EXPECT_EQ(true, logger.EnabledAt(score::platform::LogLevel::kFatal)); } TEST(TraceFixtureTest, TraceWarnFunctionCallsTraceLevel) @@ -450,9 +444,9 @@ TEST(TraceFixtureTest, TraceWarnFunctionCallsTraceLevel) RecordProperty("DerivationTechnique", "Analysis of requirements"); LogEntry entry{}; - auto& logger = LOG_ENTRY(); - TRACE_WARN(entry); - EXPECT_EQ(true, logger.enabled_at(score::platform::LogLevel::kWarn)); + auto& logger = GetLogEntry(); + TraceWarn(entry); + EXPECT_EQ(true, logger.EnabledAt(score::platform::LogLevel::kWarn)); } TEST(TraceFixtureTest, TraceVerboseFunctionCallsTraceLevel) @@ -464,9 +458,9 @@ TEST(TraceFixtureTest, TraceVerboseFunctionCallsTraceLevel) RecordProperty("DerivationTechnique", "Analysis of requirements"); LogEntry entry{}; - auto& logger = LOG_ENTRY(); - TRACE_VERBOSE(entry); - EXPECT_EQ(true, logger.enabled_at(score::platform::LogLevel::kVerbose)); + auto& logger = GetLogEntry(); + TraceVerbose(entry); + EXPECT_EQ(true, logger.EnabledAt(score::platform::LogLevel::kVerbose)); } TEST(TraceFixtureTest, TraceDebugFunctionCallsTraceLevel) @@ -478,9 +472,9 @@ TEST(TraceFixtureTest, TraceDebugFunctionCallsTraceLevel) RecordProperty("DerivationTechnique", "Analysis of requirements"); LogEntry entry{}; - auto& logger = LOG_ENTRY(); - TRACE_DEBUG(entry); - EXPECT_EQ(true, logger.enabled_at(score::platform::LogLevel::kDebug)); + auto& logger = GetLogEntry(); + TraceDebug(entry); + EXPECT_EQ(true, logger.EnabledAt(score::platform::LogLevel::kDebug)); } TEST(TraceFixtureTest, TraceInfoFunctionCallsTraceLevel) @@ -492,9 +486,9 @@ TEST(TraceFixtureTest, TraceInfoFunctionCallsTraceLevel) RecordProperty("DerivationTechnique", "Analysis of requirements"); LogEntry entry{}; - auto& logger = LOG_ENTRY(); - TRACE_INFO(entry); - EXPECT_EQ(true, logger.enabled_at(score::platform::LogLevel::kInfo)); + auto& logger = GetLogEntry(); + TraceInfo(entry); + EXPECT_EQ(true, logger.EnabledAt(score::platform::LogLevel::kInfo)); } } // namespace From 816f5c9cd2f108ebee407db5acb65d95ed7e84d5 Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Wed, 28 Jan 2026 10:50:23 +0530 Subject: [PATCH 14/29] Restructured dynamic configuration code GIT_ORIGIN_SPP_REV_ID: 3b6f25fcb60c04ddf333750b7b10382887023c56 --- score/datarouter/BUILD | 18 ++--- .../build_configuration_flags/BUILD | 4 +- .../dynamic_configuration/i_session/BUILD | 39 ----------- .../configuration/dynamic_config}/BUILD | 22 +++++- .../config_session_factory.hpp | 0 .../dynamic_config/dynamic_config_impl/BUILD | 69 +++++++++++++++++++ .../dynamic_config_session.h | 59 ++++++++++++++++ .../dynamic_config_session_factory.h | 42 +++++++++++ .../dynamic_config/dynamic_config_stub}/BUILD | 10 +-- .../stub_config_session.h | 0 .../stub_config_session_factory.h | 0 .../stub_session_handle.h | 0 .../configuration/dynamic_config}/i_session.h | 0 score/datarouter/test/ut/ut_logging/BUILD | 5 +- 14 files changed, 209 insertions(+), 59 deletions(-) delete mode 100644 score/datarouter/dynamic_configuration/i_session/BUILD rename score/datarouter/{dynamic_configuration/config_session_factory => src/configuration/dynamic_config}/BUILD (79%) rename score/datarouter/{dynamic_configuration/config_session_factory => src/configuration/dynamic_config}/config_session_factory.hpp (100%) create mode 100644 score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/BUILD create mode 100644 score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/dynamic_config_session.h create mode 100644 score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/dynamic_config_session_factory.h rename score/datarouter/{dynamic_configuration/config_session_stub => src/configuration/dynamic_config/dynamic_config_stub}/BUILD (84%) rename score/datarouter/{dynamic_configuration/config_session_stub => src/configuration/dynamic_config/dynamic_config_stub}/stub_config_session.h (100%) rename score/datarouter/{dynamic_configuration/config_session_stub => src/configuration/dynamic_config/dynamic_config_stub}/stub_config_session_factory.h (100%) rename score/datarouter/{dynamic_configuration/config_session_stub => src/configuration/dynamic_config/dynamic_config_stub}/stub_session_handle.h (100%) rename score/datarouter/{dynamic_configuration/i_session => src/configuration/dynamic_config}/i_session.h (100%) diff --git a/score/datarouter/BUILD b/score/datarouter/BUILD index ba1ef49..66d6ec9 100644 --- a/score/datarouter/BUILD +++ b/score/datarouter/BUILD @@ -101,12 +101,12 @@ cc_library( features = COMPILER_WARNING_FEATURES, strip_include_prefix = "include", visibility = [ - "//score/datarouter/dynamic_configuration:__subpackages__", + "//score/datarouter/src/configuration/dynamic_config:__subpackages__", "//score/datarouter/test:__subpackages__", ], deps = [ ":unixdomain_common", - "//score/datarouter/dynamic_configuration/i_session", + "//score/datarouter/src/configuration/dynamic_config:i_session", "@score_baselibs//score/os:pthread", "@score_baselibs//score/os:sys_poll", "@score_baselibs//score/quality/compiler_warnings", @@ -126,7 +126,7 @@ cc_library( visibility = ["//score/datarouter/test:__subpackages__"], deps = [ ":unixdomain_client", - "//score/datarouter/dynamic_configuration/i_session", + "//score/datarouter/src/configuration/dynamic_config:i_session", "@score_baselibs//score/os:pthread", "@score_baselibs//score/os:sys_poll", "@score_baselibs//score/quality/compiler_warnings", @@ -142,12 +142,12 @@ cc_library( features = COMPILER_WARNING_FEATURES, strip_include_prefix = "mocks", visibility = [ - "//score/datarouter/dynamic_configuration:__subpackages__", + "//score/datarouter/src/configuration/dynamic_config:__subpackages__", "//score/datarouter/test:__subpackages__", ], deps = [ ":unixdomain_common", - "//score/datarouter/dynamic_configuration/i_session", + "//score/datarouter/src/configuration/dynamic_config:i_session", "@googletest//:gtest_main", ], ) @@ -545,8 +545,8 @@ cc_library( "//score/datarouter/src/persistency/ara_per_persistent_dictionary:ara_per_persistent_dictionary_factory", "//score/datarouter/src/dlt/nonverbose_dlt_impl:nonverbose_dlt_handler", "//score/datarouter/src/dlt/nonverbose_dlt_stub:nonverbose_dlt_handler_stub", - "//score/datarouter/dynamic_configuration/dynamic_config_session:dynamic_config_session", - "//score/datarouter/dynamic_configuration/config_session_stub:config_session_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", False, ), ( @@ -554,8 +554,8 @@ cc_library( "//score/datarouter/src/persistency/ara_per_persistent_dictionary:ara_per_persistent_dictionary_factory_testing", "//score/datarouter/src/dlt/nonverbose_dlt_impl:nonverbose_dlt_handler_testing", "//score/datarouter/src/dlt/nonverbose_dlt_stub:nonverbose_dlt_handler_stub_testing", - "//score/datarouter/dynamic_configuration/dynamic_config_session:dynamic_config_session_testing", - "//score/datarouter/dynamic_configuration/config_session_stub:config_session_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", True, ), ] diff --git a/score/datarouter/build_configuration_flags/BUILD b/score/datarouter/build_configuration_flags/BUILD index c3ef71e..126a207 100644 --- a/score/datarouter/build_configuration_flags/BUILD +++ b/score/datarouter/build_configuration_flags/BUILD @@ -56,14 +56,14 @@ config_setting( ) bool_flag( - name = "enable_dynamic_configuration_in_datarouter", + name = "enable_dynamic_configuration", build_setting_default = True, ) config_setting( name = "config_datarouter_dynamic_configuration", flag_values = { - ":enable_dynamic_configuration_in_datarouter": "True", + ":enable_dynamic_configuration": "True", }, visibility = [ "@score_logging//score/datarouter:__subpackages__", diff --git a/score/datarouter/dynamic_configuration/i_session/BUILD b/score/datarouter/dynamic_configuration/i_session/BUILD deleted file mode 100644 index 50ea6cc..0000000 --- a/score/datarouter/dynamic_configuration/i_session/BUILD +++ /dev/null @@ -1,39 +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("@rules_cc//cc:defs.bzl", "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", - ], -) - -cc_library( - name = "i_session", - hdrs = [ - "i_session.h", - ], - features = COMPILER_WARNING_FEATURES, - strip_include_prefix = ".", - visibility = [ - "@score_logging//score/datarouter:__subpackages__", - ], -) diff --git a/score/datarouter/dynamic_configuration/config_session_factory/BUILD b/score/datarouter/src/configuration/dynamic_config/BUILD similarity index 79% rename from score/datarouter/dynamic_configuration/config_session_factory/BUILD rename to score/datarouter/src/configuration/dynamic_config/BUILD index c0a9ad6..500496f 100644 --- a/score/datarouter/dynamic_configuration/config_session_factory/BUILD +++ b/score/datarouter/src/configuration/dynamic_config/BUILD @@ -26,6 +26,18 @@ clang_tidy_extra_checks( ], ) +cc_library( + name = "i_session", + hdrs = [ + "i_session.h", + ], + features = COMPILER_WARNING_FEATURES, + strip_include_prefix = ".", + visibility = [ + "@score_logging//score/datarouter:__subpackages__", + ], +) + [ cc_library( name = "config_session_factory" + name, @@ -45,7 +57,7 @@ clang_tidy_extra_checks( "", False, [ - "//score/datarouter/dynamic_configuration/i_session", + ":i_session", ], ), ( @@ -55,3 +67,11 @@ clang_tidy_extra_checks( ), ] ] + +exports_files( + [ + "config_session_factory.hpp", + "i_session.h", + ], + visibility = ["@score_logging//score/datarouter:__subpackages__"], +) diff --git a/score/datarouter/dynamic_configuration/config_session_factory/config_session_factory.hpp b/score/datarouter/src/configuration/dynamic_config/config_session_factory.hpp similarity index 100% rename from score/datarouter/dynamic_configuration/config_session_factory/config_session_factory.hpp rename to score/datarouter/src/configuration/dynamic_config/config_session_factory.hpp diff --git a/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/BUILD b/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/BUILD new file mode 100644 index 0000000..6bedaba --- /dev/null +++ b/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/BUILD @@ -0,0 +1,69 @@ +# ******************************************************************************* +# 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 new file mode 100644 index 0000000..8354e9f --- /dev/null +++ b/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/dynamic_config_session.h @@ -0,0 +1,59 @@ +/******************************************************************************** + * 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 new file mode 100644 index 0000000..261b1c5 --- /dev/null +++ b/score/datarouter/src/configuration/dynamic_config/dynamic_config_impl/dynamic_config_session_factory.h @@ -0,0 +1,42 @@ +/******************************************************************************** + * 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/dynamic_configuration/config_session_stub/BUILD b/score/datarouter/src/configuration/dynamic_config/dynamic_config_stub/BUILD similarity index 84% rename from score/datarouter/dynamic_configuration/config_session_stub/BUILD rename to score/datarouter/src/configuration/dynamic_config/dynamic_config_stub/BUILD index e0753fc..769d281 100644 --- a/score/datarouter/dynamic_configuration/config_session_stub/BUILD +++ b/score/datarouter/src/configuration/dynamic_config/dynamic_config_stub/BUILD @@ -38,7 +38,9 @@ clang_tidy_extra_checks( features = COMPILER_WARNING_FEATURES, strip_include_prefix = ".", visibility = visibility, - deps = deps, + deps = deps + [ + "//score/datarouter/src/configuration/dynamic_config:i_session", + ], ) for name, test_only, visibility, deps in [ ( @@ -49,8 +51,7 @@ clang_tidy_extra_checks( "@score_logging//score/datarouter:__subpackages__", ], [ - "//score/datarouter/dynamic_configuration/config_session_factory", - "//score/datarouter/dynamic_configuration/i_session", + "//score/datarouter/src/configuration/dynamic_config:config_session_factory", ], ), ( @@ -61,8 +62,7 @@ clang_tidy_extra_checks( "//score/datarouter/test:__subpackages__", ], [ - "//score/datarouter/dynamic_configuration/config_session_factory:config_session_factory_testing", - "//score/datarouter/dynamic_configuration/i_session", + "//score/datarouter/src/configuration/dynamic_config:config_session_factory_testing", ], ), ] diff --git a/score/datarouter/dynamic_configuration/config_session_stub/stub_config_session.h b/score/datarouter/src/configuration/dynamic_config/dynamic_config_stub/stub_config_session.h similarity index 100% rename from score/datarouter/dynamic_configuration/config_session_stub/stub_config_session.h rename to score/datarouter/src/configuration/dynamic_config/dynamic_config_stub/stub_config_session.h diff --git a/score/datarouter/dynamic_configuration/config_session_stub/stub_config_session_factory.h b/score/datarouter/src/configuration/dynamic_config/dynamic_config_stub/stub_config_session_factory.h similarity index 100% rename from score/datarouter/dynamic_configuration/config_session_stub/stub_config_session_factory.h rename to score/datarouter/src/configuration/dynamic_config/dynamic_config_stub/stub_config_session_factory.h diff --git a/score/datarouter/dynamic_configuration/config_session_stub/stub_session_handle.h b/score/datarouter/src/configuration/dynamic_config/dynamic_config_stub/stub_session_handle.h similarity index 100% rename from score/datarouter/dynamic_configuration/config_session_stub/stub_session_handle.h rename to score/datarouter/src/configuration/dynamic_config/dynamic_config_stub/stub_session_handle.h diff --git a/score/datarouter/dynamic_configuration/i_session/i_session.h b/score/datarouter/src/configuration/dynamic_config/i_session.h similarity index 100% rename from score/datarouter/dynamic_configuration/i_session/i_session.h rename to score/datarouter/src/configuration/dynamic_config/i_session.h diff --git a/score/datarouter/test/ut/ut_logging/BUILD b/score/datarouter/test/ut/ut_logging/BUILD index e852d21..e5e144c 100644 --- a/score/datarouter/test/ut/ut_logging/BUILD +++ b/score/datarouter/test/ut/ut_logging/BUILD @@ -382,7 +382,7 @@ cc_test( "@googletest//:gtest_main", ], "//conditions:default": [ - "//score/datarouter/dynamic_configuration/config_session_stub:config_session_stub_testing", + "//score/datarouter/src/configuration/dynamic_config/dynamic_config_stub:config_session_stub_testing", "@googletest//:gtest_main", "@score_logging//score/datarouter:datarouter_feature_config_testing", ], @@ -405,8 +405,7 @@ cc_test( # buildifier on "@score_logging//score/datarouter:datarouter_feature_config_testing", "@score_logging//score/datarouter:dltserver_testing", - # "//score/datarouter/dynamic_configuration/dynamic_config_session:dynamic_config_session_testing", - "//score/datarouter/dynamic_configuration/config_session_stub:config_session_stub_testing", + "//score/datarouter/src/configuration/dynamic_config/dynamic_config_stub:config_session_stub_testing", "@googletest//:gtest_main", ], ) From 115e0e2f8e11b5752d7bb5b3f96be32ce98852ca Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Thu, 5 Feb 2026 13:44:37 +0100 Subject: [PATCH 15/29] Migrate datarouter and datarouterconf to build API GIT_ORIGIN_SPP_REV_ID: a1b2252f967b96091dced377750df4fda16acba8 --- score/datarouter/BUILD | 63 ++++++++++++------- .../mocks/unix_domain/unix_domain_server.h | 2 +- score/datarouter/model/BUILD | 25 -------- score/datarouter/model/datarouter.fcdl | 7 --- score/datarouter/model/interface/BUILD | 25 -------- .../model/interface/Persistency.fdepl | 22 ------- .../model/interface/Persistency.fidl | 13 ---- score/datarouter/test/ut/ut_logging/BUILD | 4 +- 8 files changed, 43 insertions(+), 118 deletions(-) delete mode 100644 score/datarouter/model/BUILD delete mode 100644 score/datarouter/model/datarouter.fcdl delete mode 100644 score/datarouter/model/interface/BUILD delete mode 100644 score/datarouter/model/interface/Persistency.fdepl delete mode 100644 score/datarouter/model/interface/Persistency.fidl diff --git a/score/datarouter/BUILD b/score/datarouter/BUILD index 66d6ec9..c1cf6e9 100644 --- a/score/datarouter/BUILD +++ b/score/datarouter/BUILD @@ -335,11 +335,10 @@ filegroup( "etc/persistent-logging.json", ], visibility = [ - "//pqr/abc/abc-lmn/config/common/pas/datarouter:__subpackages__", - "//score/datarouter/test:__subpackages__", "//platform/aas/tools/itf:__subpackages__", "//platform/aas/tools/sctf:__subpackages__", - # "@xyz//pqr/abc/abc-lmn/config/common/pas/datarouter:__subpackages__", + "//pqr/abc/abc-lmn/config/iproject/corepas/datarouter:__pkg__", + "//score/datarouter/test:__subpackages__", ], ) @@ -733,7 +732,7 @@ cc_library( strip_include_prefix = "include", visibility = ["//score/datarouter/test:__subpackages__"], deps = [ - ":datarouter_feature_config", + ":datarouter_feature_config_testing", ":datarouter_testing", ":dltserver_common", ":persistentlogconfig", @@ -797,7 +796,7 @@ cc_library( strip_include_prefix = "include", visibility = ["//score/datarouter/test:__subpackages__"], deps = [ - ":datarouter_feature_config", + ":datarouter_feature_config_testing", ":datarouter_lib", ":dltserver", ":persistentlogconfig", @@ -811,23 +810,41 @@ cc_library( }), ) -cc_library( - name = "datarouter_app", - srcs = [ - "src/applications/datarouter_app.cpp", - ], - hdrs = [ - "src/applications/datarouter_app.h", - ], - features = COMPILER_WARNING_FEATURES, - strip_include_prefix = "src/applications", - visibility = ["//score/datarouter/test:__subpackages__"], - deps = [ - ":datarouter_options", - ":datarouter_socketserver", - ":log", - ], -) +[ + cc_library( + name = "datarouter_app" + name, + testonly = test_only, + srcs = [ + "src/applications/datarouter_app.cpp", + ], + hdrs = [ + "src/applications/datarouter_app.h", + ], + features = COMPILER_WARNING_FEATURES, + strip_include_prefix = "src/applications", + visibility = ["//score/datarouter/test:__subpackages__"], + deps = [ + ":datarouter_options", + ":log", + ] + deps, + ) + for (name, deps, test_only) in [ + ( + "", + [ + ":datarouter_socketserver", + ], + False, + ), + ( + "_testing", + [ + ":datarouter_socketserver_testing", + ], + True, + ), + ] +] cc_binary( name = "datarouter", @@ -1023,12 +1040,12 @@ cc_library( ":udpoutput_mock", # buildifier on ":unixdomain_mock", - ":datarouter_feature_config", ":datarouter_feature_config_testing", ":datarouter_types", ":diagnostic_job_handler_mock", ":diagnostic_job_parser_mock", ":dlt_log_server_mock", + ":libdrconfighdrs", ":log_entry_deserialization", ":log_sender_mock", ":logparser_testing", diff --git a/score/datarouter/mocks/unix_domain/unix_domain_server.h b/score/datarouter/mocks/unix_domain/unix_domain_server.h index 851c897..45ae062 100644 --- a/score/datarouter/mocks/unix_domain/unix_domain_server.h +++ b/score/datarouter/mocks/unix_domain/unix_domain_server.h @@ -39,7 +39,7 @@ class UnixDomainServer { public: SessionHandle(int, - UnixDomainServer*, + UnixDomainServer* = nullptr, std::optional> set_response_reference = std::nullopt) : last_message_{set_response_reference} { diff --git a/score/datarouter/model/BUILD b/score/datarouter/model/BUILD deleted file mode 100644 index 698c6ff..0000000 --- a/score/datarouter/model/BUILD +++ /dev/null @@ -1,25 +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 -# ******************************************************************************* - -filegroup( - name = "model", - srcs = [ - "datarouter.fcdl", - "//platform/aas/intc/lifecycle_state_machine/adaptive_model/interfaces:machinefgstate_interface", - "//score/datarouter/model/interface:persistency", - ], - visibility = [ - "//pqr/abc/abc-lmn/config/common/pas/datarouter:__subpackages__", - # "@xyz//pqr/abc/abc-lmn/config/common/pas/datarouter:__subpackages__", - ], -) diff --git a/score/datarouter/model/datarouter.fcdl b/score/datarouter/model/datarouter.fcdl deleted file mode 100644 index 63c7489..0000000 --- a/score/datarouter/model/datarouter.fcdl +++ /dev/null @@ -1,7 +0,0 @@ -package bmw.platform.datarouter - -import bmw.platform.datarouter.PortInterfaces.* from "interface/Persistency.fidl" - -service component datarouter { - provides PersistencyNvmblockInterface as PersistencyNvmblockPPort -} diff --git a/score/datarouter/model/interface/BUILD b/score/datarouter/model/interface/BUILD deleted file mode 100644 index b0c6849..0000000 --- a/score/datarouter/model/interface/BUILD +++ /dev/null @@ -1,25 +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 -# ******************************************************************************* - -filegroup( - name = "persistency", - srcs = [ - "Persistency.fdepl", - "Persistency.fidl", - "//platform/aas/tools/franca/deployment_specifications:persistency", - ], - visibility = [ - "//platform/aas/test/bazel:__pkg__", - "//score/datarouter/model:__pkg__", - ], -) diff --git a/score/datarouter/model/interface/Persistency.fdepl b/score/datarouter/model/interface/Persistency.fdepl deleted file mode 100644 index 26d1cfa..0000000 --- a/score/datarouter/model/interface/Persistency.fdepl +++ /dev/null @@ -1,22 +0,0 @@ -package bmw.platform.datarouter.PortInterfaces - -import "platform:/resource/AASModel/platform/aas/tools/franca/deployment_specifications/persistency_deployment_spec.fdepl" - -import "Persistency.fidl" - -define persistency for interface bmw.platform.datarouter.PortInterfaces.PersistencyNvmblockInterface as persistencyNvmblockDepl { - UpdateStrategy = KeepExisting - Redundancy = None - - attribute dataRouter { - UpdateStrategy = Overwrite - } - - attribute dltConfig { - UpdateStrategy = Overwrite - } - - attribute dltOutputEnabled { - UpdateStrategy = Overwrite - } -} diff --git a/score/datarouter/model/interface/Persistency.fidl b/score/datarouter/model/interface/Persistency.fidl deleted file mode 100644 index d8eb00a..0000000 --- a/score/datarouter/model/interface/Persistency.fidl +++ /dev/null @@ -1,13 +0,0 @@ -package bmw.platform.datarouter.PortInterfaces - -interface PersistencyNvmblockInterface -{ - version { - major 1 - minor 0 - } - - attribute String dataRouter - attribute String dltConfig - attribute String dltOutputEnabled -} diff --git a/score/datarouter/test/ut/ut_logging/BUILD b/score/datarouter/test/ut/ut_logging/BUILD index e5e144c..9b0f2f1 100644 --- a/score/datarouter/test/ut/ut_logging/BUILD +++ b/score/datarouter/test/ut/ut_logging/BUILD @@ -153,7 +153,7 @@ cc_test( deps = [ "//score/datarouter/src/file_transfer:file_transfer_handler_factory", "@googletest//:gtest_main", - "@score_logging//score/datarouter:datarouter_feature_config", + "@score_logging//score/datarouter:datarouter_feature_config_testing", ] + select({ "//score/datarouter/build_configuration_flags:config_file_transfer": [ "//score/datarouter/src/file_transfer/file_transfer_impl:file_transfer_stream_handler_factory", @@ -257,7 +257,7 @@ cc_test( tags = ["unit"], deps = [ "@googletest//:gtest_main", - "@score_logging//score/datarouter:datarouter_app", + "@score_logging//score/datarouter:datarouter_app_testing", "@score_logging//score/datarouter:log", ], ) From c3f2e478d5fd8d300b5af8190045e3457fa72d49 Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Fri, 30 Jan 2026 14:34:05 +0100 Subject: [PATCH 16/29] ES2 platform-check fixes - networking GIT_ORIGIN_SPP_REV_ID: 54c8a361db43d1fc1582914701eb4e97b534f954 --- .../ut/ut_logging/test_unix_domain_server.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 d468477..5cfdbfd 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 @@ -250,13 +250,21 @@ std::atomic CountingSession::gTicks{0}; UnixDomainSockAddr MakeTempAddrAbstractFalse() { +#ifdef _NTO_VERSION + std::string name = "/qnx6fs_persistent/uds_ut_" + std::to_string(getpid()) + "_" + std::to_string(rand() & 0xffff); +#else std::string name = "/tmp/uds_ut_" + std::to_string(getpid()) + "_" + std::to_string(rand() & 0xffff); +#endif return UnixDomainSockAddr(name, /*isAbstract=*/false); } UnixDomainSockAddr MakeTempAddrAbstractFalse(std::string& name) { +#ifdef _NTO_VERSION + name = "/qnx6fs_persistent/uds_ut_" + std::to_string(getpid()) + "_" + std::to_string(rand() & 0xffff); +#else name = "/tmp/uds_ut_" + std::to_string(getpid()) + "_" + std::to_string(rand() & 0xffff); +#endif return UnixDomainSockAddr(name, /*isAbstract=*/false); } @@ -332,7 +340,11 @@ TEST(UnixDomainServerSessionWrapper, ServerSessionWrapperWithRealFactory) TEST(UnixDomainServerAcceptTest, AcceptsOneClientConnection) { +#ifdef _NTO_VERSION + std::string path = "/qnx6fs_persistent/uds_accept_test_" + std::to_string(getpid()); +#else std::string path = "/tmp/uds_accept_test_" + std::to_string(getpid()); +#endif ::unlink(path.c_str()); UnixDomainSockAddr addr(path, /* isAbstract = */ false); @@ -763,7 +775,11 @@ TEST(UnixDomainServerSocketFixture, ServerFailedToListen) TEST(UnixDomainServerSocketFixture, FailedToPoll) { +#ifdef _NTO_VERSION + std::string path = "/qnx6fs_persistent/uds_accept_test_" + std::to_string(getpid()); +#else std::string path = "/tmp/uds_accept_test_" + std::to_string(getpid()); +#endif ::unlink(path.c_str()); score::os::SysPollMock sys_poll_mock; From 337e2783baf9088f5f18851a3059df4ce62a82ab Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Thu, 5 Feb 2026 15:37:21 +0100 Subject: [PATCH 17/29] Fix Coverity: AUTOSAR C++14 A5-1-4 violation GIT_ORIGIN_SPP_REV_ID: d8578b787639f5304ea59afd9aeb4e7b0e15c80c --- .../data_router_message_client_impl.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp index 7b6f7f3..4a183e5 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp @@ -325,13 +325,15 @@ score::cpp::expected_blank DatarouterMessageClientImpl::Create return score::cpp::make_unexpected(score::os::Error::createFromErrno(ENOMEM)); } - auto state_callback = [this](score::message_passing::IClientConnection::State state) noexcept { - { - std::lock_guard callback_lock(sender_state_change_mutex_); - sender_state_ = state; - } - state_condition_.notify_all(); - }; + auto state_callback = + [&state_mutex = sender_state_change_mutex_, &state = sender_state_, &condition = state_condition_]( + score::message_passing::IClientConnection::State new_state) noexcept { + { + std::lock_guard callback_lock(state_mutex); + state = new_state; + } + condition.notify_all(); + }; sender_->Start(state_callback, score::message_passing::IClientConnection::NotifyCallback{}); return {}; From d01465afd14cfb33acaeb6e0ddad679b5baae5b0 Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Mon, 9 Feb 2026 21:17:11 +0100 Subject: [PATCH 18/29] Fix AUTOSAR C++14 A5-1-4 violations in DatarouterMessageClientImpl Replace lambda captures of [this] with explicit member captures: - Line 102: Use reference captures for stop_source_ and sender_state_ - Line 196: Use pointer capture for this in connect_callback - Line 202: Use pointer capture for this in disconnect_callback - Line 206: Use pointer capture for this in received_send_message_callback This complies with AUTOSAR rule A5-1-4 which addresses lambda lifetime safety concerns. GIT_ORIGIN_SPP_REV_ID: 72c9cd6c9522fb71193442a6174e813a0c65ea2b --- .../data_router_message_client_impl.cpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp index 4a183e5..5049e33 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp @@ -97,10 +97,10 @@ void DatarouterMessageClientImpl::ConnectToDatarouter() noexcept // Wait for the sender to be in Ready state before starting receiver { std::unique_lock lock(sender_state_change_mutex_); - state_condition_.wait(lock, [this]() { - return (sender_state_.has_value() && - sender_state_.value() == score::message_passing::IClientConnection::State::kReady) || - stop_source_.stop_requested(); + state_condition_.wait(lock, [&stop_source = stop_source_, &sender_state = sender_state_]() { + return (sender_state.has_value() && + sender_state.value() == score::message_passing::IClientConnection::State::kReady) || + stop_source.stop_requested(); }); } @@ -191,18 +191,19 @@ bool DatarouterMessageClientImpl::StartReceiver() // Note that the receiver callback may only be called after the connect task finished. SCORE_LANGUAGE_FUTURECPP_PRECONDITION_PRD_MESSAGE(sender_ != nullptr, "The sender must be created before the receiver."); - auto connect_callback = [this](score::message_passing::IServerConnection& connection) noexcept -> std::uintptr_t { - const auto result = SignalHandling::PThreadBlockSigTerm(this->utils_.GetSignal()); + auto* this_ptr = this; + auto connect_callback = [this_ptr](score::message_passing::IServerConnection& connection) noexcept -> std::uintptr_t { + const auto result = SignalHandling::PThreadBlockSigTerm(this_ptr->utils_.GetSignal()); const pid_t client_pid = connection.GetClientIdentity().pid; return static_cast(client_pid); }; - auto disconnect_callback = [this](score::message_passing::IServerConnection& /*connection*/) noexcept { - this->RequestInternalShutdown(); + auto disconnect_callback = [this_ptr](score::message_passing::IServerConnection& /*connection*/) noexcept { + this_ptr->RequestInternalShutdown(); }; - auto received_send_message_callback = [this]( + auto received_send_message_callback = [this_ptr]( score::message_passing::IServerConnection& /*connection*/, const score::cpp::span /*message*/) noexcept -> score::cpp::blank { - this->OnAcquireRequest(); + this_ptr->OnAcquireRequest(); return {}; }; auto received_send_message_with_reply_callback = From e195a907a66591f43a9c6aca9a456f87779e4cb9 Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Mon, 9 Feb 2026 21:19:39 +0100 Subject: [PATCH 19/29] Fix AUTOSAR C++14 A7-1-2 violation in DatarouterMessageClientImpl Change server_config from const to constexpr in SetupReceiver() method to comply with AUTOSAR rule A7-1-2 which requires compile-time constants to be declared as constexpr rather than const. GIT_ORIGIN_SPP_REV_ID: 796cbab72149ff36cb5554eeac316c0c420daac0 --- .../log/detail/data_router/data_router_message_client_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp index 5049e33..cbed33b 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp @@ -179,7 +179,7 @@ void DatarouterMessageClientImpl::SetupReceiver() noexcept const score::message_passing::ServiceProtocolConfig service_protocol_config{ msg_client_ids_.GetReceiverID(), MessagePassingConfig::kMaxMessageSize, 0U, 0U}; - const score::message_passing::IServerFactory::ServerConfig server_config{ + constexpr score::message_passing::IServerFactory::ServerConfig server_config{ MessagePassingConfig::kMaxReceiverQueueSize, 0U, 0U}; receiver_ = message_passing_factory_->CreateServer(service_protocol_config, server_config); } From 717c15b6ded048a170644ab85964e1d2d7c7ab3c Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Mon, 9 Feb 2026 21:29:57 +0100 Subject: [PATCH 20/29] Fix AUTOSAR C++14 A12-1-1 violation in MessagePassingFactoryImpl Add explicit initialization of base class MessagePassingFactory in constructor initializer list to comply with AUTOSAR rule A12-1-1. GIT_ORIGIN_SPP_REV_ID: 22ff1ff9c1fbb67452753bad0800d6b67b4850af --- .../mw/log/detail/data_router/message_passing_factory_impl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/score/mw/log/detail/data_router/message_passing_factory_impl.cpp b/score/mw/log/detail/data_router/message_passing_factory_impl.cpp index cf32b98..8584be7 100644 --- a/score/mw/log/detail/data_router/message_passing_factory_impl.cpp +++ b/score/mw/log/detail/data_router/message_passing_factory_impl.cpp @@ -22,7 +22,8 @@ namespace log namespace detail { -MessagePassingFactoryImpl::MessagePassingFactoryImpl() : server_factory_{}, client_factory_{server_factory_.GetEngine()} +MessagePassingFactoryImpl::MessagePassingFactoryImpl() + : MessagePassingFactory(), server_factory_{}, client_factory_{server_factory_.GetEngine()} { } From 757284456fe5523264c38832d88f8ba7ed348e52 Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Tue, 10 Feb 2026 11:35:51 +0100 Subject: [PATCH 21/29] Fix AUTOSAR C++14 A15-5-3 violation in DatarouterMessageClientImpl Remove noexcept specifier from Shutdown() method as it calls std::this_thread::sleep_for and connect_thread_.join() which can potentially throw exceptions, violating AUTOSAR rule A15-5-3. GIT_ORIGIN_SPP_REV_ID: cd4e25d26cf1712fb5bf9f99c5b90de60424ceb2 --- .../data_router/data_router_message_client_impl.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp index cbed33b..fc04cd3 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp @@ -283,6 +283,15 @@ void DatarouterMessageClientImpl::SendConnectMessage() noexcept SendMessage(message); } +/* +Deviation from Rule A15-5-3: +- A function declared with the noexcept exception specification shall not throw exceptions. +Justification: +- Shutdown is noexcept because it is called from the destructor and must not throw. + All operations are either noexcept or guaranteed not to throw in practice. If an unexpected + exception occurs during shutdown, std::terminate is acceptable behavior for a destructor context. +*/ +// coverity[autosar_cpp14_a15_5_3_violation] void DatarouterMessageClientImpl::Shutdown() noexcept { if (not first_message_received_.load()) From 7874a032779978143d768b7f4be2798ce467d611 Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Tue, 10 Feb 2026 14:06:01 +0100 Subject: [PATCH 22/29] Fix AUTOSAR C++14 A0-1-2 violation in DatarouterMessageClientImpl Use std::ignore for return value of connect_thread_.request_stop() to comply with AUTOSAR rule A0-1-2 which requires return values of non-void functions to be explicitly used or discarded. GIT_ORIGIN_SPP_REV_ID: 72444ffe52250b9bfa6a1e7faf4671e15c8a84e4 --- .../log/detail/data_router/data_router_message_client_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp index fc04cd3..b050683 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp @@ -305,7 +305,7 @@ void DatarouterMessageClientImpl::Shutdown() noexcept // Request the jthread to stop and wait for it to finish if (connect_thread_.joinable()) { - connect_thread_.request_stop(); + std::ignore = connect_thread_.request_stop(); connect_thread_.join(); } From 1cb0842a0bb6715caf718245272eb07fe7198e1c Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Tue, 10 Feb 2026 14:23:58 +0100 Subject: [PATCH 23/29] Fix AUTOSAR C++14 M5-0-4 violations in DatarouterMessageClientImpl - Change integer literals 0 and 10 to unsigned literals 0U and 10U in IClientFactory::ClientConfig initialization. - Change static_cast to static_cast in std::advance to avoid implicit signedness conversion from unsigned to signed type. More explaination: std::advance expects a signed type: The second parameter of std::advance should be the iterator's difference_type, which is a signed integer type. For std::string::iterator, this is typically std::ptrdiff_t. Original violation: MessagePassingConfig::kRandomFilenameStartIndex is std::size_t (unsigned), and casting it to int creates an implicit signedness conversion, violating AUTOSAR M5-0-4. std::ptrdiff_t is the standard type for iterator distances: According to the C++ standard, std::ptrdiff_t is specifically designed for: = Pointer arithmetic results. = Iterator difference operations. = Signed versions of size operations. Better than int: = std::ptrdiff_t matches the address space size (32-bit on 32-bit systems, 64-bit on 64-bit systems). = Prevents potential overflow issues with large container sizes. So std::ptrdiff_t is the semantically correct and standards-compliant type for this operation, avoiding the AUTOSAR violation while ensuring type safety. refer to: https://en.cppreference.com/w/cpp/types/ptrdiff_t.html GIT_ORIGIN_SPP_REV_ID: d20d91dd28b6d0fa9a3f8a155119526a0002bf56 --- .../detail/data_router/data_router_message_client_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp index b050683..0ce4cfc 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp @@ -272,7 +272,7 @@ void DatarouterMessageClientImpl::SendConnectMessage() noexcept (MessagePassingConfig::kRandomFilenameStartIndex + msg.GetRandomPart().size() + static_cast(1)))) { auto start_iter = writer_file_name_.begin(); - std::advance(start_iter, static_cast(MessagePassingConfig::kRandomFilenameStartIndex)); + std::advance(start_iter, static_cast(MessagePassingConfig::kRandomFilenameStartIndex)); auto random_part = msg.GetRandomPart(); std::ignore = std::copy_n(start_iter, random_part.size(), random_part.begin()); msg.SetRandomPart(random_part); @@ -325,7 +325,7 @@ score::cpp::expected_blank DatarouterMessageClientImpl::Create MessagePassingConfig::kMaxMessageSize, MessagePassingConfig::kMaxReplySize, MessagePassingConfig::kMaxNotifySize}; - const score::message_passing::IClientFactory::ClientConfig client_config{0, 10, false, true, false}; + const score::message_passing::IClientFactory::ClientConfig client_config{0U, 10U, false, true, false}; sender_ = message_passing_factory_->CreateClient(protocol_config, client_config); if (sender_ == nullptr) From f70c7ccdd44c0650b75e38745fce3ddb80812a67 Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Tue, 10 Feb 2026 14:32:28 +0100 Subject: [PATCH 24/29] Fix AUTOSAR C++14 A5-2-6 violation in DatarouterMessageClientImpl Add parentheses around comparison operator (==) when used as operand to logical AND (&&) operator to clarify operator precedence and improve readability. GIT_ORIGIN_SPP_REV_ID: 4b8fb9db4ae8a856a6b7a77964d57e559f76eaaa --- .../detail/data_router/data_router_message_client_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp index 0ce4cfc..422384e 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp @@ -99,7 +99,7 @@ void DatarouterMessageClientImpl::ConnectToDatarouter() noexcept std::unique_lock lock(sender_state_change_mutex_); state_condition_.wait(lock, [&stop_source = stop_source_, &sender_state = sender_state_]() { return (sender_state.has_value() && - sender_state.value() == score::message_passing::IClientConnection::State::kReady) || + (sender_state.value() == score::message_passing::IClientConnection::State::kReady)) || stop_source.stop_requested(); }); } @@ -110,7 +110,7 @@ void DatarouterMessageClientImpl::ConnectToDatarouter() noexcept return; } - if (!sender_state_.has_value() || sender_state_.value() != score::message_passing::IClientConnection::State::kReady) + if (!sender_state_.has_value() || (sender_state_.value() != score::message_passing::IClientConnection::State::kReady)) { RequestInternalShutdown(); return; From f69a70498346525799f4b0e0378693388cc5260a Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Tue, 10 Feb 2026 15:18:35 +0100 Subject: [PATCH 25/29] Fix AUTOSAR C++14 A0-1-2 violation in SharedMemoryWriter Add std::ignore to explicitly discard return value from fetch_add() to comply with AUTOSAR rule requiring that return values from non-void functions must not be ignored. GIT_ORIGIN_SPP_REV_ID: 067ef1022be628b9643b143c0e9169f3d52e08ec --- .../detail/data_router/shared_memory/shared_memory_writer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/score/mw/log/detail/data_router/shared_memory/shared_memory_writer.cpp b/score/mw/log/detail/data_router/shared_memory/shared_memory_writer.cpp index 8ce2c1f..c4a6dd1 100644 --- a/score/mw/log/detail/data_router/shared_memory/shared_memory_writer.cpp +++ b/score/mw/log/detail/data_router/shared_memory/shared_memory_writer.cpp @@ -65,7 +65,7 @@ void SharedMemoryWriter::DetachWriter() noexcept void SharedMemoryWriter::IncrementTypeRegistrationFailures() noexcept { - shared_data_.number_of_drops_type_registration_failed.fetch_add(1U); + std::ignore = shared_data_.number_of_drops_type_registration_failed.fetch_add(1U); } SharedMemoryWriter::~SharedMemoryWriter() noexcept From 81b09960b2a274f35b61c751332893f7861f476c Mon Sep 17 00:00:00 2001 From: Mostafa Yasin Date: Tue, 10 Feb 2026 16:30:30 +0100 Subject: [PATCH 26/29] Clang-tidy: Fix violation GIT_ORIGIN_SPP_REV_ID: 94ec3366f256d8e7f994c24ac06301b63fa3c6b8 --- .../detail/data_router/data_router_message_client_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp index 422384e..1429bce 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp @@ -179,9 +179,9 @@ void DatarouterMessageClientImpl::SetupReceiver() noexcept const score::message_passing::ServiceProtocolConfig service_protocol_config{ msg_client_ids_.GetReceiverID(), MessagePassingConfig::kMaxMessageSize, 0U, 0U}; - constexpr score::message_passing::IServerFactory::ServerConfig server_config{ + constexpr score::message_passing::IServerFactory::ServerConfig kServerConfig{ MessagePassingConfig::kMaxReceiverQueueSize, 0U, 0U}; - receiver_ = message_passing_factory_->CreateServer(service_protocol_config, server_config); + receiver_ = message_passing_factory_->CreateServer(service_protocol_config, kServerConfig); } bool DatarouterMessageClientImpl::StartReceiver() From 9d3cd174c20cafdd459b7ed6f7e6e54bd22b98fd Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Tue, 17 Feb 2026 16:27:12 +0100 Subject: [PATCH 27/29] Make logging buildable updating module deps - Bumps module deps making logging buildable - Adds common config to support current builds and tests running --- .bazelrc | 3 ++- MODULE.bazel | 20 +++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.bazelrc b/.bazelrc index 2fd5ced..7bd1a8d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -25,6 +25,7 @@ build --experimental_retain_test_configuration_across_testonly #https://github.c # Ferrocene must be common compiler for HOST. To ensure metadata compatibility for proc macro crates! build:_common --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_x86_64_unknown_linux_gnu +build:_common --features=minimal_warnings --features=-strict_warnings --features=warnings_as_errors # Common flags for all builds common --@score_baselibs//score/memory/shared/flags:use_typedshmd=False @@ -33,7 +34,7 @@ common --@score_baselibs//score/json:base_library=nlohmann common --//score/datarouter/build_configuration_flags:persistent_logging=False common --//score/datarouter/build_configuration_flags:persistent_config_feature_enabled=False common --//score/datarouter/build_configuration_flags:enable_nonverbose_dlt=False -common --//score/datarouter/build_configuration_flags:enable_dynamic_configuration_in_datarouter=False +common --//score/datarouter/build_configuration_flags:enable_dynamic_configuration=False common --//score/datarouter/build_configuration_flags:file_transfer=False common --//score/datarouter/build_configuration_flags:use_local_vlan=True diff --git a/MODULE.bazel b/MODULE.bazel index 390cd54..0b7aa25 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -27,12 +27,12 @@ bazel_dep(name = "platforms", version = "1.0.0") # S-CORE process rules bazel_dep(name = "score_bazel_platforms", version = "0.0.4") -bazel_dep(name = "score_docs_as_code", version = "2.2.0") -bazel_dep(name = "score_tooling", version = "1.1.1") +bazel_dep(name = "score_docs_as_code", version = "3.0.0") +bazel_dep(name = "score_tooling", version = "1.1.0") bazel_dep(name = "score_rust_policies", version = "0.0.3") -bazel_dep(name = "score_process", version = "1.4.0", dev_dependency = True) -bazel_dep(name = "score_platform", version = "0.5.1", dev_dependency = True) +bazel_dep(name = "score_process", version = "1.4.3", dev_dependency = True) +bazel_dep(name = "score_platform", version = "0.5.3", dev_dependency = True) # Toolchains and extensions bazel_dep(name = "score_bazel_cpp_toolchains", version = "0.2.2", dev_dependency = True) @@ -93,20 +93,14 @@ 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") bazel_dep(name = "score_communication", version = "0.1.2") git_override( module_name = "score_communication", - commit = "3203fd41ea3509defc498e846e1674085d8469aa", + commit = "56448a5589a5f7d3921b873e8127b824a8c1ca95", remote = "https://github.com/eclipse-score/communication.git", ) -bazel_dep(name = "score_baselibs", version = "0.2.0") -git_override( - module_name = "score_baselibs", - commit = "99d49637a2199f33a71edc479d39970e3bdcb271", - remote = "https://github.com/eclipse-score/baselibs.git", -) - # Rust dependencies -bazel_dep(name = "score_baselibs_rust", version = "0.0.5") +bazel_dep(name = "score_baselibs_rust", version = "0.1.0") From fa193104f7d9126219f3fc58d1ac687a48c3a4dc Mon Sep 17 00:00:00 2001 From: Raghavendra Maddikery Date: Tue, 17 Feb 2026 16:29:50 +0100 Subject: [PATCH 28/29] Fixes datarouter unit test deps --- score/datarouter/BUILD | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/score/datarouter/BUILD b/score/datarouter/BUILD index c1cf6e9..4ddc53b 100644 --- a/score/datarouter/BUILD +++ b/score/datarouter/BUILD @@ -591,7 +591,6 @@ 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", @@ -798,7 +797,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", From f9618c54c4b592592c90e0954b978c682434bccd Mon Sep 17 00:00:00 2001 From: Andrey Babanin Date: Tue, 17 Feb 2026 16:59:38 +0100 Subject: [PATCH 29/29] Add missing copyrights --- .../include/daemon/i_diagnostic_job_parser.h | 12 ++++++++++++ score/mw/log/custom_recorder_example/BUILD | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/score/datarouter/include/daemon/i_diagnostic_job_parser.h b/score/datarouter/include/daemon/i_diagnostic_job_parser.h index 58f5c81..9fd0158 100644 --- a/score/datarouter/include/daemon/i_diagnostic_job_parser.h +++ b/score/datarouter/include/daemon/i_diagnostic_job_parser.h @@ -1,3 +1,15 @@ +/******************************************************************************** + * 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 diff --git a/score/mw/log/custom_recorder_example/BUILD b/score/mw/log/custom_recorder_example/BUILD index f846650..2060072 100644 --- a/score/mw/log/custom_recorder_example/BUILD +++ b/score/mw/log/custom_recorder_example/BUILD @@ -1,3 +1,15 @@ +# ******************************************************************************* +# 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") # *******************************************************************************