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 10, 2022
1 parent df29bfb commit a461023
Show file tree
Hide file tree
Showing 4 changed files with 94 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
26 changes: 26 additions & 0 deletions jsk_tools/test/sh/rossetip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/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 () {
# overwrite ip command.
echo "$ECHO_OUTPUT"
}

rossetip_addr > /dev/null 2>&1
echo $ROS_IP
21 changes: 21 additions & 0 deletions jsk_tools/test/sh/rossetmaster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

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


hostname=${1-"localhost"}
ros_port=${2-"11311"}
rossetmaster "$hostname" "$ros_port" > /dev/null 2>&1
echo "$ROS_MASTER_URI"
46 changes: 46 additions & 0 deletions jsk_tools/test/test_env_hooks.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<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;133.11.216.210 dev wlp9s0 src 133.11.216.144 uid 1000 \ cache&quot;" />
<param name="stdout" value="133.11.216.144" />
<param name="shell" value="true" />
</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;local 133.11.216.144 dev lo src 133.11.216.144 uid 1000 \ cache&quot;" />
<param name="stdout" value="133.11.216.144" />
<param name="shell" value="true" />
</test>

<test test-name="test_rossetip2"
name="test_rossetip2"
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;8.8.8.8 via 133.11.216.254 dev wlp9s0 src 133.11.216.144 uid 1000 \ cache&quot;" />
<param name="stdout" value="133.11.216.144" />
<param name="shell" value="true" />
</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" />
<param name="shell" value="true" />
</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" />
<param name="shell" value="true" />
</test>

</launch>

0 comments on commit a461023

Please sign in to comment.