summaryrefslogtreecommitdiff
path: root/client/mysqltest.c
diff options
context:
space:
mode:
authorunknown <serg@janus.mylan>2007-12-27 18:16:02 +0100
committerunknown <serg@janus.mylan>2007-12-27 18:16:02 +0100
commit7fdbc4230e68171e17e0dd4f6ae2d3fe3acb7549 (patch)
treeb06c9309a63829e580019be688f7e51e47604caa /client/mysqltest.c
parentc1350b873165429f06b061565b91a0d423e39bdb (diff)
parent3fa2803a7737cd01aea6babd1c601649cab7968c (diff)
downloadmariadb-git-7fdbc4230e68171e17e0dd4f6ae2d3fe3acb7549.tar.gz
Merge janus.mylan:/usr/home/serg/Abk/mysql-5.1
into janus.mylan:/usr/home/serg/Abk/mysql-maria Makefile.am: Auto merged configure.in: Auto merged BitKeeper/triggers/post-commit: Auto merged client/mysqldump.c: Auto merged client/mysqltest.c: Auto merged include/my_dbug.h: Auto merged include/mysql_com.h: Auto merged libmysql/CMakeLists.txt: Auto merged libmysqld/Makefile.am: Auto merged mysql-test/lib/mtr_report.pl: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/t/disabled.def: Auto merged mysql-test/t/variables.test: Auto merged server-tools/instance-manager/CMakeLists.txt: Auto merged server-tools/instance-manager/mysql_connection.cc: Auto merged sql/Makefile.am: Auto merged sql/filesort.cc: Auto merged sql/gen_lex_hash.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/ha_partition.cc: Auto merged sql/item_func.cc: Auto merged sql/item_strfunc.cc: Auto merged sql/lex.h: Auto merged sql/lock.cc: Auto merged sql/log.cc: Auto merged sql/net_serv.cc: Auto merged sql/opt_range.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_table.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged sql/table.h: Auto merged storage/myisam/ha_myisam.cc: Auto merged storage/myisam/mi_open.c: Auto merged storage/myisammrg/ha_myisammrg.cc: Auto merged sql/handler.cc: merged sql/handler.h: merged sql/mysql_priv.h: merged sql/mysqld.cc: merged sql/set_var.cc: merged sql/sql_select.cc: merged sql/sql_show.cc: merged unittest/mysys/my_atomic-t.c: merged
Diffstat (limited to 'client/mysqltest.c')
-rw-r--r--client/mysqltest.c59
1 files changed, 54 insertions, 5 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index e0662fc2251..dbf6c999478 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -63,7 +63,8 @@
enum {
OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
- OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES
+ OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES,
+ OPT_GLOBAL_SUBST
};
static int record= 0, opt_sleep= -1;
@@ -104,6 +105,9 @@ static char delimiter[MAX_DELIMITER_LENGTH]= ";";
static uint delimiter_length= 1;
static char TMPDIR[FN_REFLEN];
+static char global_subst_from[200];
+static char global_subst_to[200];
+static char *global_subst= NULL;
/* Block stack */
enum block_cmd {
@@ -168,6 +172,10 @@ static void init_re(void);
static int match_re(my_regex_t *, char *);
static void free_re(void);
+static int replace(DYNAMIC_STRING *ds_str,
+ const char *search_str, ulong search_len,
+ const char *replace_str, ulong replace_len);
+
DYNAMIC_ARRAY q_lines;
#include "sslopt-vars.h"
@@ -1542,6 +1550,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
void check_result(DYNAMIC_STRING* ds)
{
+ int res;
const char* mess= "Result content mismatch\n";
DBUG_ENTER("check_result");
@@ -1551,7 +1560,32 @@ void check_result(DYNAMIC_STRING* ds)
if (access(result_file_name, F_OK) != 0)
die("The specified result file does not exist: '%s'", result_file_name);
- switch (dyn_string_cmp(ds, result_file_name)) {
+ res= dyn_string_cmp(ds, result_file_name);
+ if (global_subst && res != RESULT_OK)
+ {
+ /**
+ @todo MARIA_HACK
+ This serves for when a test is run with --default-storage-engine=X
+ where X is not MyISAM: tests using SHOW CREATE TABLE will always fail
+ because SHOW CREATE TABLE prints X instead of MyISAM. With
+ --global-subst=X,MyISAM , such trivial differences are eliminated and
+ test may be reported as passing.
+ --global-subst is only a quick way to run a lot of existing tests
+ with Maria and find bugs; it is not good enough for reaching the main
+ trees when Maria is merged into them.
+ --global-subst should be removed.
+ */
+ uint global_subst_from_len= strlen(global_subst_from);
+ uint global_subst_to_len= strlen(global_subst_to);
+ while (replace(ds,
+ global_subst_from, global_subst_from_len,
+ global_subst_to, global_subst_to_len) == 0)
+ /* do nothing */ ;
+ /* let's compare again to see if it is ok now */
+ res= dyn_string_cmp(ds, result_file_name);
+ }
+ switch(res)
+ {
case RESULT_OK:
break; /* ok */
case RESULT_LENGTH_MISMATCH:
@@ -1997,9 +2031,9 @@ void var_set_query_get_value(struct st_command *command, VAR *var)
static DYNAMIC_STRING ds_col;
static DYNAMIC_STRING ds_row;
const struct command_arg query_get_value_args[] = {
- "query", ARG_STRING, TRUE, &ds_query, "Query to run",
- "column name", ARG_STRING, TRUE, &ds_col, "Name of column",
- "row number", ARG_STRING, TRUE, &ds_row, "Number for row"
+ {"query", ARG_STRING, TRUE, &ds_query, "Query to run"},
+ {"column name", ARG_STRING, TRUE, &ds_col, "Name of column"},
+ {"row number", ARG_STRING, TRUE, &ds_row, "Number for row"},
};
DBUG_ENTER("var_set_query_get_value");
@@ -5006,6 +5040,11 @@ static struct my_option my_long_options[] =
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
(uchar**) &debug_info_flag, (uchar**) &debug_info_flag,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"global-subst", OPT_GLOBAL_SUBST, "argument should be 'X,Y' ;"
+ " substitute string X with another Y accross the whole test's current"
+ " result before comparing with expected result file",
+ (uchar**) &global_subst, (uchar**) &global_subst, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", (uchar**) &opt_host, (uchar**) &opt_host, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"include", 'i', "Include SQL before each test case.", (uchar**) &opt_include,
@@ -5264,6 +5303,16 @@ int parse_args(int argc, char **argv)
if (debug_check_flag)
my_end_arg= MY_CHECK_ERROR;
+ if (global_subst != NULL)
+ {
+ char *comma= strstr(global_subst, ",");
+ if (comma == NULL)
+ die("wrong --global-subst, must be X,Y");
+ memcpy(global_subst_from, global_subst, (comma-global_subst));
+ global_subst_from[comma-global_subst]= 0;
+ memcpy(global_subst_to, comma+1, strlen(comma));
+ }
+
return 0;
}