+
+function validate_trace_exp()
+{
+ local event_exp=$1
+ local trace_path=$2
+
+ 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)
+ if [ "$traced" -ne 0 ]; then
+ pass "Validate trace for expression '${event_exp}', $traced events"
+ else
+ fail "Validate trace for expression '${event_exp}'"
+ diag "Found $traced occurences of '${event_exp}'"
+ fi
+ ret=$?
+ return $ret
+}
+
+function validate_trace_only_exp()
+{
+ local event_exp=$1
+ local trace_path=$2
+
+ 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 total=$($BABELTRACE_BIN $trace_path | wc -l)
+
+ if [ "$count" -ne 0 ] && [ "$total" -eq "$count" ]; then
+ 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"
+ fi
+ ret=$?
+ return $ret
+}
+
+function validate_trace_empty()
+{
+ local trace_path=$1
+
+ which $BABELTRACE_BIN >/dev/null
+ if [ $? -ne 0 ]; then
+ skip 0 "Babeltrace binary not found. Skipping trace validation"
+ fi
+
+ traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | wc -l)
+ if [ "$traced" -eq 0 ]; then
+ pass "Validate empty trace"
+ else
+ fail "Validate empty trace"
+ diag "Found $traced events in trace"
+ fi
+ ret=$?
+ return $ret
+}