Fix: check for NULL in destroy_pretty_data
[babeltrace.git] / tests / cli / test_intersection
CommitLineData
e8b45bc8
JD
1#!/bin/bash
2#
644e0364 3# Copyright (C) 2015 Julien Desfossez <jdesfossez@efficios.com>
e8b45bc8
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"
e8b45bc8
JD
28
29NUM_TESTS=10
30
31plan_tests $NUM_TESTS
32
33test_intersect() {
644e0364
MJ
34 local trace="$1"
35 local totalevents="$2"
36 local intersect="$3"
e8b45bc8 37
644e0364
MJ
38 local cnt
39
40 cnt=$("${BT_TESTS_BT2_BIN}" "$trace" | wc -l)
41 test "${cnt// /}" = "$totalevents"
e8b45bc8 42 ok $? "$totalevents events in the whole trace"
644e0364
MJ
43
44 cnt=$("${BT_TESTS_BT2_BIN}" --stream-intersection "$trace" 2>/dev/null| wc -l)
45 test "${cnt// /}" = "$intersect"
e8b45bc8
JD
46 ok $? "$intersect events in packets intersecting"
47}
48
49diag "Test the stream intersection feature"
50
51diag "2 streams offsetted with 3 packets intersecting"
bbff0ab4 52test_intersect "${BT_CTF_TRACES_PATH}/intersection/3eventsintersect" 8 3
e8b45bc8
JD
53
54diag "2 streams offsetted with 3 packets intersecting (exchanged file names)"
bbff0ab4 55test_intersect "${BT_CTF_TRACES_PATH}/intersection/3eventsintersectreverse" 8 3
e8b45bc8
JD
56
57diag "No intersection between 2 streams"
bbff0ab4 58test_intersect "${BT_CTF_TRACES_PATH}/intersection/nointersect" 6 0
e8b45bc8
JD
59
60diag "Only 1 stream"
bbff0ab4 61test_intersect "${BT_CTF_TRACES_PATH}/intersection/onestream" 3 3
e8b45bc8
JD
62
63diag "No stream at all"
bbff0ab4 64test_intersect "${BT_CTF_TRACES_PATH}/intersection/nostream" 0 0
This page took 0.054326 seconds and 4 git commands to generate.