forked from os-autoinst/os-autoinst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autotest.pm
55 lines (50 loc) · 1.01 KB
/
autotest.pm
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
package autotest;
use bmwqemu;
sub runtest
{
my($script,$testfunc)=@_;
my $name=$script;
$name=~s{.*/}{}; $name=~s{^\d+_}{}; $name=~s/\.pm$//;
{
eval "package $name;
require \$script;" or (diag("error on $script: $@") and return);
}
my $test=$name->new();
return unless $test->is_applicable;
if (defined $testfunc) {
my $ret;
unless(defined $ENV{'checklog_working'} && $ENV{'checklog_working'}) {
if(open(my $fd, ">currentstep")) { # to track progress
print $fd "$script\n$name\n";
close $fd;
}
modstart "starting $name $script";
$ret=&$testfunc($test);
#sleep 1;
diag "||| finished $name";
}
else {
modstart "checking $name $script";
$ret=&$testfunc($test);
diag "";
}
return $ret;
}
else {
diag "scheduling $name $script";
}
}
sub runtestlist($&)
{
my($tests,$testfunc)=@_;
foreach my $script (@$tests) {
runtest($script,$testfunc);
}
}
sub runtestdir($&)
{ my($dir,$testfunc)=@_;
foreach my $script (<$dir/*.pm>) {
runtest($script,$testfunc);
}
}
1;