File tree Expand file tree Collapse file tree 3 files changed +27
-19
lines changed
.github/actions/build-and-test Expand file tree Collapse file tree 3 files changed +27
-19
lines changed Original file line number Diff line number Diff line change @@ -31,10 +31,16 @@ runs:
3131 source /opt/ros/${{ inputs.ros-distro }}/setup.bash
3232 IS_CI=1 colcon build --merge-install
3333
34+ - name : 🔗 Set library path
35+ shell : bash
36+ run : |
37+ echo "LD_LIBRARY_PATH=$(pwd)/build/install/lib:$(pwd)/build/install/deep_test/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
38+
3439 - name : ✅ Run tests
3540 shell : bash
3641 run : |
3742 source /opt/ros/${{ inputs.ros-distro }}/setup.bash
43+ source build/install/setup.bash
3844 IS_CI=1 colcon test --merge-install --event-handlers console_cohesion+
3945 colcon test-result --verbose
4046
Original file line number Diff line number Diff line change 1414
1515#include " test_fixtures/test_executor_fixture.hpp"
1616
17+ #include < atomic>
18+ #include < mutex>
19+
1720#include < lifecycle_msgs/msg/state.hpp>
1821
1922namespace deep_ros ::test
2023{
2124
25+ // Static members for safe one-time initialization
26+ static std::mutex ros_init_mutex;
27+ static std::atomic<int > ros_init_count{0 };
28+ static std::atomic<bool > ros_initialized{false };
29+
2230ROS2Initializer::ROS2Initializer ()
2331{
24- rclcpp::init (0 , nullptr );
32+ std::lock_guard<std::mutex> lock (ros_init_mutex);
33+ if (!ros_initialized.load ()) {
34+ rclcpp::init (0 , nullptr );
35+ ros_initialized.store (true );
36+ }
37+ ros_init_count++;
2538}
2639
2740ROS2Initializer::~ROS2Initializer ()
2841{
29- rclcpp::shutdown ();
42+ std::lock_guard<std::mutex> lock (ros_init_mutex);
43+ ros_init_count--;
44+ // Only shutdown when the last instance is destroyed
45+ if (ros_init_count.load () == 0 && ros_initialized.load ()) {
46+ rclcpp::shutdown ();
47+ ros_initialized.store (false );
48+ }
3049}
3150
3251TestExecutorFixture::TestExecutorFixture ()
Original file line number Diff line number Diff line change 1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- #include < dlfcn.h>
16-
1715#include < chrono>
1816#include < future>
1917#include < memory>
3230namespace deep_ros
3331{
3432
35- /* *
36- * @brief Check if GPU/CUDA is available
37- */
38- static bool is_gpu_available ()
39- {
40- return dlopen (" libcuda.so.1" , RTLD_LAZY | RTLD_NOLOAD) != nullptr ;
41- }
42-
4333TEST_CASE_METHOD (deep_ros::test::TestExecutorFixture, " Multiple nodes with TestExecutorFixture" , " [multi_node]" )
4434{
45- // Skip this test in CPU-only environments
46- // The segfault occurs during ROS2 initialization when running in a CPU-only container
47- if (!is_gpu_available ()) {
48- WARN (" GPU/CUDA not available - skipping ROS integration test" );
49- return ;
50- }
51-
5235 std::string test_topic = " /multi_node_topic" ;
5336
5437 // Create publisher and subscriber test nodes
You can’t perform that action at this time.
0 commit comments