Tests: ctf: add basic `metadata-info` query test
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 16 Aug 2019 15:43:58 +0000 (11:43 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 16 Aug 2019 20:05:01 +0000 (16:05 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I1dcd08a024581a078c163cb09a3372bf2a7ce35f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1955
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
tests/Makefile.am
tests/data/plugins/src.ctf.fs/query/metadata-info-succeed1.expect [new file with mode: 0644]
tests/plugins/src.ctf.fs/Makefile.am
tests/plugins/src.ctf.fs/query/test_query [deleted file]
tests/plugins/src.ctf.fs/query/test_query_metadata_info [new file with mode: 0755]
tests/plugins/src.ctf.fs/query/test_query_trace_info [new file with mode: 0755]

index 20da40482e43a63585eac95a0e63e58ffcc32228..4951ee6cac97d3b8cbdf4bde6be82f084a8d3744 100644 (file)
@@ -85,7 +85,8 @@ TESTS_PLUGINS = \
 
 if !ENABLE_BUILT_IN_PLUGINS
 if ENABLE_PYTHON_BINDINGS
-TESTS_PLUGINS += plugins/src.ctf.fs/query/test_query
+TESTS_PLUGINS += plugins/src.ctf.fs/query/test_query_trace_info
+TESTS_PLUGINS += plugins/src.ctf.fs/query/test_query_metadata_info
 endif
 
 if ENABLE_DEBUG_INFO
diff --git a/tests/data/plugins/src.ctf.fs/query/metadata-info-succeed1.expect b/tests/data/plugins/src.ctf.fs/query/metadata-info-succeed1.expect
new file mode 100644 (file)
index 0000000..7a3adb8
--- /dev/null
@@ -0,0 +1,28 @@
+text: /* CTF 1.8 */
+typealias integer { size = 8; align = 8; signed = false; } := uint8_t;
+typealias integer { size = 32; align = 32; signed = false; } := uint32_t;
+
+trace {
+       major = 1;
+       minor = 8;
+       uuid = "2a6422d0-6cee-11e0-8c08-cb07d7b3a564";
+       byte_order = le;
+       packet.header := struct {
+               uint32_t magic;
+               uint8_t  uuid[16];
+       };
+};
+
+stream {
+       packet.context := struct {
+               uint32_t content_size;
+               uint32_t packet_size;
+       };
+};
+
+event {
+       name = string;
+       fields := struct { string str; };
+};
+
+is-packetized: no
index 73571141d8ea306ef807f27d20d5c5f0efae274e..57903cf6d8c22ea04d92212fd85a3a35bc893fb0 100644 (file)
@@ -1,5 +1,6 @@
 SUBDIRS = succeed
 
 dist_check_SCRIPTS = \
-       query/test_query \
+       query/test_query_metadata_info \
+       query/test_query_trace_info \
        query/test_query_trace_info.py
diff --git a/tests/plugins/src.ctf.fs/query/test_query b/tests/plugins/src.ctf.fs/query/test_query
deleted file mode 100755 (executable)
index 4ab85cc..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; only version 2
-# of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
-       UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
-else
-       UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
-fi
-
-# shellcheck source=../../../utils/utils.sh
-source "$UTILSSH"
-
-run_python_bt2_test "${BT_TESTS_SRCDIR}/plugins/src.ctf.fs/query" test_query*
diff --git a/tests/plugins/src.ctf.fs/query/test_query_metadata_info b/tests/plugins/src.ctf.fs/query/test_query_metadata_info
new file mode 100755 (executable)
index 0000000..e52e7fa
--- /dev/null
@@ -0,0 +1,63 @@
+#!/bin/bash
+#
+# Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
+# Copyright (C) 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; only version 2
+# of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+SH_TAP=1
+
+if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+       UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
+else
+       UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
+fi
+
+# shellcheck source=../../../utils/utils.sh
+source "$UTILSSH"
+
+this_dir_relative="plugins/src.ctf.fs/query"
+this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative"
+succeed_trace_dir="$BT_CTF_TRACES_PATH/succeed"
+expect_dir="$BT_TESTS_DATADIR/$this_dir_relative"
+
+test_query_metadata_info() {
+       local name="$1"
+       local ret=0
+       local trace_path="$succeed_trace_dir/$name"
+       local expected_stdout="$expect_dir/metadata-info-$name.expect"
+       local temp_stdout_output_file="$(mktemp -t actual_stdout.XXXXXX)"
+       local temp_stderr_output_file="$(mktemp -t actual_stderr.XXXXXX)"
+       local query=("query" "src.ctf.fs" "metadata-info" "--params" "path=\"$trace_path\"")
+
+       bt_cli "$temp_stdout_output_file" "$temp_stderr_output_file" \
+               "${query[@]}"
+
+       bt_diff "$expected_stdout" "$temp_stdout_output_file"
+       ret_stdout=$?
+
+       bt_diff /dev/null "$temp_stderr_output_file"
+       ret_stderr=$?
+
+       if ((ret_stdout != 0 || ret_stderr != 0)); then
+               ret=1
+       fi
+
+       ok $ret "Trace '$name' \`metadata-info\` query gives the expected output"
+       rm -f "$temp_stdout_output_file" "$temp_stderr_output_file"
+}
+
+plan_tests 1
+test_query_metadata_info succeed1
diff --git a/tests/plugins/src.ctf.fs/query/test_query_trace_info b/tests/plugins/src.ctf.fs/query/test_query_trace_info
new file mode 100755 (executable)
index 0000000..8d84887
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; only version 2
+# of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
+       UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
+else
+       UTILSSH="$(dirname "$0")/../../../utils/utils.sh"
+fi
+
+# shellcheck source=../../../utils/utils.sh
+source "$UTILSSH"
+
+run_python_bt2_test "${BT_TESTS_SRCDIR}/plugins/src.ctf.fs/query" test_query_trace_info.py
This page took 0.027082 seconds and 4 git commands to generate.