X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Futils%2Futils.sh;h=c16fa7ca40aa2fc6ef3025b3ff60cb5b54824b64;hp=7181e3b88b8e60684a869dd81359dd5786a28981;hb=c54b437e412758d71ee7cb61d1a60085009f3f90;hpb=59deec0c09b544d548711deaa6d8206efe99ea0d diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 7181e3b88..c16fa7ca4 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -1382,6 +1382,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 @@ -1496,7 +1519,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,11 +1538,11 @@ 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 - pass "Trace match with $total for expression '${event_exp}" + pass "Trace match with $total for expression '${event_exp}'" else fail "Trace match" diag "$total syscall event(s) found, only syscalls matching expression '${event_exp}' ($count occurrences) are expected"