Below is the list of changes that have just been committed into a local
maria repository of bell. When bell does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-03-27 08:09:02+02:00, bell@stripped +4 -0
New procedures of random numbers generator added.
Comand line processing added to ma_test_loghandler_multigroup-t.
storage/maria/unittest/Makefile.am@stripped, 2008-03-27 08:08:56+02:00, bell@stripped +2 -2
Random generator procedures added.
storage/maria/unittest/ma_test_loghandler_multigroup-t.c@stripped, 2008-03-27 08:08:56+02:00, bell@stripped +91 -15
New procedures of random numbers generator added.
Comand line processing added.
storage/maria/unittest/rnd_generator.c@stripped, 2008-03-27 08:08:56+02:00, bell@stripped +76 -0
New BitKeeper file ``storage/maria/unittest/rnd_generator.c''
storage/maria/unittest/rnd_generator.c@stripped, 2008-03-27 08:08:56+02:00, bell@stripped +0 -0
storage/maria/unittest/rnd_generator.h@stripped, 2008-03-27 08:08:56+02:00, bell@stripped +25 -0
New BitKeeper file ``storage/maria/unittest/rnd_generator.h''
storage/maria/unittest/rnd_generator.h@stripped, 2008-03-27 08:08:56+02:00, bell@stripped +0 -0
diff -Nrup a/storage/maria/unittest/Makefile.am b/storage/maria/unittest/Makefile.am
--- a/storage/maria/unittest/Makefile.am 2008-03-04 13:58:18 +02:00
+++ b/storage/maria/unittest/Makefile.am 2008-03-27 08:08:56 +02:00
@@ -52,7 +52,7 @@ noinst_PROGRAMS = ma_control_file-t trnm
ma_test_loghandler_nologs-t
ma_test_loghandler_t_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
-ma_test_loghandler_multigroup_t_SOURCES = ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
+ma_test_loghandler_multigroup_t_SOURCES = ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c rnd_generator.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_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
@@ -61,7 +61,7 @@ ma_test_loghandler_noflush_t_SOURCES = m
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
ma_test_loghandler_purge_t_SOURCES = ma_test_loghandler_purge-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
-ma_test_loghandler_readonly_t_SOURCES = ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
+ma_test_loghandler_readonly_t_SOURCES = ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c rnd_generator.c
ma_test_loghandler_readonly_t_CPPFLAGS = -DREADONLY_TEST
ma_test_loghandler_nologs_t_SOURCES = ma_test_loghandler_nologs-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c
diff -Nrup a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c
--- a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c 2008-03-04 13:58:19 +02:00
+++ b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c 2008-03-27 08:08:56 +02:00
@@ -18,6 +18,8 @@
#include <errno.h>
#include <tap.h>
#include "../trnman.h"
+#include "rnd_generator.h"
+#include <my_getopt.h>
extern my_bool maria_log_remove();
extern void translog_example_table_init();
@@ -130,9 +132,82 @@ static my_bool read_and_check_content(TR
static uint32 get_len()
{
return (uint32)
- ((ulonglong)rand()*(LONG_BUFFER_SIZE - MIN_REC_LENGTH - 1)/RAND_MAX)+ MIN_REC_LENGTH;
+ ((ulonglong) my_test_rand() *
+ (LONG_BUFFER_SIZE - MIN_REC_LENGTH - 1) / RAND_MAX) + MIN_REC_LENGTH;
}
+static const char *load_default_groups[]= {"ma_unit_loghandler", 0};
+#if defined(__WIN__)
+static const char *default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace";
+#else
+static const char *default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler.trace";
+#endif
+static const char *opt_wfile= NULL;
+static const char *opt_rfile= NULL;
+static struct my_option my_long_options[] =
+{
+#ifndef DBUG_OFF
+ {"debug", '#', "Output debug log. Often the argument is 'd:t:o,filename'.",
+ 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+#endif
+ {"write-random", 'w', "Path to file which will be read",
+ (uchar**) &opt_wfile, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"read-random", 'r', "Path to file which will be read",
+ (uchar**) &opt_rfile, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"help", '?', "Display this help and exit.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
+};
+
+
+static void usage(void)
+{
+ puts("Copyright (C) 2008 MySQL AB");
+ puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,");
+ puts("and you are welcome to modify and redistribute it under the GPL license\n");
+
+ puts("Unit test of maria engine");
+ VOID(printf("\nUsage: %s [OPTIONS]\n", my_progname_short));
+ my_print_help(my_long_options);
+ print_defaults("my", load_default_groups);
+ my_print_variables(my_long_options);
+}
+
+
+static my_bool
+get_one_option(int optid __attribute__((unused)),
+ const struct my_option *opt __attribute__((unused)),
+ char *argument __attribute__((unused)))
+{
+ switch (optid) {
+ case '?':
+ usage();
+ exit(0);
+#ifndef DBUG_OFF
+ case '#':
+ DBUG_SET_INITIAL(argument ? argument : default_dbug_option);
+ break;
+#endif
+ }
+ return 0;
+}
+
+
+static void get_options(int *argc,char ***argv)
+{
+ int ho_error;
+
+ if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option)))
+ exit(ho_error);
+
+ if (opt_rfile && opt_wfile)
+ {
+ usage();
+ exit(1);
+ }
+}
+
+
int main(int argc __attribute__((unused)), char *argv[])
{
uint32 i;
@@ -146,6 +221,7 @@ int main(int argc __attribute__((unused)
0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55
};
uchar *long_buffer= malloc(LONG_BUFFER_SIZE + LSN_STORE_SIZE * 2 + 2);
+ char **default_argv;
PAGECACHE pagecache;
LSN lsn, lsn_base, first_lsn;
TRANSLOG_HEADER_BUFFER rec;
@@ -157,6 +233,10 @@ int main(int argc __attribute__((unused)
bzero(&pagecache, sizeof(pagecache));
maria_data_root= (char *)".";
+ load_defaults("my", load_default_groups, &argc, &argv);
+ default_argv= argv;
+ get_options(&argc, &argv);
+
if (maria_log_remove())
exit(1);
@@ -171,18 +251,6 @@ int main(int argc __attribute__((unused)
}
bzero(long_tr_id, 6);
-#ifndef DBUG_OFF
-#if defined(__WIN__)
- default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace";
-#else
- default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler.trace";
-#endif
- if (argc > 1)
- {
- DBUG_SET(default_dbug_option);
- DBUG_SET_INITIAL(default_dbug_option);
- }
-#endif
if (ma_control_file_create_or_open(TRUE))
{
@@ -206,7 +274,10 @@ int main(int argc __attribute__((unused)
plan(((ITERATIONS - 1) * 4 + 1) * 2);
- srand(122334817L);
+ my_test_rnd_init((opt_rfile ? RNDGEN_READ :
+ (opt_wfile ? RNDGEN_WRITE : RNDGEN_LOCAL)),
+ 122334817L,
+ (opt_rfile ? opt_rfile : opt_wfile));
long_tr_id[5]= 0xff;
@@ -366,7 +437,10 @@ int main(int argc __attribute__((unused)
exit(1);
}
- srand(122334817L);
+ my_test_rnd_init((opt_rfile ? RNDGEN_READ :
+ (opt_wfile ? RNDGEN_WRITE : RNDGEN_LOCAL)),
+ 122334817L,
+ (opt_rfile ? opt_rfile : opt_wfile));
rc= 1;
@@ -653,6 +727,8 @@ err:
translog_destroy();
end_pagecache(&pagecache, 1);
ma_control_file_end();
+ free_defaults(default_argv);
+ my_test_rnd_destroy();
if (maria_log_remove())
exit(1);
diff -Nrup a/storage/maria/unittest/rnd_generator.c b/storage/maria/unittest/rnd_generator.c
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/storage/maria/unittest/rnd_generator.c 2008-03-27 08:08:56 +02:00
@@ -0,0 +1,76 @@
+/* Copyright (C) 2008 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include "../maria_def.h"
+#include <my_sys.h>
+#include "rnd_generator.h"
+
+static enum enum_my_test_rand mode= RNDGEN_LOCAL;
+static FILE *rnd_sequance_file= NULL;
+
+void my_test_rnd_init(enum enum_my_test_rand new_mode,
+ unsigned seed, const char* file)
+{
+ my_test_rnd_destroy();
+ mode= new_mode;
+ switch (mode) {
+ case RNDGEN_WRITE:
+ /* we just ignore errors here */
+ rnd_sequance_file= my_fopen(file, O_CREAT | O_TRUNC | O_WRONLY,
+ MYF(MY_WME));
+ /* fall through */
+ case RNDGEN_LOCAL:
+ srand (seed);
+ break;
+ case RNDGEN_READ:
+ if ((rnd_sequance_file= my_fopen(file, O_RDONLY, MYF(MY_WME))) == 0)
+ exit(1);
+ break;
+ default:
+ DBUG_ASSERT(0);
+ }
+}
+
+ulong my_test_rand()
+{
+ DBUG_ENTER("my_test_rand");
+ ulong rnd;
+ if (mode == RNDGEN_READ)
+ {
+ char *line= NULL;
+ size_t size= 0;
+ if (getline(&line, &size, rnd_sequance_file) == -1)
+ {
+ DBUG_PRINT("error", ("Error of reading file. Errno %d", errno));
+ exit(1);
+ }
+ rnd= atol(line);
+ DBUG_PRINT("info", ("Random number read: %lu", rnd));
+ free(line);
+ DBUG_RETURN(rnd);
+ }
+ rnd= (ulong) rand();
+ if (mode == RNDGEN_WRITE)
+ fprintf(rnd_sequance_file, "%lu\n", rnd);
+ DBUG_RETURN(rnd);
+}
+
+void my_test_rnd_destroy()
+{
+ if (mode != RNDGEN_LOCAL)
+ {
+ my_fclose(rnd_sequance_file, MYF(MY_WME));
+ }
+}
diff -Nrup a/storage/maria/unittest/rnd_generator.h b/storage/maria/unittest/rnd_generator.h
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/storage/maria/unittest/rnd_generator.h 2008-03-27 08:08:56 +02:00
@@ -0,0 +1,25 @@
+/* Copyright (C) 2008 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+enum enum_my_test_rand {
+ RNDGEN_LOCAL, /* just use local pseudo random generator */
+ RNDGEN_WRITE, /* use local pseudo random generator and write values */
+ RNDGEN_READ /* use file for reading "random" values */
+};
+
+extern void my_test_rnd_init(enum enum_my_test_rand new_mode,
+ unsigned seed, const char* file);
+extern unsigned long my_test_rand();
+extern void my_test_rnd_destroy();
| Thread |
|---|
| • bk commit into maria tree (bell:1.2623) | sanja | 27 Mar |