ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
5

How does rostest work with catkin?

asked 2013-02-02 10:28:29 -0600

joq gravatar image

updated 2013-04-17 17:13:31 -0600

130s gravatar image

The camera_info_manager package uses rostest to launch a ROS graph for unit testing.

Launching it explicitly works:

$ rostest camera_info_manager unit_test.test

But, if I run the test in a catkin build, it fails to start the rostest master. It hangs, waiting for me to start roscore by hand. After that, it completes the test successfully.

$ make run_tests
[ 42%] Built target camera_calibration_parsers
[ 57%] Built target camera_info_manager
[ 71%] Built target gtest
[ 85%] Built target gtest_main
[100%] Built target unit_test
[100%] Built target clean_test_results
[100%] Built target tests
-- run_tests.py: execute commands
  /home/joq/ros/hydro/devel/lib/camera_info_manager/unit_test --gtest_output=xml:/home/joq/ros/hydro/build/test_results/camera_info_manager/gtest-unit_test.xml
[ERROR] [1359843932.846640561]: [registerPublisher] Failed to contact master at [vision-4.local:11311].  Retrying...

How is this supposed to work, now?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2013-02-03 08:48:03 -0600

Dirk Thomas gravatar image

The camera_info_manager package mixes gtest and rostest wrongly. Currently it specifies two tests: a plain gtest (catkin_add_gtest) and a rostest (add_rostest).

The rostest invocation should work - try to call make run_tests_camera_info_manager_rostest_.... What fails is the gtest you have declared in CMakeLists.txt. It expects it to be a plain gtest file which does not require any ROS environment.

Since unit_test is not a plain gtest you should just build it as a normal executable without registering as a gtest through the catkin_add_gtest macro.

edit flag offensive delete link more

Comments

2

Thanks, Dirk, that works. For future reference, where is this documented? This page only talks about rosbuild with gtest and rostest: http://ros.org/wiki/gtest#Building_and_running_tests

joq gravatar image joq  ( 2013-02-04 02:26:05 -0600 )edit
1

@joq I cannot seem to find document for testing with catkin in general. I just started adding catkin section here while I'm learning gtest in C++ at the same time. Edition/Addition is appreciated.

130s gravatar image 130s  ( 2013-04-17 17:21:23 -0600 )edit
1

I added a github issue here: https://github.com/ros/ros_comm/issues/258 requesting a new cmake macro for this situation.

hersh gravatar image hersh  ( 2013-07-29 13:04:57 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2013-02-02 10:28:29 -0600

Seen: 2,738 times

Last updated: Feb 03 '13