From: nathan_lynch@mentor.com (Nathan Lynch)
Subject: [lttng-dev] [RFC/PATCH 3/3] babeltrace: add simple tests for converter command line options
Date: Tue, 25 Oct 2016 10:34:27 -0500 [thread overview]
Message-ID: <1477409667-8309-4-git-send-email-nathan_lynch@mentor.com> (raw)
In-Reply-To: <1477409667-8309-1-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 <nathan_lynch at mentor.com>
---
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 <nathan_lynch at mentor.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.
+
+. "$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
next prev parent reply other threads:[~2016-10-25 15:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-25 15:34 [lttng-dev] [RFC/PATCH 0/3] babeltrace: test harness improvements + new tests Nathan Lynch
2016-10-25 15:34 ` [lttng-dev] [RFC/PATCH 1/3] babeltrace: use AM_TESTS_ENVIRONMENT for tests Nathan Lynch
2016-10-25 15:34 ` [lttng-dev] [RFC/PATCH 2/3] babeltrace: drop configure-time substitutions in test scripts Nathan Lynch
2016-10-25 15:34 ` Nathan Lynch [this message]
2016-10-26 7:11 ` [lttng-dev] [RFC/PATCH 3/3] babeltrace: add simple tests for converter command line options Sebastien Boisvert
2016-10-26 13:36 ` Mathieu Desnoyers
2016-10-26 16:29 ` Nathan Lynch
2016-10-25 15:50 ` [lttng-dev] [RFC/PATCH 0/3] babeltrace: test harness improvements + new tests Jonathan Rajotte Julien
2016-10-25 16:05 ` Nathan Lynch
2016-10-25 17:43 ` Michael Jeanson
2016-10-25 20:48 ` Nathan Lynch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1477409667-8309-4-git-send-email-nathan_lynch@mentor.com \
--to=nathan_lynch@mentor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox