Ask Your Question

Cannot run rostests Sequentially, only Simultaneously

asked 2020-02-17 08:48:30 -0500

cferone gravatar image


I'm using rostest to perform integration testing on my code. I've created a single test, to which I pass in a single argument (yaml file with parameters). Here's the relevant portion of my CMakeLists.txt file.

  catkin_add_gtest(pftest test/path_follower_unit_tests.cpp)
  target_link_libraries(pftest ${catkin_LIBRARIES} pfc)
  find_package(rostest REQUIRED)
  add_executable(path_follower_ros_tester test/path_follower_ros_tests.cpp)
  #add_rostest_gtest(path_follower_ros_tester test/path_follower_verification.test test/path_follower_ros_tests.cpp)
  target_link_libraries(path_follower_ros_tester ${catkin_LIBRARIES}  pfc gtest)
  add_rostest(test/path_follower_verification.test DEPENDENCIES path_follower_ros_tester ARGS case:=case1)
  add_rostest(test/path_follower_verification.test DEPENDENCIES path_follower_ros_tester ARGS case:=case2)
  add_rostest(test/path_follower_verification.test DEPENDENCIES path_follower_ros_tester ARGS case:=case3)

When I run catkin_make run_tests the three tests run simultaneously. In other words, three different instances of roscore, and all of the nodes under test spool up at the same time. My concern is that this approach will not scale and eventually I will run out of compute resources. I currently have three different yaml files I pass into my test, but its not hard to imagine testing dozens of different test cases, each with a different set of parameters (inside a yaml file).

How can I force the tests to run sequentially rather than simultaneously?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-02-18 09:15:31 -0500

Link gravatar image

updated 2020-02-20 17:08:41 -0500

Use the -j1 flag, it will get passed through catkin_make to make. It only allows make to process 1 job at a time. The full command would be:

catkin_make run_tests -j1

One thing to note is this will make any tests that need to be compiled take forever so I would recommend running catkin_make tests beforehand to compile all of the tests and before that catkin_make to compile any things that are being tested. The full build sequence I would recommend is:

catkin_make tests
catkin_make run_tests -j1
edit flag offensive delete link more


Thanks! That's exactly what I needed. I noticed, however, that catkin_make tests no longer works after I modified my CMakeLists.txt file to support arguments. In other works, if I uncomment the add_rostest_gtest line I can build the test using catkin_make tests, but if I use add_executable and add_rostest I cannot. If it becomes an issue, I'll create a new post. Thanks again.

cferone gravatar image cferone  ( 2020-02-20 10:27:44 -0500 )edit

You probably needed the full build sequence:

catkin_make tests
catkin_make run_tests -j1

A lot of times catkin_make needs to be re-run before catkin_make tests if anything your test uses / depended on changed

Link gravatar image Link  ( 2020-02-20 17:04:12 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-02-17 08:48:30 -0500

Seen: 237 times

Last updated: Feb 20 '20