X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=tests%2Fcli%2Ftest_trace_copy;h=e8c9b2c86210a391089953e89733a240ed341d34;hb=75e396f6b20bdf52c76a3c7312e7fb815ac1e5e9;hp=8b4a46d40e2c43a2353b3eb476413346fee808d4;hpb=644e036445497ef69ccf946f0700da20a5bae84f;p=babeltrace.git diff --git a/tests/cli/test_trace_copy b/tests/cli/test_trace_copy index 8b4a46d4..e8c9b2c8 100755 --- a/tests/cli/test_trace_copy +++ b/tests/cli/test_trace_copy @@ -1,23 +1,13 @@ #!/bin/bash # -# Copyright (C) - 2017 Julien Desfossez +# SPDX-License-Identifier: GPL-2.0-only # -# 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. +# Copyright (C) 2017 Julien Desfossez # -# 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 +if [ -n "${BT_TESTS_SRCDIR:-}" ]; then UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" else UTILSSH="$(dirname "$0")/../utils/utils.sh" @@ -27,24 +17,25 @@ fi source "$UTILSSH" clean_tmp() { - rm -rf "${out_path}" "${text_output1}" "${text_output2}" + rm -rf "${out_path}" "${text_output1}" "${text_output2_intermediary}" "${text_output2}" } -SUCCESS_TRACES=(${BT_CTF_TRACES_PATH}/succeed/*) +SUCCESS_TRACES=("${BT_CTF_TRACES_PATH}/succeed/"*) -# -2 because there is an empty trace that we skip -NUM_TESTS=$((${#SUCCESS_TRACES[@]} * 3 - 2)) +# -4 because there are two empty traces that we skip +NUM_TESTS=$((${#SUCCESS_TRACES[@]} * 3 - 4)) plan_tests $NUM_TESTS for path in "${SUCCESS_TRACES[@]}"; do out_path="$(mktemp -d)" text_output1="$(mktemp)" + text_output2_intermediary="$(mktemp)" text_output2="$(mktemp)" trace="$(basename "${path}")" sort_cmd="cat" # by default do not sort the trace - "${BT_TESTS_BT2_BIN}" --no-delta "${path}" 2>/dev/null >"${text_output1}" + bt_cli "${text_output1}" "/dev/null" --no-delta "${path}" ret=$? cnt="$(wc -l < "${text_output1}")" if test "$ret" == 0 && test "${cnt// /}" == 0; then @@ -59,6 +50,7 @@ for path in "${SUCCESS_TRACES[@]}"; do # always the same. head -1 "${text_output1}" | "${BT_TESTS_GREP_BIN}" "^\[" >/dev/null if test $? = 0; then + # shellcheck disable=SC2016 uniq_ts_cnt="$("${BT_TESTS_AWK_BIN}" '{ print $1 }' < "${text_output1}" | sort | uniq | wc -l)" # Extract only the timestamp columns and compare the number of # unique lines with the total number of lines to see if there @@ -73,13 +65,14 @@ for path in "${SUCCESS_TRACES[@]}"; do fi fi - "${BT_TESTS_BT2_BIN}" "${path}" --component sink.ctf.fs --path "${out_path}" >/dev/null 2>&1 + bt_cli "/dev/null" "/dev/null" "${path}" --component sink.ctf.fs "--params=path=\"${out_path}\"" ok $? "Copy trace ${trace} with ctf-fs sink" - "${BT_TESTS_BT2_BIN}" "${out_path}" >/dev/null 2>&1 + bt_cli "/dev/null" "/dev/null" "${out_path}" ok $? "Read the new trace in ${out_path}" - "${BT_TESTS_BT2_BIN}" --no-delta "${out_path}" 2>/dev/null | $sort_cmd >"${text_output2}" + bt_cli "${text_output2_intermediary}" "/dev/null" --no-delta "${out_path}" + $sort_cmd "${text_output2_intermediary}" > "${text_output2}" cnt=$(diff "${text_output1}" "${text_output2}" | wc -l) test "${cnt// /}" == 0 ok $? "Exact same content between the two traces"