refactor: streamline platform sorting and information retrieval in test result processing

This commit is contained in:
Nicolas Saillant 2024-12-12 10:39:27 +01:00
parent acbd7ae3a0
commit ab02480ff0
1 changed files with 60 additions and 63 deletions

View File

@ -299,38 +299,30 @@ EOF
} }
} }
sub sort_pf {
sub get_platform_operating_system($) { my $platform_a = $a;
my ($platform) = @_; my $platform_b = $b;
my $long_name = ""; my $platform = $platform_a;
foreach (@available_platforms) { foreach (@available_platforms) {
if (short_pfname($_) eq $platform) { if (short_pfname($_) eq $a) {
$long_name = $_; $platform = $_;
last; last;
} }
} }
if (open(PLATFORM_INFO, "results_${long_name}.info")) { $platform_a = $platform;
while (my $line = <PLATFORM_INFO>) { $platform_b = $b;
chomp($line); foreach (@available_platforms) {
if ($line =~ /OS:\s*(.*?)$/) { if (short_pfname($_) eq $b) {
my $os = $1; $platform = $_;
$os =~ s/"//g; last;
close(PLATFORM_INFO);
return $os;
} }
} }
close(PLATFORM_INFO); $platform_b = $platform;
} my $os_a = $platforms_info{$platform_a}->{operating_system} // '';
return ""; my $os_b = $platforms_info{$platform_b}->{operating_system} // '';
} $os_a =~ s/"//g;
$os_b =~ s/"//g;
sub sort_pf {
my $os_a = get_platform_operating_system($a);
my $os_b = get_platform_operating_system($b);
if ($os_a ne $os_b) {
return $os_a cmp $os_b; return $os_a cmp $os_b;
}
return $a cmp $b;
} }
sub parse_platform($) sub parse_platform($)
@ -380,7 +372,6 @@ sub choose_platforms()
{ {
my (%platform_index, $pf); my (%platform_index, $pf);
# List all platforms for which there are results # List all platforms for which there are results
@available_platforms = list_platforms();
my $index = 0; my $index = 0;
# Put all known platforms in a hash table. # Put all known platforms in a hash table.
for ($index=0; $index < @known_platforms; $index += 1) { for ($index=0; $index < @known_platforms; $index += 1) {
@ -405,7 +396,7 @@ sub choose_platforms()
# Make a list of all the platforms that are to be treated, in the order they # Make a list of all the platforms that are to be treated, in the order they
# appear in the list of known_platforms. # appear in the list of known_platforms.
@platforms_to_do = (); @platforms_to_do = ();
#@known_platforms = sort sort_pf @known_platforms; @known_platforms = sort sort_pf @known_platforms;
for ($index=0; $index < @known_platforms; $index += 1) { for ($index=0; $index < @known_platforms; $index += 1) {
$pf = $known_platforms[$index]; $pf = $known_platforms[$index];
my $ind2 = 0; my $ind2 = 0;
@ -418,37 +409,8 @@ sub choose_platforms()
} }
} }
sub print_platform_descriptions() sub read_platform_info {
{ foreach my $pf (@available_platforms) {
print OUTPUT <<'EOF';
<h2><a name="platforms">Platform Description and Summary</a></h2>
<table border="1" cellspacing="2" cellpadding="5" class="summary">
<tr align="center">
<th colspan="2">Platform Name</th>
<th>Compiler</th>
<th>Operating System</th>
<th>Tester</th>
<th class="ok">y</th>
<th class="third_party_warning">t</th>
<th class="warning">w</th>
<th class="timeout">o</th>
<th class="error">n</th>
<th class="requirements">r</th>
<th>DEBUG?</th>
<th>CMake</th>
<th>BOOST</th>
<th>MPFR</th>
<th>GMP</th>
<th>QT</th>
<th>LEDA</th>
<th>CXXFLAGS</th>
<th>LDFLAGS</th>
</tr>
EOF
my ($platform_num, $pf)=(0);
foreach $pf (@platforms_to_do) {
my $platform_info; my $platform_info;
if (open (PLATFORM_JSON, "<results_${pf}.json")) { ## read the json file of the platform if (open (PLATFORM_JSON, "<results_${pf}.json")) { ## read the json file of the platform
local $/; local $/;
@ -513,11 +475,44 @@ EOF
$platform_info->{third_party_libs} = \@tpl_list; $platform_info->{third_party_libs} = \@tpl_list;
$platforms_info{$pf} = $platform_info; $platforms_info{$pf} = $platform_info;
} }
$platform_is_64bits{$pf} = ! ($pf =~ m/32/);
$platform_is_optimized{$pf} = ($platform_info->{CXXFLAGS} =~ m|([-/]x?O[1-9])|);
}
}
sub print_platform_descriptions()
{
print OUTPUT <<'EOF';
<h2><a name="platforms">Platform Description and Summary</a></h2>
<table border="1" cellspacing="2" cellpadding="5" class="summary">
<tr align="center">
<th colspan="2">Platform Name</th>
<th>Compiler</th>
<th>Operating System</th>
<th>Tester</th>
<th class="ok">y</th>
<th class="third_party_warning">t</th>
<th class="warning">w</th>
<th class="timeout">o</th>
<th class="error">n</th>
<th class="requirements">r</th>
<th>DEBUG?</th>
<th>CMake</th>
<th>BOOST</th>
<th>MPFR</th>
<th>GMP</th>
<th>QT</th>
<th>LEDA</th>
<th>CXXFLAGS</th>
<th>LDFLAGS</th>
</tr>
EOF
my $platform_num = 0;
foreach my $pf (@platforms_to_do) {
my $platform_info = $platforms_info{$pf};
my $pf_num_plus_one = $platform_num + 1; my $pf_num_plus_one = $platform_num + 1;
# my $pf_short = join('_',parse_platform_2($pf));
(my $pf_short) = ($pf =~ m/_(.*)/);
($platform_is_64bits{$pf}) = ! ($pf =~ m/32/);
($platform_is_optimized{$pf}) = ($platform_info->{CXXFLAGS} =~ m|([-/]x?O[1-9])|);
my $county = $testresults[$platform_num]->{"y"}; my $county = $testresults[$platform_num]->{"y"};
my $countt = $testresults[$platform_num]->{"t"}; my $countt = $testresults[$platform_num]->{"t"};
my $countw = $testresults[$platform_num]->{"w"}; my $countw = $testresults[$platform_num]->{"w"};
@ -662,6 +657,8 @@ sub main()
# init_known_platforms(); # init_known_platforms();
chdir $testresult_dir or die; chdir $testresult_dir or die;
chdir $release_name or die; chdir $release_name or die;
@available_platforms = list_platforms();
read_platform_info();
choose_platforms(); choose_platforms();
chdir ".."; chdir "..";