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