Skip to content

Commit 29481e8

Browse files
committed
Fixing libdeep_conversions linking error in CI
1 parent 1794a3a commit 29481e8

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

.github/actions/build-and-test/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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

deep_test/src/test_executor_fixture.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,38 @@
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

1922
namespace 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+
2230
ROS2Initializer::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

2740
ROS2Initializer::~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

3251
TestExecutorFixture::TestExecutorFixture()

deep_test/test/test_with_ros.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
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>
@@ -32,23 +30,8 @@
3230
namespace 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-
4333
TEST_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

0 commit comments

Comments
 (0)