Skip to content

Commit 3fd4cac

Browse files
committed
Add: test_netmon_daemon: daemon shutdown handling, timeout, error logging.
1 parent c2f89d1 commit 3fd4cac

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/integration/test_netmon_daemon.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,22 @@ class NetMonDaemonTest : public ::testing::Test {
8080
if (daemon) {
8181
daemon->stop();
8282
}
83+
84+
auto start = std::chrono::steady_clock::now();
85+
while (daemon->isRunning()) {
86+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
87+
auto elapsed = std::chrono::steady_clock::now() - start;
88+
if (elapsed > std::chrono::seconds(5)) {
89+
std::cerr << "ERROR: Daemon did not stop within expected time. Forcing shutdown." << std::endl;
90+
break;
91+
}
92+
}
93+
8394
if (daemon_thread.joinable()) {
8495
daemon_thread.join();
8596
}
97+
98+
daemon.reset();
8699
}
87100

88101
// PER-TEST SETUP: only resets session token

0 commit comments

Comments
 (0)