diff mbox series

[lttng-tools,v2,4/5] Tests: add function to validate the number of an event name in metadata

Message ID 1518213412-16593-5-git-send-email-francis.deslauriers@efficios.com
State Accepted
Delegated to: Jérémie Galarneau
Headers show
Series Support probes with the same name but different event payload | expand

Commit Message

Francis Deslauriers Feb. 9, 2018, 9:56 p.m. UTC
Signed-off-by: Francis Deslauriers <francis.deslauriers at efficios.com>
---
 tests/utils/utils.sh | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh
index 9bf1fcc..60df376 100644
--- a/tests/utils/utils.sh
+++ b/tests/utils/utils.sh
@@ -1343,6 +1343,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