Tests: use templates for stream intersection and packet_seq_num
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 5 Apr 2016 17:08:59 +0000 (13:08 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 22 Apr 2016 22:05:26 +0000 (18:05 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/bin/Makefile.am
tests/bin/test_intersection [deleted file]
tests/bin/test_intersection.in [new file with mode: 0644]
tests/bin/test_packet_seq_num [deleted file]
tests/bin/test_packet_seq_num.in [new file with mode: 0644]
tests/bin/test_trace_read.in [changed mode: 0755->0644]

index 46f8352a67d3668ab2978fd55cb64de14ea3a69f..2bf94246a893e5c03e8283e422514a347eb94e44 100644 (file)
@@ -1,6 +1,6 @@
 noinst_SCRIPTS = test_trace_read test_intersection test_packet_seq_num
 CLEANFILES = $(noinst_SCRIPTS)
 noinst_SCRIPTS = test_trace_read test_intersection test_packet_seq_num
 CLEANFILES = $(noinst_SCRIPTS)
-EXTRA_DIST = test_trace_read.in
+EXTRA_DIST = test_trace_read.in test_intersection.in test_packet_seq_num.in
 
 $(noinst_SCRIPTS): %: %.in
        sed "s#@ABSTOPSRCDIR@#$(abs_top_srcdir)#g" < $< > $@
 
 $(noinst_SCRIPTS): %: %.in
        sed "s#@ABSTOPSRCDIR@#$(abs_top_srcdir)#g" < $< > $@
diff --git a/tests/bin/test_intersection b/tests/bin/test_intersection
deleted file mode 100755 (executable)
index aec57de..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/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/bin/test_intersection.in b/tests/bin/test_intersection.in
new file mode 100644 (file)
index 0000000..28cb58a
--- /dev/null
@@ -0,0 +1,56 @@
+#!/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
+CTF_TRACES=@ABSTOPSRCDIR@/tests/ctf-traces
+
+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 ${CTF_TRACES}/intersection/3eventsintersect 8 3
+
+diag "2 streams offsetted with 3 packets intersecting (exchanged file names)"
+test_intersect ${CTF_TRACES}/intersection/3eventsintersectreverse 8 3
+
+diag "No intersection between 2 streams"
+test_intersect ${CTF_TRACES}/intersection/nointersect 6 0
+
+diag "Only 1 stream"
+test_intersect ${CTF_TRACES}/intersection/onestream 3 3
+
+diag "No stream at all"
+test_intersect ${CTF_TRACES}/intersection/nostream 0 0
diff --git a/tests/bin/test_packet_seq_num b/tests/bin/test_packet_seq_num
deleted file mode 100755 (executable)
index 1b165ec..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/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_no_lost() {
-       trace=$1
-
-       $BABELTRACE_BIN $trace >/dev/null 2>&1
-       ok $? "Trace parses"
-       $BABELTRACE_BIN $trace 2>&1 >/dev/null | grep "\[warning\] Tracer lost"
-       if test $? = 0; then
-               fail 1 "Should not find any lost events"
-       else
-               ok 0 "No events lost"
-       fi
-}
-
-test_lost() {
-       trace=$1
-       expectedcountstr=$2
-
-       $BABELTRACE_BIN $trace >/dev/null 2>&1
-       ok $? "Trace parses"
-
-       # Convert warnings like:
-       # [warning] Tracer lost 2 trace packets between ....
-       # [warning] Tracer lost 3 trace packets between ....
-       # into "2,3" and make sure it matches the expected result
-       $BABELTRACE_BIN $trace 2>&1 >/dev/null | grep "\[warning\] Tracer lost" \
-               | cut -d" " -f4 | tr "\n" "," | sed "s/.$//" | \
-               grep "$expectedcountstr" >/dev/null
-       ok $? "Lost events string matches $expectedcountstr"
-
-}
-
-diag "Test the packet_seq_num validation"
-
-diag "No packet lost"
-test_no_lost $TESTDIR/ctf-traces/packet_seq_num/no_lost
-
-diag "No packet lost, packet_seq_num not starting at 0"
-test_no_lost $TESTDIR/ctf-traces/packet_seq_num/no_lost_not_starting_at_0
-
-diag "1 stream, 2 packets lost before the last packet"
-test_lost $TESTDIR/ctf-traces/packet_seq_num/2_lost_before_last "2"
-
-diag "2 streams, packets lost in one of them"
-test_lost $TESTDIR/ctf-traces/packet_seq_num/2_streams_lost_in_1 "2"
-
-diag "2 streams, packets lost in both"
-test_lost $TESTDIR/ctf-traces/packet_seq_num/2_streams_lost_in_2 "3,2,1"
diff --git a/tests/bin/test_packet_seq_num.in b/tests/bin/test_packet_seq_num.in
new file mode 100644 (file)
index 0000000..3348a4c
--- /dev/null
@@ -0,0 +1,76 @@
+#!/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
+CTF_TRACES=@ABSTOPSRCDIR@/tests/ctf-traces
+
+source $TESTDIR/utils/tap/tap.sh
+
+NUM_TESTS=10
+
+plan_tests $NUM_TESTS
+
+test_no_lost() {
+       trace=$1
+
+       $BABELTRACE_BIN $trace >/dev/null 2>&1
+       ok $? "Trace parses"
+       $BABELTRACE_BIN $trace 2>&1 >/dev/null | grep "\[warning\] Tracer lost"
+       if test $? = 0; then
+               fail 1 "Should not find any lost events"
+       else
+               ok 0 "No events lost"
+       fi
+}
+
+test_lost() {
+       trace=$1
+       expectedcountstr=$2
+
+       $BABELTRACE_BIN $trace >/dev/null 2>&1
+       ok $? "Trace parses"
+
+       # Convert warnings like:
+       # [warning] Tracer lost 2 trace packets between ....
+       # [warning] Tracer lost 3 trace packets between ....
+       # into "2,3" and make sure it matches the expected result
+       $BABELTRACE_BIN $trace 2>&1 >/dev/null | grep "\[warning\] Tracer lost" \
+               | cut -d" " -f4 | tr "\n" "," | sed "s/.$//" | \
+               grep "$expectedcountstr" >/dev/null
+       ok $? "Lost events string matches $expectedcountstr"
+
+}
+
+diag "Test the packet_seq_num validation"
+
+diag "No packet lost"
+test_no_lost ${CTF_TRACES}/packet_seq_num/no_lost
+
+diag "No packet lost, packet_seq_num not starting at 0"
+test_no_lost ${CTF_TRACES}/packet_seq_num/no_lost_not_starting_at_0
+
+diag "1 stream, 2 packets lost before the last packet"
+test_lost ${CTF_TRACES}/packet_seq_num/2_lost_before_last "2"
+
+diag "2 streams, packets lost in one of them"
+test_lost ${CTF_TRACES}/packet_seq_num/2_streams_lost_in_1 "2"
+
+diag "2 streams, packets lost in both"
+test_lost ${CTF_TRACES}/packet_seq_num/2_streams_lost_in_2 "3,2,1"
old mode 100755 (executable)
new mode 100644 (file)
This page took 0.027938 seconds and 4 git commands to generate.