From mboxrd@z Thu Jan 1 00:00:00 1970 From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers) Date: Wed, 26 Oct 2016 13:36:32 +0000 (UTC) Subject: [lttng-dev] [RFC/PATCH 3/3] babeltrace: add simple tests for converter command line options In-Reply-To: References: <1477409667-8309-1-git-send-email-nathan_lynch@mentor.com> <1477409667-8309-4-git-send-email-nathan_lynch@mentor.com> Message-ID: <1311701030.5606.1477488992406.JavaMail.zimbra@efficios.com> ----- On Oct 26, 2016, at 3:11 AM, Sebastien Boisvert sboisvert at gydle.com wrote: > Hi Nathan, > >> diff --git a/tests/bin/test_clock_seconds b/tests/bin/test_clock_seconds >> +# [s]+.[nnnnnnnnn] >> +timestamp_fmt="\[" >> +timestamp_fmt+="[[:digit:]]+" # [s]+ >> +timestamp_fmt+="\." >> +timestamp_fmt+="[[:digit:]]{9}" # [nnnnnnnnn] >> +timestamp_fmt+="\]" >> + > > > Is the timestamp 0.123456789 possible ? > > Is there a minimum for the left part, something like Epoch ? We can also have slightly negative timestamps due to support of non-GMT timezones. A timezone with a negative offset from GMT with an offset 0 (a trace which appears to be taken exactly at epoch) ends up at the very end of Dec 31, 1969. It can be represented with a negative timestamp with the s.ns notation. This mainly happen when a system boots without network connectivity and think it is exactly at Epoch. Not that uncommon unfortunately. Thanks, Mathieu > > > > On 2016-10-25 05:34 PM, Nathan Lynch wrote: >> 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" >> > > > -- > Dr. Sébastien BOISVERT, Ph.D. > Bioinformatics Software Specialist > GYDLE inc. > sboisvert at gydle.com > +33 6 67 99 71 50 (Mobile, France) > +33 4 92 28 02 50 (Fixe, France) > +33 9 70 44 44 07 (Skype, France) > +1 418 907 9377 # 380 (Gydle Québec Office) > +1 581 308 9999 (Mobile, Canada) > 101-1332 Av. Chanoine Morel > Québec, QC G1S 4B4, Canada > http://www.gydle.com > > signature v.2016-10-10.1 > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com