Skip to content

Commit 4eda2ce

Browse files
committed
Make sure system state before and after running tests is clean
Without cleanup or checking preconditions previous failed test runs may also fail following test runs
1 parent 9747382 commit 4eda2ce

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

score/mw/com/example/ipc_bridge/test_ipc_bridge.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function cleanup_lola() {
1212
# Ensure tests are run in a clean state
1313
rm -rf /dev/shm/lola-*6432*
1414
rm -rf /tmp/mw_com_lola/*/*6432*
15+
rm -rf /tmp/lola-ctl-*6432*_lock
1516
}
1617

1718
function create_service_manifest() {

score/mw/com/impl/bindings/lola/test/proxy_component_test.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,23 @@ class ProxyWithRealMemFixture : public ::testing::Test
8282
shm_files_.push_back(std::move(shm_file));
8383
}
8484

85+
void Cleanup() {
86+
score::filesystem::IStandardFilesystem::instance().Remove("/dev/shm/lola-ctl-0000000000052719-00016");
87+
score::filesystem::IStandardFilesystem::instance().Remove("/dev/shm/lola-data-0000000000052719-00016");
88+
score::filesystem::IStandardFilesystem::instance().Remove("/tmp/lola-ctl-0000000000052719-00016_lock");
89+
score::filesystem::IStandardFilesystem::instance().Remove(kTmpPath);
90+
score::filesystem::IStandardFilesystem::instance().Remove(kServiceInstanceUsageMarkerFile);
91+
}
92+
8593
void SetUp() override
8694
{
8795
EXPECT_CALL(runtime_mock_.mock_, GetBindingRuntime(BindingType::kLoLa))
8896
.WillRepeatedly(::testing::Return(&lola_runtime_mock_));
8997
ON_CALL(lola_runtime_mock_, GetRollbackSynchronization())
9098
.WillByDefault(::testing::ReturnRef(rollback_synchronization_));
99+
100+
// Ensure we start with a clean state
101+
Cleanup();
91102
}
92103

93104
void TearDown() override
@@ -97,6 +108,9 @@ class ProxyWithRealMemFixture : public ::testing::Test
97108
score::filesystem::IStandardFilesystem::instance().Remove(std::string{"/dev/shm"} + file);
98109
}
99110
shm_files_.clear();
111+
112+
// Ensure we leave with a clean state
113+
Cleanup();
100114
}
101115

102116
ProxyWithRealMemFixture& WithAMockedServiceDiscovery()

0 commit comments

Comments
 (0)