l10n: fr v2.28.0 round 1
[git/debian.git] / t / t0211 / scrub_perf.perl
blob351af7844ed95d0823bbb8c54cee06fe340e29fb
1 #!/usr/bin/perl
3 # Scrub the variable fields from the perf trace2 output to
4 # make testing easier.
6 use strict;
7 use warnings;
9 my $qpath = '\'[^\']*\'|[^ ]*';
11 my $col_depth=0;
12 my $col_thread=1;
13 my $col_event=2;
14 my $col_repo=3;
15 my $col_t_abs=4;
16 my $col_t_rel=5;
17 my $col_category=6;
18 my $col_rest=7;
20 # This code assumes that the trace2 data was written with bare
21 # turned on (which omits the "<clock> <file>:<line> | <parents>"
22 # prefix.
24 while (<>) {
25 my @tokens = split /\|/;
27 foreach my $col (@tokens) { $col =~ s/^\s+|\s+$//g; }
29 if ($tokens[$col_event] =~ m/^start/) {
30 # The 'start' message lists the contents of argv in $col_rest.
31 # On some platforms (Windows), argv[0] is *sometimes* a canonical
32 # absolute path to the EXE rather than the value passed in the
33 # shell script. Replace it with a placeholder to simplify our
34 # HEREDOC in the test script.
35 my $argv0;
36 my $argvRest;
37 $tokens[$col_rest] =~ s/^($qpath)\W*(.*)/_EXE_ $2/;
39 elsif ($tokens[$col_event] =~ m/cmd_path/) {
40 # Likewise, the 'cmd_path' message breaks out argv[0].
42 # This line is only emitted when RUNTIME_PREFIX is defined,
43 # so just omit it for testing purposes.
44 # $tokens[$col_rest] = "_EXE_";
45 goto SKIP_LINE;
47 elsif ($tokens[$col_event] =~ m/child_exit/) {
48 $tokens[$col_rest] =~ s/ pid:\d* / pid:_PID_ /;
50 elsif ($tokens[$col_event] =~ m/data/) {
51 if ($tokens[$col_category] =~ m/process/) {
52 # 'data' and 'data_json' events containing 'process'
53 # category data are assumed to be platform-specific
54 # and highly variable. Just omit them.
55 goto SKIP_LINE;
59 # t_abs and t_rel are either blank or a float. Replace the float
60 # with a constant for matching the HEREDOC in the test script.
61 if ($tokens[$col_t_abs] =~ m/\d/) {
62 $tokens[$col_t_abs] = "_T_ABS_";
64 if ($tokens[$col_t_rel] =~ m/\d/) {
65 $tokens[$col_t_rel] = "_T_REL_";
68 my $out;
70 $out = join('|', @tokens);
71 print "$out\n";
73 SKIP_LINE: