Commit 7780d5e1 authored by unknown's avatar unknown

changes for big unit tests


Makefile.am:
  make test-unit-big
storage/maria/unittest/Makefile.am:
  support big unit tests
storage/maria/unittest/ma_pagecache_consist.c:
  support big unit tests and other changes
storage/maria/unittest/ma_pagecache_single.c:
  support big unit tests
storage/maria/unittest/ma_test_all-t:
  support big unit tests and sub skip()
storage/maria/unittest/ma_test_loghandler-t.c:
  support big unit tests
unittest/unit.pl:
  don't ignore existing $MYTAP_CONFIG
parent 79f122fa
......@@ -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 ; \
......
......@@ -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
......
/*
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();
}
}
......@@ -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();
}
......@@ -420,7 +420,14 @@ sub run_ma_test_recovery
my ($verbose, $count)= @_;
return 1 if ($count); # Number of tests in this function
ok("$maria_path/ma_test_recovery", $verbose, 0);
if ($ENV{MYTAP_CONFIG} eq 'big')
{
ok("$maria_path/ma_test_recovery", $verbose, 0);
}
else
{
skip("$maria_path/ma_test_recovery", 'big test', $verbose,);
}
return 0;
}
......@@ -567,6 +574,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
......
......@@ -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();
......
......@@ -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;
......
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