Commit | Line | Data |
---|---|---|
5177c351 JD |
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 | ||
61100ebb | 18 | BABELTRACE_BIN=@abs_top_builddir@/cli/babeltrace |
5177c351 JD |
19 | |
20 | CTF_TRACES=@abs_top_srcdir@/tests/ctf-traces | |
21 | ||
61100ebb | 22 | source @abs_top_srcdir@/tests/utils/tap/tap.sh |
5177c351 JD |
23 | |
24 | SUCCESS_TRACES=(${CTF_TRACES}/succeed/*) | |
25 | FAIL_TRACES=(${CTF_TRACES}/fail/*) | |
26 | ||
c22ffa09 JD |
27 | # -2 because there is an empty trace that we skip |
28 | NUM_TESTS=$((${#SUCCESS_TRACES[@]} * 3 - 2)) | |
5177c351 JD |
29 | |
30 | plan_tests $NUM_TESTS | |
31 | ||
32 | for path in ${SUCCESS_TRACES[@]}; do | |
33 | out_path=$(mktemp -d) | |
c22ffa09 JD |
34 | text_output1=$(mktemp) |
35 | text_output2=$(mktemp) | |
5177c351 JD |
36 | trace=$(basename ${path}) |
37 | ||
c22ffa09 JD |
38 | $BABELTRACE_BIN ${path} 2>/dev/null >${text_output1} |
39 | cnt=$(cat ${text_output1} | wc -l) | |
40 | if test $cnt == 0; then | |
41 | ok 0 "Empty trace, nothing to copy" | |
42 | continue | |
43 | fi | |
5177c351 JD |
44 | |
45 | $BABELTRACE_BIN ${path} --component sink.ctf.fs --path ${out_path} >/dev/null 2>&1 | |
46 | ok $? "Copy trace ${trace} with ctf-fs sink" | |
47 | ||
48 | $BABELTRACE_BIN ${out_path} >/dev/null 2>&1 | |
c22ffa09 JD |
49 | if test $? != 0; then |
50 | fail "Read the new trace in ${out_path}" | |
51 | continue | |
52 | fi | |
53 | ok 0 "Read the new trace in ${out_path}" | |
5177c351 | 54 | |
c22ffa09 JD |
55 | $BABELTRACE_BIN ${out_path} 2>/dev/null >${text_output2} |
56 | cnt=$(diff ${text_output1} ${text_output2} | wc -l) | |
57 | test $? == 0 | |
58 | ok $? "Exact same content between the two traces" | |
5177c351 | 59 | |
c22ffa09 | 60 | rm -rf ${out_path} ${text_output} ${text_output2} |
5177c351 | 61 | done |