Tests: Add the tracefile count test
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/3 Tests: Add the tracefile count test
This test validate the newly introduced tracefile count feature. In order to so, we enable a channel with the appropriate limits in overwrite mode. The later constraint is to ensure that at least the last few events are properly recorded and that we can validate that they are present in the resulting trace (with the help of babeltrace and babelstats).
We also validate that the tracefile count (per stream) in the trace folder is conform to the one passed on the command line.
--- configure.ac | 1 + tests/fast_regression | 1 + tests/long_regression | 1 + .../regression/tools/tracefile-limits/Makefile.am | 2 + .../tools/tracefile-limits/test_tracefile_count | 174 +++++++++++++++++++++ 5 files changed, 179 insertions(+) create mode 100644 tests/regression/tools/tracefile-limits/Makefile.am create mode 100644 tests/regression/tools/tracefile-limits/test_tracefile_count
configure.ac +1 -0
@@ -323,6 +323,7 @@ AC_CONFIG_FILES([ tests/regression/tools/streaming/Makefile tests/regression/tools/filtering/Makefile tests/regression/tools/health/Makefile + tests/regression/tools/tracefile-limits/Makefile tests/regression/ust/Makefile tests/regression/ust/nprocesses/Makefile tests/regression/ust/high-throughput/Makefile
tests/fast_regression +1 -0
@@ -5,6 +5,7 @@ regression/tools/health/test_thread_exit regression/tools/health/test_thread_stall regression/tools/health/test_tp_fail regression/tools/streaming/test_ust +regression/tools/tracefile-limits/test_tracefile_count regression/ust/before-after/test_before_after regression/ust/buffers-uid/test_buffers_uid regression/ust/periodical-metadata-flush/test_periodical_metadata_flush
tests/long_regression +1 -0
@@ -5,6 +5,7 @@ regression/tools/health/test_thread_exit regression/tools/health/test_thread_stall regression/tools/health/test_tp_fail regression/tools/streaming/test_ust +regression/tools/tracefile-limits/test_tracefile_count regression/ust/before-after/test_before_after regression/ust/buffers-uid/test_buffers_uid regression/ust/high-throughput/test_high_throughput
tests/regression/tools/tracefile-limits/Makefile.am new file +2 -0
@@ -0,0 +1,2 @@ +noinst_SCRIPTS = test_tracefile_count +EXTRA_DIST = test_tracefile_count
tests/regression/tools/tracefile-limits/test_tracefile_count new file +174 -0
174 lines not on this page · raw message
Signature · 1 line
1.8.2.2
PATCH 3/3 Tests: Add the tracefile size test
In reply to a message not in the archiveThis test validate the newly introduced tracefile count feature. In order to so, we enable a channel with the appropriate file size limits.
After running an instrumented application, we validate that each file in the trace folder is no larger than the limit set on the command line and also that some events are present (it's possible that the tracer discard events, so we can't validate on a fixed number of events in the resulting trace).
--- tests/fast_regression | 1 + tests/long_regression | 2 + .../regression/tools/tracefile-limits/Makefile.am | 4 +- .../tools/tracefile-limits/test_tracefile_size | 154 +++++++++++++++++++++ 4 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 tests/regression/tools/tracefile-limits/test_tracefile_size
tests/fast_regression +1 -0
@@ -6,6 +6,7 @@ regression/tools/health/test_thread_stall regression/tools/health/test_tp_fail regression/tools/streaming/test_ust regression/tools/tracefile-limits/test_tracefile_count +regression/tools/tracefile-limits/test_tracefile_size regression/ust/before-after/test_before_after regression/ust/buffers-uid/test_buffers_uid regression/ust/periodical-metadata-flush/test_periodical_metadata_flush
tests/long_regression +2 -0
@@ -6,8 +6,10 @@ regression/tools/health/test_thread_stall regression/tools/health/test_tp_fail regression/tools/streaming/test_ust regression/tools/tracefile-limits/test_tracefile_count +regression/tools/tracefile-limits/test_tracefile_size regression/ust/before-after/test_before_after regression/ust/buffers-uid/test_buffers_uid +regression/ust/periodical-metadata-flush/test_periodical_metadata_flush regression/ust/high-throughput/test_high_throughput regression/ust/low-throughput/test_low_throughput regression/ust/multi-session/test_multi_session
tests/regression/tools/tracefile-limits/Makefile.am +2 -2
@@ -1,2 +1,2 @@ -noinst_SCRIPTS = test_tracefile_count -EXTRA_DIST = test_tracefile_count +noinst_SCRIPTS = test_tracefile_count test_tracefile_size +EXTRA_DIST = test_tracefile_count test_tracefile_size
tests/regression/tools/tracefile-limits/test_tracefile_size new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
1.8.2.2
Re: [PATCH lttng-tools 1/3] Tests: Move the babelstats utility to tests/utils
In reply to a message not in the archiveAll 3 patches merged!
Thanks
David
Christian Babeux:
Quoted 407 lines
This utility will prove useful in trace validation for other tests, so put it in a common location accessible by the tests.
Signed-off-by Christian Babeux <[email protected]>--- tests/regression/tools/filtering/Makefile.am | 4 +- tests/regression/tools/filtering/babelstats.pl | 174 --------------------- tests/regression/tools/filtering/test_valid_filter | 4 +- tests/utils/babelstats.pl | 174 +++++++++++++++++++++ 4 files changed, 178 insertions(+), 178 deletions(-) delete mode 100755 tests/regression/tools/filtering/babelstats.pl create mode 100755 tests/utils/babelstats.pltests/regression/tools/filtering/Makefile.am +2
-2@@ -14,5 +14,5 @@ gen_ust_events_SOURCES = gen-ust-events.c tp.c tp.h gen_ust_events_LDADD = -llttng-ust endif -noinst_SCRIPTS = test_unsupported_op test_invalid_filter test_valid_filter babelstats.pl -EXTRA_DIST = test_unsupported_op test_invalid_filter test_valid_filter babelstats.pl +noinst_SCRIPTS = test_unsupported_op test_invalid_filter test_valid_filter +EXTRA_DIST = test_unsupported_op test_invalid_filter test_valid_filtertests/regression/tools/filtering/babelstats.pl deleted +0
-174@@ -1,174 +0,0 @@ -#!/usr/bin/perl - -# Copyright (C) - 2012 Christian Babeux <[email protected]> -# -# 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. - -use strict; -use warnings; - -use Getopt::Long; - -my $opt_tracepoint; - -GetOptions('tracepoint=s' => \$opt_tracepoint) - or die("Invalid command-line option\n"); - -defined($opt_tracepoint) - or die("Missing tracepoint, use --tracepoint <name>"); - -# Parse an array string. -# The format is as follow: [ [index] = value, ... ] -sub parse_array -{ - my ($arr_str) = @_; - my @array = (); - - # Strip leading and ending brackets, remove whitespace - $arr_str =~ s/^\[//; - $arr_str =~ s/\]$//; - $arr_str =~ s/\s//g; - - my @entries = split(',', $arr_str); - - foreach my $entry (@entries) { - if ($entry =~ /^\[(\d+)\]=(\d+)$/) { - my $index = $1; - my $value = $2; - splice @array, $index, 0, $value; - } - } - - return \@array; -} - -# Parse fields values. -# Format can either be a name = array or a name = value pair. -sub parse_fields -{ - my ($fields_str) = @_; - my %fields_hash; - - my $field_name = '[\w\d_]+'; - my $field_value = '[\w\d_\\\*"]+'; - my $array = '\[(?:\s\[\d+\]\s=\s\d+,)*\s\[\d+\]\s=\s\d+\s\]'; - - # Split the various fields - my @fields = ($fields_str =~ /$field_name\s=\s(?:$array|$field_value)/g); - - foreach my $field (@fields) { - if ($field =~ /($field_name)\s=\s($array)/) { - my $name = $1; - my $value = parse_array($2); - $fields_hash{$name} = $value; - } - - if ($field =~ /($field_name)\s=\s($field_value)/) { - my $name = $1; - my $value = $2; - $fields_hash{$name} = $value; - } - } - - return \%fields_hash; -} - -# Using an event array, merge all the fields -# of a particular tracepoint. -sub merge_fields -{ - my ($events_ref) = @_; - my %merged; - - foreach my $event (@{$events_ref}) { - my $tp_provider = $event->{'tp_provider'}; - my $tp_name = $event->{'tp_name'}; - my $tracepoint = "$tp_provider:$tp_name"; - - foreach my $key (keys %{$event->{'fields'}}) { - my $val = $event->{'fields'}->{$key}; - - # TODO: Merge of array is not implemented. - next if (ref($val) eq 'ARRAY'); - $merged{$tracepoint}{$key}{$val} = undef; - } - } - - return \%merged; -} - -# Print the minimum and maximum of each fields -# for a particular tracepoint. -sub print_fields_stats -{ - my ($merged_ref, $tracepoint) = @_; - - return unless ($tracepoint && exists $merged_ref->{$tracepoint}); - - foreach my $field (keys %{$merged_ref->{$tracepoint}}) { - my @sorted; - my @val = keys ($merged_ref->{$tracepoint}->{$field}); - - if ($val[0] =~ /^\d+$/) { - # Sort numerically - @sorted = sort { $a <=> $b } @val; - } elsif ($val[0] =~ /^0x[\da-f]+$/i) { - # Convert the hex values and sort numerically - @sorted = sort { hex($a) <=> hex($b) } @val; - } else { - # Fallback, alphabetical sort - @sorted = sort { lc($a) cmp lc($b) } @val; - } - - my $min = $sorted[0]; - my $max = $sorted[-1]; - - print "$field $min $max\n"; - } -} - -my @events; - -while (<>) -{ - my $timestamp = '\[(.*)\]'; - my $elapsed = '\((.*)\)'; - my $hostname = '.*'; - my $pname = '.*'; - my $pid = '\d+'; - my $tp_provider = '.*'; - my $tp_name = '.*'; - my $cpu_info = '{\scpu_id\s=\s(\d+)\s\}'; - my $fields = '{(.*)}'; - - # Parse babeltrace text output format - if (/$timestamp\s$elapsed\s($hostname):($pname):($pid)\s($tp_provider):($tp_name):\s$cpu_info,\s$fields/) { - my %event_hash; - - $event_hash{'timestamp'} = $1; - $event_hash{'elapsed'} = $2; - $event_hash{'hostname'} = $3; - $event_hash{'pname'} = $4; - $event_hash{'pid'} = $5; - $event_hash{'tp_provider'} = $6; - $event_hash{'tp_name'} = $7; - $event_hash{'cpu_id'} = $8; - $event_hash{'fields'} = parse_fields($9); - - push @events, \%event_hash; - } -} - -my %merged_fields = %{merge_fields(\@{events})}; -print_fields_stats(\%merged_fields, $opt_tracepoint);tests/regression/tools/filtering/test_valid_filter +2
-2@@ -21,7 +21,7 @@ CURDIR=$(dirname $0)/ TESTDIR=$CURDIR/../../.. LTTNG_BIN="lttng" BIN_NAME="gen-ust-events" -STATS_BIN="babelstats.pl" +STATS_BIN="$TESTDIR/utils/babelstats.pl" SESSION_NAME="valid_filter" EVENT_NAME="tp:tptest" NR_ITER=100@@ -81,7 +81,7 @@ function test_valid_filter # Destroy session destroy_lttng_session $SESSION_NAME - stats=`babeltrace $trace_path | $CURDIR/$STATS_BIN --tracepoint $EVENT_NAME` + stats=`babeltrace $trace_path | $STATS_BIN --tracepoint $EVENT_NAME` rm -rf $trace_pathtests/utils/babelstats.pl new file +174
-0@@ -0,0 +1,174 @@ +#!/usr/bin/perl + +# Copyright (C) - 2012 Christian Babeux <[email protected]> +# +# 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. + +use strict; +use warnings; + +use Getopt::Long; + +my $opt_tracepoint; + +GetOptions('tracepoint=s' => \$opt_tracepoint) + or die("Invalid command-line option\n"); + +defined($opt_tracepoint) + or die("Missing tracepoint, use --tracepoint <name>"); + +# Parse an array string. +# The format is as follow: [ [index] = value, ... ] +sub parse_array +{ + my ($arr_str) = @_; + my @array = (); + + # Strip leading and ending brackets, remove whitespace + $arr_str =~ s/^\[//; + $arr_str =~ s/\]$//; + $arr_str =~ s/\s//g; + + my @entries = split(',', $arr_str); + + foreach my $entry (@entries) { + if ($entry =~ /^\[(\d+)\]=(\d+)$/) { + my $index = $1; + my $value = $2; + splice @array, $index, 0, $value; + } + } + + return \@array; +} + +# Parse fields values. +# Format can either be a name = array or a name = value pair. +sub parse_fields +{ + my ($fields_str) = @_; + my %fields_hash; + + my $field_name = '[\w\d_]+'; + my $field_value = '[\w\d_\\\*"]+'; + my $array = '\[(?:\s\[\d+\]\s=\s\d+,)*\s\[\d+\]\s=\s\d+\s\]'; + + # Split the various fields + my @fields = ($fields_str =~ /$field_name\s=\s(?:$array|$field_value)/g); + + foreach my $field (@fields) { + if ($field =~ /($field_name)\s=\s($array)/) { + my $name = $1; + my $value = parse_array($2); + $fields_hash{$name} = $value; + } + + if ($field =~ /($field_name)\s=\s($field_value)/) { + my $name = $1; + my $value = $2; + $fields_hash{$name} = $value; + } + } + + return \%fields_hash; +} + +# Using an event array, merge all the fields +# of a particular tracepoint. +sub merge_fields +{ + my ($events_ref) = @_; + my %merged; + + foreach my $event (@{$events_ref}) { + my $tp_provider = $event->{'tp_provider'}; + my $tp_name = $event->{'tp_name'}; + my $tracepoint = "$tp_provider:$tp_name"; + + foreach my $key (keys %{$event->{'fields'}}) { + my $val = $event->{'fields'}->{$key}; + + # TODO: Merge of array is not implemented. + next if (ref($val) eq 'ARRAY'); + $merged{$tracepoint}{$key}{$val} = undef; + } + } + + return \%merged; +} + +# Print the minimum and maximum of each fields +# for a particular tracepoint. +sub print_fields_stats +{ + my ($merged_ref, $tracepoint) = @_; + + return unless ($tracepoint && exists $merged_ref->{$tracepoint}); + + foreach my $field (keys %{$merged_ref->{$tracepoint}}) { + my @sorted; + my @val = keys ($merged_ref->{$tracepoint}->{$field}); + + if ($val[0] =~ /^\d+$/) { + # Sort numerically + @sorted = sort { $a <=> $b } @val; + } elsif ($val[0] =~ /^0x[\da-f]+$/i) { + # Convert the hex values and sort numerically + @sorted = sort { hex($a) <=> hex($b) } @val; + } else { + # Fallback, alphabetical sort + @sorted = sort { lc($a) cmp lc($b) } @val; + } + + my $min = $sorted[0]; + my $max = $sorted[-1]; + + print "$field $min $max\n"; + } +} + +my @events; + +while (<>) +{ + my $timestamp = '\[(.*)\]'; + my $elapsed = '\((.*)\)'; + my $hostname = '.*'; + my $pname = '.*'; + my $pid = '\d+'; + my $tp_provider = '.*'; + my $tp_name = '.*'; + my $cpu_info = '{\scpu_id\s=\s(\d+)\s\}'; + my $fields = '{(.*)}'; + + # Parse babeltrace text output format + if (/$timestamp\s$elapsed\s($hostname):($pname):($pid)\s($tp_provider):($tp_name):\s$cpu_info,\s$fields/) { + my %event_hash; + + $event_hash{'timestamp'} = $1; + $event_hash{'elapsed'} = $2; + $event_hash{'hostname'} = $3; + $event_hash{'pname'} = $4; + $event_hash{'pid'} = $5; + $event_hash{'tp_provider'} = $6; + $event_hash{'tp_name'} = $7; + $event_hash{'cpu_id'} = $8; + $event_hash{'fields'} = parse_fields($9); + + push @events, \%event_hash; + } +} + +my %merged_fields = %{merge_fields(\@{events})}; +print_fields_stats(\%merged_fields, $opt_tracepoint);