From dfa664f9be160bace24f960b444818d06e75aeb5 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 30 Jun 2022 10:33:50 -0400 Subject: [PATCH] tests: src.ctf.fs: add test for metadata with invalid syntax 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. Change-Id: I82cae8ebc5df984592205c28041276cc861f30df Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/8511 Reviewed-by: Philippe Proulx --- tests/data/ctf-traces/fail/metadata-syntax-error/metadata | 3 +++ tests/plugins/src.ctf.fs/fail/test_fail | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/data/ctf-traces/fail/metadata-syntax-error/metadata 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 index 00000000..f38aed91 --- /dev/null +++ b/tests/data/ctf-traces/fail/metadata-syntax-error/metadata @@ -0,0 +1,3 @@ +/* CTF 1.8 */ + +typealias integer { size = 8; align = 8; signed = false; ] := uint8_t; diff --git a/tests/plugins/src.ctf.fs/fail/test_fail b/tests/plugins/src.ctf.fs/fail/test_fail index a3526d1d..652ec6f4 100755 --- a/tests/plugins/src.ctf.fs/fail/test_fail +++ b/tests/plugins/src.ctf.fs/fail/test_fail @@ -49,7 +49,7 @@ test_fail() { } -plan_tests 8 +plan_tests 12 test_fail \ "invalid-packet-size/trace" \ @@ -61,4 +61,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" \ + "^ At line 3 in metadata stream: syntax error, unexpected CTF_RSBRAC: token=\"]\"" + rm -f "${stdout_file}" "${stderr_file}" -- 2.34.1