summaryrefslogtreecommitdiff
path: root/storage/maria/unittest/ma_test_all-t
diff options
context:
space:
mode:
Diffstat (limited to 'storage/maria/unittest/ma_test_all-t')
-rwxr-xr-xstorage/maria/unittest/ma_test_all-t176
1 files changed, 116 insertions, 60 deletions
diff --git a/storage/maria/unittest/ma_test_all-t b/storage/maria/unittest/ma_test_all-t
index 0b11daf7f98..e66d269ab93 100755
--- a/storage/maria/unittest/ma_test_all-t
+++ b/storage/maria/unittest/ma_test_all-t
@@ -8,7 +8,7 @@ use File::Basename;
$|= 1;
$^W = 1; # warnings, because env cannot parse 'perl -w'
-$VER= "1.4";
+$VER= "1.5";
$opt_version= 0;
$opt_help= 0;
@@ -28,7 +28,10 @@ my $NEW_TEST= 0; # Test group separator in an array of tests
my $test_begin= 0;
my $test_end= 0;
my $test_counter= 0;
-
+my $using_internal_tmpdir= 0;
+my $full_tmpdir;
+my $tmpdir="tmp";
+my $exec_dir="TMP-ma_test_all"; # Run test in this directory
run_tests();
####
@@ -46,6 +49,7 @@ sub run_tests
"abort-on-error" => \$opt_abort_on_error,
"valgrind=s" => \$opt_valgrind,
"silent=s" => \$opt_silent,
+ "tmpdir=s" => \$full_tmpdir,
"number-of-tests" => \$opt_number_of_tests,
"run-tests=s" => \$opt_run_tests,
"start-from=s" => \$opt_run_tests))
@@ -57,7 +61,14 @@ sub run_tests
print "$my_progname version $VER\n";
exit(0);
}
- $maria_path= dirname($0) . "/..";
+
+ if (! -d $exec_dir)
+ {
+ die if (!mkdir("$exec_dir"));
+ }
+ chdir($exec_dir);
+
+ $maria_path= "../" . dirname($0) . "/..";
my $suffix= ( $^O =~ /win/i && $^O !~ /darwin/i ) ? ".exe" : "";
$maria_exe_path= "$maria_path/release";
@@ -73,14 +84,28 @@ sub run_tests
$maria_exe_path= $maria_path;
if ( ! -f "$maria_exe_path/ma_test1$suffix" )
{
- die("Cannot find ma_test1 executable\n");
+ die("Cannot find ma_test1 executable in $maria_path\n");
}
}
}
- }
+ }
usage() if ($opt_help || $flag_exit);
+ if (defined($full_tmpdir))
+ {
+ $tmpdir= $full_tmpdir;
+ }
+ else
+ {
+ $full_tmpdir= $tmpdir;
+ $using_internal_tmpdir= 1;
+ if (! -d "$full_tmpdir")
+ {
+ die if (!mkdir("$full_tmpdir"));
+ }
+ }
+
#
# IMPORTANT: If you modify this file, please read this:
#
@@ -146,7 +171,7 @@ sub run_tests
# clean-up
#
- unlink <*.TMD aria_log*>; # Delete temporary files
+ unlink_all_possible_tmp_files();
#
# Run tests
@@ -210,6 +235,14 @@ sub run_tests
run_ma_test_recovery($opt_verbose, 0);
run_tests_on_clrs($suffix, $opt_verbose, 0);
+ unlink_all_possible_tmp_files();
+ if ($using_internal_tmpdir)
+ {
+ rmdir($tmpdir);
+ }
+ rmdir($exec_dir);
+ chdir("..");
+ rmdir($exec_dir);
exit($runtime_error);
}
@@ -250,6 +283,7 @@ sub run_check_tests
["-p -B --key_length=480","-sm"],
["--checksum --unique","-se"],
["--unique","-se"],
+ ["--rows-no-data", "-s"],
["--key_multiple -N -S","-sm"],
["--key_multiple -a -p --key_length=480","-sm"],
["--key_multiple -a -B --key_length=480","-sm"],
@@ -280,38 +314,38 @@ sub run_check_tests
for ($i= 0; defined($ma_test1_opt[$i]); $i++)
{
- unlink <aria_log_control aria_log.*>;
- ok("$maria_exe_path/ma_test1$suffix $silent $ma_test1_opt[$i][0] $row_type",
+ unlink_log_files();
+ ok("$maria_exe_path/ma_test1$suffix $silent -h$tmpdir $ma_test1_opt[$i][0] $row_type",
$verbose, $i + 1);
- ok("$maria_exe_path/aria_chk$suffix $ma_test1_opt[$i][1] test1",
+ ok("$maria_exe_path/aria_chk$suffix -h$tmpdir $ma_test1_opt[$i][1] $tmpdir/test1",
$verbose, $i + 1);
}
#
# These tests are outside the loops. Make sure to include them in
# nr_tests manually
#
- ok("$maria_exe_path/aria_pack$suffix --force -s test1", $verbose, 0);
- ok("$maria_exe_path/aria_chk$suffix -ess test1", $verbose, 0);
+ ok("$maria_exe_path/aria_pack$suffix --force -s $tmpdir/test1", $verbose, 0);
+ ok("$maria_exe_path/aria_chk$suffix -ess $tmpdir/test1", $verbose, 0);
for ($i= 0; defined($ma_test2_opt[$i]); $i++)
{
- unlink <aria_log_control aria_log.*>;
- ok("$maria_exe_path/ma_test2$suffix $silent $ma_test2_opt[$i][0] $row_type",
+ unlink_log_files();
+ ok("$maria_exe_path/ma_test2$suffix $silent -h$tmpdir $ma_test2_opt[$i][0] $row_type",
$verbose, $i + 1);
- ok("$maria_exe_path/aria_chk$suffix $ma_test2_opt[$i][1] test2",
+ ok("$maria_exe_path/aria_chk$suffix -h$tmpdir $ma_test2_opt[$i][1] $tmpdir/test2",
$verbose, $i + 1);
}
for ($i= 0; defined($ma_rt_test_opt[$i]); $i++)
{
- unlink <aria_log_control aria_log.*>;
- ok("$maria_exe_path/ma_rt_test$suffix $silent $ma_rt_test_opt[$i][0] $row_type",
+ unlink_log_files();
+ ok("$maria_exe_path/ma_rt_test$suffix $silent -h$tmpdir $ma_rt_test_opt[$i][0] $row_type",
$verbose, $i + 1);
- ok("$maria_exe_path/aria_chk$suffix $ma_rt_test_opt[$i][1] rt_test",
+ ok("$maria_exe_path/aria_chk$suffix -h$tmpdir $ma_rt_test_opt[$i][1] $tmpdir/rt_test",
$verbose, $i + 1);
}
- unlink <aria_log_control aria_log.*>;
+ unlink_log_files();
return 0;
}
@@ -412,13 +446,16 @@ sub run_pack_tests()
"cp test1.MAD test2.MAD",
"cp test1.MAI test2.MAI",
"$maria_exe_path/aria_pack$suffix --force -s --join=test3 test1 test2",
- "$maria_exe_path/aria_chk -s test3",
- "$maria_exe_path/aria_chk -s --safe-recover test3",
- "$maria_exe_path/aria_chk -s test3"
);
- return &count_tests(\@t) if ($count);
+ return (&count_tests(\@t) + 3) if ($count);
&run_test_bunch(\@t, $verbose, 0);
+
+ ok("$maria_exe_path/aria_chk -s test3", $verbose, 0, 1);
+ @t= ("$maria_exe_path/aria_chk -s --safe-recover test3",
+ "$maria_exe_path/aria_chk -s test3");
+ &run_test_bunch(\@t, $verbose, 0);
+
return 0;
}
@@ -433,25 +470,25 @@ sub run_tests_on_warnings_and_errors
return 9 if ($count); # Number of tests in this function, e.g. calls to ok()
- ok("$maria_exe_path/ma_test2$suffix $silent -L -K -W -P -S -R1 -m500",
+ ok("$maria_exe_path/ma_test2$suffix -h$tmpdir $silent -L -K -W -P -S -R1 -m500",
$verbose, 0);
- ok("$maria_exe_path/aria_chk$suffix -sm test2", $verbose, 0);
+ ok("$maria_exe_path/aria_chk$suffix -h$tmpdir -sm $tmpdir/test2", $verbose, 0);
# ma_test2$suffix $silent -L -K -R1 -m2000 ; Should give error 135\n
# In the following a failure is a success and success is a failure
- $com= "$maria_exe_path/ma_test2$suffix $silent -L -K -R1 -m2000 ";
+ $com= "$maria_exe_path/ma_test2$suffix -h$tmpdir $silent -L -K -R1 -m2000 ";
$com.= ">ma_test2_message.txt 2>&1";
ok($com, $verbose, 0, 1);
ok("cat ma_test2_message.txt", $verbose, 0);
ok("grep \"Error: 135\" ma_test2_message.txt > /dev/null", $verbose, 0);
- # maria_exe_path/aria_chk$suffix -sm test2 will warn that
+ # maria_exe_path/aria_chk$suffix -h$tmpdir -sm $tmpdir/test2 will warn that
# Datafile is almost full
- ok("$maria_exe_path/aria_chk$suffix -sm test2 >ma_test2_message.txt 2>&1",
- $verbose, 0);
+ ok("$maria_exe_path/aria_chk$suffix -h$tmpdir -sm $tmpdir/test2 >ma_test2_message.txt 2>&1",
+ $verbose, 0, 1);
ok("cat ma_test2_message.txt", $verbose, 0);
ok("grep \"warning: Datafile is almost full\" ma_test2_message.txt>/dev/null",
$verbose, 0);
unlink <ma_test2_message.txt>;
- ok("$maria_exe_path/aria_chk$suffix -ssm test2", $verbose, 0);
+ ok("$maria_exe_path/aria_chk$suffix -h$tmpdir -ssm $tmpdir/test2", $verbose, 0);
return 0;
}
@@ -479,33 +516,33 @@ sub run_tests_on_clrs
my ($i);
my @t= ($NEW_TEST,
- "$maria_exe_path/ma_test2$suffix -s -L -K -W -P -M -T -c -b -t2 -A1",
- "cp aria_log_control tmp",
- "$maria_exe_path/aria_read_log$suffix -a -s",
- "$maria_exe_path/aria_chk$suffix -s -e test2",
- "cp tmp/aria_log_control .",
- "rm test2.MA?",
- "$maria_exe_path/aria_read_log$suffix -a -s",
- "$maria_exe_path/aria_chk$suffix -s -e test2",
- "rm test2.MA?",
+ "$maria_exe_path/ma_test2$suffix -h$tmpdir -s -L -K -W -P -M -T -c -b -t2 -A1",
+ "cp $tmpdir/aria_log_control $tmpdir/aria_log_control.backup",
+ "$maria_exe_path/aria_read_log$suffix -a -s -h$tmpdir",
+ "$maria_exe_path/aria_chk$suffix -h$tmpdir -s -e $tmpdir/test2",
+ "mv $tmpdir/aria_log_control.backup $tmpdir/aria_log_control",
+ "rm $tmpdir/test2.MA?",
+ "$maria_exe_path/aria_read_log$suffix -a -s -h$tmpdir",
+ "$maria_exe_path/aria_chk$suffix -h$tmpdir -s -e $tmpdir/test2",
+ "rm $tmpdir/test2.MA?",
$NEW_TEST,
- "$maria_exe_path/ma_test2$suffix -s -L -K -W -P -M -T -c -b -t2 -A1",
- "$maria_exe_path/aria_read_log$suffix -a -s",
- "$maria_exe_path/aria_chk$suffix -s -e test2",
- "rm test2.MA?",
- "$maria_exe_path/aria_read_log$suffix -a -s",
- "$maria_exe_path/aria_chk$suffix -e -s test2",
- "rm test2.MA?",
+ "$maria_exe_path/ma_test2$suffix -h$tmpdir -s -L -K -W -P -M -T -c -b -t2 -A1",
+ "$maria_exe_path/aria_read_log$suffix -a -s -h$tmpdir ",
+ "$maria_exe_path/aria_chk$suffix -h$tmpdir -s -e $tmpdir/test2",
+ "rm $tmpdir/test2.MA?",
+ "$maria_exe_path/aria_read_log$suffix -a -s -h$tmpdir",
+ "$maria_exe_path/aria_chk$suffix -h$tmpdir -e -s $tmpdir/test2",
+ "rm $tmpdir/test2.MA?",
$NEW_TEST,
- "$maria_exe_path/ma_test2$suffix -s -L -K -W -P -M -T -c -b32768 -t4 -A1",
- "$maria_exe_path/aria_read_log$suffix -a -s",
- "$maria_exe_path/aria_chk$suffix -es test2",
- "$maria_exe_path/aria_read_log$suffix -a -s",
- "$maria_exe_path/aria_chk$suffix -es test2",
- "rm test2.MA?",
- "$maria_exe_path/aria_read_log$suffix -a -s",
- "$maria_exe_path/aria_chk$suffix -es test2",
- "rm test2.MA?"
+ "$maria_exe_path/ma_test2$suffix -h$tmpdir -s -L -K -W -P -M -T -c -b32768 -t4 -A1",
+ "$maria_exe_path/aria_read_log$suffix -a -s -h$tmpdir",
+ "$maria_exe_path/aria_chk$suffix -h$tmpdir -es $tmpdir/test2",
+ "$maria_exe_path/aria_read_log$suffix -a -s -h$tmpdir ",
+ "$maria_exe_path/aria_chk$suffix -h$tmpdir -es $tmpdir/test2",
+ "rm $tmpdir/test2.MA?",
+ "$maria_exe_path/aria_read_log$suffix -a -s -h$tmpdir",
+ "$maria_exe_path/aria_chk$suffix -h$tmpdir -es $tmpdir/test2",
+ "rm $tmpdir/test2.MA?"
);
return &count_tests(\@t) if ($count);
@@ -533,7 +570,7 @@ sub run_tests_on_clrs
sub ok
{
my ($com, $verbose, $iteration, $expected_error)= @_;
- my ($msg, $output, $err, $len);
+ my ($msg, $output, $err, $errcode, $len);
$test_counter++;
if ($test_begin > $test_counter)
@@ -550,17 +587,22 @@ sub ok
if ($verbose)
{
- print "$com ";
+ # Print command with out the long unittest/../ prefix
+ my $tmp;
+ $tmp= $com;
+ $tmp =~ s|^unittest/../||;
+ print "$tmp ";
+ $len= length($tmp);
}
$output= `$com 2>&1`;
- $len= length($com);
if ($verbose)
{
print " " x (62 - $len);
}
$err= $?;
+ $errcode= ($? >> 8);
if ((!$err && !$expected_error) ||
- (($err >> 8) == $expected_error && $expected_error))
+ ($errcode == $expected_error && $expected_error))
{
print "[ " if ($verbose);
print "ok";
@@ -597,7 +639,7 @@ sub ok
}
$msg.= "at line ";
$msg.= (caller)[2];
- $msg.= "\n(errcode: $err, test: $test_counter)\n";
+ $msg.= "\n(errcode: $errcode, test: $test_counter)\n";
if ($expected_error)
{
$msg.= "Was expecting errcode: $expected_error\n";
@@ -650,6 +692,19 @@ sub count_tests
return $nr_tests;
}
+sub unlink_log_files
+{
+ unlink "$full_tmpdir/aria_log_control", "$full_tmpdir/aria_log.00000001", "$full_tmpdir/aria_log.00000002";
+}
+
+sub unlink_all_possible_tmp_files()
+{
+ unlink_log_files();
+
+ # Unlink tmp files that may have been created when testing the test programs
+ unlink <$full_tmpdir/*.TMD $full_tmpdir/aria_read_log_test1.txt $full_tmpdir/test1*.MA? $full_tmpdir/ma_test_recovery.output aria_log_control aria_log.00000001 aria_log.00000002 aria_logtest1.MA? test1.MA? test2.MA? test3.MA?>;
+}
+
####
#### Run a bunch of tests
#### Arguments: $t: an array of the tests
@@ -666,7 +721,7 @@ sub run_test_bunch
{
if ($clear && @$t[$i] eq $NEW_TEST)
{
- unlink <aria_log.* aria_log_control>;
+ unlink_log_files();
}
if (@$t[$i] ne $NEW_TEST)
{
@@ -699,6 +754,7 @@ Options
might depend on previous ones.
--start-from=... Alias for --run-tests
--silent=... Silent option passed to ma_test* tests ('$opt_silent')
+--tmpdir=... Store tests data in this directory (works for most tests)
--valgrind=... Options for valgrind.
('$opt_valgrind')
--verbose Be more verbose. Will print each unittest on a line