X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Fworking-directory%2Ftest_relayd_working_directory;h=6231ece0ed37bb40961f8c6a2c31e127cb916598;hb=9d16b343fb9e781fc8d8fa3c448a3f382306dd33;hp=13e816d8a1d476309779ffdc44f0ae44258256c1;hpb=f3630ec4ac23f0bc4f2e9b438310eadb5d3ebcb4;p=lttng-tools.git diff --git a/tests/regression/tools/working-directory/test_relayd_working_directory b/tests/regression/tools/working-directory/test_relayd_working_directory index 13e816d8a..6231ece0e 100755 --- a/tests/regression/tools/working-directory/test_relayd_working_directory +++ b/tests/regression/tools/working-directory/test_relayd_working_directory @@ -1,19 +1,8 @@ #!/bin/bash # -# Copyright (C) - 2018 Jonathan Rajotte +# Copyright (C) 2018 Jonathan Rajotte # -# This library is free software; you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation; version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# SPDX-License-Identifier: LGPL-2.1-only TEST_DESC="Change working directory of process" @@ -22,11 +11,10 @@ TESTDIR=$CURDIR/../../../ DIR=$(readlink -f "$TESTDIR") -NUM_TESTS=27 +NUM_TESTS=35 source $TESTDIR/utils/utils.sh - #MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS @@ -38,7 +26,7 @@ function test_relayd() local pid local cwd - working_dir=$(mktemp -d) + working_dir=$(realpath "$(mktemp -d)") diag "Test lttng-relayd normal mode change working directory" @@ -73,7 +61,7 @@ function test_relayd_daemon() local cwd local pid - working_dir=$(mktemp -d) + working_dir=$(realpath "$(mktemp -d)") diag "Test lttng-relayd daemon mode change working directory" @@ -117,7 +105,7 @@ function test_relayd_background() local cwd local pid - working_dir=$(mktemp -d) + working_dir=$(realpath "$(mktemp -d)") diag "Test lttng-relayd background mode change working directory" @@ -162,7 +150,7 @@ function test_relayd_debug_permission() local cwd local pid - working_dir=$(mktemp -d) + working_dir=$(realpath "$(mktemp -d)") diag "Test lttng-relayd change working directory on non writable directory" @@ -198,7 +186,7 @@ function test_relayd_failure() local output_dest local pid - working_dir="$(mktemp -d)" + working_dir=$(realpath "$(mktemp -d)") working_dir_imaginary="${working_dir}/imaginary_directory" output_dest=$(mktemp) @@ -223,6 +211,59 @@ function test_relayd_failure() rm -rf "$working_dir" } +function test_relayd_env() +{ + local working_dir + local cwd + local pid + + working_dir=$(mktemp -d) + working_dir=$(realpath "$(mktemp -d)") + + diag "Test lttng-relayd change working directory from env. variable" + + export LTTNG_RELAYD_WORKING_DIRECTORY=${working_dir} + start_lttng_relayd_opt 1 "-b" "" + + pid=$(pgrep "$RELAYD_MATCH") + ok $? "Found lttng-relayd" + + cwd=$(readlink "/proc/$pid/cwd") + + is "$cwd" "$working_dir" "Working directory changed" + + stop_lttng_relayd + rm -rf "$working_dir" + unset LTTNG_RELAYD_WORKING_DIRECTORY +} + +function test_relayd_cmdline_overwrite_env() +{ + local working_dir_env + local working_dir_cmdline + local cwd + local pid + + working_dir_env=$(realpath "$(mktemp -d)") + working_dir_cmdline=$(realpath "$(mktemp -d)") + + diag "Test lttng-relayd change working directory command line overwrite env variable" + + export LTTNG_RELAYD_WORKING_DIRECTORY=${working_dir_env} + start_lttng_relayd_opt 1 "-b" "--working-dir ${working_dir_cmdline}" + + pid=$(pgrep "$RELAYD_MATCH") + ok $? "Found lttng-relayd" + + cwd=$(readlink "/proc/$pid/cwd") + + is "$cwd" "$working_dir_cmdline" "Working directory is the one from command line" + + stop_lttng_relayd + rm -rf "$working_dir_env" "$working_dir_cmdline" + unset LTTNG_RELAYD_WORKING_DIRECTORY +} + TESTS=( test_relayd test_relayd_daemon @@ -231,6 +272,8 @@ TESTS=( test_relayd_background_no_working_dir test_relayd_debug_permission test_relayd_failure + test_relayd_env + test_relayd_cmdline_overwrite_env ) for fct_test in "${TESTS[@]}";