src.ctf.lttng-live: remove some goto error-handling
[babeltrace.git] / tests / cli / test_intersection
1 #!/bin/bash
2 #
3 # SPDX-License-Identifier: GPL-2.0-only
4 #
5 # Copyright (C) 2015 Julien Desfossez <jdesfossez@efficios.com>
6 #
7
8 SH_TAP=1
9
10 if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
11 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
12 else
13 UTILSSH="$(dirname "$0")/../utils/utils.sh"
14 fi
15
16 # shellcheck source=../utils/utils.sh
17 source "$UTILSSH"
18
19 plan_tests 20
20
21 stdout=$(mktemp -t test_intersection_stdout.XXXXXX)
22 stderr=$(mktemp -t test_intersection_stderr.XXXXXX)
23
24 test_intersect() {
25 local trace="$1"
26 local totalevents="$2"
27 local intersect="$3"
28
29 local cnt
30
31 bt_cli "${stdout}" "/dev/null" "${trace}"
32 ok $? "run without --stream-intersection"
33
34 cnt=$(wc -l < "${stdout}")
35 test "${cnt// /}" = "$totalevents"
36 ok $? "$totalevents events in the whole trace"
37
38 bt_cli "${stdout}" "/dev/null" --stream-intersection "${trace}"
39 ok $? "run with --stream-intersection"
40
41 cnt=$(wc -l < "${stdout}")
42 test "${cnt// /}" = "$intersect"
43 ok $? "$intersect events in streams intersecting"
44 }
45
46 test_intersect_fails() {
47 local trace="$1"
48 local totalevents="$2"
49 local expected_error_message="$3"
50
51 bt_cli "${stdout}" "/dev/null" "${trace}"
52 ok $? "run without --stream-intersection"
53
54 cnt=$(wc -l < "${stdout}")
55 test "${cnt// /}" = "$totalevents"
56 ok $? "$totalevents events in the whole trace"
57
58 bt_cli "${stdout}" "${stderr}" --stream-intersection "${trace}"
59 isnt "$?" 0 "run with --stream-intersection fails"
60
61 grep --silent "${expected_error_message}" "${stderr}"
62 ok $? "stderr contains expected error message"
63 }
64
65 diag "Test the stream intersection feature"
66
67 diag "2 streams offsetted with 3 packets intersecting"
68 test_intersect "${BT_CTF_TRACES_PATH}/intersection/3eventsintersect" 8 3
69
70 diag "2 streams offsetted with 3 packets intersecting (exchanged file names)"
71 test_intersect "${BT_CTF_TRACES_PATH}/intersection/3eventsintersectreverse" 8 3
72
73 diag "Only 1 stream"
74 test_intersect "${BT_CTF_TRACES_PATH}/intersection/onestream" 3 3
75
76 diag "No intersection between 2 streams"
77 test_intersect_fails "${BT_CTF_TRACES_PATH}/intersection/nointersect" 6 \
78 "Trimming time range's beginning time is greater than end time: "
79
80 diag "No stream at all"
81 test_intersect_fails "${BT_CTF_TRACES_PATH}/intersection/nostream" 0 \
82 "Trace has no streams: "
83
84 rm -f "${stdout}" "${stderr}"
This page took 0.031452 seconds and 4 git commands to generate.