From 4097894b429a80b5c1ffc1b788144a754aa69c9f Mon Sep 17 00:00:00 2001 From: iory Date: Mon, 23 Jul 2018 17:29:10 +0900 Subject: [PATCH] [jsk_tools] Add test_env_hooks.test. --- jsk_tools/CMakeLists.txt | 1 + jsk_tools/test/sh/rossetip.sh | 23 ++++++++++++++++++++ jsk_tools/test/sh/rossetmaster.sh | 18 +++++++++++++++ jsk_tools/test/test_env_hooks.test | 35 ++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100755 jsk_tools/test/sh/rossetip.sh create mode 100755 jsk_tools/test/sh/rossetmaster.sh create mode 100644 jsk_tools/test/test_env_hooks.test 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..e4ee1550b --- /dev/null +++ b/jsk_tools/test/sh/rossetip.sh @@ -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 diff --git a/jsk_tools/test/sh/rossetmaster.sh b/jsk_tools/test/sh/rossetmaster.sh new file mode 100755 index 000000000..85d7c5135 --- /dev/null +++ b/jsk_tools/test/sh/rossetmaster.sh @@ -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 diff --git a/jsk_tools/test/test_env_hooks.test b/jsk_tools/test/test_env_hooks.test new file mode 100644 index 000000000..918d25ae7 --- /dev/null +++ b/jsk_tools/test/test_env_hooks.test @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + +