-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_test.pl
executable file
·168 lines (129 loc) · 4.45 KB
/
run_test.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#! /usr/bin/perl
use Time::HiRes qw( time );
use Cwd;
# count failures
my $failed= 0;
my $title = $ARGV[0];
chomp $title;
$title =~ s/\//\./g;
$title =~ s/\.out//g;
print "##teamcity[testSuiteStarted name='$title']\n";
print "Running test : $title \n";
open IN, "< $ARGV[0]";
my $call = <IN>;
chomp $call;
$ENV{'BK_EXAMINATION'}= (split / /,$call)[1];
if ($ARGV[1] eq "-t") {
$ENV{'BK_TIME_CONFINEMENT'}=$ARGV[2];
$call= $call." ".join (" ",@ARGV[3..$#ARGV]);
} else {
$call= $call." ".join (" ",@ARGV[1..$#ARGV]);
# default is 15 minutes
$ENV{'BK_TIME_CONFINEMENT'}=900;
}
print "Timeout set at :".$ENV{'BK_TIME_CONFINEMENT'}." seconds\n";
# position other BK_ variables
if (! defined $ENV{'BK_TOOL'}) {
$ENV{'BK_TOOL'}=TEST;
}
if (! defined $ENV{'BK_MEM_CONFINEMENT'}) {
$ENV{'BK_MEM_CONFINEMENT'}=16384; # 16 GB
}
$ENV{'BK_BIN_PATH'}=getcwd()."/bin/"; # assume this test script lives next to binaries
# print $call;
my $header;
my %verdicts = ();
select IN ;
$| = 1 ; # disable buffering
select STDOUT ;
$| = 1 ; # disable buffering
while (my $line = <IN>) {
if ($line =~ /STATE\_SPACE/ || $line =~ /FORMULA/ ) {
my @words = split /\s+/,$line;
# Note that the final reported Statistic is what will be taken
$verdicts{@words[1]} = @words[2];
}
}
close IN;
my $nbtests = keys(%verdicts);
print "Test : $title ; ".$nbtests." values to test \n";
print "Control values :\n";
foreach my $key (sort keys %verdicts) {
print "$key=$verdicts{$key}\n";
}
if ($nbtests == 0) {
print "\n##teamcity[testStarted name='oracle-integrity']\n";
print "\n##teamcity[testFailed name='oracle-integrity' message='Oracle file empty or otherwise incorrect' details='Was reading : $title' expected='greater than 0' actual='$nbtests'] \n";
print "\n##teamcity[testFinished name='oracle-integrity']\n";
exit 1;
}
# Now run the tool
my $tmpfile = "$ARGV[0].tmp";
$call = "./runatest.sh ".$call ;
print "syscalling : $call \n";
my %formouts = ();
print "##teamcity[testStarted name='runits']\n";
my $start = time();
open IN, "($call) |" or die "An exception was raised when attempting to run "+$call+"\n";
my $first=1;
my $last = time();
while (my $line = <IN>) {
print $line;
if ($line =~ /STATE\_SPACE/ || $line =~ /\bFORMULA\b/ ) {
if ($first) {
$first = 0;
my $cur = time();
my $duration = int(($cur - $last) * 1000) ;
$last = $cur;
print "##teamcity[testFinished name='runits' duration='$duration']\n";
}
my @words = split /\s+/,$line;
$formouts{@words[1]} = @words[2];
my $out = @words[2];
my $exp = $verdicts{@words[1]};
my $tname = @words[1]; #$title.".".@words[1];
print "##teamcity[testStarted name='$tname']\n";
my $cur = time();
my $duration = int(($cur - $last) * 1000) ;
$last = $cur;
if (! defined $exp) {
print "\n Formula @words[1] : no verdict in oracle !! expected/real : $exp / $out\n";
print "\n##teamcity[testFailed name='$tname' message='oracle incomplete : formula ( @words[1] )' details='' expected='$exp' actual='$out'] \n";
$failed++;
} elsif ( $out ne $exp && $exp ne "?" ) {
print "\n Formula @words[1] : failed test expected/real : $exp / $out\n";
print "\n##teamcity[testFailed name='$tname' message='regression detected : formula ( @words[1] ) $exp / $out' details='' expected='$exp' actual='$out'] \n";
$failed++;
} else {
print "\n Formula @words[1] test successful expected/real : $exp / $out\n";
}
print "##teamcity[testFinished name='$tname' duration='$duration']\n";
} elsif ($line =~ /\/tmp\/eclipse\/\d+\.log/g) {
open (IN2, '<', $line) or die "An exception was raised when attempting to open "+$line+"\n";
while (my $line2 = <IN2>) {
print $line2;
}
close IN2;
}
}
close IN;
print "Actual read output values :\n";
foreach my $key (sort keys %formouts) {
print "$key=$formouts{$key}\n";
}
$o = keys (%formouts);
$e = keys (%verdicts);
print "\n##teamcity[testStarted name='all']\n";
if ( $o != $e ) {
# unless ( $title =~ /SS/ && $o == 3 && $e == 4) {
print "\n##teamcity[testFailed name='all' message='regression detected : less results than expected ( $o / $e )' details='' expected='$e' actual='$o'] \n";
$failed++;
# }
} elsif ($o > 0) {
print "All $o tests successful in suite : $title\n";
}
my $end = time();
my $duration = int(($end - $start) * 1000) ;
print "\n##teamcity[testFinished name='all' duration='$duration']\n";
print "##teamcity[testSuiteFinished name='$title']\n";
exit $failed;