Commit 1b7d7718 authored by unknown's avatar unknown

code of the "mysqltest --global-subst" hack made a bit less horrible.


client/mysqltest.c:
  making code a bit less horrible (no system()). Removing bad free().
parent 4fdaaa77
...@@ -173,6 +173,10 @@ static void init_re(void); ...@@ -173,6 +173,10 @@ static void init_re(void);
static int match_re(my_regex_t *, char *); static int match_re(my_regex_t *, char *);
static void free_re(void); 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; DYNAMIC_ARRAY q_lines;
#include "sslopt-vars.h" #include "sslopt-vars.h"
...@@ -792,7 +796,6 @@ void free_used_memory() ...@@ -792,7 +796,6 @@ void free_used_memory()
my_free(opt_pass,MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_pass,MYF(MY_ALLOW_ZERO_PTR));
free_defaults(default_argv); free_defaults(default_argv);
free_re(); free_re();
my_free(global_subst, MYF(MY_ALLOW_ZERO_PTR));
#ifdef __WIN__ #ifdef __WIN__
free_tmp_sh_file(); free_tmp_sh_file();
free_win_path_patterns(); free_win_path_patterns();
...@@ -1084,16 +1087,12 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) ...@@ -1084,16 +1087,12 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
void check_result(DYNAMIC_STRING* ds) void check_result(DYNAMIC_STRING* ds)
{ {
int res;
DBUG_ENTER("check_result"); DBUG_ENTER("check_result");
DBUG_ASSERT(result_file_name); DBUG_ASSERT(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)
case RESULT_OK:
break; /* ok */
case RESULT_LENGTH_MISMATCH:
dump_result_to_reject_file(ds->str, ds->length);
if (global_subst)
{ {
/** /**
@todo MARIA_HACK @todo MARIA_HACK
...@@ -1104,29 +1103,24 @@ void check_result(DYNAMIC_STRING* ds) ...@@ -1104,29 +1103,24 @@ void check_result(DYNAMIC_STRING* ds)
test may be reported as passing. test may be reported as passing.
--global-subst is only a quick way to run a lot of existing tests --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 with Maria and find bugs; it is not good enough for reaching the main
trees when Maria is merged into them. It relies on hard-coded path of trees when Maria is merged into them.
"replace", on existence of "cmp". It's just horrible but it works for
devs using a bk tree in a GNU-based system, which is what we have in
the team.
--global-subst should be removed. --global-subst should be removed.
*/ */
char reject_file[FN_REFLEN]; uint global_subst_from_len= strlen(global_subst_from);
char sys_com[50 + FN_REFLEN]; uint global_subst_to_len= strlen(global_subst_to);
fn_format(reject_file, result_file_name, "", ".reject", while (replace(ds,
MY_REPLACE_EXT); global_subst_from, global_subst_from_len,
sprintf(sys_com, "../extra/replace %s %s -- %s >/dev/null", global_subst_to, global_subst_to_len) == 0)
global_subst_from, global_subst_to, reject_file); /* do nothing */ ;
if (system(sys_com)) /* let's compare again to see if it is ok now */
die("replace failed"); res= dyn_string_cmp(ds, result_file_name);
sprintf(sys_com, "cmp %s %s >/dev/null",
reject_file, result_file_name);
if (!system(sys_com))
{
/* test is ok in fact */
my_delete(reject_file, MYF(0));
break;
}
} }
switch(res)
{
case RESULT_OK:
break; /* ok */
case RESULT_LENGTH_MISMATCH:
dump_result_to_reject_file(ds->str, ds->length);
die("Result length mismatch"); die("Result length mismatch");
break; break;
case RESULT_CONTENT_MISMATCH: case RESULT_CONTENT_MISMATCH:
......
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