Test: rework shell test scripts
[babeltrace.git] / tests / cli / test_trace_copy.in
1 #!/bin/bash
2 #
3 # Copyright (C) - 2017 Julien Desfossez <jdesfossez@efficios.com>
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
18 . "@abs_top_srcdir@/tests/utils/common.sh"
19
20 SUCCESS_TRACES=(${BT_CTF_TRACES}/succeed/*)
21
22 # -2 because there is an empty trace that we skip
23 NUM_TESTS=$((${#SUCCESS_TRACES[@]} * 3 - 2))
24
25 plan_tests $NUM_TESTS
26
27 for path in "${SUCCESS_TRACES[@]}"; do
28 out_path="$(mktemp -d)"
29 text_output1="$(mktemp)"
30 text_output2="$(mktemp)"
31 trace="$(basename "${path}")"
32
33 "${BT_BIN}" "${path}" 2>/dev/null >"${text_output1}"
34 ret=$?
35 cnt="$(wc -l < "${text_output1}")"
36 if test "$ret" == 0 && test "$cnt" == 0; then
37 pass "Empty trace, nothing to copy"
38 continue
39 fi
40
41 "${BT_BIN}" "${path}" --component sink.ctf.fs --path "${out_path}" >/dev/null 2>&1
42 ok $? "Copy trace ${trace} with ctf-fs sink"
43
44 "${BT_BIN}" "${out_path}" >/dev/null 2>&1
45 if test $? != 0; then
46 fail "Read the new trace in ${out_path}"
47 continue
48 fi
49 pass "Read the new trace in ${out_path}"
50
51 "${BT_BIN}" "${out_path}" 2>/dev/null >"${text_output2}"
52 cnt=$(diff "${text_output1}" "${text_output2}" | wc -l)
53 test "$cnt" == 0
54 ok $? "Exact same content between the two traces"
55
56 rm -rf "${out_path}" "${text_output1}" "${text_output2}"
57 done
This page took 0.031106 seconds and 4 git commands to generate.