2 # Copyright (c) 2000, 2001, 2003, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc.
3 # Use is subject to license terms.
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Library General Public
7 # License as published by the Free Software Foundation; version 2
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Library General Public License for more details.
15 # You should have received a copy of the GNU Library General Public
16 # License along with this library; if not, write to the Free
17 # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
20 # This program runs all test that starts with 'test-' and sums
21 # the results that the program prints.
22 # Each time result should be of the form:
23 # Time for|to KEYWORD (number_of_runs) 'other info': timestr()
25 # All options to this script is passed to all test program.
27 # --fast --force --lock-tables
28 # --server ==> mysql (default) / mSQL / Pg (postgres) / Solid
29 # --user ==> the user with permission to create / drop / select
30 # --pass ==> password for the user
31 # --cmp ==> Compare --server with one of the others (mysql/mSQL/Pg/Solid)
32 # --comments ==> everything you want to say such as the extra options you
33 # gave to the db server. (use --comments="xxx xxx xxx"
34 # --machine ==> Give a OS/machine id for your logfiles.
35 # --log ==> puts output in output/RUN-server-machine-cmp-$opt_cmp
40 $opt_silent=1; # Don't write header
43 $pwd = cwd
(); $pwd = "." if ($pwd eq '');
44 require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!\n";
48 $redirect= !($machine =~ /windows/i || $machine =~ "^NT\s") ?
"2>&1" : "";
49 $dir= ($pwd =~ /\\/) ?
'\\' : '/'; # directory symbol for shell
52 foreach $arg (@ORG_ARGV)
56 $prog_args.="'" . $arg . "' ";
60 # Windows/NT can't handle ' around arguments
61 $prog_args.=$arg . " ";
65 $prog_count=$errors=0;
68 $filename = "$opt_server$opt_suffix-" . machine_part
() . "-cmp-$opt_cmp";
70 $filename = "$opt_server$opt_suffix-" . machine_part
();
77 die "$opt_dir isn't a directory\n";
79 mkdir $opt_dir,0777 || die "Can't create directory: $opt_dir\n";
83 (@skip_tests) = split(/,\s*/, $opt_skip_test);
88 read_headers
("$opt_dir/RUN-$filename");
92 $server_version=$server->version();
101 open(LOG
, "> $opt_dir/RUN-$filename") ||
102 die "Can't write to $opt_dir/RUN-$filename: $!\n";
108 print "Benchmark DBD suite: $benchmark_version\n";
109 print "Date of test: $date\n";
110 print "Running tests on: $machine\n";
111 print "Arguments: $log_prog_args\n";
112 print "Comments: $opt_comments\n";
113 print "Limits from: $opt_cmp\n";
114 print "Server version: $server_version\n";
115 print "Optimization: $opt_optimization\n";
116 print "Hardware: $opt_hw\n\n";
118 $estimated=$warning=$got_warning=0;
121 next if (/\.sh$/); # configure script
122 next if (/\-fork$/); # test script
124 /test-(.*)$/; # Remove test from name
127 foreach $skip_this (@skip_tests) {
128 if ($prog =~ /$skip_this/i) {
133 if ($opt_only_missing_tests && -f
"$opt_dir$dir$prog-$filename")
135 # Test already run, skip it
139 if ((!$opt_use_old_results) && (!$skip_prog))
141 if (system("$perl ./test-$prog $prog_args > \"$opt_dir$dir$prog-$filename\" $redirect"))
143 printf STDERR
"Warning: Can't execute $prog. Check the file '$opt_dir$dir$prog-$filename'\n";
144 die "aborted" if ($opt_die_on_errors);
147 open(TEST
,"$opt_dir/$prog-$filename");
152 $last_line=$_ if (!(/^\s*$/)); # Search after last line
154 if ($last_line =~ /Total time:/i)
156 print $last_line . "\n";
157 open(TEST
,"$opt_dir/$prog-$filename");
160 if (/^(estimated |)time (to|for) ([^\s:]*)\s*\((\d*)(:\d*)*\)[^:]*:\s*([\d.]+) .*secs \(\s*([^\s]*) usr\s*\+*\s*([^\s]*) sys.*=\s+([\d.]*)\s+cpu/i)
165 $summa{$3}= [ $4,$6,$7,$8,$9,""];
182 $summa{$3}->[5].="+";
187 $summa{$3}->[5].="?";
203 print "Summary for $prog: ", join(" ",@prog_sum), "\n";
206 elsif ($last_line =~ /^Test skipped/i)
208 print "$last_line\n";
213 print "Failed ($opt_dir/$prog-$filename)\n";
220 print "All $prog_count test executed successfully\n";
224 print "Of $prog_count tests, $errors tests didn't work\n";
228 print "Tests with estimated time have a + at end of line\n"
232 print "Tests with didn't return the correct result have a ? at end of line\n";
237 @total=(0,0,0,0,0,"");
238 print "\nTotals per operation:\n";
239 print "Operation seconds usr sys cpu tests\n";
240 foreach $key (sort(keys %summa))
243 printf("%-35.35s %7.2f %7.2f %7.2f %7.2f %7d %s\n",
244 $key,$arg->[1],$arg->[2],$arg->[3],$arg->[4],$arg->[0],
247 for ($i=0 ; $i < 5 ; $i++)
249 $total[$i]+=$arg->[$i];
251 $total[5].=$arg->[$i];
253 printf("%-35.35s %7.2f %7.2f %7.2f %7.2f %7d %s\n",
254 "TOTALS",$total[1],$total[2],$total[3],$total[4],$total[0],
261 print "Test finished. You can find the result in:\n$opt_dir/RUN-$filename\n";
266 # Read headers from an old benchmark run
273 # Clear current values
274 $benchmark_version=$date=$machine=$server_version="";
276 open(TMP
, "<$filename") || die "Can't open $filename\n";
280 if (/^Benchmark DBD.*:\s+(.*)$/)
282 $benchmark_version=$1;
284 elsif (/^Date of.*:\s+(.*)/)
288 elsif (/^Running.*:\s+(.*)$/)
292 elsif (/^Arguments.*:\s+(.*)$/)
296 elsif (/^Limits.*:\s+(.*)$/)
300 elsif (/^Server ver.*:\s+(.*)$/)
304 elsif (/^Optimiz.*:\s+(.*)$/)
306 $opt_optimization=$1;
308 elsif (/^Hardwar.*:\s+(.*)$/)