From mboxrd@z Thu Jan 1 00:00:00 1970 From: nathan_lynch@mentor.com (Nathan Lynch) Date: Tue, 25 Oct 2016 10:34:27 -0500 Subject: [lttng-dev] [RFC/PATCH 3/3] babeltrace: add simple tests for converter command line options In-Reply-To: <1477409667-8309-1-git-send-email-nathan_lynch@mentor.com> References: <1477409667-8309-1-git-send-email-nathan_lynch@mentor.com> Message-ID: <1477409667-8309-4-git-send-email-nathan_lynch@mentor.com> Add simple tests for the following converter command line options: --no-delta --clock-cycles --clock-seconds --clock-date Signed-off-by: Nathan Lynch --- tests/Makefile.am | 4 ++++ tests/bin/Makefile.am | 3 ++- tests/bin/test_clock_cycles | 41 ++++++++++++++++++++++++++++++++++++++ tests/bin/test_clock_date | 47 ++++++++++++++++++++++++++++++++++++++++++++ tests/bin/test_clock_seconds | 43 ++++++++++++++++++++++++++++++++++++++++ tests/bin/test_no_delta | 40 +++++++++++++++++++++++++++++++++++++ 6 files changed, 177 insertions(+), 1 deletion(-) create mode 100755 tests/bin/test_clock_cycles create mode 100755 tests/bin/test_clock_date create mode 100755 tests/bin/test_clock_seconds create mode 100755 tests/bin/test_no_delta diff --git a/tests/Makefile.am b/tests/Makefile.am index 28cb2eca7770..58d8ac861c4b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -8,6 +8,10 @@ TESTS = bin/test_trace_read \ bin/test_trace_read \ bin/test_packet_seq_num \ bin/test_formats \ + bin/test_no_delta \ + bin/test_clock_cycles \ + bin/test_clock_date \ + bin/test_clock_seconds \ bin/intersection/test_intersection \ lib/test_bitfield \ lib/test_seek_empty_packet \ diff --git a/tests/bin/Makefile.am b/tests/bin/Makefile.am index 57b90ea72d80..00551c53f062 100644 --- a/tests/bin/Makefile.am +++ b/tests/bin/Makefile.am @@ -1,2 +1,3 @@ SUBDIRS = intersection -check_SCRIPTS = test_trace_read test_packet_seq_num test_formats +check_SCRIPTS = test_trace_read test_packet_seq_num test_formats test_no_delta \ + test_clock_cycles test_clock_seconds test_clock_date diff --git a/tests/bin/test_clock_cycles b/tests/bin/test_clock_cycles new file mode 100755 index 000000000000..2d0ca6a0f953 --- /dev/null +++ b/tests/bin/test_clock_cycles @@ -0,0 +1,41 @@ +#!/bin/bash +# +# Author: Nathan Lynch +# Copyright (C) 2016 Mentor Graphics Corporation +# +# 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. + +. "$TAPLIB" + +# [cccccccccccccccccccc] +timestamp_fmt="\[" +timestamp_fmt+="[[:digit:]]{20}" +timestamp_fmt+="\]" + +# (+N.nnnnnnnnn) +delta_fmt="\(\+[[:digit:]]+\.[[:digit:]]{9}\)" + +pattern="^$timestamp_fmt $delta_fmt wk-heartbeat:" + +plan_tests 1 + +test_clock_cycles() { + trace="$1" + + count=$($BABELTRACE_BIN --clock-cycles $trace | $GREP -c -E "$pattern") + test $count -eq 19 + ok $? "--clock-cycles prints timestamps in cycles" +} + +test_clock_cycles "$CTF_TRACES/succeed/wk-heartbeat-u" diff --git a/tests/bin/test_clock_date b/tests/bin/test_clock_date new file mode 100755 index 000000000000..0aaab23d5869 --- /dev/null +++ b/tests/bin/test_clock_date @@ -0,0 +1,47 @@ +#!/bin/bash +# +# Author: Nathan Lynch +# Copyright (C) 2016 Mentor Graphics Corporation +# +# 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. + +. "$TAPLIB" + +# [YYYY-MM-DD hh:mm:ss.nnnnnnnnn] +timestamp_fmt="\[" +timestamp_fmt+="[[:digit:]]{4}" # YYYY +timestamp_fmt+="-[[:digit:]]{2}" # MM +timestamp_fmt+="-[[:digit:]]{2}" # DD +timestamp_fmt+=" [[:digit:]]{2}" # hh +timestamp_fmt+=":[[:digit:]]{2}" # mm +timestamp_fmt+=":[[:digit:]]{2}" # ss +timestamp_fmt+="\.[[:digit:]]{9}" # nnnnnnnnn +timestamp_fmt+="\]" + +(+N.nnnnnnnnn) +delta_fmt="\(\+[[:digit:]]+\.[[:digit:]]{9}\)" + +pattern="^$timestamp_fmt $delta_fmt wk-heartbeat:" + +plan_tests 1 + +test_clock_date() { + trace="$1" + + count=$($BABELTRACE_BIN --clock-date $trace | $GREP -c -E "$pattern") + test $count -eq 19 + ok $? "--clock-date displays the date in timestamps" +} + +test_clock_date "$CTF_TRACES/succeed/wk-heartbeat-u" diff --git a/tests/bin/test_clock_seconds b/tests/bin/test_clock_seconds new file mode 100755 index 000000000000..2b5e13c5206d --- /dev/null +++ b/tests/bin/test_clock_seconds @@ -0,0 +1,43 @@ +#!/bin/bash +# +# Author: Nathan Lynch +# Copyright (C) 2016 Mentor Graphics Corporation +# +# 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. + +. "$TAPLIB" + +# [s]+.[nnnnnnnnn] +timestamp_fmt="\[" +timestamp_fmt+="[[:digit:]]+" # [s]+ +timestamp_fmt+="\." +timestamp_fmt+="[[:digit:]]{9}" # [nnnnnnnnn] +timestamp_fmt+="\]" + +(+N.nnnnnnnnn) +delta_fmt="\(\+[[:digit:]]+\.[[:digit:]]{9}\)" + +pattern="^$timestamp_fmt $delta_fmt wk-heartbeat:" + +plan_tests 1 + +test_clock_seconds() { + trace="$1" + + count=$($BABELTRACE_BIN --clock-seconds $trace | $GREP -c -E "$pattern") + test $count -eq 19 + ok $? "--clock-seconds prints timestamps as [sec.ns]" +} + +test_clock_seconds "$CTF_TRACES/succeed/wk-heartbeat-u" diff --git a/tests/bin/test_no_delta b/tests/bin/test_no_delta new file mode 100755 index 000000000000..37c118d30b8c --- /dev/null +++ b/tests/bin/test_no_delta @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Copyright (C) - 2016 Nathan Lynch +# +# 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. + +. "$TAPLIB" + +# [hh:mm:ss.nnnnnnnnn] +timestamp_fmt="\[" +timestamp_fmt+="[[:digit:]]{2}" # hh +timestamp_fmt+=":[[:digit:]]{2}" # mm +timestamp_fmt+=":[[:digit:]]{2}" # ss +timestamp_fmt+="\.[[:digit:]]{9}" # nnnnnnnnn +timestamp_fmt+="\]" + +pattern="^$timestamp_fmt wk-heartbeat:" + +plan_tests 1 + +test_no_delta() { + trace="$1" + + count=$($BABELTRACE_BIN --no-delta $trace | $GREP -c -E "$pattern") + test $count -eq 20 + ok $? "--no-delta suppresses delta between events" +} + +test_no_delta "$CTF_TRACES/succeed/wk-heartbeat-u" -- 2.7.4