diff --git a/.bzrignore b/.bzrignore index 3b65e8d24e4688b356036378fd699bcc5b3fda5b..9c60fecca1cf9865c186b98bb5912351510a97e6 100644 --- a/.bzrignore +++ b/.bzrignore @@ -3073,3 +3073,6 @@ libmysqld/sql_profile.cc comments maria-win.patch storage/maria/maria_dump_log +maria_log.00000* +ma_test_recovery.output +test?.MA? diff --git a/Makefile.am b/Makefile.am index 698e49f61f02a16edf8ee015ab913f154f885981..12001c4b962fe81456ed3f3f4668272f98d84cf3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,7 +64,7 @@ tags: .PHONY: init-db bin-dist \ test test-force test-full test-force-full test-force-mem \ test-pl test-force-pl test-full-pl test-force-full-pl test-force-pl-mem \ - test-unit test-ps test-nr test-pr test-ns test-binlog-statement \ + test-unit test-unit-big test-ps test-nr test-pr test-ns test-binlog-statement \ test-ext-funcs test-ext-rpl test-ext-partitions test-ext-jp \ test-ext-stress test-ext test-embedded \ test-fast test-fast-cursor test-fast-view test-fast-prepare \ @@ -79,7 +79,10 @@ tags: # making sure each user use different ports. test-unit: - cd unittest && $(MAKE) test + cd unittest; $(MAKE) test + +test-unit-big: + cd unittest; MYTAP_CONFIG=big $(MAKE) test test-ps: cd mysql-test ; \ diff --git a/storage/maria/unittest/Makefile.am b/storage/maria/unittest/Makefile.am index fd4a8c99ed2ea3e86d97cc62156d9f42336102ee..ace875a83441e99d37ec1fee47ce45fd0f5c65c0 100644 --- a/storage/maria/unittest/Makefile.am +++ b/storage/maria/unittest/Makefile.am @@ -29,20 +29,20 @@ LDADD= $(top_builddir)/unittest/mytap/libmytap.a \ $(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@ noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t \ ma_pagecache_single_1k-t ma_pagecache_single_8k-t \ - ma_pagecache_single_64k-t-big \ - ma_pagecache_consist_1k-t-big \ - ma_pagecache_consist_64k-t-big \ - ma_pagecache_consist_1kHC-t-big \ - ma_pagecache_consist_64kHC-t-big \ - ma_pagecache_consist_1kRD-t-big \ - ma_pagecache_consist_64kRD-t-big \ - ma_pagecache_consist_1kWR-t-big \ - ma_pagecache_consist_64kWR-t-big \ + ma_pagecache_single_64k_big-t \ + ma_pagecache_consist_1k_big-t \ + ma_pagecache_consist_64k_big-t \ + ma_pagecache_consist_1kHC_big-t \ + ma_pagecache_consist_64kHC_big-t \ + ma_pagecache_consist_1kRD_big-t \ + ma_pagecache_consist_64kRD_big-t \ + ma_pagecache_consist_1kWR_big-t \ + ma_pagecache_consist_64kWR_big-t \ ma_test_loghandler-t \ ma_test_loghandler_multigroup-t \ ma_test_loghandler_multithread-t \ ma_test_loghandler_pagecache-t \ - ma_test_loghandler_long-t-big \ + ma_test_loghandler_long_big-t \ ma_test_loghandler_noflush-t \ ma_test_loghandler_first_lsn-t \ ma_test_loghandler_max_lsn-t \ @@ -54,8 +54,8 @@ ma_test_loghandler_t_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_ ma_test_loghandler_multigroup_t_SOURCES = ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c ma_test_loghandler_multithread_t_SOURCES = ma_test_loghandler_multithread-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c ma_test_loghandler_pagecache_t_SOURCES = ma_test_loghandler_pagecache-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c -ma_test_loghandler_long_t_big_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c -ma_test_loghandler_long_t_big_CPPFLAGS = -DLONG_LOG_TEST +ma_test_loghandler_long_big_t_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c +ma_test_loghandler_long_big_t_CPPFLAGS = -DLONG_LOG_TEST ma_test_loghandler_noflush_t_SOURCES = ma_test_loghandler_noflush-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c ma_test_loghandler_first_lsn_t_SOURCES = ma_test_loghandler_first_lsn-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c ma_test_loghandler_max_lsn_t_SOURCES = ma_test_loghandler_max_lsn-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c @@ -70,30 +70,30 @@ ma_pagecache_common_cppflags = -DEXTRA_DEBUG -DPAGECACHE_DEBUG -DMAIN ma_pagecache_single_1k_t_SOURCES = $(ma_pagecache_single_src) ma_pagecache_single_8k_t_SOURCES = $(ma_pagecache_single_src) -ma_pagecache_single_64k_t_big_SOURCES = $(ma_pagecache_single_src) +ma_pagecache_single_64k_big_t_SOURCES = $(ma_pagecache_single_src) ma_pagecache_single_1k_t_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=1024 ma_pagecache_single_8k_t_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=8192 -ma_pagecache_single_64k_t_big_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=65536 +ma_pagecache_single_64k_big_t_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DBIG -ma_pagecache_consist_1k_t_big_SOURCES = $(ma_pagecache_consist_src) -ma_pagecache_consist_1k_t_big_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=1024 -ma_pagecache_consist_64k_t_big_SOURCES = $(ma_pagecache_consist_src) -ma_pagecache_consist_64k_t_big_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=65536 +ma_pagecache_consist_1k_big_t_SOURCES = $(ma_pagecache_consist_src) +ma_pagecache_consist_1k_big_t_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=1024 +ma_pagecache_consist_64k_big_t_SOURCES = $(ma_pagecache_consist_src) +ma_pagecache_consist_64k_big_t_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=65536 -ma_pagecache_consist_1kHC_t_big_SOURCES = $(ma_pagecache_consist_src) -ma_pagecache_consist_1kHC_t_big_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_HIGH_CONCURENCY -ma_pagecache_consist_64kHC_t_big_SOURCES = $(ma_pagecache_consist_src) -ma_pagecache_consist_64kHC_t_big_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_HIGH_CONCURENCY +ma_pagecache_consist_1kHC_big_t_SOURCES = $(ma_pagecache_consist_src) +ma_pagecache_consist_1kHC_big_t_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_HIGH_CONCURENCY +ma_pagecache_consist_64kHC_big_t_SOURCES = $(ma_pagecache_consist_src) +ma_pagecache_consist_64kHC_big_t_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_HIGH_CONCURENCY -ma_pagecache_consist_1kRD_t_big_SOURCES = $(ma_pagecache_consist_src) -ma_pagecache_consist_1kRD_t_big_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_READERS -ma_pagecache_consist_64kRD_t_big_SOURCES = $(ma_pagecache_consist_src) -ma_pagecache_consist_64kRD_t_big_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_READERS +ma_pagecache_consist_1kRD_big_t_SOURCES = $(ma_pagecache_consist_src) +ma_pagecache_consist_1kRD_big_t_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_READERS +ma_pagecache_consist_64kRD_big_t_SOURCES = $(ma_pagecache_consist_src) +ma_pagecache_consist_64kRD_big_t_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_READERS -ma_pagecache_consist_1kWR_t_big_SOURCES = $(ma_pagecache_consist_src) -ma_pagecache_consist_1kWR_t_big_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_WRITERS -ma_pagecache_consist_64kWR_t_big_SOURCES = $(ma_pagecache_consist_src) -ma_pagecache_consist_64kWR_t_big_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_WRITERS +ma_pagecache_consist_1kWR_big_t_SOURCES = $(ma_pagecache_consist_src) +ma_pagecache_consist_1kWR_big_t_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_WRITERS +ma_pagecache_consist_64kWR_big_t_SOURCES = $(ma_pagecache_consist_src) +ma_pagecache_consist_64kWR_big_t_CPPFLAGS = $(ma_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_WRITERS # the generic lock manager may not be used in the end and lockman1-t crashes, # so we don't build lockman-t and lockman1-t diff --git a/storage/maria/unittest/ma_pagecache_consist.c b/storage/maria/unittest/ma_pagecache_consist.c index 70c3dd67ba65181ceaf988846dbf71529104df07..da2a1218c536e06fd26e3cb1ba35528227c9d129 100644 --- a/storage/maria/unittest/ma_pagecache_consist.c +++ b/storage/maria/unittest/ma_pagecache_consist.c @@ -1,7 +1,6 @@ /* TODO: use pthread_join instead of wait_for_thread_count_to_be_zero, like in my_atomic-t.c (see BUG#22320). - Use diag() instead of fprintf(stderr). Use ok() and plan(). */ #include <tap.h> @@ -225,11 +224,9 @@ void reader(int num) PAGECACHE_LOCK_LEFT_UNLOCKED, 0); check_page(buffr, page * PAGE_SIZE, 0, page, -num); - if (i % 500 == 0) - printf("reader%d: %d\n", num, i); } - printf("reader%d: done\n", num); + ok(1, "reader%d: done\n", num); free(buffr); } @@ -258,10 +255,8 @@ void writer(int num) if (i % flush_divider == 0) flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE); - if (i % 500 == 0) - printf("writer%d: %d\n", num, i); } - printf("writer%d: done\n", num); + ok(1, "writer%d: done\n", num); free(buffr); } @@ -332,10 +327,14 @@ int main(int argc __attribute__((unused)), { DBUG_ENTER("main"); DBUG_PRINT("info", ("Main thread: %s\n", my_thread_name())); + plan(number_of_writers + number_of_readers); + SKIP_BIG_TESTS(number_of_writers + number_of_readers) + { + if ((file1.file= my_open(file1_name, O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1) { - fprintf(stderr, "Got error during file1 creation from open() (errno: %d)\n", + diag( "Got error during file1 creation from open() (errno: %d)\n", errno); exit(1); } @@ -348,26 +347,26 @@ int main(int argc __attribute__((unused)), if ((error= pthread_cond_init(&COND_thread_count, NULL))) { - fprintf(stderr, "COND_thread_count: %d from pthread_cond_init (errno: %d)\n", + diag( "COND_thread_count: %d from pthread_cond_init (errno: %d)\n", error, errno); exit(1); } if ((error= pthread_mutex_init(&LOCK_thread_count, MY_MUTEX_INIT_FAST))) { - fprintf(stderr, "LOCK_thread_count: %d from pthread_cond_init (errno: %d)\n", + diag( "LOCK_thread_count: %d from pthread_cond_init (errno: %d)\n", error, errno); exit(1); } if ((error= pthread_attr_init(&thr_attr))) { - fprintf(stderr,"Got error: %d from pthread_attr_init (errno: %d)\n", + diag("Got error: %d from pthread_attr_init (errno: %d)\n", error,errno); exit(1); } if ((error= pthread_attr_setdetachstate(&thr_attr, PTHREAD_CREATE_DETACHED))) { - fprintf(stderr, + diag( "Got error: %d from pthread_attr_setdetachstate (errno: %d)\n", error,errno); exit(1); @@ -380,7 +379,7 @@ int main(int argc __attribute__((unused)), if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0, PAGE_SIZE, 0)) == 0) { - fprintf(stderr,"Got error: init_pagecache() (errno: %d)\n", + diag("Got error: init_pagecache() (errno: %d)\n", errno); exit(1); } @@ -411,7 +410,7 @@ int main(int argc __attribute__((unused)), if ((error= pthread_create(&tid, &thr_attr, test_thread_reader, (void*) param))) { - fprintf(stderr,"Got error: %d from pthread_create (errno: %d)\n", + diag("Got error: %d from pthread_create (errno: %d)\n", error,errno); exit(1); } @@ -425,7 +424,7 @@ int main(int argc __attribute__((unused)), if ((error= pthread_create(&tid, &thr_attr, test_thread_writer, (void*) param))) { - fprintf(stderr,"Got error: %d from pthread_create (errno: %d)\n", + diag("Got error: %d from pthread_create (errno: %d)\n", error,errno); exit(1); } @@ -443,7 +442,7 @@ int main(int argc __attribute__((unused)), while (thread_count) { if ((error= pthread_cond_wait(&COND_thread_count,&LOCK_thread_count))) - fprintf(stderr,"COND_thread_count: %d from pthread_cond_wait\n",error); + diag("COND_thread_count: %d from pthread_cond_wait\n",error); } pthread_mutex_unlock(&LOCK_thread_count); DBUG_PRINT("info", ("thread ended")); @@ -453,17 +452,18 @@ int main(int argc __attribute__((unused)), if (my_close(file1.file, MYF(0)) != 0) { - fprintf(stderr, "Got error during file1 closing from close() (errno: %d)\n", + diag( "Got error during file1 closing from close() (errno: %d)\n", errno); exit(1); } my_delete(file1_name, MYF(0)); - my_end(0); DBUG_PRINT("info", ("file1 (%d) closed", file1.file)); - DBUG_PRINT("info", ("Program end")); - DBUG_RETURN(exit_status()); + } /* SKIP_BIG_TESTS */ + my_end(0); + + return exit_status(); } } diff --git a/storage/maria/unittest/ma_pagecache_single.c b/storage/maria/unittest/ma_pagecache_single.c index c4efda7d8cfb03d2601d5cf1bde172b13a5c05eb..1212de73932f5e2aeb6cc55e598c51e2945ad53f 100644 --- a/storage/maria/unittest/ma_pagecache_single.c +++ b/storage/maria/unittest/ma_pagecache_single.c @@ -15,6 +15,11 @@ static const char* default_dbug_option; #endif +#ifndef BIG +#undef SKIP_BIG_TESTS +#define SKIP_BIG_TESTS(X) /* no-op */ +#endif + static char *file1_name= (char*)"page_cache_test_file_1"; static char *file2_name= (char*)"page_cache_test_file_2"; static PAGECACHE_FILE file1; @@ -631,6 +636,11 @@ int main(int argc __attribute__((unused)), { DBUG_ENTER("main"); DBUG_PRINT("info", ("Main thread: %s\n", my_thread_name())); + + plan(16); + SKIP_BIG_TESTS(16) + { + if ((tmp_file= my_open(file2_name, O_CREAT | O_TRUNC | O_RDWR, MYF(MY_WME))) < 0) exit(1); @@ -683,8 +693,6 @@ int main(int argc __attribute__((unused)), VOID(thr_setconcurrency(2)); #endif - plan(16); - if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0, PAGE_SIZE, MYF(MY_WME))) == 0) { @@ -725,11 +733,13 @@ int main(int argc __attribute__((unused)), exit(1); my_delete(file1_name, MYF(0)); - my_end(0); + } /* SKIP_BIG_TESTS */ DBUG_PRINT("info", ("file1 (%d) closed", file1.file)); DBUG_PRINT("info", ("Program end")); - DBUG_RETURN(exit_status()); + my_end(0); + } + return exit_status(); } diff --git a/storage/maria/unittest/ma_test_all-t b/storage/maria/unittest/ma_test_all-t index 33a8d711ef7a112532367344f2837a9a06a4c4a7..c3485d0ab4c33f76d5047264aaacf8585a1542e2 100755 --- a/storage/maria/unittest/ma_test_all-t +++ b/storage/maria/unittest/ma_test_all-t @@ -4,6 +4,7 @@ # use Getopt::Long; +use File::Basename; $|= 1; $VER= "1.3"; @@ -56,8 +57,9 @@ sub run_tests } if (!defined($maria_path) || !length($maria_path)) { - $maria_path= "."; + $maria_path= dirname($0) . '/..'; } + $ENV{'maria_path'}=$maria_path; usage() if ($opt_help || $flag_exit); @@ -524,12 +526,17 @@ sub ok print " " x (5 - length("$test_counter")); print "$test_counter"; } + else + { + print " $test_counter - $com" + } print "\n"; return 1; } print "[ " if ($verbose); print "not ok"; print " ]" if ($verbose); + print " $test_counter - $com" unless $verbose; print "\n"; if ($verbose && defined($output) && length($output)) { @@ -560,6 +567,30 @@ sub ok return 0; } +# +# Print "skip" and the reason +# +# Note: Every time this function is called it will be counted +# as a unit test. +# +# Args: $com: The actual command run. Will be printed on a failure +# $reason: The reason to skip a test +# $verbose: Be more verbose. +# + +sub skip +{ + my ($com, $reason, $verbose)= @_; + + $test_counter++; + return 0 if $test_begin > $test_counter; + exit 0 if $test_end && $test_end < $test_counter; + printf '%-64s[ skipped ]%5d', $com, $test_counter if $verbose; + print "ok $test_counter # skip $reason" unless $verbose; + print "\n"; + return 1; +} + #### #### Count tests #### Arguments: $t: an array of the tests @@ -612,9 +643,6 @@ $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. diff --git a/storage/maria/unittest/ma_test_loghandler-t.c b/storage/maria/unittest/ma_test_loghandler-t.c index 779400834bea1074baf34016d16cc27040ecc736..2bb21482fc34fdabacc9857d671028338e289b10 100644 --- a/storage/maria/unittest/ma_test_loghandler-t.c +++ b/storage/maria/unittest/ma_test_loghandler-t.c @@ -22,6 +22,10 @@ static TRN *trn= &dummy_transaction_object; #define ITERATIONS (1600*4) #else + +#undef SKIP_BIG_TESTS +#define SKIP_BIG_TESTS(X) /* no-op */ + #define LOG_FLAGS (TRANSLOG_SECTOR_PROTECTION | TRANSLOG_PAGE_CRC) #define LOG_FILE_SIZE (1024L*1024L*8L) #define ITERATIONS 1600 @@ -197,6 +201,9 @@ int main(int argc __attribute__((unused)), char *argv[]) plan(((ITERATIONS - 1) * 4 + 1)*2 + ITERATIONS - 1 + 1); + SKIP_BIG_TESTS(((ITERATIONS - 1) * 4 + 1)*2 + ITERATIONS - 1 + 1) + { + srand(122334817L); long_tr_id[5]= 0xff; @@ -626,6 +633,7 @@ int main(int argc __attribute__((unused)), char *argv[]) err: if (rc) ok(0, "read record"); + } /* SKIP_BIG_TESTS */ translog_destroy(); end_pagecache(&pagecache, 1); ma_control_file_end(); diff --git a/unittest/Makefile.am b/unittest/Makefile.am index e9eb6737ce52f7ed35b14982656cd0e154484f23..8684fd3fc7d836ab1915105799e8692c5ca1a763 100644 --- a/unittest/Makefile.am +++ b/unittest/Makefile.am @@ -21,10 +21,10 @@ CLEANFILES = unit unittests = mytap mysys @mysql_se_unittest_dirs@ @mysql_pg_unittest_dirs@ test: - maria_path=../storage/maria perl unit.pl run $(unittests) + perl unit.pl run $(unittests) test-verbose: - HARNESS_VERBOSE=1 maria_path=../storage/maria perl unit.pl run $(unittests) + HARNESS_VERBOSE=1 perl unit.pl run $(unittests) # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/unittest/unit.pl b/unittest/unit.pl index 0b2a26446f0a1eadfc3bd0ff2299cddac7c67b18..a1aab376fdf17725dd8792395b65976e0903f5d0 100644 --- a/unittest/unit.pl +++ b/unittest/unit.pl @@ -32,18 +32,18 @@ unit - Run unit tests in directory =head1 SYNOPSIS - unit run + unit [--[no]big] [--[no]verbose] run [tests to run] =cut -my $big=1; +my $big= $ENV{'MYTAP_CONFIG'} eq 'big'; my $result = GetOptions ( "big!" => \$big, "verbose!" => \$Test::Harness::verbose, ); -$ENV{'MYTAP_CONFIG'} = $big ? "big" : ""; +$ENV{'MYTAP_CONFIG'} = $big ? 'big' : ''; my $cmd = shift;