From ff391e9fe189c8cc6a497cd1391d0a5b983747e7 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 2 Mar 2006 11:08:43 +0100 Subject: [PATCH 1/5] Fix unsigned warning on windows --- client/mysqltest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 0558df7a568..1a9f6f0d34f 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -3134,7 +3134,7 @@ static void init_win_path_patterns() static void free_win_path_patterns() { - int i= 0; + uint i= 0; for (i=0 ; i < patterns.elements ; i++) { const char** pattern= dynamic_element(&patterns, i, const char**); From e4b6f64a16240994c58a15eab12007d9650d2612 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 2 Mar 2006 11:10:29 +0100 Subject: [PATCH 2/5] Make do_block return void, return value never used. --- client/mysqltest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 1a9f6f0d34f..5dd2f5dc65e 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -2404,7 +2404,7 @@ int do_done(struct st_query *q) */ -int do_block(enum block_cmd cmd, struct st_query* q) +void do_block(enum block_cmd cmd, struct st_query* q) { char *p= q->first_argument; const char *expr_start, *expr_end; @@ -2428,7 +2428,7 @@ int do_block(enum block_cmd cmd, struct st_query* q) cur_block++; cur_block->cmd= cmd; cur_block->ok= FALSE; - return 0; + DBUG_VOID_RETURN; } /* Parse and evaluate test expression */ From 52d51e5e262a1c2ae148d03d91db9dd6a1ac089c Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 2 Mar 2006 16:28:45 +0100 Subject: [PATCH 3/5] Make the "system" command become executed in a bash shell in cygwin. --- client/mysqltest.c | 13 ++++++++++++- mysql-test/t/mysqldump.test | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 5dd2f5dc65e..a039d970b18 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1367,7 +1367,9 @@ int do_modify_var(struct st_query *query, const char *name, NOTE If mysqltest is executed from cygwin shell, the command will be - executed in cygwin shell. Thus commands like "rm" etc can be used. + executed in the "windows command interpreter" cmd.exe and we prepend "sh" + to make it be executed by cygwins "bash". Thus commands like "rm", + "mkdir" as well as shellscripts can executed by "system" in Windows. */ int do_system(struct st_query *command) @@ -1379,9 +1381,18 @@ int do_system(struct st_query *command) init_dynamic_string(&ds_cmd, 0, strlen(command->first_argument) + 64, 256); +#ifdef __WIN__ + /* Execute the command in "bash", ie. sh -c "" */ + dynstr_append(&ds_cmd, "sh -c \""); +#endif + /* Eval the system command, thus replacing all environment variables */ do_eval(&ds_cmd, command->first_argument, TRUE); +#ifdef __WIN__ + dynstr_append(&ds_cmd, "\""); +#endif + DBUG_PRINT("info", ("running system command '%s' as '%s'", command->first_argument, ds_cmd.str)); if (system(ds_cmd.str)) diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 9008eff6642..b5e05579023 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -830,8 +830,8 @@ DROP TABLE t1, t2; # Bugs #9136, #12917: problems with --defaults-extra-file option # ---system echo "[mysqltest1]" > $MYSQLTEST_VARDIR/tmp/tmp.cnf ---system echo "port=1234" >> $MYSQLTEST_VARDIR/tmp/tmp.cnf +--system echo '[mysqltest1]' > $MYSQLTEST_VARDIR/tmp/tmp.cnf +--system echo 'port=1234' >> $MYSQLTEST_VARDIR/tmp/tmp.cnf --exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 --exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 mysqltest1 --system rm $MYSQLTEST_VARDIR/tmp/tmp.cnf From f601d2696142787fc30982354a47aa62429998c5 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 2 Mar 2006 17:33:34 +0100 Subject: [PATCH 4/5] Remove superfluous DBUG_PRINT --- client/mysqltest.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index a039d970b18..12bcda267be 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1120,8 +1120,6 @@ static void do_exec(struct st_query *query) ("error: %d, status: %d", error, status)); for (i= 0; i < query->expected_errors; i++) { - DBUG_PRINT("info", - ("error: %d, status: %d", error, status)); DBUG_PRINT("info", ("expected error: %d", query->expected_errno[i].code.errnum)); if ((query->expected_errno[i].type == ERR_ERRNO) && From 21cc7c9555ba37c058e1d9de42e86dff8cbd5848 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 3 Mar 2006 14:55:05 +0100 Subject: [PATCH 5/5] Windows fixes - Use pipes "|" - Improved system command, create a temporary .sh faile that is executed with cygwins sh(bash) This makes the Windows version behave exactly as the Lunix version(well almost...) - Give unix path to DBUG, trace files is no produced if running ./mysql-test-run.pl --debug" --- client/mysqltest.c | 54 +++++++++++++++++++++++------------- mysql-test/lib/mtr_misc.pl | 11 +++++++- mysql-test/mysql-test-run.pl | 3 ++ 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 12bcda267be..3db51336553 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1351,6 +1351,35 @@ int do_modify_var(struct st_query *query, const char *name, } +/* + Wrapper for 'system' function + + NOTE + If mysqltest is executed from cygwin shell, the command will be + executed in the "windows command interpreter" cmd.exe and we prepend "sh" + to make it be executed by cygwins "bash". Thus commands like "rm", + "mkdir" as well as shellscripts can executed by "system" in Windows. + +*/ + +int my_system(DYNAMIC_STRING* ds_cmd) +{ +#ifdef __WIN__ + /* Dump the command into a sh script file and execute with "sh" */ + int err; + char tmp_sh_name[64], tmp_sh_cmd[70]; + my_snprintf(tmp_sh_name, sizeof(tmp_sh_name), "tmp_%d.sh", getpid()); + my_snprintf(tmp_sh_cmd, sizeof(tmp_sh_cmd), "sh %s", tmp_sh_name); + str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length); + err= system(tmp_sh_cmd); + my_delete(tmp_sh_name, MYF(0)); + return err; +#else + return system(ds_cmd->str); +#endif +} + + /* SYNOPSIS @@ -1363,37 +1392,24 @@ int do_modify_var(struct st_query *query, const char *name, Eval the query to expand any $variables in the command. Execute the command with the "system" command. - NOTE - If mysqltest is executed from cygwin shell, the command will be - executed in the "windows command interpreter" cmd.exe and we prepend "sh" - to make it be executed by cygwins "bash". Thus commands like "rm", - "mkdir" as well as shellscripts can executed by "system" in Windows. - */ +*/ -int do_system(struct st_query *command) +void do_system(struct st_query *command) { DYNAMIC_STRING ds_cmd; + DBUG_ENTER("do_system"); if (strlen(command->first_argument) == 0) die("Missing arguments to system, nothing to do!"); init_dynamic_string(&ds_cmd, 0, strlen(command->first_argument) + 64, 256); -#ifdef __WIN__ - /* Execute the command in "bash", ie. sh -c "" */ - dynstr_append(&ds_cmd, "sh -c \""); -#endif - /* Eval the system command, thus replacing all environment variables */ do_eval(&ds_cmd, command->first_argument, TRUE); -#ifdef __WIN__ - dynstr_append(&ds_cmd, "\""); -#endif - DBUG_PRINT("info", ("running system command '%s' as '%s'", command->first_argument, ds_cmd.str)); - if (system(ds_cmd.str)) + if (my_system(&ds_cmd)) { if (command->abort_on_error) die("system command '%s' failed", command->first_argument); @@ -1405,7 +1421,7 @@ int do_system(struct st_query *command) } command->last_argument= command->end; - return 0; + DBUG_VOID_RETURN; } @@ -1656,7 +1672,7 @@ int do_sleep(struct st_query *query, my_bool real_sleep) char *p= query->first_argument; char *sleep_start, *sleep_end= query->end; double sleep_val; - char *cmd = (real_sleep ? "real_sleep" : "sleep"); + const char *cmd = (real_sleep ? "real_sleep" : "sleep"); while (my_isspace(charset_info, *p)) p++; diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl index a76f1b2d7b1..1f7ebdde457 100644 --- a/mysql-test/lib/mtr_misc.pl +++ b/mysql-test/lib/mtr_misc.pl @@ -96,7 +96,16 @@ sub mtr_exe_exists (@) { map {$_.= ".exe"} @path if $::glob_win32; foreach my $path ( @path ) { - return $path if -x $path; + if ( -x $path ) + { + if ( $::glob_cygwin_perl ) + { + $path= `cygpath -w $path`; + # Chop off the \n that cygpath adds + $path=~ s/\n//; + } + return $path; + } } if ( @path == 1 ) { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 905a2b2af37..ce2dfc8f67e 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -668,6 +668,9 @@ sub command_line_setup () { $opt_vardir= "$glob_mysql_test_dir/var"; } $opt_vardir_trace= $opt_vardir; + # Chop off any "c:", DBUG likes a unix path ex: c:/src/... => /src/... + $opt_vardir_trace=~ s/^\w://; + # We make the path absolute, as the server will do a chdir() before usage unless ( $opt_vardir =~ m,^/, or ($glob_win32 and $opt_vardir =~ m,^[a-z]:/,i) )