diff --git a/jsk_tools/CMakeLists.txt b/jsk_tools/CMakeLists.txt index c1a9e6779..7ce1c35ac 100644 --- a/jsk_tools/CMakeLists.txt +++ b/jsk_tools/CMakeLists.txt @@ -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() diff --git a/jsk_tools/test/sh/rossetip.sh b/jsk_tools/test/sh/rossetip.sh new file mode 100755 index 000000000..b402fb192 --- /dev/null +++ b/jsk_tools/test/sh/rossetip.sh @@ -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 diff --git a/jsk_tools/test/sh/rossetmaster.sh b/jsk_tools/test/sh/rossetmaster.sh new file mode 100755 index 000000000..4dccff8a8 --- /dev/null +++ b/jsk_tools/test/sh/rossetmaster.sh @@ -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" diff --git a/jsk_tools/test/test_env_hooks.test b/jsk_tools/test/test_env_hooks.test new file mode 100644 index 000000000..f612176eb --- /dev/null +++ b/jsk_tools/test/test_env_hooks.test @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +