0.67.1
by Philip Stoev
initial import from internal tree |
1 |
use strict; |
2 |
use lib 'lib'; |
|
3 |
use lib "$ENV{RQG_HOME}/lib"; |
|
4 |
use List::Util 'shuffle'; |
|
5 |
use GenTest::Random; |
|
6 |
use Getopt::Long; |
|
7 |
use Data::Dumper; |
|
8 |
||
0.67.9
by Philip Stoev
merge from internal tree |
9 |
my ($config_file, $basedir, $vardir, $trials, $duration, $grammar, $gendata, $seed); |
10 |
||
0.67.1
by Philip Stoev
initial import from internal tree |
11 |
my $combinations; |
12 |
my %results; |
|
13 |
my @commands; |
|
14 |
my $max_result = 0; |
|
15 |
||
16 |
my $opt_result = GetOptions( |
|
17 |
'config=s' => \$config_file, |
|
18 |
'basedir=s' => \$basedir, |
|
19 |
'vardir=s' => \$vardir, |
|
20 |
'trials=i' => \$trials, |
|
21 |
'duration=i' => \$duration, |
|
22 |
'seed=s' => \$seed, |
|
23 |
'grammar=s' => \$grammar, |
|
24 |
'gendata=s' => \$gendata |
|
25 |
);
|
|
26 |
||
27 |
my $prng = GenTest::Random->new( |
|
28 |
seed => $seed eq 'time' ? time() : $seed |
|
29 |
);
|
|
30 |
||
31 |
open(CONF, $config_file) or die "unable to open config file '$config_file': $!"; |
|
32 |
read(CONF, my $config_text, -s $config_file); |
|
33 |
eval ($config_text); |
|
34 |
die "Unable to load $config_file: $@" if $@; |
|
35 |
||
0.67.9
by Philip Stoev
merge from internal tree |
36 |
mkdir($basedir); |
37 |
||
0.67.1
by Philip Stoev
initial import from internal tree |
38 |
my $comb_count = $#$combinations + 1; |
39 |
||
40 |
foreach my $trial_id (1..$trials) { |
|
41 |
my @comb; |
|
42 |
foreach my $comb_id (0..($comb_count-1)) { |
|
43 |
$comb[$comb_id] = $combinations->[$comb_id]->[$prng->uint16(0, $#{$combinations->[$comb_id]})]; |
|
44 |
}
|
|
45 |
||
46 |
my $comb_str = join(' ', @comb); |
|
47 |
||
48 |
my $mask = $prng->uint16(0, 65535); |
|
49 |
||
50 |
my $command = " |
|
51 |
perl runall.pl $comb_str
|
|
52 |
--mask=$mask
|
|
53 |
--queries=100000000
|
|
54 |
"; |
|
55 |
||
56 |
$command .= " --duration=$duration" if $duration ne ''; |
|
57 |
$command .= " --basedir=$basedir " if $basedir ne ''; |
|
58 |
$command .= " --gendata=$gendata " if $gendata ne ''; |
|
59 |
$command .= " --grammar=$grammar " if $grammar ne ''; |
|
60 |
$command .= " --seed=$seed " if $seed ne ''; |
|
61 |
||
62 |
$command .= " --vardir=$vardir/current " if $command !~ m{--mem}sio && $vardir ne ''; |
|
63 |
$command =~ s{[\t\r\n]}{ }sgio; |
|
64 |
$command .= " 2>&1 | tee $vardir/trial".$trial_id.'.log'; |
|
65 |
||
66 |
$commands[$trial_id] = $command; |
|
67 |
||
68 |
$command =~ s{"}{\\"}sgio; |
|
69 |
$command = 'bash -c "set -o pipefail; '.$command.'"'; |
|
70 |
||
71 |
print localtime()." [$$] $command\n"; |
|
72 |
my $result = system($command); |
|
73 |
print localtime()." [$$] runall.pl exited with exit status ".($result >> 8)."\n"; |
|
74 |
||
75 |
if ($result > 0) { |
|
76 |
$max_result = $result >> 8 if ($result >> 8) > $max_result; |
|
77 |
print localtime()." [$$] Copying vardir to $vardir/vardir".$trial_id."\n"; |
|
78 |
if ($command =~ m{--mem}) { |
|
79 |
system("cp -r /dev/shm/var $vardir/vardir".$trial_id); |
|
80 |
} else { |
|
81 |
system("cp -r $vardir/current $vardir/vardir".$trial_id); |
|
82 |
}
|
|
83 |
open(OUT, ">$vardir/vardir".$trial_id."/command"); |
|
84 |
print OUT $command; |
|
85 |
close(OUT); |
|
86 |
}
|
|
87 |
$results{$result >> 8}++; |
|
88 |
}
|
|
89 |
||
90 |
print localtime()." [$$] Summary of various interesting strings from the logs:\n"; |
|
91 |
print Dumper \%results; |
|
0.67.10
by Philip Stoev
initial fixes for drizzle |
92 |
foreach my $string ('text=', 'bugcheck', 'Error: assertion', 'mysqld got signal', 'Received signal', 'exception') { |
0.67.1
by Philip Stoev
initial import from internal tree |
93 |
system("grep -i '$string' $vardir/trial*log"); |
94 |
}
|
|
95 |
||
96 |
print localtime()." [$$] $0 will exit with exit status $max_result\n"; |
|
97 |
exit($max_result); |