diff --git a/tests/integration/process_fd_leak/BUILD b/tests/integration/process_fd_leak/BUILD index 13fdbb029..1cd769e83 100644 --- a/tests/integration/process_fd_leak/BUILD +++ b/tests/integration/process_fd_leak/BUILD @@ -16,6 +16,7 @@ load("//tests/utils/bazel:integration.bzl", "integration_test") cc_binary( name = "native", srcs = [ + "common.hpp", "get_fds.hpp", "native.cpp", ], @@ -29,6 +30,7 @@ cc_binary( cc_binary( name = "reporting", srcs = [ + "common.hpp", "get_fds.hpp", "reporting.cpp", ], @@ -42,6 +44,7 @@ cc_binary( cc_binary( name = "control_client", srcs = [ + "common.hpp", "control_client.cpp", "get_fds.hpp", ], diff --git a/tests/integration/process_fd_leak/common.hpp b/tests/integration/process_fd_leak/common.hpp new file mode 100644 index 000000000..e4de894b9 --- /dev/null +++ b/tests/integration/process_fd_leak/common.hpp @@ -0,0 +1,29 @@ +/******************************************************************************** + * 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 + ********************************************************************************/ + +#ifndef PROCESS_FD_LEAK_HPP_ +#define PROCESS_FD_LEAK_HPP_ + +#include + +// Macros for consistent, constexpr names of marker files across test processes + +#define PROC_FILES(x) \ + constexpr std::string_view x##_terminating = "proc_" #x "_terminating"; + +PROC_FILES(native) +PROC_FILES(reporting) + +#undef PROC_FILES + +#endif // PROCESS_FD_LEAK_HPP_ diff --git a/tests/integration/process_fd_leak/control_client.cpp b/tests/integration/process_fd_leak/control_client.cpp index bca336898..ec80122a9 100644 --- a/tests/integration/process_fd_leak/control_client.cpp +++ b/tests/integration/process_fd_leak/control_client.cpp @@ -12,8 +12,12 @@ ********************************************************************************/ #include +#include +#include #include +#include +#include "common.hpp" #include "get_fds.hpp" #include "tests/utils/test_helper/test_helper.hpp" #include @@ -58,6 +62,16 @@ TEST(ControlClientFDs, FindOpenFDs) oss << open_fds; EXPECT_TRUE(open_fds.empty()) << "Found open files!\n" << oss.str(); } + + TEST_STEP("Wait for other procs to finish") + { + while (!std::filesystem::exists(reporting_terminating) || !std::filesystem::exists(native_terminating)) + { + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + } + + ASSERT_TRUE(touch_file(test_end_location)); + } } int main(int argc, char** argv) @@ -65,7 +79,11 @@ int main(int argc, char** argv) g_argc = argc; g_argv = argv; - TestRunner runner{__FILE__, TerminationBehavior::kContinue, TerminationNotification::kTestEnd}; + // test end file is made in the test so that we block to wait for other + // procs to finish + TestRunner runner{__FILE__, TerminationBehavior::kWait, TerminationNotification::kNone}; + + auto result = runner.RunTests(); - return runner.RunTests(); + return result; } diff --git a/tests/integration/process_fd_leak/get_fds.hpp b/tests/integration/process_fd_leak/get_fds.hpp index f8d117164..69d87d305 100644 --- a/tests/integration/process_fd_leak/get_fds.hpp +++ b/tests/integration/process_fd_leak/get_fds.hpp @@ -20,12 +20,14 @@ #include #include #include -#include #include +#include #include #include #include +#ifndef GET_FDS_HPP_ +#define GET_FDS_HPP_ inline std::ostream& operator<<(std::ostream& outstream, const std::vector>& data) { @@ -36,7 +38,6 @@ inline std::ostream& operator<<(std::ostream& outstream, const std::vector> get_fds() ::closedir(fd_dir); return out_vector; -#endif +#endif //__QNXNTO__ } + +#endif // GET_FDS_HPP_ diff --git a/tests/integration/process_fd_leak/native.cpp b/tests/integration/process_fd_leak/native.cpp index 63131d91b..86a19194a 100644 --- a/tests/integration/process_fd_leak/native.cpp +++ b/tests/integration/process_fd_leak/native.cpp @@ -15,6 +15,7 @@ #include #include "get_fds.hpp" +#include "common.hpp" #include "tests/utils/test_helper/test_helper.hpp" int g_argc; @@ -26,6 +27,8 @@ TEST(NativeFDs, FindOpenFDs) std::ostringstream oss; oss << open_fds; EXPECT_TRUE(open_fds.empty()) << "Found open files!\n" << oss.str(); + + ASSERT_TRUE(touch_file(native_terminating)); } int main(int argc, char** argv) diff --git a/tests/integration/process_fd_leak/process_fd_leak.json b/tests/integration/process_fd_leak/process_fd_leak.json index c07f055d4..2a1c20f3e 100644 --- a/tests/integration/process_fd_leak/process_fd_leak.json +++ b/tests/integration/process_fd_leak/process_fd_leak.json @@ -28,7 +28,10 @@ "component_properties": { "application_profile": { "application_type": "Native", - "is_self_terminating": true + "is_self_terminating": true, + "alive_supervision": { + "min_indications": 0 + } }, "ready_condition": { "process_state": "Running" diff --git a/tests/integration/process_fd_leak/reporting.cpp b/tests/integration/process_fd_leak/reporting.cpp index c895a5c72..38b395f1b 100644 --- a/tests/integration/process_fd_leak/reporting.cpp +++ b/tests/integration/process_fd_leak/reporting.cpp @@ -15,6 +15,7 @@ #include #include "get_fds.hpp" +#include "common.hpp" #include "tests/utils/test_helper/test_helper.hpp" #include @@ -41,6 +42,8 @@ TEST(ReportingProcessFDs, FindOpenFDs) oss << open_fds; EXPECT_TRUE(open_fds.empty()) << "Found open files!\n" << oss.str(); } + + ASSERT_TRUE(touch_file(reporting_terminating)); } int main(int argc, char** argv)