Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jsk_tools] Add test_env_hooks.test. #1590

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
30 changes: 30 additions & 0 deletions jsk_tools/test/sh/rossetip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/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 getent () {
echo "127.0.0.1 localhost"
}

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>