Test: validate that the output of ctf-fs sink is identical to source
authorJulien Desfossez <jdesfossez@efficios.com>
Thu, 15 Jun 2017 17:48:48 +0000 (13:48 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 16 Jun 2017 20:50:40 +0000 (16:50 -0400)
Process all the "succeed" CTF traces with the CTF-FS sink, check the
return code of babeltrace and compare the number of events in the new
trace from the number of events in the source trace.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
.gitignore
configure.ac
tests/cli/Makefile.am
tests/cli/test_trace_copy.in [new file with mode: 0644]

index f9af7c5522346a57d1d2dafd77ea39fb63e65ef0..d7a49b12e379f7bfe002fd0415450b00ce5efd54 100644 (file)
@@ -3,6 +3,7 @@
 /tests/cli/intersection/test_intersection
 /tests/cli/test_packet_seq_num
 /tests/cli/test_trace_read
+/tests/cli/test_trace_copy
 /tests/cli/test_convert_args
 /tests/bin/intersection/bt_python_helper.py
 /tests/bin/intersection/test_intersection
index b6ba0fe2f834c5b274f15fbb5d0c176019d9f156..323afa75e49b25c9c5995ac96d4007301ed0adda 100644 (file)
@@ -541,6 +541,7 @@ AC_CONFIG_FILES([tests/lib/test_bin_info_complete], [chmod +x tests/lib/test_bin
 AC_CONFIG_FILES([tests/plugins/test-utils-muxer-complete], [chmod +x tests/plugins/test-utils-muxer-complete])
 
 AC_CONFIG_FILES([tests/cli/test_trace_read], [chmod +x tests/cli/test_trace_read])
+AC_CONFIG_FILES([tests/cli/test_trace_copy], [chmod +x tests/cli/test_trace_copy])
 AC_CONFIG_FILES([tests/cli/intersection/test_intersection], [chmod +x tests/cli/intersection/test_intersection])
 AC_CONFIG_FILES([tests/cli/test_convert_args], [chmod +x tests/cli/test_convert_args])
 AC_CONFIG_FILES([tests/cli/intersection/bt_python_helper.py])
index b123ed01c34fc8e3522dd84a156cd76409e8cc42..27e67dfae58422b2c2d29f6b66f41c8a84ca0429 100644 (file)
@@ -1,5 +1,5 @@
 SUBDIRS = intersection
-check_SCRIPTS = test_trace_read test_packet_seq_num test_convert_args
+check_SCRIPTS = test_trace_read test_packet_seq_num test_convert_args test_trace_copy
 
 LOG_DRIVER_FLAGS='--merge'
 LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/config/tap-driver.sh
@@ -7,7 +7,8 @@ LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/config/tap-driver.sh
 TESTS = test_trace_read \
        test_packet_seq_num \
        test_convert_args \
-       intersection/test_intersection
+       intersection/test_intersection \
+       test_trace_copy
 
 if USE_PYTHON
 TESTS += intersection/test_multi_trace_intersection.py
diff --git a/tests/cli/test_trace_copy.in b/tests/cli/test_trace_copy.in
new file mode 100644 (file)
index 0000000..b2de187
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/bash
+#
+# Copyright (C) - 2017 Julien Desfossez <jdesfossez@efficios.com>
+#
+# 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.
+#
+# 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.
+
+CURDIR=$(dirname $0)
+TESTDIR=$CURDIR/..
+
+BABELTRACE_BIN=$CURDIR/../../cli/babeltrace
+
+CTF_TRACES=@abs_top_srcdir@/tests/ctf-traces
+
+source $TESTDIR/utils/tap/tap.sh
+
+SUCCESS_TRACES=(${CTF_TRACES}/succeed/*)
+FAIL_TRACES=(${CTF_TRACES}/fail/*)
+
+NUM_TESTS=$((${#SUCCESS_TRACES[@]} * 3))
+
+plan_tests $NUM_TESTS
+
+for path in ${SUCCESS_TRACES[@]}; do
+       out_path=$(mktemp -d)
+       trace=$(basename ${path})
+
+       orig_cnt=$($BABELTRACE_BIN ${path} 2>/dev/null | wc -l)
+
+       $BABELTRACE_BIN ${path} --component sink.ctf.fs --path ${out_path} >/dev/null 2>&1
+       ok $? "Copy trace ${trace} with ctf-fs sink"
+
+       $BABELTRACE_BIN ${out_path} >/dev/null 2>&1
+       ok $? "Read the new trace in ${out_path}"
+
+       new_cnt=$($BABELTRACE_BIN ${out_path} 2>/dev/null | wc -l)
+
+       test $orig_cnt == $new_cnt
+       ok $? "Same number of events as the original trace ($orig_cnt -> $new_cnt)"
+
+       rm -rf ${out_path}
+done
This page took 0.026398 seconds and 4 git commands to generate.