Skip to content

Commit

Permalink
[jsk_tools] Add test_env_hooks.test.
Browse files Browse the repository at this point in the history
  • Loading branch information
iory committed Jun 2, 2022
1 parent df29bfb commit 4097894
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions jsk_tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ if (CATKIN_ENABLE_TESTING)
jsk_tools_add_rostest(test/test_stdout.test)
jsk_tools_add_rostest(test/test_rostopic_host_sanity.test)
jsk_tools_add_rostest(test/test_sanity_diagnostics.test)
jsk_tools_add_rostest(test/test_env_hooks.test)
find_package(jsk_tools REQUIRED)
jsk_tools_add_shell_test(COMMAND echo "testing jsk_tools_add_shell_test")
endif()
Expand Down
23 changes: 23 additions & 0 deletions jsk_tools/test/sh/rossetip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

JSK_TOOLS_PATH=$(rospack find jsk_tools)
if [ "$JSK_TOOLS_PATH" = "/opt/ros/${ROS_DISTRO}/share/jsk_tools" ]; then
source /opt/ros/${ROS_DISTRO}/setup.bash
else
source `catkin locate --shell-verbs`
if [ "$(rospack find jsk_tools)" = "$(catkin locate --install)/share/jsk_tools" ]; then
# for install
source "$(rospack find jsk_tools)"/catkin_env_hook/99.jsk_tools.sh
else
# for devel
cd "$JSK_TOOLS_PATH" && source `catkin locate --devel`/etc/catkin/profile.d/99.jsk_tools.sh
fi
fi


ECHO_OUTPUT="$1"
function ip() {
echo "$ECHO_OUTPUT"
}
rossetip > /dev/null 2>&1
echo $ROS_IP
18 changes: 18 additions & 0 deletions jsk_tools/test/sh/rossetmaster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

JSK_TOOLS_PATH=$(rospack find jsk_tools)
if [ "$JSK_TOOLS_PATH" = "/opt/ros/${ROS_DISTRO}/share/jsk_tools" ]; then
source /opt/ros/${ROS_DISTRO}/setup.bash
else
source `catkin locate --shell-verbs`
if [ "$(rospack find jsk_tools)" = "$(catkin locate --install)/share/jsk_tools" ]; then
# for install
source "$(rospack find jsk_tools)"/catkin_env_hook/99.jsk_tools.sh
else
# for devel
cd "$JSK_TOOLS_PATH" && source `catkin locate --devel`/etc/catkin/profile.d/99.jsk_tools.sh
fi
fi

rossetmaster "$1" "${2-11311}" > /dev/null 2>&1
echo $ROS_MASTER_URI
35 changes: 35 additions & 0 deletions jsk_tools/test/test_env_hooks.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<launch>

<test test-name="test_rossetip0"
name="test_rossetip0"
pkg="jsk_tools" type="test_stdout.py">
<!-- testing https://github.com/jsk-ros-pkg/jsk_common/issues/1472 -->
<param name="~command" value="/bin/bash $(find jsk_tools)/test/sh/rossetip.sh
&quot;2: eth33 inet 133.11.216.88/24 brd 133.11.216.255 scope global eth33&quot;" />
<param name="stdout" value="133.11.216.88" />
</test>

<test test-name="test_rossetip1"
name="test_rossetip1"
pkg="jsk_tools" type="test_stdout.py">
<!-- testing https://github.com/jsk-ros-pkg/jsk_common/issues/1472 -->
<param name="~command" value="/bin/bash $(find jsk_tools)/test/sh/rossetip.sh
&quot;2: lo inet 192.168.96.20/24 brd 192.168.102.255 scope global&quot;" />
<param name="stdout" value="192.168.96.20" />
</test>

<test test-name="test_rossetmaster0"
name="test_rossetmaster0"
pkg="jsk_tools" type="test_stdout.py">
<param name="~command" value="/bin/bash $(find jsk_tools)/test/sh/rossetmaster.sh localhost" />
<param name="stdout" value="http://localhost:11311" />
</test>

<test test-name="test_rossetmaster1"
name="test_rossetmaster1"
pkg="jsk_tools" type="test_stdout.py">
<param name="~command" value="/bin/bash $(find jsk_tools)/test/sh/rossetmaster.sh hrp2017v 10017" />
<param name="stdout" value="http://hrp2017v:10017" />
</test>

</launch>

0 comments on commit 4097894

Please sign in to comment.