Skip to content

Commit

Permalink
Fix: support for older versions of Babeltrace in test script
Browse files Browse the repository at this point in the history
A new context field was introduced in version LTTng 2.8 that is printed
by Babeltrace prior to v1.2.5. This regex thus fails to match the
output. Since the context fields are not used by the script, we create a
non-capturing group for these fields that matches on both old and new
Babeltrace.
This is causing problems on Ubuntu 14.04 Trusty when building
lttng-tools from source and using the Babeltrace package from the
official repository (v1.2.1) to run the test suite.

Also, this patch removes commented and used code in the function but
keeps the names of non-capturing groups for readability.

Signed-off-by: Francis Deslauriers <[email protected]>
CC: Philippe Proulx <[email protected]>
Signed-off-by: Jérémie Galarneau <[email protected]>
  • Loading branch information
frdeso authored and jgalar committed Jan 9, 2017
1 parent fb549e7 commit 4b2c2c1
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions tests/utils/babelstats.pl
Original file line number Diff line number Diff line change
Expand Up @@ -141,31 +141,18 @@ sub print_fields_stats

while (<>)
{
my $timestamp = '\[(.*)\]';
my $elapsed = '\((.*)\)';
my $hostname = '.*';
my $pname = '.*';
my $pinfo = '.*';
my $pid = '\d+';
my $tp_event = '.*';
my $cpu_info = '{\scpu_id\s=\s(\d+)\s\}';
my $fields = '{(.*)}';
my $timestamp = '\[(?:.*)\]';
my $elapsed = '\((?:.*)\)';
my $hostname = '(?:.*)';
my $tp_event = '(.*)';
my $pkt_context = '(?:\{[^}]*\},\s)*';
my $fields = '\{(.*)\}$';

# Parse babeltrace text output format
if (/$timestamp\s$elapsed\s($pinfo)\s($tp_event):\s$cpu_info,\s$fields/) {
if (/$timestamp\s$elapsed\s$hostname\s$tp_event:\s$pkt_context$fields/) {
my %event_hash;
$event_hash{'timestamp'} = $1;
$event_hash{'elapsed'} = $2;
$event_hash{'pinfo'} = $3;

# my @split_pinfo = split(':', $3);
# $event_hash{'hostname'} = $split_pinfo[0];
# $event_hash{'pname'} = defined($split_pinfo[1]) ? $split_pinfo[1] : undef;
# $event_hash{'pid'} = defined($split_pinfo[2]) ? $split_pinfo[2] : undef;

$event_hash{'tp_event'} = $4;
$event_hash{'cpu_id'} = $5;
$event_hash{'fields'} = parse_fields($6);
$event_hash{'tp_event'} = $1;
$event_hash{'fields'} = parse_fields($2);

push @events, \%event_hash;
}
Expand Down

0 comments on commit 4b2c2c1

Please sign in to comment.