X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Fworking-directory%2Ftest_relayd_working_directory;h=0a5bad027bb8f0b995ad8b6451e49299423c1460;hp=8a261af213631662da28b1643e7c8b6eef305d77;hb=e7b7a0e3be68a5a9cadb2d98aed69be873f7563c;hpb=2a10de3b3b5a198a1633ff4167a9610c493994c1 diff --git a/tests/regression/tools/working-directory/test_relayd_working_directory b/tests/regression/tools/working-directory/test_relayd_working_directory index 8a261af21..0a5bad027 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" @@ -37,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" @@ -72,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" @@ -116,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" @@ -156,35 +145,47 @@ function test_relayd_background_no_working_dir() function test_relayd_debug_permission() { - local output_pattern='Working directory \".*\" is not writable' - local working_dir - local cwd - local pid - - working_dir=$(mktemp -d) + local is_user diag "Test lttng-relayd change working directory on non writable directory" - # Removing write access to working dir - okx chmod -w "$working_dir" + if [ "$(id -u)" == "0" ]; then + is_user=0 + else + is_user=1 + fi + + skip $is_user "Skipping permission debug output test; operation can't fail as root" 6 || + { + local output_pattern='Working directory \".*\" is not writable' + local working_dir + local cwd + local pid - # Redirect the error output to a temporary file - ERROR_OUTPUT_DEST=$(mktemp) - start_lttng_relayd_opt 1 "-b" "-v --working-dir $working_dir" + working_dir=$(realpath "$(mktemp -d)") - pid=$(pgrep "$RELAYD_MATCH") - ok $? "Found lttng-relayd" + # Removing write access to working dir + okx chmod -w "$working_dir" - cwd=$(readlink "/proc/${pid}/cwd") - is "$cwd" "$working_dir" "Working directory changed" + # Redirect the error output to a temporary file - grep -q "$output_pattern" "$ERROR_OUTPUT_DEST" - ok $? "Warning about missing write permission is present" + ERROR_OUTPUT_DEST=$(mktemp) + start_lttng_relayd_opt 1 "-b" "-v --working-dir $working_dir" - stop_lttng_relayd - rm "$ERROR_OUTPUT_DEST" - rm -rf "$working_dir" "$ERROR_OUTPUT_DEST" - ERROR_OUTPUT_DEST=/dev/null + pid=$(pgrep "$RELAYD_MATCH") + ok $? "Found lttng-relayd" + + cwd=$(readlink "/proc/${pid}/cwd") + is "$cwd" "$working_dir" "Working directory changed" + + grep -q "$output_pattern" "$ERROR_OUTPUT_DEST" + ok $? "Warning about missing write permission is present" + + stop_lttng_relayd + rm "$ERROR_OUTPUT_DEST" + rm -rf "$working_dir" "$ERROR_OUTPUT_DEST" + ERROR_OUTPUT_DEST=/dev/null + } } function test_relayd_failure() @@ -197,7 +198,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) @@ -229,6 +230,7 @@ function test_relayd_env() local pid working_dir=$(mktemp -d) + working_dir=$(realpath "$(mktemp -d)") diag "Test lttng-relayd change working directory from env. variable" @@ -254,8 +256,8 @@ function test_relayd_cmdline_overwrite_env() local cwd local pid - working_dir_env=$(mktemp -d) - working_dir_cmdline=$(mktemp -d) + working_dir_env=$(realpath "$(mktemp -d)") + working_dir_cmdline=$(realpath "$(mktemp -d)") diag "Test lttng-relayd change working directory command line overwrite env variable"