Cleanup: tests: name all temporary files to better identify leakage
[lttng-tools.git] / tests / utils / utils.sh
index f3b4c68c1337720cc599cb534c5131d411bebe42..b2991207a8b9f348c38792ccbdbe6b71a24ef6f1 100644 (file)
@@ -718,7 +718,7 @@ function stop_lttng_sessiond_opt()
        fi
 
        if [ -z "$pids" ]; then
-               if [ "$is_cleanup" -eq 1 ]; then 
+               if [ "$is_cleanup" -eq 1 ]; then
                        :
                elif [ "$withtap" -eq "1" ]; then
                        fail "No session daemon to kill"
@@ -1783,7 +1783,7 @@ function validate_metadata_event ()
        local nr_event_id=$2
        local trace_path=$3
 
-       local metadata_file=$(find $trace_path | grep metadata)
+       local metadata_file=$(find $trace_path -name "metadata")
        local metadata_path=$(dirname $metadata_file)
 
        which $BABELTRACE_BIN >/dev/null
@@ -2247,6 +2247,29 @@ function lttng_remove_trigger_ok()
        lttng_remove_trigger 0 "$@"
 }
 
+function list_triggers_matches_ok ()
+{
+       local tmp_stdout=$(mktemp --tmpdir -t "tmp.${FUNCNAME[0]}_stdout.XXXXXX")
+       local tmp_stderr=$(mktemp --tmpdir -t "tmp.${FUNCNAME[0]}_stderr.XXXXXX")
+
+       local test_name="$1"
+       local expected_stdout_file="$2"
+
+       diag "$TESTDIR/../src/bin/lttng/$LTTNG_BIN list-triggers"
+
+       "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" list-triggers > "${tmp_stdout}" 2> "${tmp_stderr}"
+       ok $? "${test_name}: exit code is 0"
+
+       diff -u "${expected_stdout_file}" "${tmp_stdout}"
+       ok $? "${test_name}: expected stdout"
+
+       diff -u /dev/null "${tmp_stderr}"
+       ok $? "${test_name}: expected stderr"
+
+       rm -f "${tmp_stdout}"
+       rm -f "${tmp_stderr}"
+}
+
 function validate_path_pattern ()
 {
        local message=$1
This page took 0.024868 seconds and 4 git commands to generate.