Implement lttng-mi for userspace-probe
[lttng-tools.git] / tests / utils / utils.sh
index 3a619201f936d3ec3b9ea6a3f81beabcd9570c55..2343b4b28d3e872437072fee95bb00601c300fd2 100644 (file)
@@ -1081,54 +1081,76 @@ function disable_python_lttng_event ()
        ok $? "Disable Python event $event_name for session $sess_name"
 }
 
-function start_lttng_tracing ()
+function start_lttng_tracing_opt ()
 {
-       local expected_to_fail=$1
-       local sess_name=$2
+       local withtap=$1
+       local expected_to_fail=$2
+       local sess_name=$3
 
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
        ret=$?
        if [[ $expected_to_fail -eq "1" ]]; then
                test "$ret" -ne "0"
-               ok $? "Start tracing for session $sess_name failed as expected"
+               ret=$?
+               if [ $withtap -eq "1" ]; then
+                       ok $? "Start tracing for session $sess_name failed as expected"
+               fi
        else
-               ok $ret "Start tracing for session $sess_name"
+               if [ $withtap -eq "1" ]; then
+                       ok $ret "Start tracing for session $sess_name"
+               fi
        fi
 }
 
 function start_lttng_tracing_ok ()
 {
-       start_lttng_tracing 0 "$@"
+       start_lttng_tracing_opt 1 0 "$@"
 }
 
 function start_lttng_tracing_fail ()
 {
-       start_lttng_tracing 1 "$@"
+       start_lttng_tracing_opt 1 1 "$@"
 }
 
-function stop_lttng_tracing ()
+function start_lttng_tracing_notap ()
 {
-       local expected_to_fail=$1
-       local sess_name=$2
+       start_lttng_tracing_opt 0 1 "$@"
+}
+
+function stop_lttng_tracing_opt ()
+{
+       local withtap=$1
+       local expected_to_fail=$2
+       local sess_name=$3
 
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
        ret=$?
        if [[ $expected_to_fail -eq "1" ]]; then
                test "$ret" -ne "0"
-               ok $? "Stop lttng tracing for session $sess_name failed as expected"
+               ret=$?
+               if [ $withtap -eq "1" ]; then
+                       ok $? "Stop lttng tracing for session $sess_name failed as expected"
+               fi
        else
-               ok $ret "Stop lttng tracing for session $sess_name"
+               if [ $withtap -eq "1" ]; then
+                       ok $ret "Stop lttng tracing for session $sess_name"
+               fi
        fi
 }
 
 function stop_lttng_tracing_ok ()
 {
-       stop_lttng_tracing 0 "$@"
+       stop_lttng_tracing_opt 1 0 "$@"
 }
 
 function stop_lttng_tracing_fail ()
 {
-       stop_lttng_tracing 1 "$@"
+       stop_lttng_tracing_opt 1 1 "$@"
+}
+
+function stop_lttng_tracing_notap ()
+{
+       stop_lttng_tracing_opt 0 0 "$@"
 }
 
 function destroy_lttng_session ()
@@ -1382,6 +1404,29 @@ function add_context_kernel_fail()
        add_context_lttng 1 -k "$@"
 }
 
+function validate_metadata_event ()
+{
+       local event_name=$1
+       local nr_event_id=$2
+       local trace_path=$3
+
+       local metadata_file=$(find $trace_path | grep metadata)
+       local metadata_path=$(dirname $metadata_file)
+
+       which $BABELTRACE_BIN >/dev/null
+       skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
+
+       local count=$($BABELTRACE_BIN --output-format=ctf-metadata $metadata_path | grep $event_name | wc -l)
+
+       if [ "$count" -ne "$nr_event_id" ]; then
+               fail "Metadata match with the metadata of $count event(s) named $event_name"
+               diag "$count matching event id found in metadata"
+       else
+               pass "Metadata match with the metadata of $count event(s) named $event_name"
+       fi
+
+}
+
 function trace_matches ()
 {
        local event_name=$1
@@ -1413,12 +1458,12 @@ function trace_match_only()
        local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
        local total=$($BABELTRACE_BIN $trace_path | wc -l)
 
-    if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
-        pass "Trace match with $total event $event_name"
-    else
-        fail "Trace match"
-        diag "$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
-    fi
+       if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
+               pass "Trace match with $total event $event_name"
+       else
+               fail "Trace match"
+               diag "$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
+       fi
 }
 
 function validate_trace
@@ -1496,7 +1541,7 @@ function validate_trace_exp()
        which $BABELTRACE_BIN >/dev/null
        skip $? -ne 0 "Babeltrace binary not found. Skipping trace validation"
 
-       traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep ${event_exp} | wc -l)
+       traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep --extended-regexp ${event_exp} | wc -l)
        if [ "$traced" -ne 0 ]; then
                pass "Validate trace for expression '${event_exp}', $traced events"
        else
@@ -1515,7 +1560,7 @@ function validate_trace_only_exp()
        which $BABELTRACE_BIN >/dev/null
        skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
 
-       local count=$($BABELTRACE_BIN $trace_path | grep ${event_exp} | wc -l)
+       local count=$($BABELTRACE_BIN $trace_path | grep --extended-regexp ${event_exp} | wc -l)
        local total=$($BABELTRACE_BIN $trace_path | wc -l)
 
        if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
This page took 0.026004 seconds and 5 git commands to generate.