From 8b6a8cc5615f4df62e70ff54e8a90498a8a393a5 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Sep 2005 16:39:16 +0200 Subject: [PATCH 1/6] BUG#12984 mysqltest.test: different output from "exec NonExistsinfComamdn" - Improved solution mysql-test/r/mysqltest.result: Update test results mysql-test/t/mysqltest.test: Fix test for failing "exec" and "system", by using the false command --- mysql-test/r/mysqltest.result | 2 ++ mysql-test/t/mysqltest.test | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index ae44233aab6..2277fe1b5ed 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -179,6 +179,7 @@ source database echo message echo message mysqltest: At line 1: Empty variable +mysqltest: At line 1: command "false" failed mysqltest: At line 1: Missing argument in exec MySQL "MySQL" @@ -300,6 +301,7 @@ mysqltest: At line 1: First argument to dec must be a variable (start with $) mysqltest: At line 1: End of line junk detected: "1000" mysqltest: At line 1: Missing arguments to system, nothing to do! mysqltest: At line 1: Missing arguments to system, nothing to do! +mysqltest: At line 1: system command 'false' failed test test2 test3 diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 4d3bcc037d1..fc9f621f7cd 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -426,9 +426,8 @@ echo ; # ---------------------------------------------------------------------------- # Illegal use of exec -# Disabled, some shells prints the failed command regardless of pipes -#--error 1 -#--exec echo "--exec ';' 2> /dev/null" | $MYSQL_TEST 2>&1 +--error 1 +--exec echo "--exec false" | $MYSQL_TEST 2>&1 --error 1 --exec echo "--exec " | $MYSQL_TEST 2>&1 @@ -675,9 +674,8 @@ system echo "hej" > /dev/null; --exec echo "system;" | $MYSQL_TEST 2>&1 --error 1 --exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1 -# Disabled, some shells prints the failed command regardless of pipes -#--error 1 -#--exec echo "system NonExistsinfComamdn 2> /dev/null;" | $MYSQL_TEST 2>&1 +--error 1 +--exec echo "system false;" | $MYSQL_TEST 2>&1 --disable_abort_on_error system NonExistsinfComamdn; From 56f457b67f01a87c2828920040767d302f7b79cb Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Sep 2005 12:24:59 +0200 Subject: [PATCH 2/6] Clean up printout of line numbers client/mysqltest.c: Only print line no if start_lineno > 0 Remove lineno in calls to verbose_msg and die, this is handled by the function. --- client/mysqltest.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 3e2cde92aa9..19c74629a55 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -610,7 +610,9 @@ static void verbose_msg(const char *fmt, ...) va_start(args, fmt); - fprintf(stderr, "mysqltest: At line %u: ", start_lineno); + fprintf(stderr, "mysqltest: "); + if (start_lineno > 0) + fprintf(stderr, "At line %u: ", start_lineno); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); va_end(args); @@ -1345,9 +1347,7 @@ int do_sync_with_master2(long offset) int rpl_parse; if (!master_pos.file[0]) - { - die("Line %u: Calling 'sync_with_master' without calling 'save_master_pos'", start_lineno); - } + die("Calling 'sync_with_master' without calling 'save_master_pos'"); rpl_parse= mysql_rpl_parse_enabled(mysql); mysql_disable_rpl_parse(mysql); @@ -1357,14 +1357,13 @@ int do_sync_with_master2(long offset) wait_for_position: if (mysql_query(mysql, query_buf)) - die("line %u: failed in %s: %d: %s", start_lineno, query_buf, - mysql_errno(mysql), mysql_error(mysql)); + die("failed in %s: %d: %s", query_buf, mysql_errno(mysql), + mysql_error(mysql)); if (!(last_result= res= mysql_store_result(mysql))) - die("line %u: mysql_store_result() returned NULL for '%s'", start_lineno, - query_buf); + die("mysql_store_result() returned NULL for '%s'", query_buf); if (!(row= mysql_fetch_row(res))) - die("line %u: empty result in %s", start_lineno, query_buf); + die("empty result in %s", query_buf); if (!row[0]) { /* @@ -1372,10 +1371,7 @@ wait_for_position: SLAVE has been issued ? */ if (tries++ == 3) - { - die("line %u: could not sync with master ('%s' returned NULL)", - start_lineno, query_buf); - } + die("could not sync with master ('%s' returned NULL)", query_buf); sleep(1); /* So at most we will wait 3 seconds and make 4 tries */ mysql_free_result(res); goto wait_for_position; @@ -1421,10 +1417,9 @@ int do_save_master_pos() mysql_errno(mysql), mysql_error(mysql)); if (!(last_result =res = mysql_store_result(mysql))) - die("line %u: mysql_store_result() retuned NULL for '%s'", start_lineno, - query); + die("mysql_store_result() retuned NULL for '%s'", query); if (!(row = mysql_fetch_row(res))) - die("line %u: empty result in show master status", start_lineno); + die("empty result in show master status"); strnmov(master_pos.file, row[0], sizeof(master_pos.file)-1); master_pos.pos = strtoul(row[1], (char**) 0, 10); mysql_free_result(res); last_result=0; From 6bec4bc605961b7c8066a8d8e594dc60aabd5e75 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Sep 2005 12:13:17 +0200 Subject: [PATCH 3/6] Improved output client/mysqltest.c: Don't print "At line: 0" --- client/mysqltest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 19c74629a55..1e04b41f35c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -577,7 +577,8 @@ static void die(const char *fmt, ...) if (cur_file && cur_file != file_stack) fprintf(stderr, "In included file \"%s\": ", cur_file->file_name); - fprintf(stderr, "At line %u: ", start_lineno); + if (start_lineno != 0) + fprintf(stderr, "At line %u: ", start_lineno); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); fflush(stderr); From 0aee9b2c19b52be26e9a0dc67ae178ccfa70db35 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Sep 2005 14:11:58 +0200 Subject: [PATCH 4/6] BUG#12959 mysqltest crashes if testcase passed with -x option - Enable testcases after help from Serg client/mysqltest.c: Dump output to stdout if no result file is specified Don't print verbose_msg when command fails whith expected error mysql-test/mysql-test-run.pl: Don't add all args to the MYSQL_TEST environment variable. mysql-test/r/mysqltest.result: Add test for mysqltest -x mysql-test/t/mysqltest.test: Add test for mysqltest -x --- client/mysqltest.c | 24 ++++++++++++++++-------- mysql-test/mysql-test-run.pl | 19 ++++++++++++------- mysql-test/r/mysqltest.result | 4 ++++ mysql-test/t/mysqltest.test | 10 +++++----- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 1e04b41f35c..6963ff2f99e 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1062,8 +1062,8 @@ static void do_exec(struct st_query *query) (query->expected_errno[i].code.errnum == status)) { ok= 1; - verbose_msg("command \"%s\" failed with expected error: %d", - cmd, status); + DBUG_PRINT("info", ("command \"%s\" failed with expected error: %d", + cmd, status)); } } if (!ok) @@ -2557,7 +2557,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), fn_format(buff, argument, "", "", 4); DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0); if (!(cur_file->file= - my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(MY_WME)))) + my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0)))) die("Could not open %s: errno = %d", buff, errno); cur_file->file_name= my_strdup(buff, MYF(MY_FAE)); break; @@ -2663,7 +2663,7 @@ void str_to_file(const char *fname, char *str, int size) fname=buff; } fn_format(buff,fname,"","",4); - + if ((fd = my_open(buff, O_WRONLY | O_CREAT | O_TRUNC, MYF(MY_WME | MY_FFNF))) < 0) die("Could not open %s: errno = %d", buff, errno); @@ -4043,12 +4043,20 @@ int main(int argc, char **argv) parser.current_line += current_line_inc; } - if (result_file && ds_res.length && !error) + if (ds_res.length && !error) { - if (!record) - error |= check_result(&ds_res, result_file, q->require_file); + if (result_file) + { + if (!record) + error |= check_result(&ds_res, result_file, q->require_file); + else + str_to_file(result_file, ds_res.str, ds_res.length); + } else - str_to_file(result_file, ds_res.str, ds_res.length); + { + // Print the result to stdout + printf("%s", ds_res.str); + } } dynstr_free(&ds_res); diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 013b8d49967..eed80b1e339 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2155,11 +2155,6 @@ sub run_mysqltest ($) { mtr_add_arg($args, "--big-test"); } - if ( $opt_record ) - { - mtr_add_arg($args, "--record"); - } - if ( $opt_compress ) { mtr_add_arg($args, "--compress"); @@ -2185,8 +2180,6 @@ sub run_mysqltest ($) { $glob_mysql_test_dir); } - mtr_add_arg($args, "-R"); - mtr_add_arg($args, $tinfo->{'result_file'}); # ---------------------------------------------------------------------- # If embedded server, we create server args to give mysqltest to pass on @@ -2202,6 +2195,18 @@ sub run_mysqltest ($) { # ---------------------------------------------------------------------- $ENV{'MYSQL_TEST'}= "$exe_mysqltest " . join(" ", @$args); + # ---------------------------------------------------------------------- + # Add arguments that should not go into the MYSQL_TEST env var + # ---------------------------------------------------------------------- + + mtr_add_arg($args, "-R"); + mtr_add_arg($args, $tinfo->{'result_file'}); + + if ( $opt_record ) + { + mtr_add_arg($args, "--record"); + } + return mtr_run_test($exe,$args,$tinfo->{'path'},"",$path_timefile,""); } diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 2277fe1b5ed..0e3d3812781 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -345,6 +345,10 @@ mysqltest: At line 1: Wrong column number to replace_column in 'replace_column 1 mysqltest: At line 1: Invalid integer argument "10!" mysqltest: At line 1: End of line junk detected: "!" mysqltest: At line 1: Invalid integer argument "a" +Output from mysqltest-x.inc +Output from mysqltest-x.inc +Output from mysqltest-x.inc +mysqltest: Could not open ./non_existing_file.inc: errno = 2 failing_statement; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'failing_statement' at line 1 failing_statement; diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index fc9f621f7cd..7ed204fc6d3 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -810,11 +810,11 @@ select "a" as col1, "c" as col2; # ---------------------------------------------------------------------------- # -x , use the file specified after -x as the test file -#--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1 -#--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1 -#--exec $MYSQL_TEST --result_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1 -#--error 1 -#--exec $MYSQL_TEST -x non_existing_file.inc 2>&1 +--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc +--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc +--exec $MYSQL_TEST --test_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc +--error 1 +--exec $MYSQL_TEST -x non_existing_file.inc 2>&1 # ---------------------------------------------------------------------------- From ea5d6776b0ddc753c543da378c461f1cd69b6e95 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Sep 2005 09:47:41 +0200 Subject: [PATCH 5/6] BUG#7037 MySQL Bugs: #7037: Test "mysql_protocols" fails on Solaris 8 + 9 /x86 mysys/my_init.c: Changed implementation slightly to use a local variable for keeping track of wheter we should print to the info_file even if the flag is not set in infoflag Explicitly turn off print_info if there is no DBUG_FILE --- mysys/my_init.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mysys/my_init.c b/mysys/my_init.c index bee485c3bed..c50c00c1e5c 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -127,11 +127,18 @@ my_bool my_init(void) void my_end(int infoflag) { - FILE *info_file; - if (!(info_file=DBUG_FILE)) - info_file=stderr; - DBUG_PRINT("info",("Shutting down")); - if (infoflag & MY_CHECK_ERROR || info_file != stderr) + DBUG_ENTER("my_end"); + FILE *info_file= DBUG_FILE; + bool print_info= (info_file != stderr); + if (!info_file) + { + info_file= stderr; + print_info= 0; + } + + DBUG_PRINT("info",("Shutting down: print_info: %d", print_info)); + if ((infoflag & MY_CHECK_ERROR) || print_info) + { /* Test if some file is left open */ if (my_file_opened | my_stream_opened) { @@ -141,7 +148,8 @@ void my_end(int infoflag) } } my_once_free(); - if (infoflag & MY_GIVE_INFO || info_file != stderr) + + if ((infoflag & MY_GIVE_INFO) || print_info) { #ifdef HAVE_GETRUSAGE struct rusage rus; From b9ace625400f3b5c13c23236d13f93a2f886b326 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Sep 2005 14:07:31 +0200 Subject: [PATCH 6/6] Bug #7037 Test "mysql_protocols" fails on Solaris 8 + 9 /x86 mysys/my_init.c: Updated after review --- mysys/my_init.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mysys/my_init.c b/mysys/my_init.c index c50c00c1e5c..3e5130ec670 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -127,9 +127,14 @@ my_bool my_init(void) void my_end(int infoflag) { - DBUG_ENTER("my_end"); + /* + this code is suboptimal to workaround a bug in + Sun CC: Sun C++ 5.6 2004/06/02 for x86, and should not be + optimized until this compiler is not in use anymore + */ FILE *info_file= DBUG_FILE; - bool print_info= (info_file != stderr); + my_bool print_info= (info_file != stderr); + DBUG_ENTER("my_end"); if (!info_file) { info_file= stderr;