Fix: Babelstats fail to parse output with no process name or pid
authorChristian Babeux <christian.babeux@efficios.com>
Fri, 12 Jul 2013 20:39:02 +0000 (16:39 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 17 Jul 2013 21:47:04 +0000 (17:47 -0400)
The process name and pid are optionnal components in the babeltrace
text output.

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
tests/utils/babelstats.pl

index d8d4dd08e04cafb92276549b9b279713858b61f9..64a243fc8a69f8b1428d8bf7c5a2231cc8756afd 100755 (executable)
@@ -146,6 +146,7 @@ while (<>)
        my $elapsed     = '\((.*)\)';
        my $hostname    = '.*';
        my $pname       = '.*';
+       my $pinfo       = '.*';
        my $pid         = '\d+';
        my $tp_provider = '.*';
        my $tp_name     = '.*';
@@ -153,18 +154,21 @@ while (<>)
        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/) {
+       if (/$timestamp\s$elapsed\s($pinfo)\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);
+               $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_provider'} = $4;
+               $event_hash{'tp_name'}     = $5;
+               $event_hash{'cpu_id'}      = $6;
+               $event_hash{'fields'}      = parse_fields($7);
 
                push @events, \%event_hash;
        }
This page took 0.029886 seconds and 4 git commands to generate.