Skip to content

Commit a461023

Browse files
committed
[jsk_tools] Add test_env_hooks.test.
1 parent df29bfb commit a461023

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

jsk_tools/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ if (CATKIN_ENABLE_TESTING)
5252
jsk_tools_add_rostest(test/test_stdout.test)
5353
jsk_tools_add_rostest(test/test_rostopic_host_sanity.test)
5454
jsk_tools_add_rostest(test/test_sanity_diagnostics.test)
55+
jsk_tools_add_rostest(test/test_env_hooks.test)
5556
find_package(jsk_tools REQUIRED)
5657
jsk_tools_add_shell_test(COMMAND echo "testing jsk_tools_add_shell_test")
5758
endif()

jsk_tools/test/sh/rossetip.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
JSK_TOOLS_PATH=$(rospack find jsk_tools)
4+
if [ "$JSK_TOOLS_PATH" = "/opt/ros/${ROS_DISTRO}/share/jsk_tools" ]; then
5+
source /opt/ros/${ROS_DISTRO}/setup.bash
6+
else
7+
source `catkin locate --shell-verbs`
8+
if [ "$(rospack find jsk_tools)" = "$(catkin locate --install)/share/jsk_tools" ]; then
9+
# for install
10+
source "$(rospack find jsk_tools)"/catkin_env_hook/99.jsk_tools.sh
11+
else
12+
# for devel
13+
cd "$JSK_TOOLS_PATH" && source `catkin locate --devel`/etc/catkin/profile.d/99.jsk_tools.sh
14+
fi
15+
fi
16+
17+
18+
ECHO_OUTPUT="$1"
19+
20+
function ip () {
21+
# overwrite ip command.
22+
echo "$ECHO_OUTPUT"
23+
}
24+
25+
rossetip_addr > /dev/null 2>&1
26+
echo $ROS_IP

jsk_tools/test/sh/rossetmaster.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
JSK_TOOLS_PATH=$(rospack find jsk_tools)
4+
if [ "$JSK_TOOLS_PATH" = "/opt/ros/${ROS_DISTRO}/share/jsk_tools" ]; then
5+
. /opt/ros/${ROS_DISTRO}/setup.bash
6+
else
7+
. `catkin locate --shell-verbs`
8+
if [ "$(rospack find jsk_tools)" = "$(catkin locate --install)/share/jsk_tools" ]; then
9+
# for install
10+
. "$(rospack find jsk_tools)"/catkin_env_hook/99.jsk_tools.sh
11+
else
12+
# for devel
13+
cd "$JSK_TOOLS_PATH" && . `catkin locate --devel`/etc/catkin/profile.d/99.jsk_tools.sh
14+
fi
15+
fi
16+
17+
18+
hostname=${1-"localhost"}
19+
ros_port=${2-"11311"}
20+
rossetmaster "$hostname" "$ros_port" > /dev/null 2>&1
21+
echo "$ROS_MASTER_URI"

jsk_tools/test/test_env_hooks.test

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<launch>
2+
3+
<test test-name="test_rossetip0"
4+
name="test_rossetip0"
5+
pkg="jsk_tools" type="test_stdout.py">
6+
<!-- testing https://github.com/jsk-ros-pkg/jsk_common/issues/1472 -->
7+
<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;" />
8+
<param name="stdout" value="133.11.216.144" />
9+
<param name="shell" value="true" />
10+
</test>
11+
12+
<test test-name="test_rossetip1"
13+
name="test_rossetip1"
14+
pkg="jsk_tools" type="test_stdout.py">
15+
<!-- testing https://github.com/jsk-ros-pkg/jsk_common/issues/1472 -->
16+
<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;" />
17+
<param name="stdout" value="133.11.216.144" />
18+
<param name="shell" value="true" />
19+
</test>
20+
21+
<test test-name="test_rossetip2"
22+
name="test_rossetip2"
23+
pkg="jsk_tools" type="test_stdout.py">
24+
<!-- testing https://github.com/jsk-ros-pkg/jsk_common/issues/1472 -->
25+
<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;" />
26+
<param name="stdout" value="133.11.216.144" />
27+
<param name="shell" value="true" />
28+
</test>
29+
30+
<test test-name="test_rossetmaster0"
31+
name="test_rossetmaster0"
32+
pkg="jsk_tools" type="test_stdout.py">
33+
<param name="~command" value="/bin/bash $(find jsk_tools)/test/sh/rossetmaster.sh localhost" />
34+
<param name="stdout" value="http://localhost:11311" />
35+
<param name="shell" value="true" />
36+
</test>
37+
38+
<test test-name="test_rossetmaster1"
39+
name="test_rossetmaster1"
40+
pkg="jsk_tools" type="test_stdout.py">
41+
<param name="~command" value="/bin/bash $(find jsk_tools)/test/sh/rossetmaster.sh hrp2017v 10017" />
42+
<param name="stdout" value="http://hrp2017v:10017" />
43+
<param name="shell" value="true" />
44+
</test>
45+
46+
</launch>

0 commit comments

Comments
 (0)