diff --git a/examples/control_application/control.hpp b/examples/control_application/control.hpp index 3e379b056..8447aec73 100644 --- a/examples/control_application/control.hpp +++ b/examples/control_application/control.hpp @@ -15,11 +15,12 @@ #include -struct RunTargetInfo { +struct RunTargetInfo +{ char runTargetName[1024]{}; }; -static constexpr char const* control_socket_path = "/sm_control"; +static constexpr const char* control_socket_path = "/sm_control"; static constexpr std::size_t control_socket_capacity = 32; #endif diff --git a/examples/control_application/control_app_cli.cpp b/examples/control_application/control_app_cli.cpp index ac93161bd..9a29e3c7f 100644 --- a/examples/control_application/control_app_cli.cpp +++ b/examples/control_application/control_app_cli.cpp @@ -12,28 +12,33 @@ ********************************************************************************/ #include -#include "ipc_dropin/socket.hpp" #include "control.hpp" +#include "ipc_dropin/socket.hpp" int main(int argc, char** argv) { - if(argc <= 1) { + if (argc <= 1) + { std::cout << "Usage: " << argv[0] << " MyRunTargetName" << std::endl; return EXIT_FAILURE; } ipc_dropin::Socket(sizeof(RunTargetInfo)), control_socket_capacity> sm_control_socket{}; - if (sm_control_socket.connect(control_socket_path) != ipc_dropin::ReturnCode::kOk) { + if (sm_control_socket.connect(control_socket_path) != ipc_dropin::ReturnCode::kOk) + { std::cerr << "Could not connect to control socket" << std::endl; return EXIT_FAILURE; } RunTargetInfo info{}; std::strncpy(info.runTargetName, argv[1], sizeof(info.runTargetName) - 1); - if(ipc_dropin::ReturnCode::kOk == sm_control_socket.trySend(info)) { + if (ipc_dropin::ReturnCode::kOk == sm_control_socket.trySend(info)) + { std::cout << "Successfully sent request" << std::endl; return EXIT_SUCCESS; - } else { + } + else + { std::cerr << "Request could not be sent" << std::endl; return EXIT_FAILURE; } diff --git a/examples/control_application/control_daemon.cpp b/examples/control_application/control_daemon.cpp index 59404855c..3f55d43b8 100644 --- a/examples/control_application/control_daemon.cpp +++ b/examples/control_application/control_daemon.cpp @@ -11,29 +11,32 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ #include -#include -#include #include +#include #include +#include -#include -#include -#include "ipc_dropin/socket.hpp" #include "control.hpp" +#include "ipc_dropin/socket.hpp" +#include +#include std::atomic exitRequested{false}; -void signalHandler(int) { +void signalHandler(int) +{ exitRequested = true; } -int main(int argc, char** argv) { +int main(int argc, char** argv) +{ signal(SIGINT, signalHandler); signal(SIGTERM, signalHandler); score::mw::lifecycle::report_running(); ipc_dropin::Socket(sizeof(RunTargetInfo)), control_socket_capacity> sm_control_socket{}; - if (sm_control_socket.create(control_socket_path, 600) != ipc_dropin::ReturnCode::kOk) { + if (sm_control_socket.create(control_socket_path, 600) != ipc_dropin::ReturnCode::kOk) + { std::cerr << "Could not create control socket" << std::endl; return EXIT_FAILURE; } @@ -41,19 +44,27 @@ int main(int argc, char** argv) { score::mw::lifecycle::ControlClient client; score::safecpp::Scope<> scope{}; - while (!exitRequested) { + while (!exitRequested) + { RunTargetInfo info{}; - if (ipc_dropin::ReturnCode::kOk == sm_control_socket.tryReceive(info)) { + if (ipc_dropin::ReturnCode::kOk == sm_control_socket.tryReceive(info)) + { std::string runTargetName{info.runTargetName}; std::cout << "Activating Run Target: " << runTargetName << std::endl; client.ActivateRunTarget(runTargetName).Then({scope, [runTargetName](auto& result) noexcept { - if (!result) { - std::cerr << "Activating Run Target " << runTargetName << " failed with error: " << result.error().Message() << std::endl; - } else { - std::cout << "Activating Run Target " << runTargetName << " succeeded" << std::endl; - } - }}); + if (!result) + { + std::cerr << "Activating Run Target " << runTargetName + << " failed with error: " + << result.error().Message() << std::endl; + } + else + { + std::cout << "Activating Run Target " << runTargetName + << " succeeded" << std::endl; + } + }}); } std::this_thread::sleep_for(std::chrono::milliseconds(100)); diff --git a/examples/cpp_lifecycle_app/main.cpp b/examples/cpp_lifecycle_app/main.cpp index 4ad81a156..0679660a4 100644 --- a/examples/cpp_lifecycle_app/main.cpp +++ b/examples/cpp_lifecycle_app/main.cpp @@ -11,17 +11,17 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#include #include -#include +#include #include +#include +#include #include -#include #include #ifdef __linux__ - #include - #include +#include +#include #endif #include @@ -31,20 +31,20 @@ struct Config { std::int32_t responseTimeInMs{100}; - bool crashRequested{false}; + bool crashRequested{false}; std::int32_t crashTimeInMs{1000}; - bool failToStart{false}; - bool verbose{false}; + bool failToStart{false}; + bool verbose{false}; }; std::string helpSstring = -"Usage:\n\ + "Usage:\n\ -r Worst case response time to SIGTERM signal in milliseconds.\n\ -c Simulate crash of the application, after specified time in milliseconds.\n\ -s Simulate failure during start-up of the application.\n\ -v Run in verbose mode.\n"; -std::optional parseOptions(int argc, char *const *argv) noexcept +std::optional parseOptions(int argc, char* const* argv) noexcept { Config config{}; int c; @@ -52,34 +52,34 @@ std::optional parseOptions(int argc, char *const *argv) noexcept { switch (static_cast(c)) { - case 'r': - config.responseTimeInMs = std::stoi(optarg); - break; - - case 'c': - config.crashRequested = true; - config.crashTimeInMs = std::stoi(optarg); - break; - - case 's': - config.failToStart = true; - break; - - case 'h': - std::cout << helpSstring; - return std::nullopt; - - case 'v': - config.verbose = true; - break; - - case '?': - std::cout << "Unrecognized option: -" << static_cast(optopt) << std::endl; - std::cout << helpSstring; - return std::nullopt; - - default: - break; + case 'r': + config.responseTimeInMs = std::stoi(optarg); + break; + + case 'c': + config.crashRequested = true; + config.crashTimeInMs = std::stoi(optarg); + break; + + case 's': + config.failToStart = true; + break; + + case 'h': + std::cout << helpSstring; + return std::nullopt; + + case 'v': + config.verbose = true; + break; + + case '?': + std::cout << "Unrecognized option: -" << static_cast(optopt) << std::endl; + std::cout << helpSstring; + return std::nullopt; + + default: + break; } } return config; @@ -90,23 +90,23 @@ void set_process_name() const char* identifier = getenv("PROCESSIDENTIFIER"); if (identifier != nullptr) { - #ifdef __QNXNTO__ +#ifdef __QNXNTO__ if (pthread_setname_np(pthread_self(), identifier) != 0) { std::cerr << "Failed to set QNX thread name" << std::endl; } - #elif defined(__linux__) +#elif defined(__linux__) if (prctl(PR_SET_NAME, identifier) < 0) { std::cerr << "Failed to set process name to " << identifier << std::endl; } - #endif +#endif } } class LifecycleApp final : public score::mw::lifecycle::Application { -public: + public: std::int32_t Initialize(const score::mw::lifecycle::ApplicationContext& appCtx) override { set_process_name(); @@ -156,10 +156,8 @@ class LifecycleApp final : public score::mw::lifecycle::Application std::chrono::time_point startTime = std::chrono::steady_clock::now(); std::chrono::duration runTime; - timespec req{ - static_cast(m_config.responseTimeInMs / 1000), - static_cast((m_config.responseTimeInMs % 1000) * 1000000L) - }; + timespec req{static_cast(m_config.responseTimeInMs / 1000), + static_cast((m_config.responseTimeInMs % 1000) * 1000000L)}; auto timeLastVerboseLog = std::chrono::steady_clock::now(); @@ -174,10 +172,8 @@ class LifecycleApp final : public score::mw::lifecycle::Application { if (timeTillCrash > 0) { - timespec crash_req{ - static_cast(timeTillCrash / 1000), - static_cast((timeTillCrash % 1000) * 1000000L) - }; + timespec crash_req{static_cast(timeTillCrash / 1000), + static_cast((timeTillCrash % 1000) * 1000000L)}; nanosleep(&crash_req, nullptr); } @@ -201,7 +197,7 @@ class LifecycleApp final : public score::mw::lifecycle::Application return EXIT_SUCCESS; } -private: + private: Config m_config{}; std::vector m_argvStorage{}; }; diff --git a/examples/cpp_supervised_app/main.cpp b/examples/cpp_supervised_app/main.cpp index f6705e65c..6cd7d2e1f 100644 --- a/examples/cpp_supervised_app/main.cpp +++ b/examples/cpp_supervised_app/main.cpp @@ -23,10 +23,10 @@ #include #endif -#include -#include #include #include +#include +#include #include /// @brief CLI configuration options for the demo_application process diff --git a/score/health_monitor/src/cpp/common.cpp b/score/health_monitor/src/cpp/common.cpp index d53d81c24..b06fdefb3 100644 --- a/score/health_monitor/src/cpp/common.cpp +++ b/score/health_monitor/src/cpp/common.cpp @@ -10,8 +10,8 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#include #include "score/mw/health/common.h" +#include namespace score::mw::health::internal { diff --git a/score/health_monitor/src/cpp/deadline/deadline_monitor.h b/score/health_monitor/src/cpp/deadline/deadline_monitor.h index 9ea0cd7ac..09d40cbb4 100644 --- a/score/health_monitor/src/cpp/deadline/deadline_monitor.h +++ b/score/health_monitor/src/cpp/deadline/deadline_monitor.h @@ -13,9 +13,9 @@ #ifndef SCORE_HM_DEADLINE_DEADLINE_MONITOR_H #define SCORE_HM_DEADLINE_DEADLINE_MONITOR_H -#include #include "score/mw/health/common.h" #include "score/mw/health/tag.h" +#include #include #include diff --git a/score/health_monitor/src/cpp/heartbeat/heartbeat_monitor.cpp b/score/health_monitor/src/cpp/heartbeat/heartbeat_monitor.cpp index bb4b6ba03..28daf5cb7 100644 --- a/score/health_monitor/src/cpp/heartbeat/heartbeat_monitor.cpp +++ b/score/health_monitor/src/cpp/heartbeat/heartbeat_monitor.cpp @@ -12,13 +12,16 @@ ********************************************************************************/ #include "score/mw/health/heartbeat_monitor.h" -namespace { +namespace +{ extern "C" { using namespace score::mw::health; using namespace score::mw::health::internal; using namespace score::mw::health::heartbeat; -FFICode heartbeat_monitor_builder_create(uint32_t range_min_ms, uint32_t range_max_ms, FFIHandle* heartbeat_monitor_builder_handle_out); +FFICode heartbeat_monitor_builder_create(uint32_t range_min_ms, + uint32_t range_max_ms, + FFIHandle* heartbeat_monitor_builder_handle_out); FFICode heartbeat_monitor_builder_destroy(FFIHandle heartbeat_monitor_builder_handle); FFICode heartbeat_monitor_destroy(FFIHandle heartbeat_monitor_builder_handle); FFICode heartbeat_monitor_heartbeat(FFIHandle heartbeat_monitor_builder_handle); @@ -32,7 +35,7 @@ FFIHandle heartbeat_monitor_builder_create_wrapper(uint32_t range_min_ms, uint32 return handle; } -} +} // namespace namespace score::mw::health::heartbeat { diff --git a/score/health_monitor/src/cpp/heartbeat/heartbeat_monitor.h b/score/health_monitor/src/cpp/heartbeat/heartbeat_monitor.h index e6c41fe3e..b8cc2ba2b 100644 --- a/score/health_monitor/src/cpp/heartbeat/heartbeat_monitor.h +++ b/score/health_monitor/src/cpp/heartbeat/heartbeat_monitor.h @@ -13,8 +13,8 @@ #ifndef SCORE_HM_HEARTBEAT_HEARTBEAT_MONITOR_H #define SCORE_HM_HEARTBEAT_HEARTBEAT_MONITOR_H -#include #include "score/mw/health/common.h" +#include namespace score::mw::health { diff --git a/tests/integration/complex_monitoring/control_client_mock.cpp b/tests/integration/complex_monitoring/control_client_mock.cpp index c83bb537f..ea36f81db 100644 --- a/tests/integration/complex_monitoring/control_client_mock.cpp +++ b/tests/integration/complex_monitoring/control_client_mock.cpp @@ -17,18 +17,17 @@ #include #include - TEST(ComplexMonitoring, ControlClientMock) { score::mw::lifecycle::ControlClient client; - + ASSERT_TRUE(check_clean({test_end_location, fallback_file})); TEST_STEP("Report running") { score::mw::lifecycle::report_running(); } - + TEST_STEP("Launch monitored process") { score::cpp::stop_token stop_token; diff --git a/tests/integration/crash_on_startup/control_client_mock.cpp b/tests/integration/crash_on_startup/control_client_mock.cpp index c0dcd1be0..f3935bb2b 100644 --- a/tests/integration/crash_on_startup/control_client_mock.cpp +++ b/tests/integration/crash_on_startup/control_client_mock.cpp @@ -17,11 +17,10 @@ #include #include - TEST(CrashOnStartup, ControlClientMock) { score::mw::lifecycle::ControlClient client; - + ASSERT_TRUE(check_clean({crashed_once_file, crashed_twice_file, test_end_location, fallback_file})); TEST_STEP("Report running") diff --git a/tests/integration/process_complex_rep_failure/control_client_mock.cpp b/tests/integration/process_complex_rep_failure/control_client_mock.cpp index b505ee0be..9f82436c0 100644 --- a/tests/integration/process_complex_rep_failure/control_client_mock.cpp +++ b/tests/integration/process_complex_rep_failure/control_client_mock.cpp @@ -26,58 +26,56 @@ // containing "control_client_mock" and // "component_does_not_report_krunning_in_time" -TEST(RecoveryActionComplexRepFailure, ControlClientMock) { - score::mw::lifecycle::ControlClient client; +TEST(RecoveryActionComplexRepFailure, ControlClientMock) +{ + score::mw::lifecycle::ControlClient client; - ASSERT_TRUE(check_clean({test_end_location, fallback_file})); + ASSERT_TRUE(check_clean({test_end_location, fallback_file})); - // Establish communication with launch manager - TEST_STEP("Report running from ControlClientMock") { - score::mw::lifecycle::report_running(); - } - // Start the run target run_target_app_does_report_krunning_in_time - TEST_STEP("Activate RunTarget run_target_app_does_report_krunning_in_time") { - score::cpp::stop_token stop_token; - auto result = - client.ActivateRunTarget("run_target_app_does_report_krunning_in_time") - .Get(stop_token); - EXPECT_TRUE(result.has_value()) - << "Activating target run_target_app_does_report_krunning_in_time " - "failed: " - << result.error().Message(); - } - // Limitation: we cannot wait for the transition to fallback to complete - sleep(1); - // Then, the LM should continue without triggering the fallback - TEST_STEP("Verify fallback run target has not been activated") { - EXPECT_FALSE(std::filesystem::exists(fallback_file)) - << "Fallback run target should have not been activated"; - } - // Start the run target run_target_app_does_not_report_krunning_in_time - TEST_STEP( - "Activate RunTarget run_target_app_does_not_report_krunning_in_time") { - score::cpp::stop_token stop_token; - auto result = client - .ActivateRunTarget( - "run_target_app_does_not_report_krunning_in_time") - .Get(stop_token); - EXPECT_FALSE(result.has_value()) - << "Activating target run_target_app_does_not_report_krunning_in_time " - "did not fail as expected."; - } - // Limitation: we cannot wait for the transition to fallback to complete - sleep(1); - // Then, the LM should exhaust retries and trigger the fallback - TEST_STEP("Verify fallback run target was activated") { - EXPECT_TRUE(std::filesystem::exists(fallback_file)) - << "Fallback run target should have been activated"; - } + // Establish communication with launch manager + TEST_STEP("Report running from ControlClientMock") + { + score::mw::lifecycle::report_running(); + } + // Start the run target run_target_app_does_report_krunning_in_time + TEST_STEP("Activate RunTarget run_target_app_does_report_krunning_in_time") + { + score::cpp::stop_token stop_token; + auto result = client.ActivateRunTarget("run_target_app_does_report_krunning_in_time").Get(stop_token); + EXPECT_TRUE(result.has_value()) << "Activating target run_target_app_does_report_krunning_in_time " + "failed: " + << result.error().Message(); + } + // Limitation: we cannot wait for the transition to fallback to complete + sleep(1); + // Then, the LM should continue without triggering the fallback + TEST_STEP("Verify fallback run target has not been activated") + { + EXPECT_FALSE(std::filesystem::exists(fallback_file)) << "Fallback run target should have not been activated"; + } + // Start the run target run_target_app_does_not_report_krunning_in_time + TEST_STEP("Activate RunTarget run_target_app_does_not_report_krunning_in_time") + { + score::cpp::stop_token stop_token; + auto result = client.ActivateRunTarget("run_target_app_does_not_report_krunning_in_time").Get(stop_token); + EXPECT_FALSE(result.has_value()) << "Activating target run_target_app_does_not_report_krunning_in_time " + "did not fail as expected."; + } + // Limitation: we cannot wait for the transition to fallback to complete + sleep(1); + // Then, the LM should exhaust retries and trigger the fallback + TEST_STEP("Verify fallback run target was activated") + { + EXPECT_TRUE(std::filesystem::exists(fallback_file)) << "Fallback run target should have been activated"; + } - TEST_STEP("Activate RunTarget Off") { client.ActivateRunTarget("Off"); } + TEST_STEP("Activate RunTarget Off") + { + client.ActivateRunTarget("Off"); + } } -int main(int argc, char **argv) { - return TestRunner(__FILE__, TerminationBehavior::kContinue, - TerminationNotification::kTestEnd) - .RunTests(); +int main(int argc, char** argv) +{ + return TestRunner(__FILE__, TerminationBehavior::kContinue, TerminationNotification::kTestEnd).RunTests(); } diff --git a/tests/integration/process_crash_monitoring/control_client_mock.cpp b/tests/integration/process_crash_monitoring/control_client_mock.cpp index 7bd5c14de..b0b7e9a4e 100644 --- a/tests/integration/process_crash_monitoring/control_client_mock.cpp +++ b/tests/integration/process_crash_monitoring/control_client_mock.cpp @@ -17,7 +17,6 @@ #include #include - // Given a correct configuration with: // - An initial Run Target named "Startup" containing "control_client_mock" // - A Run Target named "run_target_crashing_app_on_runtime" containing "control_client_mock" and @@ -26,14 +25,14 @@ TEST(ProcessCrashMonitoring, ControlClientMock) { score::mw::lifecycle::ControlClient client; - + ASSERT_TRUE(check_clean({test_end_location, fallback_file})); // Establish communication with launch manager TEST_STEP("Report running") { score::mw::lifecycle::report_running(); } - + TEST_STEP("Start crashing process") { score::cpp::stop_token stop_token; diff --git a/tests/integration/process_simple_rep_failure/control_client_mock.cpp b/tests/integration/process_simple_rep_failure/control_client_mock.cpp index a30ca8b24..cc41e9897 100644 --- a/tests/integration/process_simple_rep_failure/control_client_mock.cpp +++ b/tests/integration/process_simple_rep_failure/control_client_mock.cpp @@ -26,58 +26,56 @@ // containing "control_client_mock" and // "component_does_not_report_krunning_in_time" -TEST(RecoveryActionSimpleRepFailure, ControlClientMock) { - score::mw::lifecycle::ControlClient client; +TEST(RecoveryActionSimpleRepFailure, ControlClientMock) +{ + score::mw::lifecycle::ControlClient client; - ASSERT_TRUE(check_clean({test_end_location, fallback_file})); + ASSERT_TRUE(check_clean({test_end_location, fallback_file})); - // Establish communication with launch manager - TEST_STEP("Report running from ControlClientMock") { - score::mw::lifecycle::report_running(); - } - // Start the run target run_target_app_does_report_krunning_in_time - TEST_STEP("Activate RunTarget run_target_app_does_report_krunning_in_time") { - score::cpp::stop_token stop_token; - auto result = - client.ActivateRunTarget("run_target_app_does_report_krunning_in_time") - .Get(stop_token); - EXPECT_TRUE(result.has_value()) - << "Activating target run_target_app_does_report_krunning_in_time " - "failed: " - << result.error().Message(); - } - // Limitation: we cannot wait for the transition to fallback to complete - sleep(1); - // Then, the LM should continue without triggering the fallback - TEST_STEP("Verify fallback run target has not been activated") { - EXPECT_FALSE(std::filesystem::exists(fallback_file)) - << "Fallback run target should have not been activated"; - } - // Start the run target run_target_app_does_not_report_krunning_in_time - TEST_STEP( - "Activate RunTarget run_target_app_does_not_report_krunning_in_time") { - score::cpp::stop_token stop_token; - auto result = client - .ActivateRunTarget( - "run_target_app_does_not_report_krunning_in_time") - .Get(stop_token); - EXPECT_FALSE(result.has_value()) - << "Activating target run_target_app_does_not_report_krunning_in_time " - "did not fail as expected."; - } - // Limitation: we cannot wait for the transition to fallback to complete - sleep(1); - // Then, the LM should exhaust retries and trigger the fallback - TEST_STEP("Verify fallback run target was activated") { - EXPECT_TRUE(std::filesystem::exists(fallback_file)) - << "Fallback run target should have been activated"; - } + // Establish communication with launch manager + TEST_STEP("Report running from ControlClientMock") + { + score::mw::lifecycle::report_running(); + } + // Start the run target run_target_app_does_report_krunning_in_time + TEST_STEP("Activate RunTarget run_target_app_does_report_krunning_in_time") + { + score::cpp::stop_token stop_token; + auto result = client.ActivateRunTarget("run_target_app_does_report_krunning_in_time").Get(stop_token); + EXPECT_TRUE(result.has_value()) << "Activating target run_target_app_does_report_krunning_in_time " + "failed: " + << result.error().Message(); + } + // Limitation: we cannot wait for the transition to fallback to complete + sleep(1); + // Then, the LM should continue without triggering the fallback + TEST_STEP("Verify fallback run target has not been activated") + { + EXPECT_FALSE(std::filesystem::exists(fallback_file)) << "Fallback run target should have not been activated"; + } + // Start the run target run_target_app_does_not_report_krunning_in_time + TEST_STEP("Activate RunTarget run_target_app_does_not_report_krunning_in_time") + { + score::cpp::stop_token stop_token; + auto result = client.ActivateRunTarget("run_target_app_does_not_report_krunning_in_time").Get(stop_token); + EXPECT_FALSE(result.has_value()) << "Activating target run_target_app_does_not_report_krunning_in_time " + "did not fail as expected."; + } + // Limitation: we cannot wait for the transition to fallback to complete + sleep(1); + // Then, the LM should exhaust retries and trigger the fallback + TEST_STEP("Verify fallback run target was activated") + { + EXPECT_TRUE(std::filesystem::exists(fallback_file)) << "Fallback run target should have been activated"; + } - TEST_STEP("Activate RunTarget Off") { client.ActivateRunTarget("Off"); } + TEST_STEP("Activate RunTarget Off") + { + client.ActivateRunTarget("Off"); + } } -int main(int argc, char **argv) { - return TestRunner(__FILE__, TerminationBehavior::kContinue, - TerminationNotification::kTestEnd) - .RunTests(); +int main(int argc, char** argv) +{ + return TestRunner(__FILE__, TerminationBehavior::kContinue, TerminationNotification::kTestEnd).RunTests(); } diff --git a/tests/integration/smoke/gtest_process.cpp b/tests/integration/smoke/gtest_process.cpp index 5f663550d..4e2793b1c 100644 --- a/tests/integration/smoke/gtest_process.cpp +++ b/tests/integration/smoke/gtest_process.cpp @@ -12,17 +12,19 @@ ********************************************************************************/ #include -#include #include +#include -#include #include "tests/utils/test_helper/test_helper.hpp" +#include -TEST(Smoke, Process) { +TEST(Smoke, Process) +{ // report running score::mw::lifecycle::report_running(); } -int main() { +int main() +{ return TestRunner(__FILE__).RunTests(); } diff --git a/tests/integration/switch_run_target/control_client_mock.cpp b/tests/integration/switch_run_target/control_client_mock.cpp index c349a828c..6da838dae 100644 --- a/tests/integration/switch_run_target/control_client_mock.cpp +++ b/tests/integration/switch_run_target/control_client_mock.cpp @@ -17,7 +17,6 @@ #include #include - // Given a configuration with the following dependency tree: // - Startup - which is the initial run target - depends on component component_initial // - component_initial: No dependencies @@ -26,7 +25,7 @@ // - component_b: No dependencies // - run_target_c: Depends on component component_d // - component_d: No dependencies -// - component_e: No dependencies, not included in any run target +// - component_e: No dependencies, not included in any run target // The only constraint on process startup order is that A must start after B. // This is because, even though run target A depends on run target C (where @@ -36,7 +35,7 @@ TEST(SwitchRunTarget, ControlClientMock) { score::mw::lifecycle::ControlClient client; - + ASSERT_TRUE(check_clean({test_end_location, a_started, b_started, d_started, e_started})); TEST_STEP("Report running") { diff --git a/tests/utils/test_helper/complex_reporting_process.cpp b/tests/utils/test_helper/complex_reporting_process.cpp index 31ee0e370..5d9e7980c 100644 --- a/tests/utils/test_helper/complex_reporting_process.cpp +++ b/tests/utils/test_helper/complex_reporting_process.cpp @@ -15,9 +15,9 @@ #include -#include "tests/utils/test_helper/test_helper.hpp" #include "score/mw/lifecycle/application.h" #include "score/mw/lifecycle/runapplication.h" +#include "tests/utils/test_helper/test_helper.hpp" /// @file complex_reporting_process.cpp /// @brief Monitored test process using mw::lifecycle (score::mw::lifecycle::Application / @@ -25,40 +25,45 @@ /// behaviours for integration tests of the lifecycle manager. int g_argc; -char **g_argv; +char** g_argv; -class LifecycleApp final : public score::mw::lifecycle::Application { -public: - std::int32_t - Initialize(const score::mw::lifecycle::ApplicationContext &appCtx) override { - optind = 1; +class LifecycleApp final : public score::mw::lifecycle::Application +{ + public: + std::int32_t Initialize(const score::mw::lifecycle::ApplicationContext& appCtx) override + { + optind = 1; - return 0; - } + return 0; + } - std::int32_t Run(const score::cpp::stop_token &stopToken) override { - return EXIT_SUCCESS; - } + std::int32_t Run(const score::cpp::stop_token& stopToken) override + { + return EXIT_SUCCESS; + } }; -TEST(ComplexReportingProcess, ReportsRunning) { - // Check arguments - TEST_STEP("Check args") { - ASSERT_GT(g_argc, 1) << "Wrong number of arguments"; - ASSERT_FALSE((g_argv[1][0] != '0') && (atoi(g_argv[1])) == 0) - << "Argument must be a number"; - } - // Report running with the appropriate delay - TEST_STEP("Report running from ProcessComplexReporting") { - std::this_thread::sleep_for(std::chrono::milliseconds(atoi(g_argv[1]))); +TEST(ComplexReportingProcess, ReportsRunning) +{ + // Check arguments + TEST_STEP("Check args") + { + ASSERT_GT(g_argc, 1) << "Wrong number of arguments"; + ASSERT_FALSE((g_argv[1][0] != '0') && (atoi(g_argv[1])) == 0) << "Argument must be a number"; + } + // Report running with the appropriate delay + TEST_STEP("Report running from ProcessComplexReporting") + { + std::this_thread::sleep_for(std::chrono::milliseconds(atoi(g_argv[1]))); - score::mw::lifecycle::run_application(g_argc, g_argv); - } + score::mw::lifecycle::run_application(g_argc, g_argv); + } } -int main(int argc, char **argv) { - g_argc = argc; - g_argv = argv; +int main(int argc, char** argv) +{ + g_argc = argc; + g_argv = argv; - return TestRunner(__FILE__, TerminationBehavior::kContinue).RunTests(); + return TestRunner(__FILE__, TerminationBehavior::kContinue).RunTests(); } diff --git a/tests/utils/test_helper/test_helper.hpp b/tests/utils/test_helper/test_helper.hpp index 42b6c7047..a22374fb2 100644 --- a/tests/utils/test_helper/test_helper.hpp +++ b/tests/utils/test_helper/test_helper.hpp @@ -60,9 +60,8 @@ constexpr std::string_view test_end_location = "../test_end"; /// by the test framework. /// @param[in] files Files to check /// @param[in] strict If true, return a failure if any files exist. Otherwise attempt to remove them. -[[nodiscard]] -inline testing::AssertionResult check_clean(const std::initializer_list files, - const bool strict = true) +[[nodiscard]] inline testing::AssertionResult check_clean(const std::initializer_list files, + const bool strict = true) { std::stringstream failures{}; for (const auto file : files) @@ -94,14 +93,14 @@ inline testing::AssertionResult check_clean(const std::initializer_list