From ebb858ae79292e5f25546c2caed66dd5195a7658 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 15 Aug 2022 14:02:39 -0400 Subject: [PATCH] tests: add test with incomplete packet header During developement we hit a problem where src.ctf.fs's medium returned less data than the `minSize` parameter, when reading a faulty trace. The trace added in this patch reproduces the problem. It consists of a full packet, followed by a single byte. When trying to read a second packet, the ItemSeqIter instance would ask the medium for at least two bytes, but the medium would return a buffer with a single byte (the data available until the end of file). The fix was to make the medium generate an error in this case. Change-Id: I9a79360b18091f517846ca2be94fbf10fb9af349 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/12753 Reviewed-by: Philippe Proulx --- .../1/fail/incomplete-packet-header/metadata | 21 ++++++++++++++++++ .../1/fail/incomplete-packet-header/stream | Bin 0 -> 11 bytes tests/plugins/src.ctf.fs/fail/test-fail.sh | 8 ++++++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/data/ctf-traces/1/fail/incomplete-packet-header/metadata create mode 100644 tests/data/ctf-traces/1/fail/incomplete-packet-header/stream diff --git a/tests/data/ctf-traces/1/fail/incomplete-packet-header/metadata b/tests/data/ctf-traces/1/fail/incomplete-packet-header/metadata new file mode 100644 index 00000000..de600fda --- /dev/null +++ b/tests/data/ctf-traces/1/fail/incomplete-packet-header/metadata @@ -0,0 +1,21 @@ +/* CTF 1.8 */ + +trace { + major = 1; + minor = 8; + byte_order = be; +}; + +stream { + packet.context := struct { + integer { size = 16; } packet_size; + integer { size = 16; } meow_mix; + }; +}; + +event { + name = coucou; + fields := struct { + string lel; + }; +}; diff --git a/tests/data/ctf-traces/1/fail/incomplete-packet-header/stream b/tests/data/ctf-traces/1/fail/incomplete-packet-header/stream new file mode 100644 index 0000000000000000000000000000000000000000..2a770b2873c4cccffb8b89b0d3caf5dc4a7c4327 GIT binary patch literal 11 ScmZPwD9F#vP0h_LW&i*c>I1j{ literal 0 HcmV?d00001 diff --git a/tests/plugins/src.ctf.fs/fail/test-fail.sh b/tests/plugins/src.ctf.fs/fail/test-fail.sh index 69672925..5b90dcb9 100755 --- a/tests/plugins/src.ctf.fs/fail/test-fail.sh +++ b/tests/plugins/src.ctf.fs/fail/test-fail.sh @@ -88,7 +88,7 @@ test_fail() { done } -plan_tests 56 +plan_tests 64 test_fail \ "invalid-packet-size/trace" \ @@ -120,6 +120,12 @@ test_fail \ "/dev/null" \ "Variant field class's tag field class is not an enumeration field class: " +test_fail \ + "incomplete-packet-header" \ + 1 \ + "/dev/null" \ + "Insufficient data in file to fulfill request" + test_fail \ "meta-no-trace-cls-no-stream-cls" \ 2 \ -- 2.34.1