Fix: Tests: utils.sh: fix unbound variable
[lttng-tools.git] / tests / utils / utils.sh
index 1525b7b2a400a4219b754e015493dbbfd7349493..d0f76bc6f678adff8375397f673b1e89d95162be 100644 (file)
@@ -1,17 +1,7 @@
-# Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
+# Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
 #
-# 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
@@ -1836,6 +1868,24 @@ function validate_trace_empty()
        return $ret
 }
 
+function validate_folder_is_empty()
+{
+       local folder=$1
+
+       test -z "$(ls -A "$folder")"
+       ok $? "Folder ${folder} is empty"
+}
+
+function validate_trace_session_ust_empty()
+{
+       validate_folder_is_empty "$1"/ust
+}
+
+function validate_trace_session_kernel_empty()
+{
+       validate_trace_empty "$1"/kernel
+}
+
 function regenerate_metadata ()
 {
        local expected_to_fail=$1
This page took 0.024993 seconds and 4 git commands to generate.