0
$\begingroup$

Rosanswers logo

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)
project(object_motion_prediction)
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/env.sh
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!

Originally posted by tobyhijzen on ROS Answers with karma: 86 on 2018-06-11

Post score: 0


Original comments

Comment by ahendrix on 2018-06-12:
I don't see anything obviously wrong. Is it the test that's stuck in a loop, or the build?

Comment by tobyhijzen on 2018-06-12:
The build is stuck.

Comment by gvdhoorn on 2018-06-12:
Can you please update your question with a snippet of catkin output? "in a loop" and "stuck" are two different things.

Comment by tobyhijzen on 2018-06-12:
The timer:

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

keeps running indefinitely

Comment by gvdhoorn on 2018-06-12:
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.

Comment by tobyhijzen on 2018-06-12:
@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.

Comment by gvdhoorn on 2018-06-12:
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?

Comment by tobyhijzen on 2018-06-12:
What you see is in verbose mode. How do I run it with catkin_make?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by tobyhijzen with karma: 86 on 2018-06-12

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by gvdhoorn on 2018-06-12:
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).

Comment by tobyhijzen on 2018-06-12:
That makes sense but it normally if I miss a roscore I get a warning. PS did you enjoy your cake?

Comment by gvdhoorn on 2018-06-12:
The output is probably being 'eaten' by catkin.

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

Comment by tobyhijzen on 2018-06-12:
I used to work there too, hence the question ;-) bedankt voor de hulp!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.