tests: add test with incomplete packet header
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 15 Aug 2022 18:02:39 +0000 (14:02 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 23 Aug 2022 16:06:16 +0000 (12:06 -0400)
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 <simon.marchi@efficios.com>
tests/data/ctf-traces/1/fail/incomplete-packet-header/metadata [new file with mode: 0644]
tests/data/ctf-traces/1/fail/incomplete-packet-header/stream [new file with mode: 0644]
tests/plugins/src.ctf.fs/fail/test_fail

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 (file)
index 0000000..de600fd
--- /dev/null
@@ -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 (file)
index 0000000..2a770b2
Binary files /dev/null and b/tests/data/ctf-traces/1/fail/incomplete-packet-header/stream differ
index 9c940f5174a95849c89ea2b5b4d43b704836323f..c44c7e5cce9a0f5001b84c6e7d4abfed1c36d2b6 100755 (executable)
@@ -84,7 +84,7 @@ test_fail() {
        done
 }
 
-plan_tests 40
+plan_tests 48
 
 test_fail \
        "invalid-packet-size/trace" \
@@ -104,6 +104,12 @@ test_fail \
        "/dev/null" \
        "^  At line 3 in metadata stream: syntax error, unexpected CTF_RSBRAC: token=\"]\""
 
+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 \
This page took 0.024574 seconds and 5 git commands to generate.