Commit | Line | Data |
---|---|---|
097b4317 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 | ||
de3fb4cd | 18 | . "@abs_top_builddir@/tests/utils/common.sh" |
097b4317 JD |
19 | |
20 | NUM_TESTS=10 | |
21 | ||
22 | plan_tests $NUM_TESTS | |
23 | ||
24 | test_no_lost() { | |
25 | trace=$1 | |
26 | ||
de3fb4cd | 27 | "${BT_BIN}" "$trace" >/dev/null 2>&1 |
097b4317 | 28 | ok $? "Trace parses" |
de3fb4cd | 29 | "${BT_BIN}" "$trace" 2>&1 >/dev/null | @GREP@ "\[warning\] Tracer lost" |
097b4317 JD |
30 | if test $? = 0; then |
31 | fail 1 "Should not find any lost events" | |
32 | else | |
33 | ok 0 "No events lost" | |
34 | fi | |
35 | } | |
36 | ||
37 | test_lost() { | |
38 | trace=$1 | |
39 | expectedcountstr=$2 | |
40 | ||
de3fb4cd | 41 | "${BT_BIN}" "$trace" >/dev/null 2>&1 |
097b4317 JD |
42 | ok $? "Trace parses" |
43 | ||
44 | # Convert warnings like: | |
8825003a MD |
45 | # WARNING: Tracer discarded 2 trace packets between .... |
46 | # WARNING: Tracer discarded 3 trace packets between .... | |
097b4317 | 47 | # into "2,3" and make sure it matches the expected result |
de3fb4cd | 48 | "${BT_BIN}" "$trace" 2>&1 >/dev/null | @GREP@ "WARNING: Tracer discarded" \ |
c41a7502 MJ |
49 | | cut -d" " -f4 | tr "\n" "," | @SED@ "s/.$//" | \ |
50 | @GREP@ "$expectedcountstr" >/dev/null | |
097b4317 JD |
51 | ok $? "Lost events string matches $expectedcountstr" |
52 | ||
53 | } | |
54 | ||
55 | diag "Test the packet_seq_num validation" | |
56 | ||
57 | diag "No packet lost" | |
de3fb4cd | 58 | test_no_lost "${BT_CTF_TRACES}/packet_seq_num/no_lost" |
097b4317 JD |
59 | |
60 | diag "No packet lost, packet_seq_num not starting at 0" | |
de3fb4cd | 61 | test_no_lost "${BT_CTF_TRACES}/packet_seq_num/no_lost_not_starting_at_0" |
097b4317 JD |
62 | |
63 | diag "1 stream, 2 packets lost before the last packet" | |
de3fb4cd | 64 | test_lost "${BT_CTF_TRACES}/packet_seq_num/2_lost_before_last" "2" |
097b4317 JD |
65 | |
66 | diag "2 streams, packets lost in one of them" | |
de3fb4cd | 67 | test_lost "${BT_CTF_TRACES}/packet_seq_num/2_streams_lost_in_1" "2" |
097b4317 JD |
68 | |
69 | diag "2 streams, packets lost in both" | |
bf5464f8 | 70 | test_lost "${BT_CTF_TRACES}/packet_seq_num/2_streams_lost_in_2" "2,3,1" |