~drizzle-trunk/drizzle/development

0.67.1 by Philip Stoev
initial import from internal tree
1
#!/usr/bin/perl
2
0.67.768 by Bernt M. Johnsen
--transformers option added to use explicit list of transformers
3
# Copyright (c) 2008, 2011 Oracle and/or its affiliates. All rights reserved.
0.67.305 by Bernt M. Johnsen
Copyright headres and license added
4
# Use is subject to license terms.
5
#
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; version 2 of the License.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18
# USA
19
0.67.1 by Philip Stoev
initial import from internal tree
20
#
21
# This script executes the following sequence
22
#
23
# $ mysql-test-run.pl --start-and-exit with replication
24
# $ gentest.pl --gendata
25
# $ diff master slave
26
#
27
#
28
29
use lib 'lib';
30
use lib "$ENV{RQG_HOME}/lib";
31
use strict;
32
use GenTest;
33
34
$| = 1;
0.67.381 by Bernt M. Johnsen
Adjustments after merge
35
if (osWindows()) {
0.67.1 by Philip Stoev
initial import from internal tree
36
	$SIG{CHLD} = "IGNORE";
37
}
38
39
if (defined $ENV{RQG_HOME}) {
0.67.381 by Bernt M. Johnsen
Adjustments after merge
40
        if (osWindows()) {
0.67.1 by Philip Stoev
initial import from internal tree
41
                $ENV{RQG_HOME} = $ENV{RQG_HOME}.'\\';
42
        } else {
43
                $ENV{RQG_HOME} = $ENV{RQG_HOME}.'/';
44
        }
45
}
46
47
use Getopt::Long;
48
use GenTest::Constants;
49
use DBI;
50
use Cwd;
51
52
my $database = 'test';
53
my @master_dsns;
54
0.70.9 by Bernt M. Johnsen
--mtr-build-thread and MTR_BUILD_THREAD semantics added to runall.pl
55
my ($gendata, @basedirs, @mysqld_options, @vardirs, $rpl_mode,
56
    $engine, $help, $debug, $validators, $reporters, $grammar_file,
0.67.582 by eve
better messages on wrong script arguments; allow --no-mask to override --mask so that --no-mask can be specified in .CC files
57
    $redefine_file, $seed, $mask, $mask_level, $no_mask, $mem, $rows,
0.67.575 by eve
new --valgrind-xml option that reports Valgrind failures at the end of the test
58
    $varchar_len, $xml_output, $valgrind, $valgrind_xml, $views, $start_dirty,
0.101.29 by John H. Embretsen
XML: Add new options to support XML report delivery.
59
    $filter, $build_thread, $testname, $report_xml_tt, $report_xml_tt_type,
0.67.771 by Bernt M. Johnsen
--querytimeout added to parameterize QueryTimeout.pm reporter
60
    $report_xml_tt_dest, $notnull, $sqltrace, $lcov, $transformers, $querytimeout);
0.67.1 by Philip Stoev
initial import from internal tree
61
62
my $threads = my $default_threads = 10;
63
my $queries = my $default_queries = 1000;
64
my $duration = my $default_duration = 3600;
65
66
my @ARGV_saved = @ARGV;
67
68
my $opt_result = GetOptions(
69
	'mysqld=s@' => \$mysqld_options[0],
70
	'mysqld1=s@' => \$mysqld_options[0],
71
	'mysqld2=s@' => \$mysqld_options[1],
72
	'basedir=s' => \$basedirs[0],
73
	'basedir1=s' => \$basedirs[0],
74
	'basedir2=s' => \$basedirs[1],
75
	'vardir=s' => \$vardirs[0],
76
	'vardir1=s' => \$vardirs[0],
77
	'vardir2=s' => \$vardirs[1],
78
	'rpl_mode=s' => \$rpl_mode,
79
	'engine=s' => \$engine,
80
	'grammar=s' => \$grammar_file,
0.73.5 by Bernt M. Johnsen
--redfine added to runall.pl
81
	'redefine=s' => \$redefine_file,
0.67.1 by Philip Stoev
initial import from internal tree
82
	'threads=i' => \$threads,
0.67.9 by Philip Stoev
merge from internal tree
83
	'queries=s' => \$queries,
0.67.1 by Philip Stoev
initial import from internal tree
84
	'duration=i' => \$duration,
85
	'help' => \$help,
86
	'debug' => \$debug,
0.107.2 by eve
ugly hack to enable multiple --validator --reporter in runall.pl
87
	'validators:s@' => \$validators,
0.67.768 by Bernt M. Johnsen
--transformers option added to use explicit list of transformers
88
    'transformers:s@' =>\$transformers,
0.107.2 by eve
ugly hack to enable multiple --validator --reporter in runall.pl
89
	'reporters:s@' => \$reporters,
0.101.29 by John H. Embretsen
XML: Add new options to support XML report delivery.
90
	'report-xml-tt' => \$report_xml_tt,
91
	'report-xml-tt-type=s' => \$report_xml_tt_type,
92
	'report-xml-tt-dest=s' => \$report_xml_tt_dest,
0.67.96 by Bernt M. Johnsen
--gendata argument should be optional
93
	'gendata:s' => \$gendata,
0.67.497 by eve
added --notnull option to all scripts
94
	'notnull' => \$notnull,
0.67.1 by Philip Stoev
initial import from internal tree
95
	'seed=s' => \$seed,
96
	'mask=i' => \$mask,
0.67.28 by Bernt M. Johnsen
Masking implemented in the .pl-scripts
97
        'mask-level=i' => \$mask_level,
0.67.582 by eve
better messages on wrong script arguments; allow --no-mask to override --mask so that --no-mask can be specified in .CC files
98
	'no-mask' => \$no_mask,
0.67.1 by Philip Stoev
initial import from internal tree
99
	'mem' => \$mem,
100
	'rows=i' => \$rows,
101
	'varchar-length=i' => \$varchar_len,
102
	'xml-output=s'	=> \$xml_output,
103
	'valgrind'	=> \$valgrind,
0.67.575 by eve
new --valgrind-xml option that reports Valgrind failures at the end of the test
104
	'valgrind-xml'	=> \$valgrind_xml,
0.67.1 by Philip Stoev
initial import from internal tree
105
	'views'		=> \$views,
0.109.2 by John H. Embretsen
Support --sqltrace option with classic runall.pl and gentest.pl. Add to usage texts.
106
	'sqltrace' => \$sqltrace,
0.67.9 by Philip Stoev
merge from internal tree
107
	'start-dirty'	=> \$start_dirty,
0.70.9 by Bernt M. Johnsen
--mtr-build-thread and MTR_BUILD_THREAD semantics added to runall.pl
108
	'filter=s'	=> \$filter,
0.101.21 by John H. Embretsen
Add --testname option (may be temporary) to use with xml reporting.
109
    'mtr-build-thread=i' => \$build_thread,
0.67.525 by eve
simple way to generate lcov genhtml reports from runall.pl
110
    'testname=s' => \$testname,
0.67.771 by Bernt M. Johnsen
--querytimeout added to parameterize QueryTimeout.pm reporter
111
	'lcov' => \$lcov,
112
    'querytimeout=i' => \$querytimeout
0.67.1 by Philip Stoev
initial import from internal tree
113
);
114
0.67.521 by eve
provide textual exit codes for various scripts and not jus numbers
115
$ENV{RQG_DEBUG} = 1 if defined $debug;
116
0.107.2 by eve
ugly hack to enable multiple --validator --reporter in runall.pl
117
$validators = join(',', @$validators) if defined $validators;
118
$reporters = join(',', @$reporters) if defined $reporters;
0.67.768 by Bernt M. Johnsen
--transformers option added to use explicit list of transformers
119
$transformers = join(',', @$transformers) if defined $transformers;
0.107.2 by eve
ugly hack to enable multiple --validator --reporter in runall.pl
120
0.67.582 by eve
better messages on wrong script arguments; allow --no-mask to override --mask so that --no-mask can be specified in .CC files
121
if (!$opt_result) {
122
	exit(1);
123
} elsif ($help) {
0.67.1 by Philip Stoev
initial import from internal tree
124
	help();
0.67.582 by eve
better messages on wrong script arguments; allow --no-mask to override --mask so that --no-mask can be specified in .CC files
125
	exit(0);
126
} elsif ($basedirs[0] eq '') {
127
	say("No basedir provided via --basedir.");
128
	exit(0);
129
} elsif (not defined $grammar_file) {
130
	say("No grammar file provided via --grammar");
131
	exit(0);
0.67.1 by Philip Stoev
initial import from internal tree
132
}
133
0.67.768 by Bernt M. Johnsen
--transformers option added to use explicit list of transformers
134
say("Copyright (c) 2008,2011 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms.");
0.67.1 by Philip Stoev
initial import from internal tree
135
say("Please see http://forge.mysql.com/wiki/Category:RandomQueryGenerator for more information on this test framework.");
0.67.736 by eve
First fixes towards making RQG indepentent of a particular Generator, in particular random query generation from grammars
136
say("Starting: $0 ".join(" ", @ARGV_saved));
0.67.1 by Philip Stoev
initial import from internal tree
137
138
#
0.70.9 by Bernt M. Johnsen
--mtr-build-thread and MTR_BUILD_THREAD semantics added to runall.pl
139
# Calculate master and slave ports based on MTR_BUILD_THREAD (MTR
140
# Version 1 behaviour)
141
#
142
143
if (not defined $build_thread) {
144
    if (defined $ENV{MTR_BUILD_THREAD}) {
145
        $build_thread = $ENV{MTR_BUILD_THREAD}
146
    } else {
0.73.1 by Bernt M. Johnsen
Changed STATUS_OK to 0. Changed default MTR_BUILD_THREAD to 930 for legacy reasons
147
        $build_thread = DEFAULT_MTR_BUILD_THREAD;
0.70.9 by Bernt M. Johnsen
--mtr-build-thread and MTR_BUILD_THREAD semantics added to runall.pl
148
    }
149
}
150
151
if ( $build_thread eq 'auto' ) {
0.73.1 by Bernt M. Johnsen
Changed STATUS_OK to 0. Changed default MTR_BUILD_THREAD to 930 for legacy reasons
152
    say ("Please set the environment variable MTR_BUILD_THREAD to a value <> 'auto' (recommended) or unset it (will take the value ".DEFAULT_MTR_BUILD_THREAD.") ");
153
    exit (STATUS_ENVIRONMENT_FAILURE);
0.70.9 by Bernt M. Johnsen
--mtr-build-thread and MTR_BUILD_THREAD semantics added to runall.pl
154
}
155
156
my $master_port = 10000 + 10 * $build_thread;
157
my $slave_port = 10000 + 10 * $build_thread + 2;
158
my @master_ports = ($master_port,$slave_port);
159
160
say("master_port : $master_port slave_port : $slave_port master_ports : @master_ports MTR_BUILD_THREAD : $build_thread ");
161
162
$ENV{MTR_BUILD_THREAD} = $build_thread;
163
164
#
165
# If the user has provided two vardirs and one basedir, start second
166
# server using the same basedir
167
#
168
0.67.1 by Philip Stoev
initial import from internal tree
169
170
if (
171
	($vardirs[1] ne '') && 
172
	($basedirs[1] eq '')
173
) {
174
	$basedirs[1] = $basedirs[0];	
175
}
176
177
178
if (
179
	($mysqld_options[1] ne '') && 
180
	($basedirs[1] eq '')
181
) {
182
	$basedirs[1] = $basedirs[0];	
183
}
184
185
#
186
# If the user has provided identical basedirs and vardirs, warn of a potential overlap.
187
#
188
189
if (
190
	($basedirs[0] eq $basedirs[1]) &&
191
	($vardirs[0] eq $vardirs[1]) &&
192
	($rpl_mode eq '')
193
) {
194
	die("Please specify either different --basedir[12] or different --vardir[12] in order to start two MySQL servers");
195
}
196
0.67.485 by eve
use RQG_HOME to find config files specified via --gendata --grammar and --redefine
197
#
198
# If RQG_HOME is set, prepend it to config files if they can not be found without it 
199
#
200
0.67.486 by eve
fix broken handling of
201
$gendata = $ENV{RQG_HOME}.'/'.$gendata if defined $gendata && defined $ENV{RQG_HOME} && ! -e $gendata;
202
$grammar_file = $ENV{RQG_HOME}.'/'.$grammar_file if defined $grammar_file && defined $ENV{RQG_HOME} && ! -e $grammar_file;
203
$redefine_file = $ENV{RQG_HOME}.'/'.$redefine_file if defined $redefine_file && defined $ENV{RQG_HOME} && ! -e $redefine_file;
0.67.485 by eve
use RQG_HOME to find config files specified via --gendata --grammar and --redefine
204
0.67.1 by Philip Stoev
initial import from internal tree
205
my $cwd = cwd();
206
0.67.525 by eve
simple way to generate lcov genhtml reports from runall.pl
207
if ($lcov) {
208
	unlink(tmpdir()."/lcov-rqg.info");
209
	system("lcov --directory $basedirs[0] --zerocounters");
210
}
211
0.67.1 by Philip Stoev
initial import from internal tree
212
#
213
# Start servers. Use rpl_alter if replication is needed.
214
#
215
	
216
foreach my $server_id (0..1) {
217
	next if $basedirs[$server_id] eq '';
218
219
	if (
220
		($server_id == 0) ||
221
		($rpl_mode eq '') 
222
	) {
223
		$master_dsns[$server_id] = "dbi:mysql:host=127.0.0.1:port=".$master_ports[$server_id].":user=root:database=".$database;
224
	}
225
226
	my @mtr_options;
0.67.743 by eve
heap is a synonym of memory
227
	push @mtr_options, lc("--mysqld=--$engine") if defined $engine && $engine !~ m{myisam|memory|heap}sio;
0.67.1 by Philip Stoev
initial import from internal tree
228
229
	push @mtr_options, "--mem" if defined $mem;
0.67.575 by eve
new --valgrind-xml option that reports Valgrind failures at the end of the test
230
	if ((defined $valgrind) || (defined $valgrind_xml)) {
231
		push @mtr_options, "--valgrind";
232
		if (defined $valgrind_xml) {
233
			push @mtr_options, "--valgrind-option='--xml=yes'";
234
			if (defined $vardirs[$server_id]) {
235
				push @mtr_options, "--valgrind-option='--xml-file=".$vardirs[$server_id]."/log/valgrind.xml'";
236
			} else {
237
				push @mtr_options, "--valgrind-option='--xml-file=".$basedirs[$server_id]."/mysql-test/var/log/valgrind.xml'";
238
			}
239
		}
240
	}
241
			
0.67.1 by Philip Stoev
initial import from internal tree
242
	push @mtr_options, "--skip-ndb";
243
	push @mtr_options, "--mysqld=--core-file";
244
	push @mtr_options, "--mysqld=--loose-new";
245
#	push @mtr_options, "--mysqld=--default-storage-engine=$engine" if defined $engine;
246
	push @mtr_options, "--mysqld=--sql-mode=no_engine_substitution" if join(' ', @ARGV_saved) !~ m{sql-mode}io;
247
	push @mtr_options, "--mysqld=--relay-log=slave-relay-bin";
248
	push @mtr_options, "--mysqld=--loose-innodb";
249
	push @mtr_options, "--mysqld=--loose-falcon-debug-mask=2";
250
	push @mtr_options, "--mysqld=--secure-file-priv=";		# Disable secure-file-priv that mtr enables.
251
	push @mtr_options, "--mysqld=--max-allowed-packet=16Mb";	# Allow loading bigger blobs
252
	push @mtr_options, "--mysqld=--loose-innodb-status-file=1";
253
	push @mtr_options, "--mysqld=--master-retry-count=65535";
254
255
	push @mtr_options, "--start-dirty" if defined $start_dirty;
0.67.525 by eve
simple way to generate lcov genhtml reports from runall.pl
256
	push @mtr_options, "--gcov" if $lcov;
0.67.1 by Philip Stoev
initial import from internal tree
257
258
	if (($rpl_mode ne '') && ($server_id != 0)) {
259
		# If we are running in replication, and we start the slave separately (because it is a different binary)
260
		# add a few options that allow the slave and the master to be distinguished and SHOW SLAVE HOSTS to work
261
		push @mtr_options, "--mysqld=--server-id=".($server_id + 1);
262
		push @mtr_options, "--mysqld=--report-host=127.0.0.1";
263
		push @mtr_options, "--mysqld=--report-port=".$master_ports[$server_id];
264
	}
265
266
	my $mtr_path = $basedirs[$server_id].'/mysql-test/';
267
	chdir($mtr_path) or die "unable to chdir() to $mtr_path: $!";
268
	
269
	push @mtr_options, "--vardir=$vardirs[$server_id]" if defined $vardirs[$server_id];
270
	push @mtr_options, "--master_port=".$master_ports[$server_id];
271
0.67.106 by Philip Stoev
move user-supplied mysqld options to the end of the command-line, so that they override any options supplied internally by runall.pl
272
	if (defined $mysqld_options[$server_id]) {
273
		foreach my $mysqld_option (@{$mysqld_options[$server_id]}) {
274
			push @mtr_options, '--mysqld="'.$mysqld_option.'"';
275
		}
276
	}
277
0.67.1 by Philip Stoev
initial import from internal tree
278
	if (
279
		($rpl_mode ne '') &&
280
		($server_id == 0) &&
281
		(not defined $vardirs[1]) &&
282
		(not defined $mysqld_options[1])
283
	) {
284
		push @mtr_options, 'rpl_alter';
285
		push @mtr_options, "--slave_port=".$slave_port;
0.67.356 by Bernt M. Johnsen
Better 5.0 check of basedir
286
	} elsif ($basedirs[$server_id] =~ m{(^|[-/ ])5\.0}sgio) {
0.67.1 by Philip Stoev
initial import from internal tree
287
		say("Basedir implies server version 5.0. Will not use --start-and-exit 1st");
288
		# Do nothing, test name "1st" does not exist in 5.0
289
	} else {
290
		push @mtr_options, '1st';
291
	}
292
293
	$ENV{MTR_VERSION} = 1;
294
#	my $out_file = "/tmp/mtr-".$$."-".$server_id.".out";
295
	my $mtr_command = "perl mysql-test-run.pl --start-and-exit ".join(' ', @mtr_options)." 2>&1";
296
	say("Running $mtr_command .");
0.67.9 by Philip Stoev
merge from internal tree
297
298
	my $vardir = $vardirs[$server_id] || $basedirs[$server_id].'/mysql-test/var';
299
300
	open (MTR_COMMAND, '>'.$mtr_path.'/mtr_command') or say("Unable to open mtr_command: $!");
301
	print MTR_COMMAND $mtr_command;
302
	close MTR_COMMAND;
303
0.67.1 by Philip Stoev
initial import from internal tree
304
	my $mtr_status = system($mtr_command);
0.67.9 by Philip Stoev
merge from internal tree
305
0.67.1 by Philip Stoev
initial import from internal tree
306
	if ($mtr_status != 0) {
307
#		system("cat $out_file");
308
		system("cat \"$vardir/log/master.err\"");
0.67.584 by eve
report all MTR failures as STATUS_ENVIRONMENT_FAILURE
309
		exit_test(STATUS_ENVIRONMENT_FAILURE);
0.67.1 by Philip Stoev
initial import from internal tree
310
	}
311
#	unlink($out_file);
312
	
313
	if ((defined $master_dsns[$server_id]) && (defined $engine)) {
314
		my $dbh = DBI->connect($master_dsns[$server_id], undef, undef, { RaiseError => 1 } );
315
		$dbh->do("SET GLOBAL storage_engine = '$engine'");
316
	}
317
}
318
319
chdir($cwd);
320
321
my $master_dbh = DBI->connect($master_dsns[0], undef, undef, { RaiseError => 1 } );
322
323
if ($rpl_mode) {
324
	my $slave_dsn = "dbi:mysql:host=127.0.0.1:port=".$slave_port.":user=root:database=".$database;
325
	my $slave_dbh = DBI->connect($slave_dsn, undef, undef, { RaiseError => 1 } );
326
327
	say("Establishing replication, mode $rpl_mode ...");
328
329
	my ($foo, $master_version) = $master_dbh->selectrow_array("SHOW VARIABLES LIKE 'version'");
330
0.67.42 by Philip Stoev
allow 'default' binlog format
331
	if (($master_version !~ m{^5\.0}sio) && ($rpl_mode ne 'default')) {
0.67.1 by Philip Stoev
initial import from internal tree
332
		$master_dbh->do("SET GLOBAL BINLOG_FORMAT = '$rpl_mode'");
333
		$slave_dbh->do("SET GLOBAL BINLOG_FORMAT = '$rpl_mode'");
334
	}
335
336
	$slave_dbh->do("STOP SLAVE");
337
338
	$slave_dbh->do("SET GLOBAL storage_engine = '$engine'") if defined $engine;
339
340
	$slave_dbh->do("CHANGE MASTER TO
341
		MASTER_PORT = $master_ports[0],
342
		MASTER_HOST = '127.0.0.1',
343
               MASTER_USER = 'root',
344
               MASTER_CONNECT_RETRY = 1
345
	");
346
347
	$slave_dbh->do("START SLAVE");
348
}
349
350
#
351
# Run actual queries
352
#
353
354
my @gentest_options;
355
356
push @gentest_options, "--start-dirty" if defined $start_dirty;
357
push @gentest_options, "--gendata=$gendata";
0.67.497 by eve
added --notnull option to all scripts
358
push @gentest_options, "--notnull" if defined $notnull;
0.67.1 by Philip Stoev
initial import from internal tree
359
push @gentest_options, "--engine=$engine" if defined $engine;
360
push @gentest_options, "--rpl_mode=$rpl_mode" if defined $rpl_mode;
0.67.162 by Bernt M. Johnsen
fix --reporter in runall
361
push @gentest_options, map {'--validator='.$_} split(/,/,$validators) if defined $validators;
362
push @gentest_options, map {'--reporter='.$_} split(/,/,$reporters) if defined $reporters;
0.67.768 by Bernt M. Johnsen
--transformers option added to use explicit list of transformers
363
push @gentest_options, map {'--transformer='.$_} split(/,/,$transformers) if defined $transformers;
0.67.1 by Philip Stoev
initial import from internal tree
364
push @gentest_options, "--threads=$threads" if defined $threads;
365
push @gentest_options, "--queries=$queries" if defined $queries;
366
push @gentest_options, "--duration=$duration" if defined $duration;
0.67.160 by Bernt M. Johnsen
Changes + merge
367
push @gentest_options, "--dsn=$master_dsns[0]" if defined $master_dsns[0];
368
push @gentest_options, "--dsn=$master_dsns[1]" if defined $master_dsns[1];
0.67.1 by Philip Stoev
initial import from internal tree
369
push @gentest_options, "--grammar=$grammar_file";
0.73.5 by Bernt M. Johnsen
--redfine added to runall.pl
370
push @gentest_options, "--redefine=$redefine_file" if defined $redefine_file;
0.67.1 by Philip Stoev
initial import from internal tree
371
push @gentest_options, "--seed=$seed" if defined $seed;
0.67.582 by eve
better messages on wrong script arguments; allow --no-mask to override --mask so that --no-mask can be specified in .CC files
372
push @gentest_options, "--mask=$mask" if ((defined $mask) && (not defined $no_mask));
0.67.28 by Bernt M. Johnsen
Masking implemented in the .pl-scripts
373
push @gentest_options, "--mask-level=$mask_level" if defined $mask_level;
0.67.1 by Philip Stoev
initial import from internal tree
374
push @gentest_options, "--rows=$rows" if defined $rows;
375
push @gentest_options, "--views" if defined $views;
376
push @gentest_options, "--varchar-length=$varchar_len" if defined $varchar_len;
377
push @gentest_options, "--xml-output=$xml_output" if defined $xml_output;
0.101.29 by John H. Embretsen
XML: Add new options to support XML report delivery.
378
push @gentest_options, "--report-xml-tt" if defined $report_xml_tt;
379
push @gentest_options, "--report-xml-tt-type=$report_xml_tt_type" if defined $report_xml_tt_type;
380
push @gentest_options, "--report-xml-tt-dest=$report_xml_tt_dest" if defined $report_xml_tt_dest;
0.67.1 by Philip Stoev
initial import from internal tree
381
push @gentest_options, "--debug" if defined $debug;
0.67.9 by Philip Stoev
merge from internal tree
382
push @gentest_options, "--filter=$filter" if defined $filter;
0.67.10 by Philip Stoev
initial fixes for drizzle
383
push @gentest_options, "--valgrind" if defined $valgrind;
0.67.575 by eve
new --valgrind-xml option that reports Valgrind failures at the end of the test
384
push @gentest_options, "--valgrind-xml" if defined $valgrind_xml;
0.101.21 by John H. Embretsen
Add --testname option (may be temporary) to use with xml reporting.
385
push @gentest_options, "--testname=$testname" if defined $testname;
0.109.2 by John H. Embretsen
Support --sqltrace option with classic runall.pl and gentest.pl. Add to usage texts.
386
push @gentest_options, "--sqltrace" if defined $sqltrace;
0.67.771 by Bernt M. Johnsen
--querytimeout added to parameterize QueryTimeout.pm reporter
387
push @gentest_options, "--querytimeout=$querytimeout" if defined $querytimeout;
0.67.9 by Philip Stoev
merge from internal tree
388
389
# Push the number of "worker" threads into the environment.
390
# lib/GenTest/Generator/FromGrammar.pm will generate a corresponding grammar element.
391
$ENV{RQG_THREADS}= $threads;
0.67.1 by Philip Stoev
initial import from internal tree
392
0.67.521 by eve
provide textual exit codes for various scripts and not jus numbers
393
my $gentest_result = system("perl $ENV{RQG_HOME}gentest.pl ".join(' ', @gentest_options)) >> 8;
394
say("gentest.pl exited with exit status ".status2text($gentest_result). " ($gentest_result)");
0.67.525 by eve
simple way to generate lcov genhtml reports from runall.pl
395
396
if ($lcov) {
397
	say("Trying to generate a genhtml lcov report in ".tmpdir()."/rqg-lcov-$$ ...");
398
	system("lcov --quiet --directory $basedirs[0] --capture --output-file ".tmpdir()."/lcov-rqg.info");
399
	system("genhtml --quiet --no-sort --output-directory=".tmpdir()."/rqg-lcov-$$ ".tmpdir()."/lcov-rqg.info");
400
	say("genhtml lcov report may have been generated in ".tmpdir()."/rqg-lcov-$$ .");
401
402
}	
403
0.67.695 by eve
put final master+slave dumping in a separate Reporter. Also, enable Shutdown to shut down both master and slave
404
exit_test($gentest_result);
0.67.1 by Philip Stoev
initial import from internal tree
405
406
sub help {
407
408
	print <<EOF
0.67.768 by Bernt M. Johnsen
--transformers option added to use explicit list of transformers
409
Copyright (c) 2008,2011 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms.
0.70.8 by Bernt M. Johnsen
runall.pl help() updated
410
411
$0 - Run a complete random query generation test, including server start with replication and master/slave verification
412
    
413
    Options related to one standalone MySQL server:
414
415
    --basedir   : Specifies the base directory of the stand-alone MySQL installation;
416
    --mysqld    : Options passed to the MySQL server
417
    --vardir    : Optional. (default \$basedir/mysql-test/var);
418
419
    Options related to two MySQL servers
420
421
    --basedir1  : Specifies the base directory of the first MySQL installation;
422
    --basedir2  : Specifies the base directory of the second MySQL installation;
423
    --mysqld1   : Options passed to the first MySQL server
424
    --mysqld2   : Options passed to the second MySQL server
425
    --vardir1   : Optional. (default \$basedir1/mysql-test/var);
426
    --vardir2   : Optional. (default \$basedir2/mysql-test/var);
427
428
    General options
429
430
    --grammar   : Grammar file to use when generating queries (REQUIRED);
0.73.5 by Bernt M. Johnsen
--redfine added to runall.pl
431
    --redefine  : Grammar file to redefine and/or add rules to the given grammar
0.70.8 by Bernt M. Johnsen
runall.pl help() updated
432
    --rpl_mode  : Replication type to use (statement|row|mixed) (default: no replication);
433
    --vardir1   : Optional.
434
    --vardir2   : Optional. 
435
    --engine    : Table engine to use when creating tables with gendata (default no ENGINE in CREATE TABLE);
436
    --threads   : Number of threads to spawn (default $default_threads);
437
    --queries   : Number of queries to execute per thread (default $default_queries);
438
    --duration  : Duration of the test in seconds (default $default_duration seconds);
0.67.160 by Bernt M. Johnsen
Changes + merge
439
    --validator : The validators to use
440
    --reporter  : The reporters to use
0.67.772 by Roel Van de Paar
Add/clarify new options in help file + some cleanup
441
    --transformer: The transformers to use (turns on --validator=transformer). Accepts comma separated list
442
    --querytimeout: The timeout to use for the QueryTimeout reporter
0.70.8 by Bernt M. Johnsen
runall.pl help() updated
443
    --gendata   : Generate data option. Passed to gentest.pl
444
    --seed      : PRNG seed. Passed to gentest.pl
445
    --mask      : Grammar mask. Passed to gentest.pl
446
    --mask-level: Grammar mask level. Passed to gentest.pl
447
    --rows      : No of rows. Passed to gentest.pl
448
    --varchar-length: length of strings. passed to gentest.pl
0.101.29 by John H. Embretsen
XML: Add new options to support XML report delivery.
449
    --xml-output: Passed to gentest.pl
450
    --report-xml-tt: Passed to gentest.pl
451
    --report-xml-tt-type: Passed to gentest.pl
452
    --report-xml-tt-dest: Passed to gentest.pl
0.67.772 by Roel Van de Paar
Add/clarify new options in help file + some cleanup
453
    --testname  : Name of test, used for reporting purposes
454
    --sqltrace  : Print all generated SQL statements
0.70.8 by Bernt M. Johnsen
runall.pl help() updated
455
    --views     : Generate views. Passed to gentest.pl
456
    --valgrind  : Passed to gentest.pl
457
    --filter    : Passed to gentest.pl
0.67.772 by Roel Van de Paar
Add/clarify new options in help file + some cleanup
458
    --mem       : Passed to mtr
459
    --mtr-build-thread: Value used for MTR_BUILD_THREAD when servers are started and accessed 
0.70.8 by Bernt M. Johnsen
runall.pl help() updated
460
    --debug     : Debug mode
461
    --help      : This help message
462
463
    If you specify --basedir1 and --basedir2 or --vardir1 and --vardir2, two servers will be started and the results from the queries
464
    will be compared between them.
0.67.1 by Philip Stoev
initial import from internal tree
465
EOF
466
	;
0.67.81 by Philip Stoev
in case of runall.pl startup failure, print command-line arguments
467
	print "$0 arguments were: ".join(' ', @ARGV_saved)."\n";
0.67.1 by Philip Stoev
initial import from internal tree
468
	exit_test(STATUS_UNKNOWN_ERROR);
469
}
470
471
sub exit_test {
472
	my $status = shift;
473
0.67.521 by eve
provide textual exit codes for various scripts and not jus numbers
474
	print isoTimestamp()." [$$] $0 will exit with exit status ".status2text($status)." ($status)\n";
0.67.1 by Philip Stoev
initial import from internal tree
475
	safe_exit($status);
476
}