tests: src.ctf.fs: add test for metadata with invalid syntax
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 30 Jun 2022 14:33:50 +0000 (10:33 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 13 Mar 2023 15:26:10 +0000 (11:26 -0400)
It looks like we don't have any test for a metadata file with a syntax
error in it.  Add one.

It could be argued that we should not error out in that case, as there
may be unrelated files called `metadata`, and if they don't parse as CTF
1 metadata files, we should just skip over them.  But erroring out is
the current behavior of Babeltrace 2, so it should be tested to ensure
it doesn't change by mistake.

Cherry-pick note
----------------
The test needed to be adjusted to look for:

  Component class's "query" method failed:

instead of

  At line 3 in metadata stream: syntax error, unexpected CTF_RSBRAC: token=\"]\""

because the stable-2.0 branch does not include the patch that makes the
CTF metadata reader append error causes (50f6fce8d00b ("ctf: append
error causes when returning errors")).  The test is still relevant, as
it catches an assertion failure that would crash babeltrace.

Change-Id: I82cae8ebc5df984592205c28041276cc861f30df
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8511
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
(cherry picked from commit dfa664f9be160bace24f960b444818d06e75aeb5)
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9532
Tested-by: jenkins <jenkins@lttng.org>
tests/data/ctf-traces/fail/metadata-syntax-error/metadata [new file with mode: 0644]
tests/plugins/src.ctf.fs/fail/test_fail

diff --git a/tests/data/ctf-traces/fail/metadata-syntax-error/metadata b/tests/data/ctf-traces/fail/metadata-syntax-error/metadata
new file mode 100644 (file)
index 0000000..f38aed9
--- /dev/null
@@ -0,0 +1,3 @@
+/* CTF 1.8 */
+
+typealias integer { size = 8; align = 8; signed = false; ] := uint8_t;
index 397c5e0233d4b60a1b15c4a38efe01ab680a237b..ed54bd3db2dd9d19aeaa52c68d9fe60aab4607c7 100755 (executable)
@@ -60,7 +60,7 @@ test_fail() {
 }
 
 
-plan_tests 8
+plan_tests 12
 
 test_fail \
        "invalid-packet-size/trace" \
@@ -72,4 +72,9 @@ test_fail \
        "${data_dir}/valid-events-then-invalid-events.expect" \
        "No event class with ID of event class ID to use in stream class: .*stream-class-id=0, event-class-id=255"
 
+test_fail \
+       "metadata-syntax-error" \
+       "/dev/null" \
+       "^  Component class's \"query\" method failed: "
+
 rm -f "${stdout_file}" "${stderr_file}"
This page took 0.026078 seconds and 4 git commands to generate.