-
Notifications
You must be signed in to change notification settings - Fork 8
/
sort.pl
137 lines (121 loc) · 4.54 KB
/
sort.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/perl
#--------------------------------------------------------------------------
#
# Copyright (C) 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#--------------------------------------------------------------------------
#-------------------------------------------------------------------
# Parses the list of failing tests and sort them out based on signatures.
# Arguments:
# -pf <path> - path to the file - list of test results ()
# -bf <path> - path to the file - result of stat.sh
# ? 1 - path to the dir of the tests
#-------------------------------------------------------------------
$DEL = "#";
&init();
logIt("sort.pl: This may take a few minutes... ");
defined $pass_file and %pres = &parse($pass_file);
defined $build_file and %bres = &parse($build_file);
defined $pass_file and defined $build_file and %res = &combineLists();
!%res and defined $pass_file and %res = %pres;
!%res and defined $build_file and %res = %bres;
logIt("Groups count: ".keys(%res));
foreach $k (keys(%res)) {
#next if $res{$k} eq "";
print "-----------------------------------------------------";
print join("\n", split($DEL, $k));
print "\n ".$res{$k}."\n";
}
logIt(" ...all done\n");
exit 0;
sub logIt {
#-------------------------------------------------------------------
# Print a message to the log stream. Argument:
# 0 - message to be printed
#-------------------------------------------------------------------
print STDERR @_;
}
sub stop {
#-------------------------------------------------------------------
# Print diagnostics and quit the script
#-------------------------------------------------------------------
die "ERROR: ", @_, "\n"
}
sub init {
#-------------------------------------------------------------------
# Check arguments, set variables
#-------------------------------------------------------------------
$_ = shift @ARGV;
while ($_) {
/^-pf$/ and do {$pass_file = shift @ARGV; next;};
/^-bf$/ and do {$build_file = shift @ARGV; next;};
&stop("Invalid argument: $_");
} continue {
$_ = shift @ARGV;
}
defined $pass_file or defined $build_file or &stop("No file to process");
!defined $pass_file or -f $pass_file or &stop("List of opt pass results does not exist: $pass_file");
!defined $build_file or -f $build_file or &stop("List of build results does not exist: $build_file");
}
sub parse {
#-------------------------------------------------------------------
# Parse file of results
#-------------------------------------------------------------------
my ($fpath, %groups, $key, $test_id) = @_;
open(LIST, $fpath) or &stop("Cannot open file: $fpath");
while (<LIST>) {
chomp;
s/^\s+|\s+$//g;
next if $_ eq "";
#/^(.+\S)\s*$/;
#$_ = $1;
#logIt("_ = ".$_."\n");
if (/^---/) { # info on the next test begins
#logIt("key = ".$key."\n");
defined $key and $groups{$key} .= " ".$test_id;
/\s(\S+)$/;
$test_id = $1;
$key = "";
next;
}
#/^(.+)\s+-/;
#$key .= $DEL.$1;
$key .= $DEL.$_;
}
close(LIST);
$groups{$key} .= " ".$test_id;
%groups
}
sub combineLists {
#-------------------------------------------------------------------
# Combine results for options with the results for builds and produce new groups list
#-------------------------------------------------------------------
my %mark, %cmb, @tlist;
foreach $opts (keys(%pres)) {
#logIt("\nopts = ".$opts."\n");
@ptests = split(" ", $pres{$opts});
#logIt("ptests = ".$#ptests."\n");
foreach $builds (keys(%bres)) {
#logIt("\nbuilds = ".$builds."\n\n");
undef %mark;
grep($mark{$_}++, @ptests);
@tlist = grep($mark{$_}, split(" ", $bres{$builds}));
#logIt("tlist = ".$#tlist."\n");
#$cmb{$opts.$DEL.$builds} .= join(" ", grep($mark{$_}, split(" ", $bres{$builds})));
$cmb{$opts.$DEL.$builds} .= join(" ", @tlist) if $#tlist > -1;
}
}
%cmb
}