Ask Your Question

catkin build run_tests stuck in a loop.

asked 2018-06-11 16:38:39 -0600

tobyhijzen gravatar image

updated 2018-06-12 03:42:55 -0600

gvdhoorn gravatar image

I've implemented a simpel unit test following the guide here. When I build the code using catkin build everything is fine. But when I build the tests using catkin build package_name --catkin-make-args run_tests catkin gets stuck in an infinite loop. If I remove the nodehandle in the utest.cpp file everything is fine. Help!

I'm not sure if this is a bug in catkin_tools or on my end. Hence I created an issue in the catkin_tools repository catkin/catkin_tools#517.

PS I'm using ROS kinetic, on ubuntu 16.04 (kernel 4.15.0-23).

Heres my code (test/utest.cpp):

#include <ros/ros.h>
#include <gtest/gtest.h>

TEST(TestSuite, testCase1)

int main(int argc, char **argv){
  testing::InitGoogleTest(&argc, argv);
  ros::init(argc, argv, "tester");
  ros::NodeHandle nh;
  return RUN_ALL_TESTS();

And here is the CmakeLists.txt:

find_package(catkin REQUIRED COMPONENTS  roscpp  std_msgs)
cmake_minimum_required(VERSION 2.8.3)
catkin_package(CATKIN_DEPENDS roscpp)
include_directories(include ${catkin_INCLUDE_DIRS})
catkin_add_gtest(utest test/utest.cpp)# src/motion_prediction.cpp)
target_link_libraries(utest ${catkin_LIBRARIES})

Additional CMake Args:

-DCMAKE_CXX_STANDARD=11 -DCMAKE_BUILD_TYPE=Release -GCodeBlocks - Unix Makefiles

The build seems to be stuck on this command:

catkin env -si  /usr/bin/make run_tests --jobserver-fds=6,7 -j

For the full output:

$ VERBOSE=1 catkin build unit_test_test -v -p1 --catkin-make-args run_tests
Profile:                     default
Extending:        [explicit] /opt/ros/kinetic
Workspace:                   /home/toby/wepods_ws
Source Space:       [exists] /home/toby/wepods_ws/src
Log Space:          [exists] /home/toby/wepods_ws/logs
Build Space:        [exists] /home/toby/wepods_ws/build
Devel Space:        [exists] /home/toby/wepods_ws/devel
Install Space:      [exists] /home/toby/wepods_ws/install
DESTDIR:            [unused] None
Devel Space Layout:          linked
Install Space Layout:        merged
Additional CMake Args:       -DCMAKE_CXX_STANDARD=11 -DCMAKE_BUILD_TYPE=Release -GCodeBlocks - Unix Makefiles
Additional Make Args:        None
Additional catkin Make Args: run_tests
Internal Make Job Server:    True
Cache Job Environments:      False
Whitelisted Packages:        None
Blacklisted Packages:        None
Workspace configuration appears valid.
[build] Found '21' packages in 0.0 seconds.                                   
Starting  >>> unit_test_test                                                  
Starting   >> unit_test_test:loadenv                                          
Output     << unit_test_test:loadenv /home/toby/wepods_ws/logs/unit_test_test/build.loadenv.005.log
Loading environment from: /home/toby/wepods_ws/install/
Finished   << unit_test_test:loadenv                                          
Starting   >> unit_test_test:mkdir                                            
Starting   >> unit_test_test:mkdir                                            
Starting   >> unit_test_test:cache-manifest                                   
Starting   >> unit_test_test:check                                            
Subprocess  > unit_test_test:check `cd /home/toby/wepods_ws/build/unit_test_test; catkin build --get-env unit_test_test | catkin env -si  /usr/bin/make cmake_check_build_system; cd -`
Output     << unit_test_test:check /home/toby/wepods_ws/logs/unit_test_test/build.check.004.log
/usr/bin/cmake -H/home/toby/wepods_ws/src/wepods_ros/unit_test_test -B/home/toby/wepods_ws/build/unit_test_test --check-build-system CMakeFiles/Makefile.cmake 0
cd /home/toby/wepods_ws/build/unit_test_test; catkin build --get-env unit_test_test | catkin env -si  /usr/bin/make cmake_check_build_system; cd -
Finished   << unit_test_test:check                                            
Starting   >> unit_test_test:make                                             
Subprocess  > unit_test_test:make `cd /home/toby/wepods_ws/build/unit_test_test; catkin build --get-env unit_test_test | catkin env -si  /usr/bin/make run_tests --jobserver-fds=6,7 -j; cd -`
^C[build] Interrupted by user!
edit retag flag offensive close merge delete


I don't see anything obviously wrong. Is it the test that's stuck in a loop, or the build?

ahendrix gravatar imageahendrix ( 2018-06-12 00:27:35 -0600 )edit

The build is stuck.

tobyhijzen gravatar imagetobyhijzen ( 2018-06-12 00:31:48 -0600 )edit

Can you please update your question with a snippet of catkin output? "in a loop" and "stuck" are two different things.

gvdhoorn gravatar imagegvdhoorn ( 2018-06-12 02:11:16 -0600 )edit

The timer:

[build - 03:51.2] [0/1 complete] [1/4 jobs] ...

keeps running indefinitely

tobyhijzen gravatar imagetobyhijzen ( 2018-06-12 02:18:16 -0600 )edit

This seems to be a cross-post of catkin/catkin_tools#517. Could you please not do that? It leads to split discussions in the best case, and duplicated (ie: wasted) effort in all other cases.

gvdhoorn gravatar imagegvdhoorn ( 2018-06-12 02:24:28 -0600 )edit

@gvdhoorn I'm not sure if this is a bug on my end or in catkin tools. Hence the duplication. I'll mention the connection in the post.

tobyhijzen gravatar imagetobyhijzen ( 2018-06-12 02:47:25 -0600 )edit

Have you tried running catkin build in verbose mode? That might tell us a bit more about what is going on.

Does catkin_make also get stuck?

gvdhoorn gravatar imagegvdhoorn ( 2018-06-12 03:42:00 -0600 )edit

What you see is in verbose mode. How do I run it with catkin_make?

tobyhijzen gravatar imagetobyhijzen ( 2018-06-12 03:49:24 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-06-12 05:42:22 -0600

tobyhijzen gravatar image

It turns out there is no roscore running when performing a catkin build <package> --catkin-make-args run_tests. When I run the same code with a roscore in another terminal it works! It's probably better to build the unit tests with catkin build <package> --catkin-make-args tests and then run them with a .test file or directly from a terminal.

edit flag offensive delete link more


Tests with nodes are rostests, so that would make needing a roscore a logical requirement (and they should be launched using rostest, not as stand-alone binaries).

gvdhoorn gravatar imagegvdhoorn ( 2018-06-12 06:11:17 -0600 )edit

That makes sense but it normally if I miss a roscore I get a warning. PS did you enjoy your cake?

tobyhijzen gravatar imagetobyhijzen ( 2018-06-12 06:54:59 -0600 )edit

The output is probably being 'eaten' by catkin.

re: cake: I'm not in the lab at the moment.

gvdhoorn gravatar imagegvdhoorn ( 2018-06-12 06:58:11 -0600 )edit

I used to work there too, hence the question ;-) bedankt voor de hulp!

tobyhijzen gravatar imagetobyhijzen ( 2018-06-12 07:01:51 -0600 )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

1 follower


Asked: 2018-06-11 16:38:39 -0600

Seen: 497 times

Last updated: Jun 12 '18