From 2447792c49c2576d235176e724f83e7927984978 Mon Sep 17 00:00:00 2001 From: "Empting Eelco (ETAS-ECM/XPC-Fe2)" Date: Fri, 13 Feb 2026 12:58:27 +0100 Subject: [PATCH] Fix --- docs/statistics.rst | 2 +- .../cpp/tests/health_monitor_test.cpp | 7 ++ .../src/processstateclient_UT.cpp | 65 ++++++++++++------- .../identifier_hash_UT/identifier_hash_UT.cpp | 36 ++++++++-- 4 files changed, 79 insertions(+), 31 deletions(-) diff --git a/docs/statistics.rst b/docs/statistics.rst index a78bb0f8..b1092259 100644 --- a/docs/statistics.rst +++ b/docs/statistics.rst @@ -113,4 +113,4 @@ Details About Testcases type == 'testcase' and derivation_technique == 'equivalence-classes' type == 'testcase' and derivation_technique == 'fuzz-testing' type == 'testcase' and derivation_technique == 'error-guessing' - type == 'testcase' and derivation_technique == 'explorative-testing' \ No newline at end of file + type == 'testcase' and derivation_technique == 'explorative-testing' diff --git a/src/health_monitoring_lib/cpp/tests/health_monitor_test.cpp b/src/health_monitoring_lib/cpp/tests/health_monitor_test.cpp index 32d76085..83ad1a9d 100644 --- a/src/health_monitoring_lib/cpp/tests/health_monitor_test.cpp +++ b/src/health_monitoring_lib/cpp/tests/health_monitor_test.cpp @@ -21,11 +21,18 @@ using ::testing::_; class HealthMonitorTest : public ::testing::Test { + protected: + void SetUp() override + { + RecordProperty("TestType", "requirements-based"); + RecordProperty("DerivationTechnique", "requirements-analysis"); + } }; // For first review round, only single test case to show up API TEST_F(HealthMonitorTest, TestName) { + RecordProperty("Description", "This test demonstrates the usage of HealthMonitor and DeadlineMonitor APIs. It creates a HealthMonitor with a DeadlineMonitor, retrieves the DeadlineMonitor, and tests starting a deadline."); auto builder_mon = deadline::DeadlineMonitorBuilder() .add_deadline(IdentTag("deadline_1"), TimeRange(std::chrono::milliseconds(100), std::chrono::milliseconds(200))) diff --git a/src/launch_manager_daemon/process_state_client_lib/src/processstateclient_UT.cpp b/src/launch_manager_daemon/process_state_client_lib/src/processstateclient_UT.cpp index 83eba4b1..56341e71 100644 --- a/src/launch_manager_daemon/process_state_client_lib/src/processstateclient_UT.cpp +++ b/src/launch_manager_daemon/process_state_client_lib/src/processstateclient_UT.cpp @@ -10,39 +10,47 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -#include -#include -#include #include +#include +#include +#include using namespace testing; using namespace score::lcm; -using score::lcm::internal::ProcessStateNotifier; using score::lcm::ProcessStateReceiver; +using score::lcm::internal::ProcessStateNotifier; -class ProcessStateClient_UT : public ::testing::Test { - protected: - void SetUp() override { +class ProcessStateClient_UT : public ::testing::Test +{ + protected: + void SetUp() override + { + RecordProperty("TestType", "requirements-based"); + RecordProperty("DerivationTechnique", "requirements-analysis"); notifier_ = std::make_unique(); receiver_ = notifier_->constructReceiver(); } - void TearDown() override { + void TearDown() override + { receiver_.reset(); notifier_.reset(); } std::unique_ptr notifier_; std::unique_ptr receiver_; - }; -TEST_F(ProcessStateClient_UT, ProcessStateClient_ConstructReceiver_Succeeds) { +TEST_F(ProcessStateClient_UT, ProcessStateClient_ConstructReceiver_Succeeds) +{ + RecordProperty("Description", "This test verifies that the ProcessStateNotifier can successfully construct a ProcessStateReceiver instance."); ASSERT_NE(notifier_, nullptr); ASSERT_NE(receiver_, nullptr); } -TEST_F(ProcessStateClient_UT, ProcessStateClient_QueueOneProcess_Succeeds) { - PosixProcess process1{ +TEST_F(ProcessStateClient_UT, ProcessStateClient_QueueOneProcess_Succeeds) +{ + RecordProperty("Description", "This test verifies that a single PosixProcess can be successfully queued using the ProcessStateNotifier and retrieved using the ProcessStateReceiver."); + PosixProcess process1{ .id = score::lcm::IdentifierHash("Process1"), .processStateId = score::lcm::ProcessState::kRunning, .processGroupStateId = score::lcm::IdentifierHash("PGState1"), @@ -54,22 +62,25 @@ TEST_F(ProcessStateClient_UT, ProcessStateClient_QueueOneProcess_Succeeds) { // Retrieve the queued process via the receiver auto result = receiver_->getNextChangedPosixProcess(); - ASSERT_TRUE(result.has_value()); // Result contains Optional value - ASSERT_TRUE(result->has_value()); // Optional contains PosixProcess + ASSERT_TRUE(result.has_value()); // Result contains Optional value + ASSERT_TRUE(result->has_value()); // Optional contains PosixProcess EXPECT_EQ(result->value().id, process1.id); EXPECT_EQ(result->value().processStateId, process1.processStateId); EXPECT_EQ(result->value().processGroupStateId, process1.processGroupStateId); - + // Ensure no more processes are queued auto no_more = receiver_->getNextChangedPosixProcess(); - ASSERT_TRUE(no_more.has_value()); // Result contains Optional value - ASSERT_FALSE(no_more->has_value()); // Optional is empty + ASSERT_TRUE(no_more.has_value()); // Result contains Optional value + ASSERT_FALSE(no_more->has_value()); // Optional is empty } -TEST_F(ProcessStateClient_UT, ProcessStateClient_QueueMaxNumberOfProcesses_Succeeds) { +TEST_F(ProcessStateClient_UT, ProcessStateClient_QueueMaxNumberOfProcesses_Succeeds) +{ + RecordProperty("Description", "This test verifies that the ProcessStateNotifier can successfully queue the maximum number of PosixProcess instances defined by the buffer size, and that they can be retrieved using the ProcessStateReceiver."); // Queue maximum number of processes - for (size_t i = 0; i < static_cast(BufferConstants::BUFFER_QUEUE_SIZE); ++i) { - PosixProcess process{ + for (size_t i = 0; i < static_cast(BufferConstants::BUFFER_QUEUE_SIZE); ++i) + { + PosixProcess process{ .id = score::lcm::IdentifierHash("Process" + std::to_string(i)), .processStateId = score::lcm::ProcessState::kRunning, .processGroupStateId = score::lcm::IdentifierHash("PGState" + std::to_string(i)), @@ -79,7 +90,8 @@ TEST_F(ProcessStateClient_UT, ProcessStateClient_QueueMaxNumberOfProcesses_Succe } // Retrieve and verify all queued processes - for (size_t i = 0; i < static_cast(BufferConstants::BUFFER_QUEUE_SIZE); ++i) { + for (size_t i = 0; i < static_cast(BufferConstants::BUFFER_QUEUE_SIZE); ++i) + { auto result = receiver_->getNextChangedPosixProcess(); ASSERT_TRUE(result.has_value()); ASSERT_TRUE(result->has_value()); @@ -92,16 +104,19 @@ TEST_F(ProcessStateClient_UT, ProcessStateClient_QueueMaxNumberOfProcesses_Succe ASSERT_FALSE(no_more->has_value()); } -TEST_F(ProcessStateClient_UT, ProcessStateClient_QueueOneProcessTooMany_Fails) { - PosixProcess process1{ +TEST_F(ProcessStateClient_UT, ProcessStateClient_QueueOneProcessTooMany_Fails) +{ + RecordProperty("Description", "This test verifies that attempting to queue a PosixProcess when the buffer is already at maximum capacity results in a failure, and that no additional processes can be retrieved from the receiver."); + PosixProcess process1{ .id = score::lcm::IdentifierHash("Process1"), .processStateId = score::lcm::ProcessState::kRunning, .processGroupStateId = score::lcm::IdentifierHash("PGState1"), }; // Fill the buffer to capacity - for (size_t i = 0; i < static_cast(BufferConstants::BUFFER_QUEUE_SIZE); ++i) { - PosixProcess proc{ + for (size_t i = 0; i < static_cast(BufferConstants::BUFFER_QUEUE_SIZE); ++i) + { + PosixProcess proc{ .id = score::lcm::IdentifierHash("Process" + std::to_string(i)), .processStateId = score::lcm::ProcessState::kRunning, .processGroupStateId = score::lcm::IdentifierHash("PGState" + std::to_string(i)), diff --git a/tests/ut/identifier_hash_UT/identifier_hash_UT.cpp b/tests/ut/identifier_hash_UT/identifier_hash_UT.cpp index c3dbb658..0dbc58de 100644 --- a/tests/ut/identifier_hash_UT/identifier_hash_UT.cpp +++ b/tests/ut/identifier_hash_UT/identifier_hash_UT.cpp @@ -20,8 +20,21 @@ using std::stringstream; using score::lcm::IdentifierHash; -TEST(IdentifierHashTest, IdentifierHash_with_string_view_created) +class IdentifierHashTest : public ::testing::Test { + protected: + void SetUp() override + { + RecordProperty("TestType", "requirements-based"); + RecordProperty("DerivationTechnique", "requirements-analysis"); + } +}; + +TEST_F(IdentifierHashTest, IdentifierHash_with_string_view_created) +{ + RecordProperty("Description", + "This test verifies that an IdentifierHash can be successfully created using a std::string_view, " + "and that its string representation can be retrieved correctly."); std::string_view idStrView = "ProcessGroup1/Startup"; IdentifierHash identifierHash(idStrView); stringstream strStream; @@ -29,8 +42,11 @@ TEST(IdentifierHashTest, IdentifierHash_with_string_view_created) ASSERT_EQ(strStream.str(), idStrView); } -TEST(IdentifierHashTest, IdentifierHash_with_string_created) +TEST_F(IdentifierHashTest, IdentifierHash_with_string_created) { + RecordProperty("Description", + "This test verifies that an IdentifierHash can be successfully created using a std::string, and " + "that its string representation can be retrieved correctly."); std::string idStr = "ProcessGroup1/Startup"; IdentifierHash identifierHash(idStr); stringstream strStream; @@ -38,16 +54,22 @@ TEST(IdentifierHashTest, IdentifierHash_with_string_created) ASSERT_EQ(strStream.str(), idStr); } -TEST(IdentifierHashTest, IdentifierHash_default_created) +TEST_F(IdentifierHashTest, IdentifierHash_default_created) { + RecordProperty("Description", + "This test verifies that a default-constructed IdentifierHash can be created, and that its string " + "representation is empty."); IdentifierHash identifierHash; stringstream strStream; strStream << identifierHash; ASSERT_EQ(strStream.str(), ""); } -TEST(IdentifierHashTest, IdentifierHash_invalid_hash_no_string_representation) +TEST_F(IdentifierHashTest, IdentifierHash_invalid_hash_no_string_representation) { + RecordProperty("Description", + "This test verifies that if an IdentifierHash is created with a string that is not registered in " + "the registry, its string representation indicates that it is unknown and includes the hash value."); std::string idStr = "MainFG"; IdentifierHash identifierHash(idStr); @@ -60,8 +82,12 @@ TEST(IdentifierHashTest, IdentifierHash_invalid_hash_no_string_representation) ASSERT_TRUE(strStream.str().find(std::to_string(identifierHash.data())) != std::string::npos); } -TEST(IdentifierHashTest, IdentifierHash_no_dangling_pointer_after_source_string_dies) +TEST_F(IdentifierHashTest, IdentifierHash_no_dangling_pointer_after_source_string_dies) { + RecordProperty("Description", + "This test verifies that an IdentifierHash created from a std::string does not have a dangling " + "pointer to the original string after it goes out of scope, and that its string representation can " + "still be retrieved correctly."); std::unique_ptr hash_ptr; std::string_view idStrView = "this string will be destroyed";