X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Futils%2Futils.sh;h=8e6563d0672098e7c6d2f467bd26e4460a40b636;hp=1b2f71f183b764977acd05985b48966c8e9db56a;hb=bc3c79aee8149b3e983d38bae4bf455dad927296;hpb=ba5e8d0abf1a68803de9d773fe977792e7b0b5e8 diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 1b2f71f18..8e6563d06 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -1,17 +1,7 @@ -# Copyright (C) - 2012 David Goulet +# Copyright (C) 2012 David Goulet # -# 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. +# SPDX-License-Identifier: LGPL-2.1-only # -# 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 SESSIOND_BIN="lttng-sessiond" SESSIOND_MATCH=".*lttng-sess.*" @@ -46,7 +36,7 @@ export LTTNG_SESSIOND_PATH="/bin/true" source $TESTDIR/utils/tap/tap.sh -if [ -z $LTTNG_TEST_TEARDOWN_TIMEOUT ]; then +if [ -z ${LTTNG_TEST_TEARDOWN_TIMEOUT+x} ]; then LTTNG_TEST_TEARDOWN_TIMEOUT=60 fi @@ -149,10 +139,19 @@ function conf_proc_count() # Bail out on failure function validate_lttng_modules_present () { + # Check for loadable modules. modprobe -n lttng-tracer 2>/dev/null - if [ $? -ne 0 ]; then - BAIL_OUT "LTTng modules not detected." + if [ $? -eq 0 ]; then + return 0 + fi + + # Check for builtin modules. + ls /proc/lttng > /dev/null 2>&1 + if [ $? -eq 0 ]; then + return 0 fi + + BAIL_OUT "LTTng modules not detected." } function enable_kernel_lttng_event @@ -1180,8 +1179,16 @@ function enable_ust_lttng_event_filter() local sess_name="$1" local event_name="$2" local filter="$3" + local channel_name=$4 + + if [ -z $channel_name ]; then + # default channel if none specified + chan="" + else + chan="-c $channel_name" + fi - $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $chan "$event_name" -s $sess_name -u --filter "$filter" 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST ok $? "Enable event $event_name with filtering for session $sess_name" } @@ -1469,6 +1476,7 @@ function lttng_load_fail() function lttng_track() { local expected_to_fail="$1" + shift 1 local opts="$@" $TESTDIR/../src/bin/lttng/$LTTNG_BIN track $opts >$OUTPUT_DEST ret=$? @@ -1493,6 +1501,7 @@ function lttng_track_fail() function lttng_untrack() { local expected_to_fail="$1" + shift 1 local opts="$@" $TESTDIR/../src/bin/lttng/$LTTNG_BIN untrack $opts >$OUTPUT_DEST ret=$? @@ -1612,18 +1621,6 @@ function add_context_kernel_fail() add_context_lttng 1 -k "$@" } -function validate_directory_empty () -{ - local trace_path=$1 - - ls -A $local_path > /dev/null 2>&1 - if [ $? -eq 0 ]; then - pass "Directory empty" - else - fail "Directory empty" - fi -} - function wait_live_trace_ready () { local url=$1 @@ -1876,17 +1873,26 @@ function validate_trace_empty() return $ret } -function validate_folder_is_empty() +function validate_directory_empty () { - local folder=$1 + local trace_path="$1" + + # Do not double quote `$trace_path` below as we want wildcards to be + # expanded. + files="$(ls -A $trace_path)" + ret=$? + if [ $ret -ne 0 ]; then + fail "Failed to list content of directory \"$trace_path\"" + return $ret + fi - test -z "$(ls -A "$folder")" - ok $? "Folder ${folder} is empty" + nb_files="$(echo -n "$files" | wc -l)" + ok $nb_files "Directory \"$trace_path\" is empty" } function validate_trace_session_ust_empty() { - validate_folder_is_empty "$1"/ust + validate_directory_empty "$1"/ust } function validate_trace_session_kernel_empty()