#!/bin/bash # # Copyright (C) 2015 Julien Desfossez # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License, version 2 only, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. SH_TAP=1 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" else UTILSSH="$(dirname "$0")/../utils/utils.sh" fi # shellcheck source=../utils/utils.sh source "$UTILSSH" NUM_TESTS=10 plan_tests $NUM_TESTS test_intersect() { local trace="$1" local totalevents="$2" local intersect="$3" local cnt cnt=$("${BT_TESTS_BT2_BIN}" "$trace" | wc -l) test "${cnt// /}" = "$totalevents" ok $? "$totalevents events in the whole trace" cnt=$("${BT_TESTS_BT2_BIN}" --stream-intersection "$trace" 2>/dev/null| wc -l) test "${cnt// /}" = "$intersect" ok $? "$intersect events in packets intersecting" } diag "Test the stream intersection feature" diag "2 streams offsetted with 3 packets intersecting" test_intersect "${BT_CTF_TRACES_PATH}/intersection/3eventsintersect" 8 3 diag "2 streams offsetted with 3 packets intersecting (exchanged file names)" test_intersect "${BT_CTF_TRACES_PATH}/intersection/3eventsintersectreverse" 8 3 diag "No intersection between 2 streams" test_intersect "${BT_CTF_TRACES_PATH}/intersection/nointersect" 6 0 diag "Only 1 stream" test_intersect "${BT_CTF_TRACES_PATH}/intersection/onestream" 3 3 diag "No stream at all" test_intersect "${BT_CTF_TRACES_PATH}/intersection/nostream" 0 0