Commit cab8a363 authored by unknown's avatar unknown

Bug fixes and new features to ma_test_all-t


scripts/mysql_fix_privilege_tables.sh:
  Fix a problem with events table not getting updated correctly.
  This happens when you run scripts/mysql_fix_privilege_tables and
  you have an old version of mysql_fix_privilege_tables.sql in
  the actual installation directory. This patch makes it look for
  the file inside the source dir first.
storage/maria/unittest/ma_test_all-t:
  Added several new options for ma_test_all-t
  
  --verbose is handy, if you want to run the tests separately on the
  screen.
  
  Added functions for counting tests and a possibility to
  separate a group of tests inside an array of test.
unittest/Makefile.am:
  Fixed a problem with make test not executing
  ma_test_all-t properly from the top source dir.
parent c719e1fd
...@@ -149,7 +149,7 @@ then ...@@ -149,7 +149,7 @@ then
fi fi
# Find where first mysql_fix_privilege_tables.sql is located # Find where first mysql_fix_privilege_tables.sql is located
for i in $basedir/support-files $basedir/share $basedir/share/mysql \ for i in scripts $basedir/support-files $basedir/share $basedir/share/mysql \
$basedir/scripts $pkgdatadir . "$dirname" $basedir/scripts $pkgdatadir . "$dirname"
do do
if test -f $i/$file if test -f $i/$file
......
...@@ -3,8 +3,25 @@ ...@@ -3,8 +3,25 @@
# Run various unit tests. # Run various unit tests.
# #
use Getopt::Long;
$|= 1;
$VER= "1.1";
$opt_version= 0;
$opt_help= 0;
$opt_verbose= 0;
$opt_maria_path= undef();
$opt_valgrind= "valgrind --alignment=8 --leak-check=yes";
$opt_suffix= "";
$opt_silent= "-s";
my $maria_path= $ENV{'maria_path'}; my $maria_path= $ENV{'maria_path'};
my $my_progname= $0;
$my_progname=~ s/.*[\/]//;
my $runtime_error= 0; # Return 1 if error(s) occur during run
my $NEW_TEST= 0; # Test group separator in an array of tests
run_tests(); run_tests();
#### ####
...@@ -13,16 +30,34 @@ run_tests(); ...@@ -13,16 +30,34 @@ run_tests();
sub run_tests sub run_tests
{ {
my $valgrind_opt= "valgrind --alignment=8 --leak-check=yes";
my $silent_opt= "-s";
my $suffix= "";
my $nr_tests= 0; my $nr_tests= 0;
my $flag_exit= 0;
if (!GetOptions("help", "version", "verbose", "maria-path=s",
"valgrind=s", "suffix=s", "silent=s"))
{
$flag_exit= 1;
}
if ($opt_version)
{
print "$my_progname version $VER\n";
exit(0);
}
if (defined($opt_maria_path))
{
$maria_path= $opt_maria_path;
}
if (!defined($maria_path) || !length($maria_path))
{
$maria_path= ".";
}
usage() if ($opt_help || $flag_exit);
# #
# initialisations and previous run clean-ups # clean-up
# #
$maria_path= "." if (!defined($maria_path) || !length($maria_path));
unlink <*.TMD maria_log*>; # Delete temporary files unlink <*.TMD maria_log*>; # Delete temporary files
# #
...@@ -49,33 +84,52 @@ sub run_tests ...@@ -49,33 +84,52 @@ sub run_tests
# Run tests # Run tests
# #
if (!$opt_verbose)
{
print "1..$nr_tests\n"; print "1..$nr_tests\n";
}
else
{
print "Total tests: $nr_tests\n";
}
print "Running tests with dynamic row format\n"; if ($opt_verbose)
run_check_tests($suffix, $silent_opt, "", 0, 0); {
run_repair_tests($suffix, $silent_opt, "", 0, 0); print "Running tests with dynamic row format\n"
run_pack_tests($suffix, $silent_opt, "", 0, 0); }
run_check_tests($opt_suffix, $opt_silent, "", $opt_verbose, 0);
run_repair_tests($opt_suffix, $opt_silent, "", $opt_verbose, 0);
run_pack_tests($opt_suffix, $opt_silent, "", $opt_verbose, 0);
print "Running tests with static row format\n"; if ($opt_verbose)
run_check_tests($suffix, $silent_opt, "-S", 0, 0); {
run_repair_tests($suffix, $silent_opt, "-S", 0, 0); print "\nRunning tests with static row format\n";
run_pack_tests($suffix, $silent_opt, "-S", 0, 0); }
run_check_tests($opt_suffix, $opt_silent, "-S", $opt_verbose, 0);
run_repair_tests($opt_suffix, $opt_silent, "-S", $opt_verbose, 0);
run_pack_tests($opt_suffix, $opt_silent, "-S", $opt_verbose, 0);
print "Running tests with block row format\n"; if ($opt_verbose)
run_check_tests($suffix, $silent_opt, "-M", 0, 0); {
run_repair_tests($suffix, $silent_opt, "-M", 0, 0); print "\nRunning tests with block row format\n";
run_pack_tests($suffix, $silent_opt, "-M", 0, 0); }
run_check_tests($opt_suffix, $opt_silent, "-M", $opt_verbose, 0);
run_repair_tests($opt_suffix, $opt_silent, "-M", $opt_verbose, 0);
run_pack_tests($opt_suffix, $opt_silent, "-M", $opt_verbose, 0);
print "Running tests with block row format and transactions\n"; if ($opt_verbose)
run_check_tests($suffix, $silent_opt, "-M -T", 0, 0); {
run_repair_tests($suffix, $silent_opt, "-M -T", 0, 0); print "\nRunning tests with block row format and transactions\n";
run_pack_tests($suffix, $silent_opt, "-M -T", 0, 0); }
run_check_tests($opt_suffix, $opt_silent, "-M -T", $opt_verbose, 0);
run_repair_tests($opt_suffix, $opt_silent, "-M -T", $opt_verbose, 0);
run_pack_tests($opt_suffix, $opt_silent, "-M -T", $opt_verbose, 0);
run_tests_on_warnings_and_errors($suffix, $silent_opt, 0, 0); run_tests_on_warnings_and_errors($opt_suffix, $opt_silent, $opt_verbose, 0);
run_ma_test_recovery(0, 0); run_ma_test_recovery($opt_verbose, 0);
run_tests_on_clrs(0, 0); run_tests_on_clrs($opt_verbose, 0);
return; exit($runtime_error);
} }
#### ####
...@@ -161,7 +215,7 @@ sub run_check_tests ...@@ -161,7 +215,7 @@ sub run_check_tests
ok("$maria_path/maria_chk$suffix $ma_test2_opt[$i][1] test2", ok("$maria_path/maria_chk$suffix $ma_test2_opt[$i][1] test2",
$verbose, $i + 1); $verbose, $i + 1);
} }
unlink <rm -f maria_log_control maria_log.*>; unlink <maria_log_control maria_log.*>;
return 0; return 0;
} }
...@@ -173,8 +227,10 @@ sub run_check_tests ...@@ -173,8 +227,10 @@ sub run_check_tests
sub run_repair_tests() sub run_repair_tests()
{ {
my ($suffix, $silent, $row_type, $verbose, $count)= @_; my ($suffix, $silent, $row_type, $verbose, $count)= @_;
my ($i, $nr_tests); my ($i);
my @t1= ("$maria_path/ma_test1$suffix $silent --checksum $row_type",
my @t= ($NEW_TEST,
"$maria_path/ma_test1$suffix $silent --checksum $row_type",
"$maria_path/maria_chk$suffix -se test1", "$maria_path/maria_chk$suffix -se test1",
"$maria_path/maria_chk$suffix --silent -re --transaction-log test1", "$maria_path/maria_chk$suffix --silent -re --transaction-log test1",
"$maria_path/maria_chk$suffix -rs test1", "$maria_path/maria_chk$suffix -rs test1",
...@@ -205,16 +261,8 @@ sub run_repair_tests() ...@@ -205,16 +261,8 @@ sub run_repair_tests()
"$maria_path/maria_chk$suffix -se test1" "$maria_path/maria_chk$suffix -se test1"
); );
if ($count) return &count_tests(\@t) if ($count);
{ &run_test_bunch(\@t, $verbose, 0);
$nr_tests= 0;
for ($i= 0; defined($t1[$i]); $i++) { $nr_tests++; }
return $nr_tests;
}
for ($i= 0; defined($t1[$i]); $i++)
{
ok($t1[$i], $verbose, $i + 1);
}
return 0; return 0;
} }
...@@ -225,9 +273,10 @@ sub run_repair_tests() ...@@ -225,9 +273,10 @@ sub run_repair_tests()
sub run_pack_tests() sub run_pack_tests()
{ {
my ($suffix, $silent, $row_type, $verbose, $count)= @_; my ($suffix, $silent, $row_type, $verbose, $count)= @_;
my ($i, $nr_tests); my ($i);
my @t1= ("$maria_path/ma_test1$suffix $silent --checksum $row_type", my @t= ($NEW_TEST,
"$maria_path/ma_test1$suffix $silent --checksum $row_type",
"$maria_path/maria_pack$suffix --force -s test1", "$maria_path/maria_pack$suffix --force -s test1",
"$maria_path/maria_chk$suffix -ess test1", "$maria_path/maria_chk$suffix -ess test1",
"$maria_path/maria_chk$suffix -rqs test1", "$maria_path/maria_chk$suffix -rqs test1",
...@@ -236,24 +285,24 @@ sub run_pack_tests() ...@@ -236,24 +285,24 @@ sub run_pack_tests()
"$maria_path/maria_chk$suffix -es test1", "$maria_path/maria_chk$suffix -es test1",
"$maria_path/maria_chk$suffix -rus test1", "$maria_path/maria_chk$suffix -rus test1",
"$maria_path/maria_chk$suffix -es test1", "$maria_path/maria_chk$suffix -es test1",
$NEW_TEST,
"$maria_path/ma_test1$suffix $silent --checksum $row_type", "$maria_path/ma_test1$suffix $silent --checksum $row_type",
"$maria_path/maria_pack$suffix --force -s test1", "$maria_path/maria_pack$suffix --force -s test1",
"$maria_path/maria_chk$suffix -rus --safe-recover test1", "$maria_path/maria_chk$suffix -rus --safe-recover test1",
"$maria_path/maria_chk$suffix -es test1", "$maria_path/maria_chk$suffix -es test1",
$NEW_TEST,
"$maria_path/ma_test1$suffix $silent --checksum -S $row_type", "$maria_path/ma_test1$suffix $silent --checksum -S $row_type",
"$maria_path/maria_chk$suffix -se test1", "$maria_path/maria_chk$suffix -se test1",
"$maria_path/maria_chk$suffix -ros test1", "$maria_path/maria_chk$suffix -ros test1",
"$maria_path/maria_chk$suffix -rqs test1", "$maria_path/maria_chk$suffix -rqs test1",
"$maria_path/maria_chk$suffix -se test1", "$maria_path/maria_chk$suffix -se test1",
$NEW_TEST,
"$maria_path/maria_pack$suffix --force -s test1", "$maria_path/maria_pack$suffix --force -s test1",
"$maria_path/maria_chk$suffix -rqs test1", "$maria_path/maria_chk$suffix -rqs test1",
"$maria_path/maria_chk$suffix -es test1", "$maria_path/maria_chk$suffix -es test1",
"$maria_path/maria_chk$suffix -rus test1", "$maria_path/maria_chk$suffix -rus test1",
"$maria_path/maria_chk$suffix -es test1", "$maria_path/maria_chk$suffix -es test1",
$NEW_TEST,
"$maria_path/ma_test2$suffix $silent -c -d1 $row_type", "$maria_path/ma_test2$suffix $silent -c -d1 $row_type",
"$maria_path/maria_chk$suffix -s --parallel-recover test2", "$maria_path/maria_chk$suffix -s --parallel-recover test2",
"$maria_path/maria_chk$suffix -se test2", "$maria_path/maria_chk$suffix -se test2",
...@@ -264,16 +313,8 @@ sub run_pack_tests() ...@@ -264,16 +313,8 @@ sub run_pack_tests()
"$maria_path/maria_chk$suffix -se test2" "$maria_path/maria_chk$suffix -se test2"
); );
if ($count) return &count_tests(\@t) if ($count);
{ &run_test_bunch(\@t, $verbose, 0);
$nr_tests= 0;
for ($i= 0; defined($t1[$i]); $i++) { $nr_tests++; }
return $nr_tests;
}
for ($i= 0; defined($t1[$i]); $i++)
{
ok($t1[$i], $verbose, $i + 1);
}
return 0; return 0;
} }
...@@ -305,7 +346,7 @@ sub run_tests_on_warnings_and_errors ...@@ -305,7 +346,7 @@ sub run_tests_on_warnings_and_errors
ok("cat ma_test2_message.txt", $verbose, 0); ok("cat ma_test2_message.txt", $verbose, 0);
ok("grep \"warning: Datafile is almost full\" ma_test2_message.txt>/dev/null", ok("grep \"warning: Datafile is almost full\" ma_test2_message.txt>/dev/null",
$verbose, 0); $verbose, 0);
unlink <rm -f ma_test2_message.txt>; unlink <ma_test2_message.txt>;
ok("$maria_path/maria_chk$suffix -ssm test2", $verbose, 0); ok("$maria_path/maria_chk$suffix -ssm test2", $verbose, 0);
return 0; return 0;
...@@ -331,9 +372,10 @@ sub run_ma_test_recovery ...@@ -331,9 +372,10 @@ sub run_ma_test_recovery
sub run_tests_on_clrs sub run_tests_on_clrs
{ {
my ($verbose, $count)= @_; my ($verbose, $count)= @_;
my ($i, $nr_tests); my ($i);
my @t1= ("$maria_path/ma_test2 -s -L -K -W -P -M -T -c -b -t2 -A1", my @t= ($NEW_TEST,
"$maria_path/ma_test2 -s -L -K -W -P -M -T -c -b -t2 -A1",
"cp maria_log_control tmp", "cp maria_log_control tmp",
"$maria_path/maria_read_log -a -s", "$maria_path/maria_read_log -a -s",
"$maria_path/maria_chk -s -e test2", "$maria_path/maria_chk -s -e test2",
...@@ -341,18 +383,17 @@ sub run_tests_on_clrs ...@@ -341,18 +383,17 @@ sub run_tests_on_clrs
"rm test2.MA?", "rm test2.MA?",
"$maria_path/maria_read_log -a -s", "$maria_path/maria_read_log -a -s",
"$maria_path/maria_chk -s -e test2", "$maria_path/maria_chk -s -e test2",
"rm test2.MA?" "rm test2.MA?",
); $NEW_TEST,
my @t2= ("$maria_path/ma_test2 -s -L -K -W -P -M -T -c -b -t2 -A1", "$maria_path/ma_test2 -s -L -K -W -P -M -T -c -b -t2 -A1",
"$maria_path/maria_read_log -a -s", "$maria_path/maria_read_log -a -s",
"$maria_path/maria_chk -s -e test2", "$maria_path/maria_chk -s -e test2",
"rm test2.MA?", "rm test2.MA?",
"$maria_path/maria_read_log -a -s", "$maria_path/maria_read_log -a -s",
"$maria_path/maria_chk -e -s test2", "$maria_path/maria_chk -e -s test2",
"rm test2.MA?" "rm test2.MA?",
); $NEW_TEST,
"$maria_path/ma_test2 -s -L -K -W -P -M -T -c -b32768 -t4 -A1",
my @t3= ("$maria_path/ma_test2 -s -L -K -W -P -M -T -c -b32768 -t4 -A1",
"$maria_path/maria_read_log -a -s", "$maria_path/maria_read_log -a -s",
"$maria_path/maria_chk -es test2", "$maria_path/maria_chk -es test2",
"$maria_path/maria_read_log -a -s", "$maria_path/maria_read_log -a -s",
...@@ -363,32 +404,8 @@ sub run_tests_on_clrs ...@@ -363,32 +404,8 @@ sub run_tests_on_clrs
"rm test2.MA?" "rm test2.MA?"
); );
if ($count) return &count_tests(\@t) if ($count);
{ &run_test_bunch(\@t, $verbose, 1);
$nr_tests= 0;
for ($i= 0; defined($t1[$i]); $i++) { $nr_tests++; }
for ($i= 0; defined($t2[$i]); $i++) { $nr_tests++; }
for ($i= 0; defined($t3[$i]); $i++) { $nr_tests++; }
return $nr_tests;
}
unlink <maria_log.* maria_log_control>;
for ($i= 0; defined($t1[$i]); $i++)
{
ok($t1[$i], $verbose, $i + 1);
}
unlink <maria_log.* maria_log_control>;
for ($i= 0; defined($t2[$i]); $i++)
{
ok($t2[$i], $verbose, $i + 1);
}
unlink <maria_log.* maria_log_control>;
for ($i= 0; defined($t3[$i]); $i++)
{
ok($t3[$i], $verbose, $i + 1);
}
return 0; return 0;
} }
...@@ -412,27 +429,44 @@ sub run_tests_on_clrs ...@@ -412,27 +429,44 @@ sub run_tests_on_clrs
sub ok sub ok
{ {
my ($com, $verbose, $iteration, $expected_error)= @_; my ($com, $verbose, $iteration, $expected_error)= @_;
my ($msg, $output, $err); my ($msg, $output, $err, $len);
$msg= "";
$expected_error= 0 if (!defined($expected_error)); $expected_error= 0 if (!defined($expected_error));
if ($verbose) if ($verbose)
{ {
print "Running: '$com'\n"; print "$com ";
} }
$output= `$com 2>&1`; $output= `$com 2>&1`;
$err= $? >> 8; $len= length($com);
if ($verbose) if ($verbose)
{ {
print "$output\n"; print " " x (65 - $len);
print " ";
} }
$err= $? >> 8;
if ($err == $expected_error) if ($err == $expected_error)
{ {
print "ok\n"; print "[ " if ($verbose);
print "ok";
print " ]" if ($verbose);
print "\n";
return 1; return 1;
} }
print "not ok\n"; print "[ " if ($verbose);
$msg= "\nFailed test '$com' "; print "not ok";
print " ]" if ($verbose);
print "\n";
if ($verbose && length($output))
{
print "$output\n";
}
if (!$verbose)
{
$msg= "\n"; # Get a nicer output in perl unit test mode
}
$msg.= "Failed test '$com' ";
if ($iteration) if ($iteration)
{ {
$msg.= "(loop iteration $iteration.) "; $msg.= "(loop iteration $iteration.) ";
...@@ -445,6 +479,81 @@ sub ok ...@@ -445,6 +479,81 @@ sub ok
$msg.= "Was expecting errcode: $expected_error\n"; $msg.= "Was expecting errcode: $expected_error\n";
} }
warn $msg; warn $msg;
$runtime_error= 1;
return 0; return 0;
} }
####
#### Count tests
#### Arguments: $t: an array of the tests
####
sub count_tests
{
my ($t)= @_;
my ($i, $nr_tests);
$nr_tests= 0;
for ($i= 0; defined(@$t[$i]); $i++) { $nr_tests++ if (@$t[$i]); }
return $nr_tests;
}
####
#### Run a bunch of tests
#### Arguments: $t: an array of the tests
#### $verbose: to be passed to ok()
#### $clear: clear log files if set
####
sub run_test_bunch
{
my ($t, $verbose, $clear)= @_;
my ($i);
for ($i= 0; defined(@$t[$i]); $i++)
{
if ($clear && @$t[$i] eq $NEW_TEST)
{
unlink <maria_log.* maria_log_control>;
}
if (@$t[$i] ne $NEW_TEST)
{
ok(@$t[$i], $verbose, $i + 1);
}
}
}
####
#### usage
####
sub usage
{
print <<EOF;
$my_progname version $VER
Description:
Run various Maria related tests. Typically used via make test as a unittest.
Please set environment variable maria_path before executing, if you
are not starting the program where ma_test1, ma_test2, ma_test3,
ma_test_recovery etc. files are.
Options
--help Show this help and exit.
--version Show version number and exit.
--verbose Be more verbose. Will print each unittest on a line
and result after. This mode cannot be used with unit.pl
when running in normal unit test mode.
--maria-path=... Path to maria test files. You can set this as an
environment variable 'maria_path' also.
(maria_path: '$maria_path')
--valgrind=... Options for valgrind.
('$opt_valgrind')
--suffix=... Suffix for test files (ma_test1, ma_test2 etc.),
if they have one ('$opt_suffix')
--silent=... Silent option passed to ma_test* tests ('$opt_silent')
EOF
exit(0);
}
...@@ -21,10 +21,10 @@ CLEANFILES = unit ...@@ -21,10 +21,10 @@ CLEANFILES = unit
unittests = mytap mysys @mysql_se_unittest_dirs@ @mysql_pg_unittest_dirs@ unittests = mytap mysys @mysql_se_unittest_dirs@ @mysql_pg_unittest_dirs@
test: test:
perl unit.pl run $(unittests) maria_path=../storage/maria perl unit.pl run $(unittests)
test-verbose: test-verbose:
HARNESS_VERBOSE=1 perl unit.pl run $(unittests) HARNESS_VERBOSE=1 maria_path=../storage/maria perl unit.pl run $(unittests)
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
%::SCCS/s.% %::SCCS/s.%
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment