Test the trimmer component
authorJulien Desfossez <jdesfossez@efficios.com>
Fri, 16 Jun 2017 19:21:47 +0000 (15:21 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 19 Jun 2017 16:21:36 +0000 (12:21 -0400)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
tests/cli/Makefile.am
tests/cli/test_trimmer.in [new file with mode: 0644]

index bdfe76ac0dc30d3777a1c69b68a4a6c076d51e35..e8966b8a747b3bc28907c936902d6d7b018a2c33 100644 (file)
@@ -543,6 +543,7 @@ AC_CONFIG_FILES([tests/plugins/test-utils-muxer-complete], [chmod +x tests/plugi
 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/test_debug_info], [chmod +x tests/cli/test_debug_info])
+AC_CONFIG_FILES([tests/cli/test_trimmer], [chmod +x tests/cli/test_trimmer])
 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 d4437659f922a83b6ee142f4e1a5aa766aeac260..923a2521739ef50280e8dec7d951a31b62a35164 100644 (file)
@@ -9,7 +9,8 @@ TESTS = test_trace_read \
        test_convert_args \
        intersection/test_intersection \
        test_trace_copy \
-       test_debug_info
+       test_debug_info \
+       test_trimmer
 
 if USE_PYTHON
 TESTS += intersection/test_multi_trace_intersection.py
diff --git a/tests/cli/test_trimmer.in b/tests/cli/test_trimmer.in
new file mode 100644 (file)
index 0000000..4318463
--- /dev/null
@@ -0,0 +1,68 @@
+#!/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.
+
+BABELTRACE_BIN=@abs_top_builddir@/cli/babeltrace
+
+TRACE_PATH=@abs_top_srcdir@/tests/ctf-traces/succeed/wk-heartbeat-u/
+
+source @abs_top_srcdir@/tests/utils/tap/tap.sh
+
+NUM_TESTS=10
+
+plan_tests $NUM_TESTS
+
+tmp_out=$(mktemp)
+
+$BABELTRACE_BIN --clock-gmt --begin 17:48:17.587029529 --end 17:48:17.588680018 \
+       ${TRACE_PATH} >/dev/null 2>&1
+ok $? "Read the trace with the trimmer enabled"
+
+$BABELTRACE_BIN --clock-gmt --begin 17:48:17.587029529 ${TRACE_PATH} \
+       2>/dev/null >${tmp_out}
+ok $? "Running with --begin"
+cnt=$(cat ${tmp_out} | wc -l)
+test $cnt == 18
+ok $? "Expected number of events after trimming begin and end"
+
+$BABELTRACE_BIN --clock-gmt --end 17:48:17.588680018 ${TRACE_PATH} \
+       2>/dev/null >${tmp_out}
+ok $? "Running with --end"
+cnt=$(cat ${tmp_out} | wc -l)
+test $cnt == 9
+ok $? "Expected number of events after trimming end"
+
+$BABELTRACE_BIN --clock-gmt --begin 17:48:17.587029529 --end 17:48:17.588680018 \
+       ${TRACE_PATH} 2>/dev/null >${tmp_out}
+ok $? "Running with --begin and --end"
+cnt=$(cat ${tmp_out} | wc -l)
+test $cnt == 7
+ok $? "Expected number of events after trimming begin and end"
+
+$BABELTRACE_BIN --clock-gmt --begin 18:48:17.587029529 ${TRACE_PATH} \
+       2>/dev/null >${tmp_out}
+ok $? "Running with --begin out of range"
+cnt=$(cat ${tmp_out} | wc -l)
+test $cnt == 0
+ok $? "No event output when begin is after the end of the trace"
+
+$BABELTRACE_BIN --clock-gmt --end 16:48:17.588680018 ${TRACE_PATH} \
+       2>/dev/null >${tmp_out}
+cnt=$(cat ${tmp_out} | wc -l)
+test $cnt == 0
+ok $? "No event output when end is before the beginning of the trace"
+
+rm ${tmp_out}
This page took 0.026668 seconds and 4 git commands to generate.