Commit | Line | Data |
---|---|---|
89f422d9 JD |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2015 Julien Desfossez <jdesfossez@efficios.com> | |
4 | # | |
5 | # This program is free software; you can redistribute it and/or modify it | |
6 | # under the terms of the GNU General Public License, version 2 only, as | |
7 | # published by the Free Software Foundation. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | # more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License along with | |
15 | # this program; if not, write to the Free Software Foundation, Inc., 51 | |
16 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 | ||
18 | CURDIR=$(dirname $0) | |
19 | TESTDIR=$CURDIR/.. | |
20 | ||
21 | BABELTRACE_BIN=$CURDIR/../../converter/babeltrace | |
fcacebd5 | 22 | CTF_TRACES=@abs_top_srcdir@/tests/ctf-traces |
89f422d9 JD |
23 | |
24 | source $TESTDIR/utils/tap/tap.sh | |
25 | ||
26 | NUM_TESTS=10 | |
27 | ||
28 | plan_tests $NUM_TESTS | |
29 | ||
30 | test_no_lost() { | |
31 | trace=$1 | |
32 | ||
33 | $BABELTRACE_BIN $trace >/dev/null 2>&1 | |
34 | ok $? "Trace parses" | |
fcacebd5 | 35 | $BABELTRACE_BIN $trace 2>&1 >/dev/null | @GREP@ "\[warning\] Tracer lost" |
89f422d9 JD |
36 | if test $? = 0; then |
37 | fail 1 "Should not find any lost events" | |
38 | else | |
39 | ok 0 "No events lost" | |
40 | fi | |
41 | } | |
42 | ||
43 | test_lost() { | |
44 | trace=$1 | |
45 | expectedcountstr=$2 | |
46 | ||
47 | $BABELTRACE_BIN $trace >/dev/null 2>&1 | |
48 | ok $? "Trace parses" | |
49 | ||
50 | # Convert warnings like: | |
51 | # [warning] Tracer lost 2 trace packets between .... | |
52 | # [warning] Tracer lost 3 trace packets between .... | |
53 | # into "2,3" and make sure it matches the expected result | |
fcacebd5 MJ |
54 | $BABELTRACE_BIN $trace 2>&1 >/dev/null | @GREP@ "\[warning\] Tracer lost" \ |
55 | | cut -d" " -f4 | tr "\n" "," | @SED@ "s/.$//" | \ | |
56 | @GREP@ "$expectedcountstr" >/dev/null | |
89f422d9 JD |
57 | ok $? "Lost events string matches $expectedcountstr" |
58 | ||
59 | } | |
60 | ||
61 | diag "Test the packet_seq_num validation" | |
62 | ||
63 | diag "No packet lost" | |
3a25c1e8 | 64 | test_no_lost ${CTF_TRACES}/packet_seq_num/no_lost |
89f422d9 JD |
65 | |
66 | diag "No packet lost, packet_seq_num not starting at 0" | |
3a25c1e8 | 67 | test_no_lost ${CTF_TRACES}/packet_seq_num/no_lost_not_starting_at_0 |
89f422d9 JD |
68 | |
69 | diag "1 stream, 2 packets lost before the last packet" | |
3a25c1e8 | 70 | test_lost ${CTF_TRACES}/packet_seq_num/2_lost_before_last "2" |
89f422d9 JD |
71 | |
72 | diag "2 streams, packets lost in one of them" | |
3a25c1e8 | 73 | test_lost ${CTF_TRACES}/packet_seq_num/2_streams_lost_in_1 "2" |
89f422d9 JD |
74 | |
75 | diag "2 streams, packets lost in both" | |
3a25c1e8 | 76 | test_lost ${CTF_TRACES}/packet_seq_num/2_streams_lost_in_2 "3,2,1" |