#!/usr/bin/perl # Copyright (C) 2008-2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA use lib 'lib'; use lib "$ENV{RQG_HOME}/lib"; use strict; use Carp; use Getopt::Long; use GenTest; use GenTest::Properties; use GenTest::Constants; use GenTest::App::GenTest; my $DEFAULT_THREADS = 10; my $DEFAULT_QUERIES = 1000; my $DEFAULT_DURATION = 3600; my $DEFAULT_DSN = 'dbi:mysql:host=127.0.0.1:port=9306:user=root:database=test'; my @ARGV_saved = @ARGV; my $options = {}; my $opt_result = GetOptions($options, 'config=s', 'dsn=s@', 'dsn1=s', 'dsn2=s', 'dsn3=s', 'engine=s', 'gendata:s', 'grammar=s', 'redefine=s', 'testname=s', 'threads=i', 'queries=s', 'duration=s', 'help', 'debug', 'rpl_mode=s', 'validators:s@', 'reporters:s@', 'report-xml-tt', 'report-xml-tt-type=s', 'report-xml-tt-dest=s', 'seed=s', 'mask=i', 'mask-level=i', 'rows=i', 'varchar-length=i', 'xml-output=s', 'sqltrace', 'views', 'start-dirty', 'filter=s', 'valgrind', 'valgrind-xml', 'notnull', 'debug'); backwardCompatability($options); my $config = GenTest::Properties->new( options => $options, defaults => {dsn=>[$DEFAULT_DSN], seed => 1, queries => $DEFAULT_QUERIES, duration => $DEFAULT_DURATION, threads => $DEFAULT_THREADS}, required => ['grammar'], legal => ['dsn', 'engine', 'gendata', 'redefine', 'testname', 'threads', 'queries', 'duration', 'help', 'debug', 'rpl_mode', 'validators', 'reporters', 'report-xml-tt', 'report-xml-tt-type', 'report-xml-tt-dest', 'seed', 'mask', 'mask-level', 'rows', 'varchar-length', 'xml-output', 'views', 'sqltrace', 'start-dirty', 'filter', 'valgrind', 'valgrind-xml', 'sqltrace', 'notnull'], help => \&help); help() if !$opt_result || $config->help; say("Starting \n $0 \\ \n ".join(" \\ \n ", @ARGV_saved)); $ENV{RQG_DEBUG} = 1 if defined $config->debug; my $gentest = GenTest::App::GenTest->new(config => $config); my $status = $gentest->run(); safe_exit($status); sub help { print <{dsn}) { croak ("Do not combine --dsn and --dsnX") if defined $options->{dsn1} or defined $options->{dsn2} or defined $options->{dsn3}; } else { my @dsns; foreach my $i (1..3) { if (defined $options->{'dsn'.$i}) { push @dsns, $options->{'dsn'.$i}; delete $options->{'dsn'.$i}; } } $options->{dsn} = \@dsns; } if (grep (/,/,@{$options->{reporters}})) { my $newreporters = []; map {push(@$newreporters,split(/,/,$_))} @{$options->{reporters}}; $options->{reporters}=$newreporters ; } if (grep (/,/,@{$options->{validators}})) { my $newvalidators = []; map {push(@$newvalidators,split(/,/,$_))} @{$options->{validators}}; $options->{validators}=$newvalidators ; } }