Commit 5933619c authored by Michael Widenius's avatar Michael Widenius

Made test-unit run in parlallel. This was achived by having all aria tests...

Made test-unit run in parlallel. This was achived by having all aria tests that uses temporary files to create the temporary file in an unique tempdirectory.
aria_chk now returns 1 if one got any warnings during check and 2 if one got errors.
lp:728919 maria_chk should fail on all detected corruptions

mysql-test/lib/My/SafeProcess.pm:
  Removed ^M lines from the file
storage/maria/ma_check.c:
  Fixed indentation
storage/maria/maria_chk.c:
  aria_chk now returns 1 if one got any warnings during check and 2 if one got errors.
storage/maria/unittest/ma_control_file-t.c:
  Use unique sub directory for test results
storage/maria/unittest/ma_maria_log_cleanup.c:
  Added help function create_tmpdir()
storage/maria/unittest/ma_pagecache_consist.c:
  Use unique sub directory for test results
storage/maria/unittest/ma_pagecache_rwconsist.c:
  Use unique sub directory for test results
storage/maria/unittest/ma_pagecache_rwconsist2.c:
  Use unique sub directory for test results
storage/maria/unittest/ma_pagecache_single.c:
  Use unique sub directory for test results
storage/maria/unittest/ma_test_all-t:
  Use unique sub directory for test results
storage/maria/unittest/ma_test_loghandler-t.c:
  Use unique sub directory for test results
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
  Use unique sub directory for test results
  remove delete of files that are already deleted by maria_log_remove()
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
  Use unique sub directory for test results
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  Use unique sub directory for test results
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  Use unique sub directory for test results
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
  Use unique sub directory for test results
  remove delete of files that are already deleted by maria_log_remove()
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
  Use unique sub directory for test results
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
  Use unique sub directory for test results
  remove delete of files that are already deleted by maria_log_remove()
storage/maria/unittest/ma_test_loghandler_purge-t.c:
  Use unique sub directory for test results
support-files/compiler_warnings.supp:
  Supress some warnings
unittest/unit.pl:
  Run 4 unittests in parallel
parent 1779c2ad
...@@ -86,17 +86,17 @@ sub is_child { ...@@ -86,17 +86,17 @@ sub is_child {
my @safe_process_cmd; my @safe_process_cmd;
my $safe_kill; my $safe_kill;
my $bindir; my $bindir;
if(defined $ENV{MTR_BINDIR}) if(defined $ENV{MTR_BINDIR})
{ {
# This is an out-of-source build. Build directory # This is an out-of-source build. Build directory
# is given in MTR_BINDIR env.variable # is given in MTR_BINDIR env.variable
$bindir = $ENV{MTR_BINDIR}."/mysql-test"; $bindir = $ENV{MTR_BINDIR}."/mysql-test";
} }
else else
{ {
$bindir = "."; $bindir = ".";
} }
# Find the safe process binary or script # Find the safe process binary or script
sub find_bin { sub find_bin {
......
...@@ -234,14 +234,14 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, ...@@ -234,14 +234,14 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info,
{ {
if (test_flag & T_VERBOSE) puts(""); if (test_flag & T_VERBOSE) puts("");
_ma_check_print_error(param,"Can't read delete-link at filepos: %s", _ma_check_print_error(param,"Can't read delete-link at filepos: %s",
llstr(next_link,buff)); llstr(next_link,buff));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (*buff != '\0') if (*buff != '\0')
{ {
if (test_flag & T_VERBOSE) puts(""); if (test_flag & T_VERBOSE) puts("");
_ma_check_print_error(param,"Record at pos: %s is not remove-marked", _ma_check_print_error(param,"Record at pos: %s is not remove-marked",
llstr(next_link,buff)); llstr(next_link,buff));
goto wrong; goto wrong;
} }
if (share->options & HA_OPTION_PACK_RECORD) if (share->options & HA_OPTION_PACK_RECORD)
...@@ -250,7 +250,9 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, ...@@ -250,7 +250,9 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info,
if (empty && prev_link != old_link) if (empty && prev_link != old_link)
{ {
if (test_flag & T_VERBOSE) puts(""); if (test_flag & T_VERBOSE) puts("");
_ma_check_print_error(param,"Deleted block at %s doesn't point back at previous delete link",llstr(next_link,buff2)); _ma_check_print_error(param,
"Deleted block at %s doesn't point back at previous delete link",
llstr(next_link,buff2));
goto wrong; goto wrong;
} }
old_link=next_link; old_link=next_link;
...@@ -269,23 +271,23 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, ...@@ -269,23 +271,23 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info,
if (empty != share->state.state.empty) if (empty != share->state.state.empty)
{ {
_ma_check_print_warning(param, _ma_check_print_warning(param,
"Found %s deleted space in delete link chain. Should be %s", "Found %s deleted space in delete link chain. Should be %s",
llstr(empty,buff2), llstr(empty,buff2),
llstr(share->state.state.empty,buff)); llstr(share->state.state.empty,buff));
} }
if (next_link != HA_OFFSET_ERROR) if (next_link != HA_OFFSET_ERROR)
{ {
_ma_check_print_error(param, _ma_check_print_error(param,
"Found more than the expected %s deleted rows in delete link chain", "Found more than the expected %s deleted rows in delete link chain",
llstr(share->state.state.del, buff)); llstr(share->state.state.del, buff));
goto wrong; goto wrong;
} }
if (i != 0) if (i != 0)
{ {
_ma_check_print_error(param, _ma_check_print_error(param,
"Found %s deleted rows in delete link chain. Should be %s", "Found %s deleted rows in delete link chain. Should be %s",
llstr(share->state.state.del - i, buff2), llstr(share->state.state.del - i, buff2),
llstr(share->state.state.del, buff)); llstr(share->state.state.del, buff));
goto wrong; goto wrong;
} }
} }
...@@ -423,8 +425,8 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info) ...@@ -423,8 +425,8 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info)
ulonglong2double(share->state.state.key_file_length) > ulonglong2double(share->state.state.key_file_length) >
ulonglong2double(share->base.margin_key_file_length)*0.9) ulonglong2double(share->base.margin_key_file_length)*0.9)
_ma_check_print_warning(param,"Keyfile is almost full, %10s of %10s used", _ma_check_print_warning(param,"Keyfile is almost full, %10s of %10s used",
llstr(share->state.state.key_file_length,buff), llstr(share->state.state.key_file_length,buff),
llstr(share->base.max_key_file_length-1,buff)); llstr(share->base.max_key_file_length-1,buff));
size= my_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0)); size= my_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0));
skr=(my_off_t) share->state.state.data_file_length; skr=(my_off_t) share->state.state.data_file_length;
...@@ -448,8 +450,8 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info) ...@@ -448,8 +450,8 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info)
else else
{ {
_ma_check_print_warning(param, _ma_check_print_warning(param,
"Size of datafile is: %-9s Should be: %s", "Size of datafile is: %-9s Should be: %s",
llstr(size,buff), llstr(skr,buff2)); llstr(size,buff), llstr(skr,buff2));
} }
} }
if (!(param->testflag & T_VERY_SILENT) && if (!(param->testflag & T_VERY_SILENT) &&
...@@ -457,8 +459,8 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info) ...@@ -457,8 +459,8 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info)
ulonglong2double(share->state.state.data_file_length) > ulonglong2double(share->state.state.data_file_length) >
(ulonglong2double(share->base.max_data_file_length)*0.9)) (ulonglong2double(share->base.max_data_file_length)*0.9))
_ma_check_print_warning(param, "Datafile is almost full, %10s of %10s used", _ma_check_print_warning(param, "Datafile is almost full, %10s of %10s used",
llstr(share->state.state.data_file_length,buff), llstr(share->state.state.data_file_length,buff),
llstr(share->base.max_data_file_length-1,buff2)); llstr(share->base.max_data_file_length-1,buff2));
DBUG_RETURN(error); DBUG_RETURN(error);
} /* maria_chk_size */ } /* maria_chk_size */
......
...@@ -938,7 +938,13 @@ static void get_options(register int *argc,register char ***argv) ...@@ -938,7 +938,13 @@ static void get_options(register int *argc,register char ***argv)
} /* get options */ } /* get options */
/* Check table */ /**
Check/repair table
@return 0 table is ok
@return 1 Got warning during check
@return 2 Got error during check/repair.
*/
static int maria_chk(HA_CHECK *param, char *filename) static int maria_chk(HA_CHECK *param, char *filename)
{ {
...@@ -1404,6 +1410,7 @@ static int maria_chk(HA_CHECK *param, char *filename) ...@@ -1404,6 +1410,7 @@ static int maria_chk(HA_CHECK *param, char *filename)
if (param->error_printed) if (param->error_printed)
{ {
error= 2;
if (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX)) if (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX))
{ {
VOID(fprintf(stderr, VOID(fprintf(stderr,
...@@ -1422,8 +1429,12 @@ static int maria_chk(HA_CHECK *param, char *filename) ...@@ -1422,8 +1429,12 @@ static int maria_chk(HA_CHECK *param, char *filename)
else if (param->warning_printed && else if (param->warning_printed &&
! (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX | ! (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX |
T_FORCE_CREATE))) T_FORCE_CREATE)))
{
if (!error)
error= 1;
VOID(fprintf(stderr, "Aria table '%s' is usable but should be fixed\n", VOID(fprintf(stderr, "Aria table '%s' is usable but should be fixed\n",
filename)); filename));
}
VOID(fflush(stderr)); VOID(fflush(stderr));
DBUG_RETURN(error); DBUG_RETURN(error);
} /* maria_chk */ } /* maria_chk */
...@@ -1754,14 +1765,14 @@ static int maria_sort_records(HA_CHECK *param, ...@@ -1754,14 +1765,14 @@ static int maria_sort_records(HA_CHECK *param,
{ {
_ma_check_print_warning(param, _ma_check_print_warning(param,
"Can't sort table '%s' on key %d; No such key", "Can't sort table '%s' on key %d; No such key",
name,sort_key+1); name,sort_key+1);
param->error_printed=0; param->error_printed=0;
DBUG_RETURN(0); /* Nothing to do */ DBUG_RETURN(0); /* Nothing to do */
} }
if (keyinfo->flag & HA_FULLTEXT) if (keyinfo->flag & HA_FULLTEXT)
{ {
_ma_check_print_warning(param,"Can't sort table '%s' on FULLTEXT key %d", _ma_check_print_warning(param,"Can't sort table '%s' on FULLTEXT key %d",
name,sort_key+1); name,sort_key+1);
param->error_printed=0; param->error_printed=0;
DBUG_RETURN(0); /* Nothing to do */ DBUG_RETURN(0); /* Nothing to do */
} }
......
...@@ -117,6 +117,26 @@ static CONTROL_FILE_ERROR local_ma_control_file_open(void) ...@@ -117,6 +117,26 @@ static CONTROL_FILE_ERROR local_ma_control_file_open(void)
return error; return error;
} }
static char *create_tmpdir(const char *progname)
{
static char test_dirname[FN_REFLEN];
char tmp_name[FN_REFLEN];
uint length;
/* Create a temporary directory of name TMP-'executable', but without the -t extension */
fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT);
length= strlen(tmp_name);
if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't')
tmp_name[length-2]= 0;
strxmov(test_dirname, "TMP-", tmp_name, NullS);
/*
Don't give an error if we can't create dir, as it may already exist from a previously aborted
run
*/
(void) my_mkdir(test_dirname, 0777, MYF(0));
return test_dirname;
}
int main(int argc,char *argv[]) int main(int argc,char *argv[])
...@@ -124,11 +144,12 @@ int main(int argc,char *argv[]) ...@@ -124,11 +144,12 @@ int main(int argc,char *argv[])
MY_INIT(argv[0]); MY_INIT(argv[0]);
my_init(); my_init();
maria_data_root= (char *)".";
default_error_handler_hook= error_handler_hook; default_error_handler_hook= error_handler_hook;
plan(12); plan(12);
maria_data_root= create_tmpdir(argv[0]);
diag("Unit tests for control file"); diag("Unit tests for control file");
get_options(argc,argv); get_options(argc,argv);
...@@ -155,6 +176,9 @@ int main(int argc,char *argv[]) ...@@ -155,6 +176,9 @@ int main(int argc,char *argv[])
ok(0 == test_bad_blocksize(), "test of bad blocksize"); ok(0 == test_bad_blocksize(), "test of bad blocksize");
ok(0 == test_bad_size(), "test of too small/big file"); ok(0 == test_bad_size(), "test of too small/big file");
delete_file(0);
rmdir(maria_data_root);
return exit_status(); return exit_status();
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "../maria_def.h" #include "../maria_def.h"
#include <my_dir.h> #include <my_dir.h>
my_bool maria_log_remove() my_bool maria_log_remove(const char *testdir)
{ {
MY_DIR *dirp; MY_DIR *dirp;
uint i; uint i;
...@@ -59,6 +59,28 @@ my_bool maria_log_remove() ...@@ -59,6 +59,28 @@ my_bool maria_log_remove()
} }
} }
my_dirend(dirp); my_dirend(dirp);
if (testdir)
rmdir(testdir);
return 0; return 0;
} }
char *create_tmpdir(const char *progname)
{
static char test_dirname[FN_REFLEN];
char tmp_name[FN_REFLEN];
uint length;
/* Create a temporary directory of name TMP-'executable', but without the -t extension */
fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT);
length= strlen(tmp_name);
if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't')
tmp_name[length-2]= 0;
strxmov(test_dirname, "TMP-", tmp_name, NullS);
/*
Don't give an error if we can't create dir, as it may already exist from a previously aborted
run
*/
(void) my_mkdir(test_dirname, 0777, MYF(0));
return test_dirname;
}
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
static const char* default_dbug_option; static const char* default_dbug_option;
#endif #endif
static char *file1_name= (char*)"page_cache_test_file_1"; static const char *base_file1_name= "page_cache_test_file_1";
static char file1_name[FN_REFLEN];
static PAGECACHE_FILE file1; static PAGECACHE_FILE file1;
static pthread_cond_t COND_thread_count; static pthread_cond_t COND_thread_count;
static pthread_mutex_t LOCK_thread_count; static pthread_mutex_t LOCK_thread_count;
...@@ -330,6 +331,27 @@ static void *test_thread_writer(void *arg) ...@@ -330,6 +331,27 @@ static void *test_thread_writer(void *arg)
return 0; return 0;
} }
static char *create_tmpdir(const char *progname)
{
static char test_dirname[FN_REFLEN];
char tmp_name[FN_REFLEN];
uint length;
/* Create a temporary directory of name TMP-'executable', but without the -t extension */
fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT);
length= strlen(tmp_name);
if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't')
tmp_name[length-2]= 0;
strxmov(test_dirname, "TMP-", tmp_name, NullS);
/*
Don't give an error if we can't create dir, as it may already exist from a previously aborted
run
*/
(void) my_mkdir(test_dirname, 0777, MYF(0));
return test_dirname;
}
int main(int argc __attribute__((unused)), int main(int argc __attribute__((unused)),
char **argv __attribute__((unused))) char **argv __attribute__((unused)))
...@@ -337,7 +359,6 @@ int main(int argc __attribute__((unused)), ...@@ -337,7 +359,6 @@ int main(int argc __attribute__((unused)),
pthread_t tid; pthread_t tid;
pthread_attr_t thr_attr; pthread_attr_t thr_attr;
int *param, error, pagen; int *param, error, pagen;
MY_INIT(argv[0]); MY_INIT(argv[0]);
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -357,9 +378,13 @@ int main(int argc __attribute__((unused)), ...@@ -357,9 +378,13 @@ int main(int argc __attribute__((unused)),
DBUG_ENTER("main"); DBUG_ENTER("main");
DBUG_PRINT("info", ("Main thread: %s\n", my_thread_name())); DBUG_PRINT("info", ("Main thread: %s\n", my_thread_name()));
plan(number_of_writers + number_of_readers); plan(number_of_writers + number_of_readers);
SKIP_BIG_TESTS(number_of_writers + number_of_readers) SKIP_BIG_TESTS(number_of_writers + number_of_readers)
{ {
char *test_dirname= create_tmpdir(argv[0]);
fn_format(file1_name, base_file1_name, test_dirname, "", MYF(0));
if ((file1.file= my_open(file1_name, if ((file1.file= my_open(file1_name,
O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1) O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1)
{ {
...@@ -491,6 +516,7 @@ int main(int argc __attribute__((unused)), ...@@ -491,6 +516,7 @@ int main(int argc __attribute__((unused)),
DBUG_PRINT("info", ("file1 (%d) closed", file1.file)); DBUG_PRINT("info", ("file1 (%d) closed", file1.file));
DBUG_PRINT("info", ("Program end")); DBUG_PRINT("info", ("Program end"));
rmdir(test_dirname);
} /* SKIP_BIG_TESTS */ } /* SKIP_BIG_TESTS */
my_end(0); my_end(0);
......
...@@ -33,7 +33,8 @@ static const char* default_dbug_option; ...@@ -33,7 +33,8 @@ static const char* default_dbug_option;
#define SLEEP my_sleep(5) #define SLEEP my_sleep(5)
static char *file1_name= (char*)"page_cache_test_file_1"; static const char *base_file1_name= "page_cache_test_file_1";
static char file1_name[FN_REFLEN];
static PAGECACHE_FILE file1; static PAGECACHE_FILE file1;
static pthread_cond_t COND_thread_count; static pthread_cond_t COND_thread_count;
static pthread_mutex_t LOCK_thread_count; static pthread_mutex_t LOCK_thread_count;
...@@ -200,6 +201,27 @@ static void *test_thread_writer(void *arg) ...@@ -200,6 +201,27 @@ static void *test_thread_writer(void *arg)
return 0; return 0;
} }
char *create_tmpdir(const char *progname)
{
static char test_dirname[FN_REFLEN];
char tmp_name[FN_REFLEN];
uint length;
/* Create a temporary directory of name TMP-'executable', but without the -t extension */
fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT);
length= strlen(tmp_name);
if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't')
tmp_name[length-2]= 0;
strxmov(test_dirname, "TMP-", tmp_name, NullS);
/*
Don't give an error if we can't create dir, as it may already exist from a previously aborted
run
*/
(void) my_mkdir(test_dirname, 0777, MYF(0));
return test_dirname;
}
int main(int argc __attribute__((unused)), int main(int argc __attribute__((unused)),
char **argv __attribute__((unused))) char **argv __attribute__((unused)))
...@@ -230,6 +252,9 @@ int main(int argc __attribute__((unused)), ...@@ -230,6 +252,9 @@ int main(int argc __attribute__((unused)),
SKIP_BIG_TESTS(number_of_writers + number_of_readers) SKIP_BIG_TESTS(number_of_writers + number_of_readers)
{ {
char *test_dirname= create_tmpdir(argv[0]);
fn_format(file1_name, base_file1_name, test_dirname, "", MYF(0));
if ((file1.file= my_open(file1_name, if ((file1.file= my_open(file1_name,
O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1) O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1)
{ {
...@@ -355,6 +380,8 @@ int main(int argc __attribute__((unused)), ...@@ -355,6 +380,8 @@ int main(int argc __attribute__((unused)),
DBUG_PRINT("info", ("file1 (%d) closed", file1.file)); DBUG_PRINT("info", ("file1 (%d) closed", file1.file));
DBUG_PRINT("info", ("Program end")); DBUG_PRINT("info", ("Program end"));
rmdir(test_dirname);
} /* SKIP_BIG_TESTS */ } /* SKIP_BIG_TESTS */
my_end(0); my_end(0);
......
...@@ -40,7 +40,8 @@ static const char* default_dbug_option; ...@@ -40,7 +40,8 @@ static const char* default_dbug_option;
#define SLEEP my_sleep(5) #define SLEEP my_sleep(5)
static char *file1_name= (char*)"page_cache_test_file_1"; static const char *base_file1_name= "page_cache_test_file_1";
static char file1_name[FN_REFLEN];
static PAGECACHE_FILE file1; static PAGECACHE_FILE file1;
static pthread_cond_t COND_thread_count; static pthread_cond_t COND_thread_count;
static pthread_mutex_t LOCK_thread_count; static pthread_mutex_t LOCK_thread_count;
...@@ -196,6 +197,27 @@ static void *test_thread_writer(void *arg) ...@@ -196,6 +197,27 @@ static void *test_thread_writer(void *arg)
return 0; return 0;
} }
static char *create_tmpdir(const char *progname)
{
static char test_dirname[FN_REFLEN];
char tmp_name[FN_REFLEN];
uint length;
/* Create a temporary directory of name TMP-'executable', but without the -t extension */
fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT);
length= strlen(tmp_name);
if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't')
tmp_name[length-2]= 0;
strxmov(test_dirname, "TMP-", tmp_name, NullS);
/*
Don't give an error if we can't create dir, as it may already exist from a previously aborted
run
*/
(void) my_mkdir(test_dirname, 0777, MYF(0));
return test_dirname;
}
int main(int argc __attribute__((unused)), int main(int argc __attribute__((unused)),
char **argv __attribute__((unused))) char **argv __attribute__((unused)))
...@@ -226,6 +248,9 @@ int main(int argc __attribute__((unused)), ...@@ -226,6 +248,9 @@ int main(int argc __attribute__((unused)),
SKIP_BIG_TESTS(number_of_writers + number_of_readers) SKIP_BIG_TESTS(number_of_writers + number_of_readers)
{ {
char *test_dirname= create_tmpdir(argv[0]);
fn_format(file1_name, base_file1_name, test_dirname, "", MYF(0));
if ((file1.file= my_open(file1_name, if ((file1.file= my_open(file1_name,
O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1) O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1)
{ {
...@@ -350,6 +375,8 @@ int main(int argc __attribute__((unused)), ...@@ -350,6 +375,8 @@ int main(int argc __attribute__((unused)),
DBUG_PRINT("info", ("file1 (%d) closed", file1.file)); DBUG_PRINT("info", ("file1 (%d) closed", file1.file));
DBUG_PRINT("info", ("Program end")); DBUG_PRINT("info", ("Program end"));
rmdir(test_dirname);
} /* SKIP_BIG_TESTS */ } /* SKIP_BIG_TESTS */
my_end(0); my_end(0);
......
...@@ -35,8 +35,9 @@ static const char* default_dbug_option; ...@@ -35,8 +35,9 @@ static const char* default_dbug_option;
#define SKIP_BIG_TESTS(X) /* no-op */ #define SKIP_BIG_TESTS(X) /* no-op */
#endif #endif
static char *file1_name= (char*)"page_cache_test_file_1"; static const char *base_file1_name= "page_cache_test_file_1";
static char *file2_name= (char*)"page_cache_test_file_2"; static const char *base_file2_name= "page_cache_test_file_2";
static char file1_name[FN_REFLEN], file2_name[FN_REFLEN];
static PAGECACHE_FILE file1; static PAGECACHE_FILE file1;
static pthread_cond_t COND_thread_count; static pthread_cond_t COND_thread_count;
static pthread_mutex_t LOCK_thread_count; static pthread_mutex_t LOCK_thread_count;
...@@ -720,6 +721,28 @@ static void *test_thread(void *arg) ...@@ -720,6 +721,28 @@ static void *test_thread(void *arg)
} }
static char *create_tmpdir(const char *progname)
{
static char test_dirname[FN_REFLEN];
char tmp_name[FN_REFLEN];
uint length;
/* Create a temporary directory of name TMP-'executable', but without the -t extension */
fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT);
length= strlen(tmp_name);
if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't')
tmp_name[length-2]= 0;
strxmov(test_dirname, "TMP-", tmp_name, NullS);
/*
Don't give an error if we can't create dir, as it may already exist from a previously aborted
run
*/
(void) my_mkdir(test_dirname, 0777, MYF(0));
return test_dirname;
}
int main(int argc __attribute__((unused)), int main(int argc __attribute__((unused)),
char **argv __attribute__((unused))) char **argv __attribute__((unused)))
{ {
...@@ -748,6 +771,9 @@ int main(int argc __attribute__((unused)), ...@@ -748,6 +771,9 @@ int main(int argc __attribute__((unused)),
plan(18); plan(18);
SKIP_BIG_TESTS(18) SKIP_BIG_TESTS(18)
{ {
char *test_dirname= create_tmpdir(argv[0]);
fn_format(file1_name, base_file1_name, test_dirname, "", MYF(0));
fn_format(file2_name, base_file2_name, test_dirname, "", MYF(0));
if ((tmp_file= my_open(file2_name, O_CREAT | O_TRUNC | O_RDWR, if ((tmp_file= my_open(file2_name, O_CREAT | O_TRUNC | O_RDWR,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
...@@ -841,13 +867,13 @@ int main(int argc __attribute__((unused)), ...@@ -841,13 +867,13 @@ int main(int argc __attribute__((unused)),
exit(1); exit(1);
my_delete(file1_name, MYF(0)); my_delete(file1_name, MYF(0));
rmdir(test_dirname);
} /* SKIP_BIG_TESTS */ } /* SKIP_BIG_TESTS */
DBUG_PRINT("info", ("file1 (%d) closed", file1.file)); DBUG_PRINT("info", ("file1 (%d) closed", file1.file));
DBUG_PRINT("info", ("Program end")); DBUG_PRINT("info", ("Program end"));
my_end(0); my_end(0);
} }
return exit_status(); return exit_status();
} }
...@@ -28,9 +28,10 @@ my $NEW_TEST= 0; # Test group separator in an array of tests ...@@ -28,9 +28,10 @@ my $NEW_TEST= 0; # Test group separator in an array of tests
my $test_begin= 0; my $test_begin= 0;
my $test_end= 0; my $test_end= 0;
my $test_counter= 0; my $test_counter= 0;
my $using_internal_tmpdir= 0;
my $full_tmpdir; my $full_tmpdir;
my $tmpdir="tmp"; my $tmpdir="tmp";
my $exec_dir="TMP-ma_test_all"; # Run test in this directory
run_tests(); run_tests();
#### ####
...@@ -60,7 +61,14 @@ sub run_tests ...@@ -60,7 +61,14 @@ sub run_tests
print "$my_progname version $VER\n"; print "$my_progname version $VER\n";
exit(0); 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" : ""; my $suffix= ( $^O =~ /win/i && $^O !~ /darwin/i ) ? ".exe" : "";
$maria_exe_path= "$maria_path/release"; $maria_exe_path= "$maria_path/release";
...@@ -76,7 +84,7 @@ sub run_tests ...@@ -76,7 +84,7 @@ sub run_tests
$maria_exe_path= $maria_path; $maria_exe_path= $maria_path;
if ( ! -f "$maria_exe_path/ma_test1$suffix" ) 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");
} }
} }
} }
...@@ -90,7 +98,8 @@ sub run_tests ...@@ -90,7 +98,8 @@ sub run_tests
} }
else else
{ {
$full_tmpdir= "tmp"; $full_tmpdir= $tmpdir;
$using_internal_tmpdir= 1;
if (! -d "$full_tmpdir") if (! -d "$full_tmpdir")
{ {
die if (!mkdir("$full_tmpdir")); die if (!mkdir("$full_tmpdir"));
...@@ -227,6 +236,13 @@ sub run_tests ...@@ -227,6 +236,13 @@ sub run_tests
run_tests_on_clrs($suffix, $opt_verbose, 0); run_tests_on_clrs($suffix, $opt_verbose, 0);
unlink_all_possible_tmp_files(); unlink_all_possible_tmp_files();
if ($using_internal_tmpdir)
{
rmdir($tmpdir);
}
rmdir($exec_dir);
chdir("..");
rmdir($exec_dir);
exit($runtime_error); exit($runtime_error);
} }
...@@ -429,13 +445,16 @@ sub run_pack_tests() ...@@ -429,13 +445,16 @@ sub run_pack_tests()
"cp test1.MAD test2.MAD", "cp test1.MAD test2.MAD",
"cp test1.MAI test2.MAI", "cp test1.MAI test2.MAI",
"$maria_exe_path/aria_pack$suffix --force -s --join=test3 test1 test2", "$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); &run_test_bunch(\@t, $verbose, 0);
return 0; return 0;
} }
...@@ -463,7 +482,7 @@ sub run_tests_on_warnings_and_errors ...@@ -463,7 +482,7 @@ sub run_tests_on_warnings_and_errors
# maria_exe_path/aria_chk$suffix -h$tmpdir -sm $tmpdir/test2 will warn that # maria_exe_path/aria_chk$suffix -h$tmpdir -sm $tmpdir/test2 will warn that
# Datafile is almost full # Datafile is almost full
ok("$maria_exe_path/aria_chk$suffix -h$tmpdir -sm $tmpdir/test2 >ma_test2_message.txt 2>&1", ok("$maria_exe_path/aria_chk$suffix -h$tmpdir -sm $tmpdir/test2 >ma_test2_message.txt 2>&1",
$verbose, 0); $verbose, 0, 1);
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);
...@@ -550,7 +569,7 @@ sub run_tests_on_clrs ...@@ -550,7 +569,7 @@ 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, $len); my ($msg, $output, $err, $errcode, $len);
$test_counter++; $test_counter++;
if ($test_begin > $test_counter) if ($test_begin > $test_counter)
...@@ -580,8 +599,9 @@ sub ok ...@@ -580,8 +599,9 @@ sub ok
print " " x (62 - $len); print " " x (62 - $len);
} }
$err= $?; $err= $?;
$errcode= ($? >> 8);
if ((!$err && !$expected_error) || if ((!$err && !$expected_error) ||
(($err >> 8) == $expected_error && $expected_error)) ($errcode == $expected_error && $expected_error))
{ {
print "[ " if ($verbose); print "[ " if ($verbose);
print "ok"; print "ok";
...@@ -618,7 +638,7 @@ sub ok ...@@ -618,7 +638,7 @@ sub ok
} }
$msg.= "at line "; $msg.= "at line ";
$msg.= (caller)[2]; $msg.= (caller)[2];
$msg.= "\n(errcode: $err, test: $test_counter)\n"; $msg.= "\n(errcode: $errcode, test: $test_counter)\n";
if ($expected_error) if ($expected_error)
{ {
$msg.= "Was expecting errcode: $expected_error\n"; $msg.= "Was expecting errcode: $expected_error\n";
...@@ -681,7 +701,7 @@ sub unlink_all_possible_tmp_files() ...@@ -681,7 +701,7 @@ sub unlink_all_possible_tmp_files()
unlink_log_files(); unlink_log_files();
# Unlink tmp files that may have been created when testing the test programs # Unlink tmp files that may have been created when testing the test programs
unlink <$full_tmpdir/*.TMD aria_log_control aria_log.00000001 aria_log.00000002 aria_logtest1.MA? test2.MA? test3.MA?>; 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?>;
} }
#### ####
...@@ -733,6 +753,7 @@ Options ...@@ -733,6 +753,7 @@ Options
might depend on previous ones. might depend on previous ones.
--start-from=... Alias for --run-tests --start-from=... Alias for --run-tests
--silent=... Silent option passed to ma_test* tests ('$opt_silent') --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. --valgrind=... Options for valgrind.
('$opt_valgrind') ('$opt_valgrind')
--verbose Be more verbose. Will print each unittest on a line --verbose Be more verbose. Will print each unittest on a line
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
#include <tap.h> #include <tap.h>
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove(const char *testdir);
extern char *create_tmpdir(const char *progname);
extern void example_loghandler_init(); extern void example_loghandler_init();
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -161,7 +162,6 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -161,7 +162,6 @@ int main(int argc __attribute__((unused)), char *argv[])
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 3]; LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 3];
struct st_translog_scanner_data scanner; struct st_translog_scanner_data scanner;
int rc; int rc;
MY_INIT(argv[0]); MY_INIT(argv[0]);
if (my_set_max_open_files(100) < 100) if (my_set_max_open_files(100) < 100)
...@@ -170,9 +170,11 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -170,9 +170,11 @@ int main(int argc __attribute__((unused)), char *argv[])
exit(1); exit(1);
} }
bzero(&pagecache, sizeof(pagecache)); bzero(&pagecache, sizeof(pagecache));
maria_data_root= (char *)".";
if (maria_log_remove()) maria_data_root= create_tmpdir(argv[0]);
if (maria_log_remove(0))
exit(1); exit(1);
/* We don't need to do physical syncs in this test */ /* We don't need to do physical syncs in this test */
my_disable_sync= 1; my_disable_sync= 1;
...@@ -207,7 +209,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -207,7 +209,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1); exit(1);
} }
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init, LOG_FLAGS, 0, &translog_example_table_init,
0)) 0))
{ {
...@@ -656,7 +658,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -656,7 +658,7 @@ int main(int argc __attribute__((unused)), char *argv[])
end_pagecache(&pagecache, 1); end_pagecache(&pagecache, 1);
ma_control_file_end(); ma_control_file_end();
if (maria_log_remove()) if (maria_log_remove(maria_data_root))
exit(1); exit(1);
return(test(exit_status())); return(test(exit_status()));
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
#include <tap.h> #include <tap.h>
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove(const char *testdir);
extern char *create_tmpdir(const char *progname);
extern void translog_example_table_init(); extern void translog_example_table_init();
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -31,7 +32,6 @@ static const char *default_dbug_option; ...@@ -31,7 +32,6 @@ static const char *default_dbug_option;
#define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512) #define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512)
#define LOG_FLAGS 0 #define LOG_FLAGS 0
static char *first_translog_file= (char*)"maria_log.00000001";
int main(int argc __attribute__((unused)), char *argv[]) int main(int argc __attribute__((unused)), char *argv[])
{ {
...@@ -40,18 +40,18 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -40,18 +40,18 @@ int main(int argc __attribute__((unused)), char *argv[])
PAGECACHE pagecache; PAGECACHE pagecache;
LSN lsn, first_lsn, theor_lsn; LSN lsn, first_lsn, theor_lsn;
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1];
MY_INIT(argv[0]); MY_INIT(argv[0]);
plan(2); plan(2);
bzero(&pagecache, sizeof(pagecache)); bzero(&pagecache, sizeof(pagecache));
maria_data_root= (char *)"."; /*
if (maria_log_remove()) Don't give an error if we can't create dir, as it may already exist from a previously aborted
run
*/
maria_data_root= create_tmpdir(argv[0]);
if (maria_log_remove(0))
exit(1); exit(1);
/* be sure that we have no logs in the directory*/
my_delete(CONTROL_FILE_BASE_NAME, MYF(0));
my_delete(first_translog_file, MYF(0));
bzero(long_tr_id, 6); bzero(long_tr_id, 6);
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -78,9 +78,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -78,9 +78,8 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1); exit(1);
} }
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init, LOG_FLAGS, 0, &translog_example_table_init, 0))
0))
{ {
fprintf(stderr, "Can't init loghandler (%d)\n", errno); fprintf(stderr, "Can't init loghandler (%d)\n", errno);
exit(1); exit(1);
...@@ -154,7 +153,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -154,7 +153,7 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_destroy(); translog_destroy();
end_pagecache(&pagecache, 1); end_pagecache(&pagecache, 1);
ma_control_file_end(); ma_control_file_end();
if (maria_log_remove()) if (maria_log_remove(maria_data_root))
exit(1); exit(1);
exit(0); exit(0);
} }
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
#include <tap.h> #include <tap.h>
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove(const char *testdir);
extern char *create_tmpdir(const char *progname);
extern void translog_example_table_init(); extern void translog_example_table_init();
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -40,14 +41,14 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -40,14 +41,14 @@ int main(int argc __attribute__((unused)), char *argv[])
PAGECACHE pagecache; PAGECACHE pagecache;
LSN lsn, max_lsn, last_lsn= LSN_IMPOSSIBLE; LSN lsn, max_lsn, last_lsn= LSN_IMPOSSIBLE;
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1];
MY_INIT(argv[0]); MY_INIT(argv[0]);
plan(2); plan(2);
bzero(&pagecache, sizeof(pagecache)); bzero(&pagecache, sizeof(pagecache));
maria_data_root= (char *)".";
if (maria_log_remove()) maria_data_root= create_tmpdir(argv[0]);
if (maria_log_remove(0))
exit(1); exit(1);
bzero(long_tr_id, 6); bzero(long_tr_id, 6);
...@@ -75,7 +76,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -75,7 +76,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1); exit(1);
} }
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init, LOG_FLAGS, 0, &translog_example_table_init,
0)) 0))
{ {
...@@ -150,7 +151,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -150,7 +151,7 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_destroy(); translog_destroy();
end_pagecache(&pagecache, 1); end_pagecache(&pagecache, 1);
ma_control_file_end(); ma_control_file_end();
if (maria_log_remove()) if (maria_log_remove(maria_data_root))
exit(1); exit(1);
exit(0); exit(0);
} }
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
#include "sequence_storage.h" #include "sequence_storage.h"
#include <my_getopt.h> #include <my_getopt.h>
extern my_bool maria_log_remove(); extern my_bool maria_log_remove(const char *testdir);
extern char *create_tmpdir(const char *progname);
extern void translog_example_table_init(); extern void translog_example_table_init();
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -238,21 +239,23 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -238,21 +239,23 @@ int main(int argc __attribute__((unused)), char *argv[])
TRANSLOG_HEADER_BUFFER rec; TRANSLOG_HEADER_BUFFER rec;
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 2]; LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 2];
struct st_translog_scanner_data scanner; struct st_translog_scanner_data scanner;
const char *progname=argv[0];
int rc; int rc;
MY_INIT(argv[0]); MY_INIT(argv[0]);
bzero(&pagecache, sizeof(pagecache));
maria_data_root= (char *)".";
load_defaults("my", load_default_groups, &argc, &argv); load_defaults("my", load_default_groups, &argc, &argv);
default_argv= argv;
get_options(&argc, &argv); get_options(&argc, &argv);
/* We don't need to do physical syncs in this test */ default_argv= argv;
my_disable_sync= 1;
if (maria_log_remove()) bzero(&pagecache, sizeof(pagecache));
maria_data_root= create_tmpdir(progname);
if (maria_log_remove(0))
exit(1); exit(1);
/* We don't need to do physical syncs in this test */
my_disable_sync= 1;
{ {
uchar buff[4]; uchar buff[4];
for (i= 0; i < (LONG_BUFFER_SIZE + LSN_STORE_SIZE * 2 + 2); i++) for (i= 0; i < (LONG_BUFFER_SIZE + LSN_STORE_SIZE * 2 + 2); i++)
...@@ -276,7 +279,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -276,7 +279,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1); exit(1);
} }
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
0, 0, &translog_example_table_init, 0)) 0, 0, &translog_example_table_init, 0))
{ {
fprintf(stderr, "Can't init loghandler (%d)\n", errno); fprintf(stderr, "Can't init loghandler (%d)\n", errno);
...@@ -439,7 +442,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -439,7 +442,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "pass2: Got error: init_pagecache() (errno: %d)\n", errno); fprintf(stderr, "pass2: Got error: init_pagecache() (errno: %d)\n", errno);
exit(1); exit(1);
} }
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
0, READONLY, &translog_example_table_init, 0)) 0, READONLY, &translog_example_table_init, 0))
{ {
fprintf(stderr, "pass2: Can't init loghandler (%d)\n", errno); fprintf(stderr, "pass2: Can't init loghandler (%d)\n", errno);
...@@ -741,7 +744,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -741,7 +744,7 @@ int main(int argc __attribute__((unused)), char *argv[])
ma_control_file_end(); ma_control_file_end();
free_defaults(default_argv); free_defaults(default_argv);
seq_storage_destroy(&seq); seq_storage_destroy(&seq);
if (maria_log_remove()) if (maria_log_remove(maria_data_root))
exit(1); exit(1);
return (test(exit_status())); return (test(exit_status()));
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
#include <tap.h> #include <tap.h>
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove(const char *testdir);
extern void translog_example_table_init(); extern char *create_tmpdir(const char *progname);
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
...@@ -268,6 +268,7 @@ int main(int argc __attribute__((unused)), ...@@ -268,6 +268,7 @@ int main(int argc __attribute__((unused)),
pthread_attr_t thr_attr; pthread_attr_t thr_attr;
int *param, error; int *param, error;
int rc; int rc;
MY_INIT(argv[0]);
plan(WRITERS + FLUSHERS + plan(WRITERS + FLUSHERS +
ITERATIONS * WRITERS * 3 + FLUSH_ITERATIONS * FLUSHERS ); ITERATIONS * WRITERS * 3 + FLUSH_ITERATIONS * FLUSHERS );
...@@ -275,7 +276,10 @@ int main(int argc __attribute__((unused)), ...@@ -275,7 +276,10 @@ int main(int argc __attribute__((unused)),
my_disable_sync= 1; my_disable_sync= 1;
bzero(&pagecache, sizeof(pagecache)); bzero(&pagecache, sizeof(pagecache));
maria_data_root= (char *)"."; maria_data_root= create_tmpdir(argv[0]);
if (maria_log_remove(0))
exit(1);
long_buffer= malloc(LONG_BUFFER_SIZE + 7 * 2 + 2); long_buffer= malloc(LONG_BUFFER_SIZE + 7 * 2 + 2);
if (long_buffer == 0) if (long_buffer == 0)
{ {
...@@ -285,11 +289,6 @@ int main(int argc __attribute__((unused)), ...@@ -285,11 +289,6 @@ int main(int argc __attribute__((unused)),
for (i= 0; i < (LONG_BUFFER_SIZE + 7 * 2 + 2); i++) for (i= 0; i < (LONG_BUFFER_SIZE + 7 * 2 + 2); i++)
long_buffer[i]= (i & 0xFF); long_buffer[i]= (i & 0xFF);
MY_INIT(argv[0]);
if (maria_log_remove())
exit(1);
#ifndef DBUG_OFF #ifndef DBUG_OFF
#if defined(__WIN__) #if defined(__WIN__)
default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace"; default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace";
...@@ -347,7 +346,7 @@ int main(int argc __attribute__((unused)), ...@@ -347,7 +346,7 @@ int main(int argc __attribute__((unused)),
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1); exit(1);
} }
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init, LOG_FLAGS, 0, &translog_example_table_init,
0)) 0))
{ {
...@@ -546,7 +545,7 @@ int main(int argc __attribute__((unused)), ...@@ -546,7 +545,7 @@ int main(int argc __attribute__((unused)),
translog_destroy(); translog_destroy();
end_pagecache(&pagecache, 1); end_pagecache(&pagecache, 1);
ma_control_file_end(); ma_control_file_end();
if (maria_log_remove()) if (maria_log_remove(maria_data_root))
exit(1); exit(1);
return(exit_status()); return(exit_status());
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
#include <tap.h> #include <tap.h>
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove(const char *testdir);
extern char *create_tmpdir(const char *progname);
extern void translog_example_table_init(); extern void translog_example_table_init();
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -31,8 +32,6 @@ static const char *default_dbug_option; ...@@ -31,8 +32,6 @@ static const char *default_dbug_option;
#define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512) #define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512)
#define LOG_FLAGS 0 #define LOG_FLAGS 0
static char *first_translog_file= (char*)"maria_log.00000001";
int main(int argc __attribute__((unused)), char *argv[]) int main(int argc __attribute__((unused)), char *argv[])
{ {
uint pagen; uint pagen;
...@@ -49,12 +48,9 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -49,12 +48,9 @@ int main(int argc __attribute__((unused)), char *argv[])
plan(1); plan(1);
bzero(&pagecache, sizeof(pagecache)); bzero(&pagecache, sizeof(pagecache));
maria_data_root= (char *)"."; maria_data_root= create_tmpdir(argv[0]);
if (maria_log_remove()) if (maria_log_remove(0))
exit(1); exit(1);
/* be sure that we have no logs in the directory*/
my_delete(CONTROL_FILE_BASE_NAME, MYF(0));
my_delete(first_translog_file, MYF(0));
bzero(long_tr_id, 6); bzero(long_tr_id, 6);
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -81,7 +77,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -81,7 +77,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1); exit(1);
} }
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init, LOG_FLAGS, 0, &translog_example_table_init,
0)) 0))
{ {
...@@ -139,7 +135,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -139,7 +135,7 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_destroy(); translog_destroy();
end_pagecache(&pagecache, 1); end_pagecache(&pagecache, 1);
ma_control_file_end(); ma_control_file_end();
if (maria_log_remove()) if (maria_log_remove(maria_data_root))
exit(1); exit(1);
exit(rc); exit(rc);
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
#include <tap.h> #include <tap.h>
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove(const char *testdir);
extern void example_loghandler_init(); extern char *create_tmpdir(const char *progname);
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
...@@ -49,8 +49,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -49,8 +49,8 @@ int main(int argc __attribute__((unused)), char *argv[])
bzero(&pagecache, sizeof(pagecache)); bzero(&pagecache, sizeof(pagecache));
bzero(long_buffer, LONG_BUFFER_SIZE); bzero(long_buffer, LONG_BUFFER_SIZE);
maria_data_root= (char *)"."; maria_data_root= create_tmpdir(argv[0]);
if (maria_log_remove()) if (maria_log_remove(0))
exit(1); exit(1);
bzero(long_tr_id, 6); bzero(long_tr_id, 6);
...@@ -78,7 +78,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -78,7 +78,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1); exit(1);
} }
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init, LOG_FLAGS, 0, &translog_example_table_init,
0)) 0))
{ {
...@@ -151,7 +151,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -151,7 +151,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1); exit(1);
} }
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init, LOG_FLAGS, 0, &translog_example_table_init,
1)) 1))
{ {
...@@ -189,7 +189,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -189,7 +189,7 @@ int main(int argc __attribute__((unused)), char *argv[])
ok(1, "New log is OK"); ok(1, "New log is OK");
if (maria_log_remove()) if (maria_log_remove(maria_data_root))
exit(1); exit(1);
exit(0); exit(0);
} }
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
#include <tap.h> #include <tap.h>
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove(const char *testdir);
extern void translog_example_table_init(); extern char *create_tmpdir(const char *progname);
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
...@@ -31,8 +31,10 @@ static const char *default_dbug_option; ...@@ -31,8 +31,10 @@ static const char *default_dbug_option;
#define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512) #define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512)
#define LOG_FLAGS 0 #define LOG_FLAGS 0
static char *first_translog_file= (char*)"aria_log.00000001"; static const char *base_first_translog_file= "aria_log.00000001";
static char *file1_name= (char*)"page_cache_test_file_1"; static const char *base_file1_name= "page_cache_test_file_1";
static char file1_name[FN_REFLEN], first_translog_file[FN_REFLEN];
static PAGECACHE_FILE file1; static PAGECACHE_FILE file1;
...@@ -68,18 +70,15 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -68,18 +70,15 @@ int main(int argc __attribute__((unused)), char *argv[])
LSN lsn; LSN lsn;
my_off_t file_size; my_off_t file_size;
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1];
MY_INIT(argv[0]); MY_INIT(argv[0]);
plan(1); plan(1);
bzero(&pagecache, sizeof(pagecache)); bzero(&pagecache, sizeof(pagecache));
maria_data_root= (char *)"."; maria_data_root= create_tmpdir(argv[0]);
if (maria_log_remove()) if (maria_log_remove(0))
exit(1); exit(1);
/* be sure that we have no logs in the directory*/ fn_format(first_translog_file, base_first_translog_file, maria_data_root, "", MYF(0));
my_delete(CONTROL_FILE_BASE_NAME, MYF(0));
my_delete(first_translog_file, MYF(0));
bzero(long_tr_id, 6); bzero(long_tr_id, 6);
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -106,7 +105,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -106,7 +105,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1); exit(1);
} }
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init, LOG_FLAGS, 0, &translog_example_table_init,
0)) 0))
{ {
...@@ -145,6 +144,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -145,6 +144,7 @@ int main(int argc __attribute__((unused)), char *argv[])
exit(1); exit(1);
} }
fn_format(file1_name, base_file1_name, maria_data_root, "", MYF(0));
if ((file1.file= my_open(file1_name, if ((file1.file= my_open(file1_name,
O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1) O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1)
{ {
...@@ -192,9 +192,9 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -192,9 +192,9 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_destroy(); translog_destroy();
end_pagecache(&pagecache, 1); end_pagecache(&pagecache, 1);
ma_control_file_end(); ma_control_file_end();
my_delete(CONTROL_FILE_BASE_NAME, MYF(0)); my_delete(file1_name, MYF(MY_WME));
my_delete(first_translog_file, MYF(0));
my_delete(file1_name, MYF(0));
if (maria_log_remove(maria_data_root))
exit(1);
exit(0); exit(0);
} }
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
#include <tap.h> #include <tap.h>
#include "../trnman.h" #include "../trnman.h"
extern my_bool maria_log_remove(); extern my_bool maria_log_remove(const char *testdir);
extern void translog_example_table_init(); extern char *create_tmpdir(const char *progname);
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
...@@ -49,8 +49,8 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -49,8 +49,8 @@ int main(int argc __attribute__((unused)), char *argv[])
bzero(&pagecache, sizeof(pagecache)); bzero(&pagecache, sizeof(pagecache));
bzero(long_buffer, LONG_BUFFER_SIZE); bzero(long_buffer, LONG_BUFFER_SIZE);
maria_data_root= (char *)"."; maria_data_root= create_tmpdir(argv[0]);
if (maria_log_remove()) if (maria_log_remove(0))
exit(1); exit(1);
bzero(long_tr_id, 6); bzero(long_tr_id, 6);
...@@ -78,7 +78,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -78,7 +78,7 @@ int main(int argc __attribute__((unused)), char *argv[])
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1); exit(1);
} }
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
LOG_FLAGS, 0, &translog_example_table_init, LOG_FLAGS, 0, &translog_example_table_init,
0)) 0))
{ {
...@@ -186,7 +186,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ...@@ -186,7 +186,7 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_destroy(); translog_destroy();
end_pagecache(&pagecache, 1); end_pagecache(&pagecache, 1);
ma_control_file_end(); ma_control_file_end();
if (maria_log_remove()) if (maria_log_remove(maria_data_root))
exit(1); exit(1);
exit(0); exit(0);
} }
...@@ -183,3 +183,10 @@ ctype-simple\.c : .*unary minus operator applied to unsigned type, result still ...@@ -183,3 +183,10 @@ ctype-simple\.c : .*unary minus operator applied to unsigned type, result still
regexec\.c : passing argument 3 of.*matcher.* discards qualifiers from pointer target type regexec\.c : passing argument 3 of.*matcher.* discards qualifiers from pointer target type
libmysql\.c: passing argument 2 of .*memcpy.* discards qualifiers from pointer target type : 3000-4000 libmysql\.c: passing argument 2 of .*memcpy.* discards qualifiers from pointer target type : 3000-4000
storage/xtradb/dict/dict0dict\.c : passing argument 1 of .*strcpy.* discards qualifiers from pointer target type : 2500-3500 storage/xtradb/dict/dict0dict\.c : passing argument 1 of .*strcpy.* discards qualifiers from pointer target type : 2500-3500
#
# Strange things from autoconf that is probably safe to ignore
#
configure.in : warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
configure.in : config/ac-macros/character_sets.m4.*prefer named diversions
...@@ -103,6 +103,7 @@ sub run_cmd (@) { ...@@ -103,6 +103,7 @@ sub run_cmd (@) {
# Removing the first './' from the file names # Removing the first './' from the file names
foreach (@files) { s!^\./!! } foreach (@files) { s!^\./!! }
$ENV{'HARNESS_PERL_SWITCHES'} .= ' -e "exec @ARGV"'; $ENV{'HARNESS_PERL_SWITCHES'} .= ' -e "exec @ARGV"';
$ENV{'HARNESS_OPTIONS'}="j4";
$Test::Harness::Timer = 1; $Test::Harness::Timer = 1;
runtests @files; runtests @files;
} }
......
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