robotology / yarp-devices-ros2

Plugins, devices and network wrappers for Yarp-ROS2 interoperation
http://www.yarp.it
10 stars 10 forks source link

Fix CI on macOS and Windows #52

Closed traversaro closed 1 year ago

traversaro commented 1 year ago

This PR fixes the following aspects:

traversaro commented 1 year ago

Ok, beside the two fixes in the PR text, I have the following test failures:

macOS Test failures

On macOS the dev::Map2D_nws_ros2_test test was failing with an error related to the fact that libmap2d_nws_ros2_msgs__rosidl_typesupport_introspection_cpp.dylib was not found:

12/21 Test #12: dev::Map2D_nws_ros2_test ........................***Failed    0.66 sec
Filters: "dev::Map2D_nws_ros2_test"
Randomness seeded to: 3914131991
[DEBUG] |yarp.dev.PolyDriver|map2D_nws_ros2| Parameters are (device map2D_nws_ros2)
Warning:  |yarp.device.map2D_nws_ros2| Missing name parameter. Using: map2D_nws_ros
[INFO] |yarp.os.Port|/map2D_nws_ros/rpc| Port /map2D_nws_ros/rpc active at tcp://localhost:10002/
Warning:  |yarp.device.map2D_nws_ros2| Missing node_name parameter. Using: map2D_nws_ros
[rcutils|error_handling.c:65] an error string (message, file name, or formatted message) will be truncated
[rcutils|error_handling.c:65] an error string (message, file name, or formatted message) will be truncated
[rcutils|error_handling.c:65] an error string (message, file name, or formatted message) will be truncated

[rcutils|error_handling.c:108] rcutils_set_error_state()
This error state is being overwritten:

  'Service type support not from this implementation. Got:
    Handle's typesupport identifier (rosidl_typesupport_cpp) is not supported by this library, at /Users/runner/mambaforge/conda-bld/ros-humble-rosidl-typesupport-cpp-0_1675650163654/work/ros-humble-rosidl-typesupport-cpp/src/work/src/type_support_dispatch.hpp:113
    Could not load library libmap2d_nws_ros2_msgs__rosidl_typesupport_introspection_cpp.dylib: dlopen error: dlopen(libmap2d_nws_ros2_msgs__rosidl_typesupport_introspection_cpp.dylib, 0x0001): tried: '/Users/runner/miniconda3/envs/test/lib/libmap2d_nws_ros2_msgs__rosidl_typesupport_introspection_cpp.dylib' (no such file), '/Users/runner/miniconda3/envs/test/lib/libmap2d_nws_ros2_msgs__rosidl_typesupport_introspection_cpp.dylib' (no such file), at /Users/runner/mambaforge/conda-bld/ros-humble-rmw-cyclonedds-cpp-0_1675652277407/work/ros-humble-rmw-cyclonedds-cpp/src/work/src/rmw_node.cpp:4508'

with this new error message:

  'type_support is null, at /Users/runner/mambaforge/conda-bld/ros-humble-rmw-cyclonedds-cpp-0_1675652277407/work/ros-humble-rmw-cyclonedds-cpp/src/work/src/rmw_node.cpp:4573'

rcutils_reset_error() should be called after error handling to avoid this.

harness_dev_Map2D_nws_ros2 is a Catch2 v3.2.1 host application.
Run with -? for options

-------------------------------------------------------------------------------
dev::Map2D_nws_ros2_test
  Checking map2D_nws_ros2 device
-------------------------------------------------------------------------------
/Users/runner/work/yarp-devices-ros2/yarp-devices-ros2/src/devices/map2D_nws_ros2/tests/Map2D_nws_ros2_test.cpp:31
...............................................................................

/Users/runner/work/yarp-devices-ros2/yarp-devices-ros2/src/devices/map2D_nws_ros2/tests/Map2D_nws_ros2_test.cpp:39: FAILED:
  REQUIRE( ddmapserver.open(pmapserver_cfg) )
due to unexpected exception with message:
  could not create service: type_support is null, at /Users/runner/mambaforge/
  conda-bld/ros-humble-rmw-cyclonedds-cpp-0_1675652277407/work/ros-humble-rmw-
  cyclonedds-cpp/src/work/src/rmw_node.cpp:4573, at /Users/runner/mambaforge/
  conda-bld/ros-humble-rcl-0_1675656184824/work/ros-humble-rcl/src/work/src/
  rcl/service.c:124

===============================================================================
test cases: 1 | 1 failed
assertions: 1 | 1 failed

As an initial fix, I moved the install before the test and changed the CMAKE_INSTALL_PREFIX to ${CONDA_PREFIX}, so to ensure that the test could find libmap2d_nws_ros2_msgs__rosidl_typesupport_introspection_cpp.dylib in the same library in which all the other libraries are found. Note that this should not be needed and apparently it is not needed on Linux, but at least is a first step in getting the test to run.

Windows test failures

Two test fails on Windows, rangefinder2D_nwc_ros2_test and rgbdSensor_nwc_ros2_test :

Test project D:/a/yarp-devices-ros2/yarp-devices-ros2/build
      Start  1: copyright
 1/21 Test  #1: copyright .......................................   Passed    0.59 sec
      Start  2: lint_cmake
 2/21 Test  #2: lint_cmake ......................................   Passed    0.39 sec
      Start  3: xmllint
 3/21 Test  #3: xmllint .........................................   Passed    0.70 sec
      Start  4: copyright
 4/21 Test  #4: copyright .......................................   Passed    0.42 sec
      Start  5: lint_cmake
 5/21 Test  #5: lint_cmake ......................................   Passed    0.33 sec
      Start  6: xmllint
 6/21 Test  #6: xmllint .........................................   Passed    0.54 sec
      Start  7: dev::Rangefinder2D_nws_ros2_test
 7/21 Test  #7: dev::Rangefinder2D_nws_ros2_test ................   Passed    0.52 sec
      Start  8: dev::rangefinder2D_nwc_ros2_test
 8/21 Test  #8: dev::rangefinder2D_nwc_ros2_test ................***Exception: SegFault  0.20 sec
Filters: "dev::rangefinder2D_nwc_ros2_test"
Randomness seeded to: 3884580989
[DEBUG] |yarp.dev.PolyDriver|rangefinder2D_nwc_ros2| Parameters are (device rangefinder2D_nwc_ros2) (node_name rangefinder2D_nwc) (topic_name "/rangefinder2D_nwc_topic")
[INFO] Ros2Subscriber creating topic:  /rangefinder2D_nwc_topic
[INFO] |yarp.ros2.rangefinder2D_nwc_ros2| opened
[INFO] |yarp.dev.PolyDriver|rangefinder2D_nwc_ros2| Created wrapper <rangefinder2D_nwc_ros2>. See C++ class Rangefinder2D_nwc_ros2 for documentation.

harness_dev_Rangefinder2D_nwc_ros2.exe is a Catch2 v3.2.1 host application.
Run with -? for options

-------------------------------------------------------------------------------
dev::rangefinder2D_nwc_ros2_test
  Checking the nwc alone
-------------------------------------------------------------------------------
D:\a\yarp-devices-ros2\yarp-devices-ros2\src\devices\rangefinder2D_nwc_ros2\tests\Rangefinder2D_nwc_ros2_test.cpp(22)
...............................................................................

D:\a\yarp-devices-ros2\yarp-devices-ros2\src\devices\rangefinder2D_nwc_ros2\tests\Rangefinder2D_nwc_ros2_test.cpp(32): PASSED:
  REQUIRE( ddnwc.open(pcfg) )
with expansion:
  true

[INFO] |yarp.ros2.rangefinder2D_nwc_ros2| closing...
[INFO] |yarp.ros2.rangefinder2D_nwc_ros2| closed
D:\a\yarp-devices-ros2\yarp-devices-ros2\src\devices\rangefinder2D_nwc_ros2\tests\Rangefinder2D_nwc_ros2_test.cpp(37): PASSED:
  CHECK( ddnwc.close() )
with expansion:
  true

===============================================================================
All tests passed (2 assertions in 1 test case)

      Start  9: dev::Rangefinder2D_nws_ros2_test
 9/21 Test  #9: dev::Rangefinder2D_nws_ros2_test ................   Passed    0.54 sec
      Start 10: dev::localization2D_nws_ros2_test
10/21 Test #10: dev::localization2D_nws_ros2_test ...............   Passed    0.43 sec
      Start 11: dev::controlBoard_nws_ros2_test
11/21 Test #11: dev::controlBoard_nws_ros2_test .................   Passed    0.45 sec
      Start 12: dev::Map2D_nws_ros2_test
12/21 Test #12: dev::Map2D_nws_ros2_test ........................   Passed    0.35 sec
      Start 13: dev::frameGrabber_nws_ros2_test
13/21 Test #13: dev::frameGrabber_nws_ros2_test .................   Passed    1.49 sec
      Start 14: dev::rgbdToPointCloudSensor_nws_ros2_test
14/21 Test #14: dev::rgbdToPointCloudSensor_nws_ros2_test .......   Passed    0.51 sec
      Start 15: dev::mobileBaseVelocityControl_nws_ros2
15/21 Test #15: dev::mobileBaseVelocityControl_nws_ros2 .........   Passed    0.47 sec
      Start 16: dev::odometry2D_nws_ros2_test
16/21 Test #16: dev::odometry2D_nws_ros2_test ...................   Passed    0.46 sec
      Start 17: dev::frameTransformSet_nwc_ros2_test
17/21 Test #17: dev::frameTransformSet_nwc_ros2_test ............   Passed    0.32 sec
      Start 18: dev::frameTransformGet_nwc_ros2_test
18/21 Test #18: dev::frameTransformGet_nwc_ros2_test ............   Passed    0.31 sec
      Start 19: dev::rgbdSensor_nwc_ros2_test
19/21 Test #19: dev::rgbdSensor_nwc_ros2_test ...................***Exception: SegFault  0.18 sec
Filters: "dev::rgbdSensor_nwc_ros2_test"
Randomness seeded to: 3359617904
[DEBUG] |yarp.dev.PolyDriver|rgbdSensor_nwc_ros2| Parameters are (color_topic_name "/rgbdSensor_nwc_color_topic") (depth_topic_name "/rgbdSensor_nwc_depth_topic") (device rgbdSensor_nwc_ros2) (node_name rgbdSensor_nwc_node)
[INFO] Ros2Subscriber creating topic:  /camera_info
[INFO] Ros2Subscriber creating topic:  /camera_info
[INFO] Ros2Subscriber creating topic:  /rgbdSensor_nwc_color_topic
[INFO] Ros2Subscriber creating topic:  /rgbdSensor_nwc_depth_topic
[INFO] |yarp.ros2.RgbdSensor_nwc_ros2| opened
[INFO] |yarp.dev.PolyDriver|rgbdSensor_nwc_ros2| Created wrapper <rgbdSensor_nwc_ros2>. See C++ class RgbdSensor_nwc_ros2 for documentation.

harness_dev_rgbdSensor_nwc_ros2.exe is a Catch2 v3.2.1 host application.
Run with -? for options

-------------------------------------------------------------------------------
dev::rgbdSensor_nwc_ros2_test
  Checking the nwc alone
-------------------------------------------------------------------------------
D:\a\yarp-devices-ros2\yarp-devices-ros2\src\devices\rgbdSensor_nwc_ros2\tests\rgbdSensor_nwc_ros2_test.cpp(22)
...............................................................................

D:\a\yarp-devices-ros2\yarp-devices-ros2\src\devices\rgbdSensor_nwc_ros2\tests\rgbdSensor_nwc_ros2_test.cpp(33): PASSED:
  REQUIRE( ddnwc.open(pcfg) )
with expansion:
  true

[INFO] |yarp.ros2.RgbdSensor_nwc_ros2| closing...
[INFO] |yarp.ros2.RgbdSensor_nwc_ros2| closed
D:\a\yarp-devices-ros2\yarp-devices-ros2\src\devices\rgbdSensor_nwc_ros2\tests\rgbdSensor_nwc_ros2_test.cpp(38): PASSED:
  CHECK( ddnwc.close() )
with expansion:
  true

===============================================================================
All tests passed (2 assertions in 1 test case)

      Start 20: dev::MultipleAnalogSensors_nws_ros2_test
20/21 Test #20: dev::MultipleAnalogSensors_nws_ros2_test ........   Passed    0.47 sec
      Start 21: dev::rangefinder2D_controlBoard_nws_ros2_test
21/21 Test #21: dev::rangefinder2D_controlBoard_nws_ros2_test ...   Passed    0.51 sec

90% tests passed, 2 tests failed out of 21

Label Time Summary:
copyright     =   1.01 sec*proc (2 tests)
lint_cmake    =   0.72 sec*proc (2 tests)
linter        =   2.97 sec*proc (6 tests)
xmllint       =   1.24 sec*proc (2 tests)

Total Test time (real) =  10.23 sec

The following tests FAILED:
      8 - dev::rangefinder2D_nwc_ros2_test (SEGFAULT)
     19 - dev::rgbdSensor_nwc_ros2_test (SEGFAULT)
Errors while running CTest
Error: Process completed with exit code 8.

In both cases the test segfault, so further checks are needed.

traversaro commented 1 year ago

The segfault related to dev::rgbdSensor_nwc_ros2_test disappears if the delete m_spinner is commented, not sure if this could be connected to the race condition you were referring to f2f @randaz81 . `

randaz81 commented 1 year ago

yep, the race condition is somehow related to rclcpp handling, but the destructor cannot be removed (it will create other issues)