Commit | Line | Data |
---|---|---|
e8b45bc8 JD |
1 | #!/bin/bash |
2 | # | |
abdabab5 | 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 | ||
abdabab5 MJ |
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" | |
e8b45bc8 JD |
28 | |
29 | NUM_TESTS=10 | |
30 | ||
31 | plan_tests $NUM_TESTS | |
32 | ||
33 | test_intersect() { | |
abdabab5 MJ |
34 | local trace="$1" |
35 | local totalevents="$2" | |
36 | local intersect="$3" | |
e8b45bc8 | 37 | |
abdabab5 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" |
abdabab5 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 | ||
49 | diag "Test the stream intersection feature" | |
50 | ||
51 | diag "2 streams offsetted with 3 packets intersecting" | |
b7c5d194 | 52 | test_intersect "${BT_CTF_TRACES_PATH}/intersection/3eventsintersect" 8 3 |
e8b45bc8 JD |
53 | |
54 | diag "2 streams offsetted with 3 packets intersecting (exchanged file names)" | |
b7c5d194 | 55 | test_intersect "${BT_CTF_TRACES_PATH}/intersection/3eventsintersectreverse" 8 3 |
e8b45bc8 JD |
56 | |
57 | diag "No intersection between 2 streams" | |
b7c5d194 | 58 | test_intersect "${BT_CTF_TRACES_PATH}/intersection/nointersect" 6 0 |
e8b45bc8 JD |
59 | |
60 | diag "Only 1 stream" | |
b7c5d194 | 61 | test_intersect "${BT_CTF_TRACES_PATH}/intersection/onestream" 3 3 |
e8b45bc8 JD |
62 | |
63 | diag "No stream at all" | |
b7c5d194 | 64 | test_intersect "${BT_CTF_TRACES_PATH}/intersection/nostream" 0 0 |