Test the stream intersection feature
authorJulien Desfossez <jdesfossez@efficios.com>
Mon, 21 Sep 2015 15:23:05 +0000 (11:23 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 22 Apr 2016 22:03:45 +0000 (18:03 -0400)
5 traces are provided:
- 3 packets intersecting between two streams slightly offsetted
- Same trace with 3 packets intersecting but with swapped trace file names
- No intersection between packets
- Only one stream
- No streams at all

These traces were generated with the CTF writer API from the master
branch, the binary traces will be replaced by the test program when the
feature arrives in master.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
14 files changed:
tests/bin/test_intersection [new file with mode: 0755]
tests/ctf-traces/intersection/3eventsintersect/metadata [new file with mode: 0644]
tests/ctf-traces/intersection/3eventsintersect/test_stream_0 [new file with mode: 0644]
tests/ctf-traces/intersection/3eventsintersect/test_stream_1 [new file with mode: 0644]
tests/ctf-traces/intersection/3eventsintersectreverse/metadata [new file with mode: 0644]
tests/ctf-traces/intersection/3eventsintersectreverse/test_stream_0 [new file with mode: 0644]
tests/ctf-traces/intersection/3eventsintersectreverse/test_stream_1 [new file with mode: 0644]
tests/ctf-traces/intersection/nointersect/metadata [new file with mode: 0644]
tests/ctf-traces/intersection/nointersect/test_stream_0 [new file with mode: 0644]
tests/ctf-traces/intersection/nointersect/test_stream_1 [new file with mode: 0644]
tests/ctf-traces/intersection/nostream/metadata [new file with mode: 0644]
tests/ctf-traces/intersection/onestream/metadata [new file with mode: 0644]
tests/ctf-traces/intersection/onestream/test_stream_0 [new file with mode: 0644]
tests/tests

diff --git a/tests/bin/test_intersection b/tests/bin/test_intersection
new file mode 100755 (executable)
index 0000000..aec57de
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# Copyright (C) - 2015 Julien Desfossez <jdesfossez@efficios.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License, version 2 only, as
+# published by the Free Software Foundation.
+#
+# 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., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+CURDIR=$(dirname $0)
+TESTDIR=$CURDIR/..
+
+BABELTRACE_BIN=$CURDIR/../../converter/babeltrace
+
+source $TESTDIR/utils/tap/tap.sh
+
+NUM_TESTS=10
+
+plan_tests $NUM_TESTS
+
+test_intersect() {
+       trace=$1
+       totalevents=$2
+       intersect=$3
+
+       test $($BABELTRACE_BIN $trace | wc -l) = $totalevents
+       ok $? "$totalevents events in the whole trace"
+       test $($BABELTRACE_BIN --stream-intersection $trace 2>/dev/null| wc -l) = $intersect
+       ok $? "$intersect events in packets intersecting"
+}
+
+diag "Test the stream intersection feature"
+
+diag "2 streams offsetted with 3 packets intersecting"
+test_intersect $TESTDIR/ctf-traces/intersection/3eventsintersect 8 3
+
+diag "2 streams offsetted with 3 packets intersecting (exchanged file names)"
+test_intersect $TESTDIR/ctf-traces/intersection/3eventsintersectreverse 8 3
+
+diag "No intersection between 2 streams"
+test_intersect $TESTDIR/ctf-traces/intersection/nointersect 6 0
+
+diag "Only 1 stream"
+test_intersect $TESTDIR/ctf-traces/intersection/onestream 3 3
+
+diag "No stream at all"
+test_intersect $TESTDIR/ctf-traces/intersection/nostream 0 0
diff --git a/tests/ctf-traces/intersection/3eventsintersect/metadata b/tests/ctf-traces/intersection/3eventsintersect/metadata
new file mode 100644 (file)
index 0000000..7972ddf
--- /dev/null
@@ -0,0 +1,58 @@
+/* CTF 1.8 */
+
+trace {
+       major = 1;
+       minor = 8;
+       uuid = "7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf";
+       byte_order = be;
+       packet.header := struct {
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } magic;
+               integer { size = 8; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } uuid[16];
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } stream_id;
+       } align(8);
+};
+
+env {
+       host = "sinkpad";
+};
+
+clock {
+       name = test_clock;
+       uuid = "7b9e2f2a-530e-4ab1-816f-0831b5c09140";
+       description = "This is a test clock";
+       freq = 1000000000;
+       precision = 10;
+       offset_s = 1351530929945824323;
+       offset = 0;
+       absolute = TRUE;
+};
+
+stream {
+       id = 0;
+       event.header := struct {
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } id;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; map = clock.test_clock.value; } timestamp;
+       } align(8);
+
+       packet.context := struct {
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } timestamp_begin;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } timestamp_end;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } content_size;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } packet_size;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } events_discarded;
+               integer { size = 64; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_seq_num;
+       } align(8);
+};
+
+event {
+       id = 0;
+       name = "dummy_event";
+       stream_id = 0;
+       fields := struct {
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } dummy_value;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } tracefile_id;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_begin;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_end;
+       } align(1);
+};
+
diff --git a/tests/ctf-traces/intersection/3eventsintersect/test_stream_0 b/tests/ctf-traces/intersection/3eventsintersect/test_stream_0
new file mode 100644 (file)
index 0000000..6a69e44
Binary files /dev/null and b/tests/ctf-traces/intersection/3eventsintersect/test_stream_0 differ
diff --git a/tests/ctf-traces/intersection/3eventsintersect/test_stream_1 b/tests/ctf-traces/intersection/3eventsintersect/test_stream_1
new file mode 100644 (file)
index 0000000..0cf1404
Binary files /dev/null and b/tests/ctf-traces/intersection/3eventsintersect/test_stream_1 differ
diff --git a/tests/ctf-traces/intersection/3eventsintersectreverse/metadata b/tests/ctf-traces/intersection/3eventsintersectreverse/metadata
new file mode 100644 (file)
index 0000000..7972ddf
--- /dev/null
@@ -0,0 +1,58 @@
+/* CTF 1.8 */
+
+trace {
+       major = 1;
+       minor = 8;
+       uuid = "7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf";
+       byte_order = be;
+       packet.header := struct {
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } magic;
+               integer { size = 8; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } uuid[16];
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } stream_id;
+       } align(8);
+};
+
+env {
+       host = "sinkpad";
+};
+
+clock {
+       name = test_clock;
+       uuid = "7b9e2f2a-530e-4ab1-816f-0831b5c09140";
+       description = "This is a test clock";
+       freq = 1000000000;
+       precision = 10;
+       offset_s = 1351530929945824323;
+       offset = 0;
+       absolute = TRUE;
+};
+
+stream {
+       id = 0;
+       event.header := struct {
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } id;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; map = clock.test_clock.value; } timestamp;
+       } align(8);
+
+       packet.context := struct {
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } timestamp_begin;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } timestamp_end;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } content_size;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } packet_size;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } events_discarded;
+               integer { size = 64; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_seq_num;
+       } align(8);
+};
+
+event {
+       id = 0;
+       name = "dummy_event";
+       stream_id = 0;
+       fields := struct {
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } dummy_value;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } tracefile_id;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_begin;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_end;
+       } align(1);
+};
+
diff --git a/tests/ctf-traces/intersection/3eventsintersectreverse/test_stream_0 b/tests/ctf-traces/intersection/3eventsintersectreverse/test_stream_0
new file mode 100644 (file)
index 0000000..0cf1404
Binary files /dev/null and b/tests/ctf-traces/intersection/3eventsintersectreverse/test_stream_0 differ
diff --git a/tests/ctf-traces/intersection/3eventsintersectreverse/test_stream_1 b/tests/ctf-traces/intersection/3eventsintersectreverse/test_stream_1
new file mode 100644 (file)
index 0000000..6a69e44
Binary files /dev/null and b/tests/ctf-traces/intersection/3eventsintersectreverse/test_stream_1 differ
diff --git a/tests/ctf-traces/intersection/nointersect/metadata b/tests/ctf-traces/intersection/nointersect/metadata
new file mode 100644 (file)
index 0000000..93090a2
--- /dev/null
@@ -0,0 +1,58 @@
+/* CTF 1.8 */
+
+trace {
+       major = 1;
+       minor = 8;
+       uuid = "a967fbc0-c89b-4b92-b5df-30688d576ddf";
+       byte_order = be;
+       packet.header := struct {
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } magic;
+               integer { size = 8; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } uuid[16];
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } stream_id;
+       } align(8);
+};
+
+env {
+       host = "sinkpad";
+};
+
+clock {
+       name = test_clock;
+       uuid = "fb759646-b2b9-42d7-9013-f790694dd902";
+       description = "This is a test clock";
+       freq = 1000000000;
+       precision = 10;
+       offset_s = 1351530929945824323;
+       offset = 0;
+       absolute = TRUE;
+};
+
+stream {
+       id = 0;
+       event.header := struct {
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } id;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; map = clock.test_clock.value; } timestamp;
+       } align(8);
+
+       packet.context := struct {
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } timestamp_begin;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } timestamp_end;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } content_size;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } packet_size;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } events_discarded;
+               integer { size = 64; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_seq_num;
+       } align(8);
+};
+
+event {
+       id = 0;
+       name = "dummy_event";
+       stream_id = 0;
+       fields := struct {
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } dummy_value;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } tracefile_id;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_begin;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_end;
+       } align(1);
+};
+
diff --git a/tests/ctf-traces/intersection/nointersect/test_stream_0 b/tests/ctf-traces/intersection/nointersect/test_stream_0
new file mode 100644 (file)
index 0000000..7c32bae
Binary files /dev/null and b/tests/ctf-traces/intersection/nointersect/test_stream_0 differ
diff --git a/tests/ctf-traces/intersection/nointersect/test_stream_1 b/tests/ctf-traces/intersection/nointersect/test_stream_1
new file mode 100644 (file)
index 0000000..e656ba6
Binary files /dev/null and b/tests/ctf-traces/intersection/nointersect/test_stream_1 differ
diff --git a/tests/ctf-traces/intersection/nostream/metadata b/tests/ctf-traces/intersection/nostream/metadata
new file mode 100644 (file)
index 0000000..93090a2
--- /dev/null
@@ -0,0 +1,58 @@
+/* CTF 1.8 */
+
+trace {
+       major = 1;
+       minor = 8;
+       uuid = "a967fbc0-c89b-4b92-b5df-30688d576ddf";
+       byte_order = be;
+       packet.header := struct {
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } magic;
+               integer { size = 8; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } uuid[16];
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } stream_id;
+       } align(8);
+};
+
+env {
+       host = "sinkpad";
+};
+
+clock {
+       name = test_clock;
+       uuid = "fb759646-b2b9-42d7-9013-f790694dd902";
+       description = "This is a test clock";
+       freq = 1000000000;
+       precision = 10;
+       offset_s = 1351530929945824323;
+       offset = 0;
+       absolute = TRUE;
+};
+
+stream {
+       id = 0;
+       event.header := struct {
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } id;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; map = clock.test_clock.value; } timestamp;
+       } align(8);
+
+       packet.context := struct {
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } timestamp_begin;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } timestamp_end;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } content_size;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } packet_size;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } events_discarded;
+               integer { size = 64; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_seq_num;
+       } align(8);
+};
+
+event {
+       id = 0;
+       name = "dummy_event";
+       stream_id = 0;
+       fields := struct {
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } dummy_value;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } tracefile_id;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_begin;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_end;
+       } align(1);
+};
+
diff --git a/tests/ctf-traces/intersection/onestream/metadata b/tests/ctf-traces/intersection/onestream/metadata
new file mode 100644 (file)
index 0000000..93090a2
--- /dev/null
@@ -0,0 +1,58 @@
+/* CTF 1.8 */
+
+trace {
+       major = 1;
+       minor = 8;
+       uuid = "a967fbc0-c89b-4b92-b5df-30688d576ddf";
+       byte_order = be;
+       packet.header := struct {
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } magic;
+               integer { size = 8; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } uuid[16];
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } stream_id;
+       } align(8);
+};
+
+env {
+       host = "sinkpad";
+};
+
+clock {
+       name = test_clock;
+       uuid = "fb759646-b2b9-42d7-9013-f790694dd902";
+       description = "This is a test clock";
+       freq = 1000000000;
+       precision = 10;
+       offset_s = 1351530929945824323;
+       offset = 0;
+       absolute = TRUE;
+};
+
+stream {
+       id = 0;
+       event.header := struct {
+               integer { size = 32; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } id;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; map = clock.test_clock.value; } timestamp;
+       } align(8);
+
+       packet.context := struct {
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } timestamp_begin;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } timestamp_end;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } content_size;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } packet_size;
+               integer { size = 64; align = 8; signed = false; encoding = none; base = decimal; byte_order = be; } events_discarded;
+               integer { size = 64; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_seq_num;
+       } align(8);
+};
+
+event {
+       id = 0;
+       name = "dummy_event";
+       stream_id = 0;
+       fields := struct {
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } dummy_value;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } tracefile_id;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_begin;
+               integer { size = 32; align = 1; signed = false; encoding = none; base = decimal; byte_order = be; } packet_end;
+       } align(1);
+};
+
diff --git a/tests/ctf-traces/intersection/onestream/test_stream_0 b/tests/ctf-traces/intersection/onestream/test_stream_0
new file mode 100644 (file)
index 0000000..7c32bae
Binary files /dev/null and b/tests/ctf-traces/intersection/onestream/test_stream_0 differ
index 19ad568dde8b1903ccf53607e3b521a8ab1f8917..6e028df27788517a9fda2955f890b3c0f690b9ed 100644 (file)
@@ -1,5 +1,6 @@
 bin/test_trace_read
 bin/test_packet_seq_num
+bin/test_intersection
 lib/test_bitfield
 lib/test_seek_empty_packet
 lib/test_seek_big_trace
This page took 0.044469 seconds and 4 git commands to generate.