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 | |
22 | ||
23 | source $TESTDIR/utils/tap/tap.sh | |
24 | ||
25 | NUM_TESTS=10 | |
26 | ||
27 | plan_tests $NUM_TESTS | |
28 | ||
29 | test_no_lost() { | |
30 | trace=$1 | |
31 | ||
32 | $BABELTRACE_BIN $trace >/dev/null 2>&1 | |
33 | ok $? "Trace parses" | |
34 | $BABELTRACE_BIN $trace 2>&1 >/dev/null | grep "\[warning\] Tracer lost" | |
35 | if test $? = 0; then | |
36 | fail 1 "Should not find any lost events" | |
37 | else | |
38 | ok 0 "No events lost" | |
39 | fi | |
40 | } | |
41 | ||
42 | test_lost() { | |
43 | trace=$1 | |
44 | expectedcountstr=$2 | |
45 | ||
46 | $BABELTRACE_BIN $trace >/dev/null 2>&1 | |
47 | ok $? "Trace parses" | |
48 | ||
49 | # Convert warnings like: | |
50 | # [warning] Tracer lost 2 trace packets between .... | |
51 | # [warning] Tracer lost 3 trace packets between .... | |
52 | # into "2,3" and make sure it matches the expected result | |
53 | $BABELTRACE_BIN $trace 2>&1 >/dev/null | grep "\[warning\] Tracer lost" \ | |
54 | | cut -d" " -f4 | tr "\n" "," | sed "s/.$//" | \ | |
55 | grep "$expectedcountstr" >/dev/null | |
56 | ok $? "Lost events string matches $expectedcountstr" | |
57 | ||
58 | } | |
59 | ||
60 | diag "Test the packet_seq_num validation" | |
61 | ||
62 | diag "No packet lost" | |
63 | test_no_lost $TESTDIR/ctf-traces/packet_seq_num/no_lost | |
64 | ||
65 | diag "No packet lost, packet_seq_num not starting at 0" | |
66 | test_no_lost $TESTDIR/ctf-traces/packet_seq_num/no_lost_not_starting_at_0 | |
67 | ||
68 | diag "1 stream, 2 packets lost before the last packet" | |
69 | test_lost $TESTDIR/ctf-traces/packet_seq_num/2_lost_before_last "2" | |
70 | ||
71 | diag "2 streams, packets lost in one of them" | |
72 | test_lost $TESTDIR/ctf-traces/packet_seq_num/2_streams_lost_in_1 "2" | |
73 | ||
74 | diag "2 streams, packets lost in both" | |
75 | test_lost $TESTDIR/ctf-traces/packet_seq_num/2_streams_lost_in_2 "3,2,1" |