X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Futils%2Futils.sh;h=b326c5bcf94166358e341217078aa1721bb2c8e7;hp=df2671eb63fbbe8dec0e3661d04d585773c1d479;hb=94360c17201a28466af49058735166c73f9ae130;hpb=c28fcefd993b7539716bb5cd9557a08a217ec463 diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index df2671eb6..b326c5bcf 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 @@ -1468,8 +1458,9 @@ function lttng_load_fail() function lttng_track() { - local expected_to_fail=$1 - local opts=$2 + local expected_to_fail="$1" + shift 1 + local opts="$@" $TESTDIR/../src/bin/lttng/$LTTNG_BIN track $opts >$OUTPUT_DEST ret=$? if [[ $expected_to_fail -eq "1" ]]; then @@ -1492,8 +1483,9 @@ function lttng_track_fail() function lttng_untrack() { - local expected_to_fail=$1 - local opts=$2 + local expected_to_fail="$1" + shift 1 + local opts="$@" $TESTDIR/../src/bin/lttng/$LTTNG_BIN untrack $opts >$OUTPUT_DEST ret=$? if [[ $expected_to_fail -eq "1" ]]; then @@ -1527,6 +1519,46 @@ function lttng_untrack_kernel_all_ok() ok $? "Lttng untrack all pid on the kernel domain" } +function lttng_track_ust_ok() +{ + lttng_track_ok -u "$@" +} + +function lttng_track_ust_fail() +{ + lttng_track_fail -u "$@" +} + +function lttng_track_kernel_ok() +{ + lttng_track_ok -k "$@" +} + +function lttng_track_kernel_fail() +{ + lttng_track_fail -k "$@" +} + +function lttng_untrack_ust_ok() +{ + lttng_untrack_ok -u "$@" +} + +function lttng_untrack_ust_fail() +{ + lttng_untrack_fail -u "$@" +} + +function lttng_untrack_kernel_ok() +{ + lttng_untrack_ok -k "$@" +} + +function lttng_untrack_kernel_fail() +{ + lttng_untrack_fail -k "$@" +} + function lttng_add_context_list() { $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context --list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST @@ -1572,18 +1604,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 @@ -1836,6 +1856,31 @@ function validate_trace_empty() return $ret } +function validate_directory_empty () +{ + local trace_path="$1" + + files="$(ls -A "$trace_path")" + ret=$? + if [ $ret -ne 0 ]; then + fail "Failed to list content of directory \"$trace_path\"" + return $ret + fi + + nb_files="$(echo -n "$files" | wc -l)" + ok $nb_files "Directory \"$trace_path\" is empty" +} + +function validate_trace_session_ust_empty() +{ + validate_directory_empty "$1"/ust +} + +function validate_trace_session_kernel_empty() +{ + validate_trace_empty "$1"/kernel +} + function regenerate_metadata () { local expected_to_fail=$1 @@ -1996,3 +2041,9 @@ function lttng_clear_session_fail () { lttng_clear_session 1 $@ } + +function lttng_clear_all () +{ + $TESTDIR/../src/bin/lttng/$LTTNG_BIN clear --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST + ok $? "Clear all lttng sessions" +}