Fix: src.ctf.fs: initialize the other_entry variable
[babeltrace.git] / tests / cli / test_packet_seq_num
CommitLineData
097b4317
JD
1#!/bin/bash
2#
644e0364 3# Copyright (C) 2015 Julien Desfossez <jdesfossez@efficios.com>
097b4317
JD
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
644e0364
MJ
18SH_TAP=1
19
20if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
21 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
22else
23 UTILSSH="$(dirname "$0")/../utils/utils.sh"
24fi
25
26# shellcheck source=../utils/utils.sh
27source "$UTILSSH"
097b4317
JD
28
29NUM_TESTS=10
30
31plan_tests $NUM_TESTS
32
33test_no_lost() {
644e0364 34 local trace=$1
097b4317 35
644e0364 36 "${BT_TESTS_BT2_BIN}" "$trace" >/dev/null 2>&1
097b4317 37 ok $? "Trace parses"
644e0364 38 "${BT_TESTS_BT2_BIN}" "$trace" 2>&1 >/dev/null | "${BT_TESTS_GREP_BIN}" "\[warning\] Tracer lost"
097b4317
JD
39 if test $? = 0; then
40 fail 1 "Should not find any lost events"
41 else
42 ok 0 "No events lost"
43 fi
44}
45
46test_lost() {
644e0364
MJ
47 local trace=$1
48 local expectedcountstr=$2
097b4317 49
644e0364 50 "${BT_TESTS_BT2_BIN}" "$trace" >/dev/null 2>&1
097b4317
JD
51 ok $? "Trace parses"
52
53 # Convert warnings like:
165711ff
MD
54 # WARNING: Tracer discarded 2 trace packets between ....
55 # WARNING: Tracer discarded 3 trace packets between ....
097b4317 56 # into "2,3" and make sure it matches the expected result
644e0364
MJ
57 "${BT_TESTS_BT2_BIN}" "$trace" 2>&1 >/dev/null | "${BT_TESTS_GREP_BIN}" "WARNING: Tracer discarded" \
58 | cut -d" " -f4 | tr "\n" "," | "${BT_TESTS_SED_BIN}" "s/.$//" | \
59 "${BT_TESTS_GREP_BIN}" "$expectedcountstr" >/dev/null
097b4317
JD
60 ok $? "Lost events string matches $expectedcountstr"
61
62}
63
64diag "Test the packet_seq_num validation"
65
66diag "No packet lost"
bbff0ab4 67test_no_lost "${BT_CTF_TRACES_PATH}/packet_seq_num/no_lost"
097b4317
JD
68
69diag "No packet lost, packet_seq_num not starting at 0"
bbff0ab4 70test_no_lost "${BT_CTF_TRACES_PATH}/packet_seq_num/no_lost_not_starting_at_0"
097b4317
JD
71
72diag "1 stream, 2 packets lost before the last packet"
bbff0ab4 73test_lost "${BT_CTF_TRACES_PATH}/packet_seq_num/2_lost_before_last" "2"
097b4317
JD
74
75diag "2 streams, packets lost in one of them"
bbff0ab4 76test_lost "${BT_CTF_TRACES_PATH}/packet_seq_num/2_streams_lost_in_1" "2"
097b4317
JD
77
78diag "2 streams, packets lost in both"
bbff0ab4 79test_lost "${BT_CTF_TRACES_PATH}/packet_seq_num/2_streams_lost_in_2" "2,3,1"
This page took 0.064628 seconds and 4 git commands to generate.