3 # Copyright (C) - 2017 Julien Desfossez <jdesfossez@efficios.com>
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.
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
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.
20 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
21 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
23 UTILSSH
="$(dirname "$0")/../utils/utils.sh"
26 # shellcheck source=../utils/utils.sh
30 rm -rf "${out_path}" "${text_output1}" "${text_output2_intermediary}" "${text_output2}"
33 SUCCESS_TRACES
=("${BT_CTF_TRACES_PATH}/succeed/"*)
35 # -4 because there are two empty traces that we skip
36 NUM_TESTS
=$
((${#SUCCESS_TRACES[@]} * 3 - 4))
40 for path
in "${SUCCESS_TRACES[@]}"; do
41 out_path
="$(mktemp -d)"
42 text_output1
="$(mktemp)"
43 text_output2_intermediary
="$(mktemp)"
44 text_output2
="$(mktemp)"
45 trace
="$(basename "${path}")"
46 sort_cmd
="cat" # by default do not sort the trace
48 bt_cli
"${text_output1}" "/dev/null" --no-delta "${path}"
50 cnt
="$(wc -l < "${text_output1}")"
51 if test "$ret" == 0 && test "${cnt// /}" == 0; then
52 pass
"Empty trace ${trace}, nothing to copy"
57 # If the trace has a timestamp (starts with [), check if there are
58 # duplicate timestamps in the output.
59 # If there are, we have to sort the text output to make sure it is
61 head -1 "${text_output1}" |
"${BT_TESTS_GREP_BIN}" "^\[" >/dev
/null
63 # shellcheck disable=SC2016
64 uniq_ts_cnt
="$("${BT_TESTS_AWK_BIN}" '{ print $1 }' < "${text_output1}" | sort | uniq | wc -l)"
65 # Extract only the timestamp columns and compare the number of
66 # unique lines with the total number of lines to see if there
67 # are duplicate timestamps.
68 if test "${cnt// /}" != "${uniq_ts_cnt// /}"; then
69 diag
"Trace with non unique timestamps, sorting the output"
72 sort "${text_output1}" > "$tmp"
78 bt_cli
"/dev/null" "/dev/null" "${path}" --component sink.ctf.fs
"--params=path=\"${out_path}\""
79 ok $?
"Copy trace ${trace} with ctf-fs sink"
81 bt_cli
"/dev/null" "/dev/null" "${out_path}"
82 ok $?
"Read the new trace in ${out_path}"
84 bt_cli
"${text_output2_intermediary}" "/dev/null" --no-delta "${out_path}"
85 $sort_cmd "${text_output2_intermediary}" > "${text_output2}"
86 cnt
=$
(diff "${text_output1}" "${text_output2}" |
wc -l)
87 test "${cnt// /}" == 0
88 ok $?
"Exact same content between the two traces"