1f8d20cfd376f24fe73d218d659d9331f0ac4d66
[babeltrace.git] / tests / cli / test_intersection
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 SH_TAP=1
19
20 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
21 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
22 else
23 UTILSSH="$(dirname "$0")/../utils/utils.sh"
24 fi
25
26 # shellcheck source=../utils/utils.sh
27 source "$UTILSSH"
28
29 NUM_TESTS=10
30
31 plan_tests $NUM_TESTS
32
33 test_intersect() {
34 local trace="$1"
35 local totalevents="$2"
36 local intersect="$3"
37
38 local cnt
39
40 cnt=$("${BT_TESTS_BT2_BIN}" "$trace" | wc -l)
41 test "${cnt// /}" = "$totalevents"
42 ok $? "$totalevents events in the whole trace"
43
44 cnt=$("${BT_TESTS_BT2_BIN}" --stream-intersection "$trace" 2>/dev/null| wc -l)
45 test "${cnt// /}" = "$intersect"
46 ok $? "$intersect events in packets intersecting"
47 }
48
49 diag "Test the stream intersection feature"
50
51 diag "2 streams offsetted with 3 packets intersecting"
52 test_intersect "${BT_CTF_TRACES_PATH}/intersection/3eventsintersect" 8 3
53
54 diag "2 streams offsetted with 3 packets intersecting (exchanged file names)"
55 test_intersect "${BT_CTF_TRACES_PATH}/intersection/3eventsintersectreverse" 8 3
56
57 diag "No intersection between 2 streams"
58 test_intersect "${BT_CTF_TRACES_PATH}/intersection/nointersect" 6 0
59
60 diag "Only 1 stream"
61 test_intersect "${BT_CTF_TRACES_PATH}/intersection/onestream" 3 3
62
63 diag "No stream at all"
64 test_intersect "${BT_CTF_TRACES_PATH}/intersection/nostream" 0 0
This page took 0.032453 seconds and 3 git commands to generate.