forked from os-autoinst/os-autoinst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checklog
executable file
·77 lines (64 loc) · 1.75 KB
/
checklog
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
#!/usr/bin/perl -w
use strict;
use bmwqemu;
use autotest;
use JSON qw( to_json );
sub checksize($) {
my $size=shift;
my $i=$ENV{ISO};
my $maxsize=737_280_000;
if($i=~m/-DVD/) {$maxsize=4_700_372_992}
if($i=~m/-DVD-Biarch/) {$maxsize=8_539_996_160}
if($size>$maxsize) {return "fail"}
if($size>$maxsize*0.998) {return "unk"}
return "ok";
}
my $testresult_dir = result_dir;
$testresult_dir=~s/\.ogv.*//;
if(!-e $testresult_dir) {
my $dir = `cd ../.. ; pwd`;
chomp($dir);
$testresult_dir = "$dir/$testresult_dir";
}
$ENV{'checklog_working'} = 1;
our %stageseen=();
our %md5seen=();
our %results;
our $testmodules = [];
sub printresult($) {
my $key=shift;
if(defined($results{$key})) {print "$key: $results{$key}\n"}
}
while(<>) {
if(/^randomenv (\w+)=(.*)/) {$ENV{$1}=$2}
if(/^stage=([0-9a-zA-Z_.-]*) ([0-9a-f]+)/) {
$stageseen{$1}=1;
$md5seen{$2}=1;
}
if(/^md5=([0-9a-f]+)/) {$md5seen{$1}=1}
if(/^standstill detected/) {$results{standstill}="fail";}
if(/^iso_size=(\d+)/) {$results{isosize}=checksize($1);}
}
sub is_ok($) { my $x=shift; $x=~m/^ok/ }
sub checkfunc {
my($test)=@_;
my $class=ref $test;
my $result=$test->check(\%md5seen)||"unknown";
push(@$testmodules, $result);
$results{$class} = $result->{result};
printresult $class;
}
print "\n====\n"; # marker
my $overall=autotest::runtest("$ENV{CASEDIR}/check.pm",sub{my $test=shift;$test->check;});
$results{overall}=($overall?"ok":"fail");
my $json_result = {'testmodules' => $testmodules};
foreach my $k ("standstill", "isosize", "overall") {
if(defined($results{$k})) {
$json_result->{$k} = $results{$k};
}
printresult $k;
}
# Write JSON result
open(my $fd, ">", "$testresult_dir/results.json") or die "can not write results";
print $fd to_json($json_result, { pretty => 1 });
close($fd);