From 0bf40b3e4c3181a0f576155baedb31696d4c6afb Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Tue, 12 Oct 2010 13:13:23 +0200 Subject: [PATCH 01/13] Bug #40406 Please make mtr print better messages when servers fail to start Added some more details to warning messages, this should be enough. --- mysql-test/lib/mtr_process.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index a42627c93cd..26a95fa13ab 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -116,18 +116,20 @@ sub sleep_until_file_created ($$$) { return 1; } + my $seconds= ($loop * $sleeptime) / 1000; + # Check if it died after the fork() was successful if ( defined $proc and ! $proc->wait_one(0) ) { - mtr_warning("Process $proc died"); + mtr_warning("Process $proc died after mysql-test-run waited $seconds " . + "seconds for $pidfile to be created."); return 0; } mtr_debug("Sleep $sleeptime milliseconds waiting for $pidfile"); # Print extra message every 60 seconds - my $seconds= ($loop * $sleeptime) / 1000; - if ( $seconds > 1 and int($seconds * 10) % 600 == 0 ) + if ( $seconds > 1 && int($seconds * 10) % 600 == 0 && $seconds < $timeout ) { my $left= $timeout - $seconds; mtr_warning("Waited $seconds seconds for $pidfile to be created, " . @@ -138,6 +140,8 @@ sub sleep_until_file_created ($$$) { } + mtr_warning("Timeout after mysql-test-run waited $timeout seconds " . + "for the process $proc to create a pid file."); return 0; } From e8fd5b58bff9bc06012c8758ce76b39ba51e6712 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 13 Oct 2010 13:07:28 +0200 Subject: [PATCH 02/13] Bug #55968 MTR does not clean up properly and chokes on its discharge Added --clean-vardir to empty vardir if no failures Also added variable $MTR_CLEAN_VARDIR --- mysql-test/mysql-test-run.pl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 494ec7a9be3..e6d988dfba6 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -195,6 +195,7 @@ sub using_extern { return (keys %opts_extern > 0);}; our $opt_fast= 0; our $opt_force; our $opt_mem= $ENV{'MTR_MEM'}; +our $opt_clean_vardir= $ENV{'MTR_CLEAN_VARDIR'}; our $opt_gcov; our $opt_gcov_exe= "gcov"; @@ -476,6 +477,8 @@ sub main { mtr_report_stats("Completed", $completed); + remove_vardir_subs() if $opt_clean_vardir; + exit(0); } @@ -946,6 +949,7 @@ sub command_line_setup { 'tmpdir=s' => \$opt_tmpdir, 'vardir=s' => \$opt_vardir, 'mem' => \$opt_mem, + 'clean-vardir' => \$opt_clean_vardir, 'client-bindir=s' => \$path_client_bindir, 'client-libdir=s' => \$path_client_libdir, @@ -2202,6 +2206,12 @@ sub environment_setup { } +sub remove_vardir_subs() { + foreach my $sdir ( glob("$opt_vardir/*") ) { + mtr_verbose("Removing subdir $sdir"); + rmtree($sdir); + } +} # # Remove var and any directories in var/ created by previous @@ -2246,11 +2256,7 @@ sub remove_stale_vardir () { mtr_error("The destination for symlink $opt_vardir does not exist") if ! -d readlink($opt_vardir); - foreach my $bin ( glob("$opt_vardir/*") ) - { - mtr_verbose("Removing bin $bin"); - rmtree($bin); - } + remove_vardir_subs(); } } else @@ -5502,6 +5508,8 @@ Options to control directories to use for tmpfs (/dev/shm) The option can also be set using environment variable MTR_MEM=[DIR] + clean-vardir Clean vardir if tests were successful and if + running in "memory". Otherwise this option is ignored client-bindir=PATH Path to the directory where client binaries are located client-libdir=PATH Path to the directory where client libraries are located From 8a67fc8c8246f5d7290b7e572fa092cf0cadb25d Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Tue, 19 Oct 2010 13:54:28 +0200 Subject: [PATCH 03/13] Test wait_timeout: do not fail by SQL syntax error, use die --- mysql-test/t/wait_timeout.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/t/wait_timeout.test b/mysql-test/t/wait_timeout.test index 6947e346675..eb86cf17ebb 100644 --- a/mysql-test/t/wait_timeout.test +++ b/mysql-test/t/wait_timeout.test @@ -53,7 +53,7 @@ while (!`select @aborted_clients`) dec $retries; if (!$retries) { - Failed to detect that client has been aborted; + die Failed to detect that client has been aborted; } } --enable_query_log @@ -108,7 +108,7 @@ while (!`select @aborted_clients`) dec $retries; if (!$retries) { - Failed to detect that client has been aborted; + die Failed to detect that client has been aborted; } } --enable_query_log From 84c57a5e278bbaa976c8d2961fd554e078c9b714 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Tue, 19 Oct 2010 13:56:30 +0200 Subject: [PATCH 04/13] Bug #52828 Tests that use perl fail when perl is not in path main.mysqltest skipped on Windows because a perl intentionally does exit(1) Use exit(2), as exit(1) on Windows is indistinguishable from failing to execute perl. --- mysql-test/t/mysqltest.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index caadce44dcf..d6bdbc2b3c1 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -331,7 +331,7 @@ eval select $mysql_errno as "after_!errno_masked_error" ; --exec illegal_command --cat_file does_not_exist --perl - exit(1); + exit(2); EOF # ---------------------------------------------------------------------------- From 05062d579a81ce9378560bee573f5769a94c579a Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Tue, 19 Oct 2010 14:01:14 +0200 Subject: [PATCH 05/13] Bug #56654 pb2 log is very hard to read Added some more info in a number of fail cases (re-commit for administrative reasons) --- mysql-test/mysql-test-run.pl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index b83c32d3815..651dabcd408 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -586,13 +586,15 @@ sub run_test_server ($$$) { if ($test_has_failed and $retries <= $opt_retry){ # Test should be run one more time unless it has failed # too many times already + my $tname= $result->{name}; my $failures= $result->{failures}; if ($opt_retry > 1 and $failures >= $opt_retry_failure){ - mtr_report("\nTest has failed $failures times,", + mtr_report("\nTest $tname has failed $failures times,", "no more retries!\n"); } else { - mtr_report("\nRetrying test, attempt($retries/$opt_retry)...\n"); + mtr_report("\nRetrying test $tname, ". + "attempt($retries/$opt_retry)...\n"); delete($result->{result}); $result->{retries}= $retries+1; $result->write_test($sock, 'TESTCASE'); @@ -3094,7 +3096,8 @@ sub check_testcase($$) "\nMTR's internal check of the test case '$tname' failed. This means that the test case does not preserve the state that existed before the test case was executed. Most likely the test case did not -do a proper clean-up. +do a proper clean-up. It could also be caused by the previous test run +by this thread, if the server wasn't restarted. This is the diff of the states of the servers before and after the test case was executed:\n"; $tinfo->{check}.= $report; @@ -3136,6 +3139,10 @@ test case was executed:\n"; # Kill any check processes still running map($_->kill(), values(%started)); + mtr_warning("Check-testcase failed, this could also be caused by the" . + " previous test run by this worker thread") + if $result > 1 && $mode eq "before"; + return $result; } @@ -3789,7 +3796,9 @@ sub get_log_from_proc ($$) { foreach my $mysqld (mysqlds()) { if ($mysqld->{proc} eq $proc) { my @srv_lines= extract_server_log($mysqld->value('#log-error'), $name); - $srv_log= "\nServer log from this test:\n" . join ("", @srv_lines); + $srv_log= "\nServer log from this test:\n" . + "----------SERVER LOG START-----------\n". join ("", @srv_lines) . + "----------SERVER LOG END-------------\n"; last; } } From 138ede4609be43e177ecd60d3e4778647f8f35fd Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Tue, 19 Oct 2010 14:08:46 +0200 Subject: [PATCH 06/13] Bug #55135 Collect times used in test execution phases in mtr Adding option --report-times Can't collect times if test run is aborted --- mysql-test/lib/mtr_misc.pl | 84 ++++++++++++++++++++++++++++++++++++ mysql-test/mysql-test-run.pl | 33 +++++++++++++- 2 files changed, 116 insertions(+), 1 deletion(-) diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl index 32960d866ce..dc9928d37c5 100644 --- a/mysql-test/lib/mtr_misc.pl +++ b/mysql-test/lib/mtr_misc.pl @@ -33,6 +33,13 @@ sub mtr_exe_maybe_exists(@); sub mtr_milli_sleep($); sub start_timer($); sub has_expired($); +sub init_timers(); +sub mark_time_used($); +sub add_total_times($); +sub print_times_used($$); +sub print_total_times($); + +our $opt_report_times; ############################################################################## # @@ -205,4 +212,81 @@ sub start_timer ($) { return time + $_[0]; } sub has_expired ($) { return $_[0] && time gt $_[0]; } +# Below code is for time usage reporting + +use Time::HiRes qw(gettimeofday); + +my %time_used= ( + 'collect' => 0, + 'restart' => 0, + 'check' => 0, + 'ch-warn' => 0, + 'test' => 0, + 'init' => 0, +); + +my %time_text= ( + 'collect' => "Collecting test cases", + 'restart' => "Server stop/start", + 'check' => "Check-testcase", + 'ch-warn' => "Check for warnings", + 'test' => "Test execution", + 'init' => "Initialization etc.", +); + +# Counts number of reports from workers + +my $time_totals= 0; + +my $last_timer_set; + +sub init_timers() { + $last_timer_set= gettimeofday(); +} + +sub mark_time_used($) { + my ($name)= @_; + return unless $opt_report_times; + die "Unknown timer $name" unless exists $time_used{$name}; + + my $curr_time= gettimeofday(); + $time_used{$name}+= int (($curr_time - $last_timer_set) * 1000 + .5); + $last_timer_set= $curr_time; +} + +sub add_total_times($) { + my ($dummy, $num, @line)= split (" ", $_[0]); + + $time_totals++; + foreach my $elem (@line) { + my ($name, $spent)= split (":", $elem); + $time_used{$name}+= $spent; + } +} + +sub print_times_used($$) { + my ($server, $num)= @_; + return unless $opt_report_times; + + my $output= "SPENT $num"; + foreach my $name (keys %time_used) { + my $spent= $time_used{$name}; + $output.= " $name:$spent"; + } + print $server $output . "\n"; +} + +sub print_total_times($) { + # Don't print if we haven't received all worker data + return if $time_totals != $_[0]; + + foreach my $name (keys %time_used) + { + my $spent= $time_used{$name}/1000; + my $text= $time_text{$name}; + print ("Spent $spent seconds on $text\n"); + } +} + + 1; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index e6d988dfba6..fe71fe69ad4 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -236,6 +236,7 @@ my $opt_skip_core; our $opt_check_testcases= 1; my $opt_mark_progress; my $opt_max_connections; +our $opt_report_times= 0; my $opt_sleep; @@ -348,8 +349,11 @@ sub main { } } + init_timers(); + mtr_report("Collecting tests..."); my $tests= collect_test_cases($opt_reorder, $opt_suites, \@opt_cases, \@opt_skip_test_list); + mark_time_used('collect'); if ( $opt_report_features ) { # Put "report features" as the first test to run @@ -418,6 +422,7 @@ sub main { $opt_tmpdir= "$opt_tmpdir/$child_num"; } + init_timers(); run_worker($server_port, $child_num); exit(1); } @@ -430,6 +435,8 @@ sub main { mtr_print_thick_line(); mtr_print_header(); + mark_time_used('init'); + my $completed= run_test_server($server, $tests, $opt_parallel); exit(0) if $opt_start_exit; @@ -475,6 +482,8 @@ sub main { $opt_gcov_msg, $opt_gcov_err); } + print_total_times($opt_parallel) if $opt_report_times; + mtr_report_stats("Completed", $completed); remove_vardir_subs() if $opt_clean_vardir; @@ -651,6 +660,9 @@ sub run_test_server ($$$) { elsif ($line eq 'START'){ ; # Send first test } + elsif ($line =~ /^SPENT/) { + add_total_times($line); + } else { mtr_error("Unknown response: '$line' from client"); } @@ -782,7 +794,9 @@ sub run_worker ($) { # Ask server for first test print $server "START\n"; - while(my $line= <$server>){ + mark_time_used('init'); + + while (my $line= <$server>){ chomp($line); if ($line eq 'TESTCASE'){ my $test= My::Test::read_test($server); @@ -800,16 +814,20 @@ sub run_worker ($) { # Send it back, now with results set #$test->print_test(); $test->write_test($server, 'TESTRESULT'); + mark_time_used('restart'); } elsif ($line eq 'BYE'){ mtr_report("Server said BYE"); stop_all_servers($opt_shutdown_timeout); + mark_time_used('restart'); if ($opt_valgrind_mysqld) { valgrind_exit_reports(); } if ( $opt_gprof ) { gprof_collect (find_mysqld($basedir), keys %gprof_dirs); } + mark_time_used('init'); + print_times_used($server, $thread_num); exit(0); } else { @@ -982,6 +1000,7 @@ sub command_line_setup { 'timediff' => \&report_option, 'max-connections=i' => \$opt_max_connections, 'default-myisam!' => \&collect_option, + 'report-times' => \$opt_report_times, 'help|h' => \$opt_usage, 'list-options' => \$opt_list_options, @@ -3169,6 +3188,7 @@ sub check_testcase($$) if ( keys(%started) == 0){ # All checks completed + mark_time_used('check'); return 0; } # Wait for next process to exit @@ -3226,6 +3246,7 @@ test case was executed:\n"; # Kill any check processes still running map($_->kill(), values(%started)); + mark_time_used('check'); return $result; } @@ -3535,6 +3556,7 @@ sub run_testcase ($) { return 1; } } + mark_time_used('restart'); # -------------------------------------------------------------------- # If --start or --start-dirty given, stop here to let user manually @@ -3587,6 +3609,8 @@ sub run_testcase ($) { do_before_run_mysqltest($tinfo); + mark_time_used('init'); + if ( $opt_check_testcases and check_testcase($tinfo, "before") ){ # Failed to record state of server or server crashed report_failure_and_restart($tinfo); @@ -3633,6 +3657,7 @@ sub run_testcase ($) { } mtr_verbose("Got $proc"); + mark_time_used('test'); # ---------------------------------------------------- # Was it the test program that exited # ---------------------------------------------------- @@ -4036,6 +4061,7 @@ sub check_warnings ($) { if ( keys(%started) == 0){ # All checks completed + mark_time_used('ch-warn'); return $result; } # Wait for next process to exit @@ -4068,6 +4094,7 @@ sub check_warnings ($) { # Kill any check processes still running map($_->kill(), values(%started)); + mark_time_used('ch-warn'); return $result; } @@ -5031,6 +5058,8 @@ sub start_mysqltest ($) { my $exe= $exe_mysqltest; my $args; + mark_time_used('init'); + mtr_init_args(\$args); mtr_add_arg($args, "--defaults-file=%s", $path_config_file); @@ -5668,6 +5697,8 @@ Misc options default-myisam Set default storage engine to MyISAM for non-innodb tests. This is needed after switching default storage engine to InnoDB. + report-times Report how much time has been spent on different + phases of test execution. HERE exit(1); From 6960db2dfdd90aa155bbc88cb802bdc697be4b9c Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 20 Oct 2010 11:22:08 +0200 Subject: [PATCH 07/13] Bug #52019 main.mysqltest fails on new tests for lowercase_result Limited to actual bug fix, fixing a while condition Again confirmed on Linux PPC and on AIX 5.3 --- client/mysqltest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 53c1f1bdf85..ee03b796873 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5742,7 +5742,7 @@ int read_line(char *buf, int size) { /* It was not a multiline char, push back the characters */ /* We leave first 'c', i.e. pretend it was a normal char */ - while (p > mb_start) + while (p-1 > mb_start) my_ungetc(*--p); } } From f73ada3722b9cd3624e9eac8d07f482baaa1f03b Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 20 Oct 2010 11:30:50 +0200 Subject: [PATCH 08/13] 48863 followup: move an array declaration out from within if block --- client/mysqltest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index ee03b796873..2bbb1c63724 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -9781,6 +9781,7 @@ void free_pointer_array(POINTER_ARRAY *pa) void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val, int len) { + char lower[512]; #ifdef __WIN__ fix_win_paths(val, len); #endif @@ -9788,7 +9789,6 @@ void replace_dynstr_append_mem(DYNAMIC_STRING *ds, if (display_result_lower) { /* Convert to lower case, and do this first */ - char lower[512]; char *c= lower; for (const char *v= val; *v; v++) *c++= my_tolower(charset_info, *v); From e533c7cc108e5b9a00c273baa027358c4edb4dd0 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 20 Oct 2010 11:39:58 +0200 Subject: [PATCH 09/13] Fixed missing cast of arg to my_mbcharlen --- client/mysqltest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 2bbb1c63724..8523b40fc80 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5721,7 +5721,7 @@ int read_line(char *buf, int size) /* Could be a multibyte character */ /* This code is based on the code in "sql_load.cc" */ #ifdef USE_MB - int charlen = my_mbcharlen(charset_info, c); + int charlen = my_mbcharlen(charset_info, (unsigned char) c); /* We give up if multibyte character is started but not */ /* completed before we pass buf_end */ if ((charlen > 1) && (p + charlen) <= buf_end) From e4f9ead1403bff9ff07b659f0e2a2575036d39da Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 20 Oct 2010 11:41:51 +0200 Subject: [PATCH 10/13] Fixed wrong feof check in read_line, see 52019 --- client/mysqltest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 8523b40fc80..de46624bf2c 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5733,9 +5733,9 @@ int read_line(char *buf, int size) for (i= 1; i < charlen; i++) { + c= my_getc(cur_file->file); if (feof(cur_file->file)) goto found_eof; - c= my_getc(cur_file->file); *p++ = c; } if (! my_ismbchar(charset_info, mb_start, p)) From 0455ff8faf97da88c0a1cb42a615e75f43e40012 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 20 Oct 2010 16:15:32 +0200 Subject: [PATCH 11/13] Follow-up to Bug #55582 which allows chaecking strings in if Simplified cases where a select was used to compare variable against '' --- .../extra/rpl_tests/rpl_get_master_version_and_clock.test | 2 +- mysql-test/extra/rpl_tests/rpl_loaddata.test | 2 +- mysql-test/include/check_concurrent_insert.inc | 4 ++-- mysql-test/include/check_no_concurrent_insert.inc | 4 ++-- mysql-test/include/get_relay_log_pos.inc | 4 ++-- mysql-test/include/kill_query.inc | 4 ++-- mysql-test/include/kill_query_and_diff_master_slave.inc | 8 ++++---- mysql-test/include/setup_fake_relay_log.inc | 2 +- mysql-test/include/show_binlog_events.inc | 4 ++-- mysql-test/include/show_rpl_debug_info.inc | 6 +++--- mysql-test/include/wait_for_slave_io_error.inc | 2 +- mysql-test/include/wait_for_slave_param.inc | 4 ++-- mysql-test/include/wait_for_slave_sql_error.inc | 2 +- mysql-test/include/wait_for_status_var.inc | 2 +- mysql-test/suite/rpl/t/rpl_killed_ddl.test | 2 +- 15 files changed, 26 insertions(+), 26 deletions(-) diff --git a/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test b/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test index 66bd61a8ea9..40e155bc314 100644 --- a/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test +++ b/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test @@ -34,7 +34,7 @@ # connection slave; -if (`SELECT $debug_sync_action = ''`) +if (!$debug_sync_action) { --die Cannot continue. Please set value for debug_sync_action. } diff --git a/mysql-test/extra/rpl_tests/rpl_loaddata.test b/mysql-test/extra/rpl_tests/rpl_loaddata.test index 1ae17398596..84419ec9cc5 100644 --- a/mysql-test/extra/rpl_tests/rpl_loaddata.test +++ b/mysql-test/extra/rpl_tests/rpl_loaddata.test @@ -24,7 +24,7 @@ connection master; # MTR is not case-sensitive. let $lower_stmt_head= load data; let $UPPER_STMT_HEAD= LOAD DATA; -if (`SELECT '$lock_option' <> ''`) +if ($lock_option) { #if $lock_option is null, an extra blank is added into the statement, #this will change the result of rpl_loaddata test case. so $lock_option diff --git a/mysql-test/include/check_concurrent_insert.inc b/mysql-test/include/check_concurrent_insert.inc index f4bec3c9cdb..62de485d8f1 100644 --- a/mysql-test/include/check_concurrent_insert.inc +++ b/mysql-test/include/check_concurrent_insert.inc @@ -23,7 +23,7 @@ # Reset DEBUG_SYNC facility for safety. set debug_sync= "RESET"; -if (`SELECT '$restore_table' <> ''`) +if ($restore_table) { --eval create temporary table t_backup select * from $restore_table; } @@ -82,7 +82,7 @@ connection default; --eval delete from $table where i = 0; -if (`SELECT '$restore_table' <> ''`) +if ($restore_table) { --eval truncate table $restore_table; --eval insert into $restore_table select * from t_backup; diff --git a/mysql-test/include/check_no_concurrent_insert.inc b/mysql-test/include/check_no_concurrent_insert.inc index f60401bcad1..6938c53fd16 100644 --- a/mysql-test/include/check_no_concurrent_insert.inc +++ b/mysql-test/include/check_no_concurrent_insert.inc @@ -23,7 +23,7 @@ # Reset DEBUG_SYNC facility for safety. set debug_sync= "RESET"; -if (`SELECT '$restore_table' <> ''`) +if ($restore_table) { --eval create temporary table t_backup select * from $restore_table; } @@ -67,7 +67,7 @@ if (!$success) --eval delete from $table where i = 0; -if (`SELECT '$restore_table' <> ''`) +if ($restore_table) { --eval truncate table $restore_table; --eval insert into $restore_table select * from t_backup; diff --git a/mysql-test/include/get_relay_log_pos.inc b/mysql-test/include/get_relay_log_pos.inc index 7ce36fd3c50..61ee07fc655 100644 --- a/mysql-test/include/get_relay_log_pos.inc +++ b/mysql-test/include/get_relay_log_pos.inc @@ -10,12 +10,12 @@ # # at this point, get_relay_log_pos.inc sets $relay_log_pos. echo position # # in $relay_log_file: $relay_log_pos. -if (`SELECT '$relay_log_file' = ''`) +if (!$relay_log_file) { --die 'variable $relay_log_file is null' } -if (`SELECT '$master_log_pos' = ''`) +if (!$master_log_pos) { --die 'variable $master_log_pos is null' } diff --git a/mysql-test/include/kill_query.inc b/mysql-test/include/kill_query.inc index b303ed0ec39..1c949d3cbad 100644 --- a/mysql-test/include/kill_query.inc +++ b/mysql-test/include/kill_query.inc @@ -44,7 +44,7 @@ connection master; # kill the query that is waiting eval kill query $connection_id; -if (`SELECT '$debug_lock' != ''`) +if ($debug_lock) { # release the lock to allow binlog continue eval SELECT RELEASE_LOCK($debug_lock); @@ -57,7 +57,7 @@ reap; connection master; -if (`SELECT '$debug_lock' != ''`) +if ($debug_lock) { # get lock again to make the next query wait eval SELECT GET_LOCK($debug_lock, 10); diff --git a/mysql-test/include/kill_query_and_diff_master_slave.inc b/mysql-test/include/kill_query_and_diff_master_slave.inc index 611d6929c99..b3846d12df1 100644 --- a/mysql-test/include/kill_query_and_diff_master_slave.inc +++ b/mysql-test/include/kill_query_and_diff_master_slave.inc @@ -25,7 +25,7 @@ source include/kill_query.inc; connection master; disable_query_log; disable_result_log; -if (`SELECT '$debug_lock' != ''`) +if ($debug_lock) { eval SELECT RELEASE_LOCK($debug_lock); } @@ -36,8 +36,8 @@ source include/diff_master_slave.inc; # Acquire the debug lock again if used connection master; -disable_query_log; disable_result_log; if (`SELECT '$debug_lock' != -''`) { eval SELECT GET_LOCK($debug_lock, 10); } enable_result_log; -enable_query_log; +disable_query_log; disable_result_log; +if ($debug_lock) { eval SELECT GET_LOCK($debug_lock, 10); } +enable_result_log; enable_query_log; connection $connection_name; diff --git a/mysql-test/include/setup_fake_relay_log.inc b/mysql-test/include/setup_fake_relay_log.inc index fb035941a29..f881f3bf4e8 100644 --- a/mysql-test/include/setup_fake_relay_log.inc +++ b/mysql-test/include/setup_fake_relay_log.inc @@ -56,7 +56,7 @@ if (`SELECT "$_sql_running" = "Yes" OR "$_io_running" = "Yes"`) { # Read server variables. let $MYSQLD_DATADIR= `SELECT @@datadir`; let $_fake_filename= query_get_value(SHOW VARIABLES LIKE 'relay_log', Value, 1); -if (`SELECT '$_fake_filename' = ''`) { +if (!$_fake_filename) { --echo Badly written test case: relay_log variable is empty. Please use the --echo server option --relay-log=FILE. } diff --git a/mysql-test/include/show_binlog_events.inc b/mysql-test/include/show_binlog_events.inc index 8649f31ad9f..6d8c8196102 100644 --- a/mysql-test/include/show_binlog_events.inc +++ b/mysql-test/include/show_binlog_events.inc @@ -27,14 +27,14 @@ if (!$binlog_start) } --let $_statement=show binlog events -if (`SELECT '$binlog_file' <> ''`) +if ($binlog_file) { --let $_statement= $_statement in '$binlog_file' } --let $_statement= $_statement from $binlog_start -if (`SELECT '$binlog_limit' <> ''`) +if ($binlog_limit) { --let $_statement= $_statement limit $binlog_limit } diff --git a/mysql-test/include/show_rpl_debug_info.inc b/mysql-test/include/show_rpl_debug_info.inc index 148d11f3b02..9944e6cd25f 100644 --- a/mysql-test/include/show_rpl_debug_info.inc +++ b/mysql-test/include/show_rpl_debug_info.inc @@ -48,13 +48,13 @@ let $binlog_name= query_get_value("SHOW MASTER STATUS", File, 1); eval SHOW BINLOG EVENTS IN '$binlog_name'; let $_master_con= $master_connection; -if (`SELECT '$_master_con' = ''`) +if (!$_master_con) { if (`SELECT '$_con' = 'slave'`) { let $_master_con= master; } - if (`SELECT '$_master_con' = ''`) + if (!$_master_con) { --echo Unable to determine master connection. No debug info printed for master. --echo Please fix the test case by setting $master_connection before sourcing @@ -62,7 +62,7 @@ if (`SELECT '$_master_con' = ''`) } } -if (`SELECT '$_master_con' != ''`) +if ($_master_con) { let $master_binlog_name_io= query_get_value("SHOW SLAVE STATUS", Master_Log_File, 1); diff --git a/mysql-test/include/wait_for_slave_io_error.inc b/mysql-test/include/wait_for_slave_io_error.inc index 34cbf20a73b..ffdcf752873 100644 --- a/mysql-test/include/wait_for_slave_io_error.inc +++ b/mysql-test/include/wait_for_slave_io_error.inc @@ -31,7 +31,7 @@ # $master_connection # See wait_for_slave_param.inc for description. -if (`SELECT '$slave_io_errno' = ''`) { +if (!$slave_io_errno) { --die !!!ERROR IN TEST: you must set \$slave_io_errno before sourcing wait_for_slave_io_error.inc } diff --git a/mysql-test/include/wait_for_slave_param.inc b/mysql-test/include/wait_for_slave_param.inc index ef864f9245e..98cd426fa11 100644 --- a/mysql-test/include/wait_for_slave_param.inc +++ b/mysql-test/include/wait_for_slave_param.inc @@ -51,7 +51,7 @@ if (!$_slave_timeout_counter) } let $_slave_param_comparison= $slave_param_comparison; -if (`SELECT '$_slave_param_comparison' = ''`) +if (!$_slave_param_comparison) { let $_slave_param_comparison= =; } @@ -71,7 +71,7 @@ while (`SELECT NOT('$_show_slave_status_value' $_slave_param_comparison '$slave_ if (!$_slave_timeout_counter) { --echo **** ERROR: timeout after $slave_timeout seconds while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value **** - if (`SELECT '$slave_error_message' != ''`) + if ($slave_error_message) { --echo Message: $slave_error_message } diff --git a/mysql-test/include/wait_for_slave_sql_error.inc b/mysql-test/include/wait_for_slave_sql_error.inc index aab04036eea..80836f908c6 100644 --- a/mysql-test/include/wait_for_slave_sql_error.inc +++ b/mysql-test/include/wait_for_slave_sql_error.inc @@ -24,7 +24,7 @@ # $master_connection # See wait_for_slave_param.inc for description. -if (`SELECT '$slave_sql_errno' = ''`) { +if (!$slave_sql_errno) { --die !!!ERROR IN TEST: you must set \$slave_sql_errno before sourcing wait_for_slave_sql_error.inc } diff --git a/mysql-test/include/wait_for_status_var.inc b/mysql-test/include/wait_for_status_var.inc index 8b644c2c3c5..9f4962aeaed 100644 --- a/mysql-test/include/wait_for_status_var.inc +++ b/mysql-test/include/wait_for_status_var.inc @@ -45,7 +45,7 @@ if (!$_status_timeout_counter) } let $_status_var_comparsion= $status_var_comparsion; -if (`SELECT '$_status_var_comparsion' = ''`) +if (!$_status_var_comparsion) { let $_status_var_comparsion= =; } diff --git a/mysql-test/suite/rpl/t/rpl_killed_ddl.test b/mysql-test/suite/rpl/t/rpl_killed_ddl.test index 61b882efcf3..69648267ca4 100644 --- a/mysql-test/suite/rpl/t/rpl_killed_ddl.test +++ b/mysql-test/suite/rpl/t/rpl_killed_ddl.test @@ -119,7 +119,7 @@ echo [on master]; # This will block the execution of a statement at the DBUG_SYNC_POINT # with given lock name -if (`SELECT '$debug_lock' != ''`) +if ($debug_lock) { disable_query_log; disable_result_log; From 909f0bf94a5bd5879fc9cf2be11b5c0cf20caed3 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 21 Oct 2010 15:20:50 +0200 Subject: [PATCH 12/13] Follow-up to Bug #55582 which allows checking strings in if Simplified cases where a select was used to compare variable against '' --- .../extra/rpl_tests/rpl_get_master_version_and_clock.test | 2 +- mysql-test/extra/rpl_tests/rpl_loaddata.test | 2 +- mysql-test/include/check_concurrent_insert.inc | 4 ++-- mysql-test/include/check_no_concurrent_insert.inc | 4 ++-- mysql-test/include/get_relay_log_pos.inc | 4 ++-- mysql-test/include/kill_query.inc | 4 ++-- mysql-test/include/kill_query_and_diff_master_slave.inc | 8 ++++---- mysql-test/include/setup_fake_relay_log.inc | 2 +- mysql-test/include/show_binlog_events.inc | 4 ++-- mysql-test/include/show_rpl_debug_info.inc | 6 +++--- mysql-test/include/wait_for_slave_io_error.inc | 2 +- mysql-test/include/wait_for_slave_param.inc | 4 ++-- mysql-test/include/wait_for_slave_sql_error.inc | 2 +- mysql-test/include/wait_for_status_var.inc | 2 +- mysql-test/suite/rpl/t/rpl_killed_ddl.test | 2 +- 15 files changed, 26 insertions(+), 26 deletions(-) diff --git a/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test b/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test index 66bd61a8ea9..40e155bc314 100644 --- a/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test +++ b/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test @@ -34,7 +34,7 @@ # connection slave; -if (`SELECT $debug_sync_action = ''`) +if (!$debug_sync_action) { --die Cannot continue. Please set value for debug_sync_action. } diff --git a/mysql-test/extra/rpl_tests/rpl_loaddata.test b/mysql-test/extra/rpl_tests/rpl_loaddata.test index 1ae17398596..84419ec9cc5 100644 --- a/mysql-test/extra/rpl_tests/rpl_loaddata.test +++ b/mysql-test/extra/rpl_tests/rpl_loaddata.test @@ -24,7 +24,7 @@ connection master; # MTR is not case-sensitive. let $lower_stmt_head= load data; let $UPPER_STMT_HEAD= LOAD DATA; -if (`SELECT '$lock_option' <> ''`) +if ($lock_option) { #if $lock_option is null, an extra blank is added into the statement, #this will change the result of rpl_loaddata test case. so $lock_option diff --git a/mysql-test/include/check_concurrent_insert.inc b/mysql-test/include/check_concurrent_insert.inc index f4bec3c9cdb..62de485d8f1 100644 --- a/mysql-test/include/check_concurrent_insert.inc +++ b/mysql-test/include/check_concurrent_insert.inc @@ -23,7 +23,7 @@ # Reset DEBUG_SYNC facility for safety. set debug_sync= "RESET"; -if (`SELECT '$restore_table' <> ''`) +if ($restore_table) { --eval create temporary table t_backup select * from $restore_table; } @@ -82,7 +82,7 @@ connection default; --eval delete from $table where i = 0; -if (`SELECT '$restore_table' <> ''`) +if ($restore_table) { --eval truncate table $restore_table; --eval insert into $restore_table select * from t_backup; diff --git a/mysql-test/include/check_no_concurrent_insert.inc b/mysql-test/include/check_no_concurrent_insert.inc index f60401bcad1..6938c53fd16 100644 --- a/mysql-test/include/check_no_concurrent_insert.inc +++ b/mysql-test/include/check_no_concurrent_insert.inc @@ -23,7 +23,7 @@ # Reset DEBUG_SYNC facility for safety. set debug_sync= "RESET"; -if (`SELECT '$restore_table' <> ''`) +if ($restore_table) { --eval create temporary table t_backup select * from $restore_table; } @@ -67,7 +67,7 @@ if (!$success) --eval delete from $table where i = 0; -if (`SELECT '$restore_table' <> ''`) +if ($restore_table) { --eval truncate table $restore_table; --eval insert into $restore_table select * from t_backup; diff --git a/mysql-test/include/get_relay_log_pos.inc b/mysql-test/include/get_relay_log_pos.inc index 7ce36fd3c50..61ee07fc655 100644 --- a/mysql-test/include/get_relay_log_pos.inc +++ b/mysql-test/include/get_relay_log_pos.inc @@ -10,12 +10,12 @@ # # at this point, get_relay_log_pos.inc sets $relay_log_pos. echo position # # in $relay_log_file: $relay_log_pos. -if (`SELECT '$relay_log_file' = ''`) +if (!$relay_log_file) { --die 'variable $relay_log_file is null' } -if (`SELECT '$master_log_pos' = ''`) +if (!$master_log_pos) { --die 'variable $master_log_pos is null' } diff --git a/mysql-test/include/kill_query.inc b/mysql-test/include/kill_query.inc index b303ed0ec39..1c949d3cbad 100644 --- a/mysql-test/include/kill_query.inc +++ b/mysql-test/include/kill_query.inc @@ -44,7 +44,7 @@ connection master; # kill the query that is waiting eval kill query $connection_id; -if (`SELECT '$debug_lock' != ''`) +if ($debug_lock) { # release the lock to allow binlog continue eval SELECT RELEASE_LOCK($debug_lock); @@ -57,7 +57,7 @@ reap; connection master; -if (`SELECT '$debug_lock' != ''`) +if ($debug_lock) { # get lock again to make the next query wait eval SELECT GET_LOCK($debug_lock, 10); diff --git a/mysql-test/include/kill_query_and_diff_master_slave.inc b/mysql-test/include/kill_query_and_diff_master_slave.inc index 611d6929c99..b3846d12df1 100644 --- a/mysql-test/include/kill_query_and_diff_master_slave.inc +++ b/mysql-test/include/kill_query_and_diff_master_slave.inc @@ -25,7 +25,7 @@ source include/kill_query.inc; connection master; disable_query_log; disable_result_log; -if (`SELECT '$debug_lock' != ''`) +if ($debug_lock) { eval SELECT RELEASE_LOCK($debug_lock); } @@ -36,8 +36,8 @@ source include/diff_master_slave.inc; # Acquire the debug lock again if used connection master; -disable_query_log; disable_result_log; if (`SELECT '$debug_lock' != -''`) { eval SELECT GET_LOCK($debug_lock, 10); } enable_result_log; -enable_query_log; +disable_query_log; disable_result_log; +if ($debug_lock) { eval SELECT GET_LOCK($debug_lock, 10); } +enable_result_log; enable_query_log; connection $connection_name; diff --git a/mysql-test/include/setup_fake_relay_log.inc b/mysql-test/include/setup_fake_relay_log.inc index fb035941a29..f881f3bf4e8 100644 --- a/mysql-test/include/setup_fake_relay_log.inc +++ b/mysql-test/include/setup_fake_relay_log.inc @@ -56,7 +56,7 @@ if (`SELECT "$_sql_running" = "Yes" OR "$_io_running" = "Yes"`) { # Read server variables. let $MYSQLD_DATADIR= `SELECT @@datadir`; let $_fake_filename= query_get_value(SHOW VARIABLES LIKE 'relay_log', Value, 1); -if (`SELECT '$_fake_filename' = ''`) { +if (!$_fake_filename) { --echo Badly written test case: relay_log variable is empty. Please use the --echo server option --relay-log=FILE. } diff --git a/mysql-test/include/show_binlog_events.inc b/mysql-test/include/show_binlog_events.inc index 8649f31ad9f..6d8c8196102 100644 --- a/mysql-test/include/show_binlog_events.inc +++ b/mysql-test/include/show_binlog_events.inc @@ -27,14 +27,14 @@ if (!$binlog_start) } --let $_statement=show binlog events -if (`SELECT '$binlog_file' <> ''`) +if ($binlog_file) { --let $_statement= $_statement in '$binlog_file' } --let $_statement= $_statement from $binlog_start -if (`SELECT '$binlog_limit' <> ''`) +if ($binlog_limit) { --let $_statement= $_statement limit $binlog_limit } diff --git a/mysql-test/include/show_rpl_debug_info.inc b/mysql-test/include/show_rpl_debug_info.inc index 148d11f3b02..9944e6cd25f 100644 --- a/mysql-test/include/show_rpl_debug_info.inc +++ b/mysql-test/include/show_rpl_debug_info.inc @@ -48,13 +48,13 @@ let $binlog_name= query_get_value("SHOW MASTER STATUS", File, 1); eval SHOW BINLOG EVENTS IN '$binlog_name'; let $_master_con= $master_connection; -if (`SELECT '$_master_con' = ''`) +if (!$_master_con) { if (`SELECT '$_con' = 'slave'`) { let $_master_con= master; } - if (`SELECT '$_master_con' = ''`) + if (!$_master_con) { --echo Unable to determine master connection. No debug info printed for master. --echo Please fix the test case by setting $master_connection before sourcing @@ -62,7 +62,7 @@ if (`SELECT '$_master_con' = ''`) } } -if (`SELECT '$_master_con' != ''`) +if ($_master_con) { let $master_binlog_name_io= query_get_value("SHOW SLAVE STATUS", Master_Log_File, 1); diff --git a/mysql-test/include/wait_for_slave_io_error.inc b/mysql-test/include/wait_for_slave_io_error.inc index 34cbf20a73b..ffdcf752873 100644 --- a/mysql-test/include/wait_for_slave_io_error.inc +++ b/mysql-test/include/wait_for_slave_io_error.inc @@ -31,7 +31,7 @@ # $master_connection # See wait_for_slave_param.inc for description. -if (`SELECT '$slave_io_errno' = ''`) { +if (!$slave_io_errno) { --die !!!ERROR IN TEST: you must set \$slave_io_errno before sourcing wait_for_slave_io_error.inc } diff --git a/mysql-test/include/wait_for_slave_param.inc b/mysql-test/include/wait_for_slave_param.inc index ef864f9245e..98cd426fa11 100644 --- a/mysql-test/include/wait_for_slave_param.inc +++ b/mysql-test/include/wait_for_slave_param.inc @@ -51,7 +51,7 @@ if (!$_slave_timeout_counter) } let $_slave_param_comparison= $slave_param_comparison; -if (`SELECT '$_slave_param_comparison' = ''`) +if (!$_slave_param_comparison) { let $_slave_param_comparison= =; } @@ -71,7 +71,7 @@ while (`SELECT NOT('$_show_slave_status_value' $_slave_param_comparison '$slave_ if (!$_slave_timeout_counter) { --echo **** ERROR: timeout after $slave_timeout seconds while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value **** - if (`SELECT '$slave_error_message' != ''`) + if ($slave_error_message) { --echo Message: $slave_error_message } diff --git a/mysql-test/include/wait_for_slave_sql_error.inc b/mysql-test/include/wait_for_slave_sql_error.inc index aab04036eea..80836f908c6 100644 --- a/mysql-test/include/wait_for_slave_sql_error.inc +++ b/mysql-test/include/wait_for_slave_sql_error.inc @@ -24,7 +24,7 @@ # $master_connection # See wait_for_slave_param.inc for description. -if (`SELECT '$slave_sql_errno' = ''`) { +if (!$slave_sql_errno) { --die !!!ERROR IN TEST: you must set \$slave_sql_errno before sourcing wait_for_slave_sql_error.inc } diff --git a/mysql-test/include/wait_for_status_var.inc b/mysql-test/include/wait_for_status_var.inc index 8b644c2c3c5..9f4962aeaed 100644 --- a/mysql-test/include/wait_for_status_var.inc +++ b/mysql-test/include/wait_for_status_var.inc @@ -45,7 +45,7 @@ if (!$_status_timeout_counter) } let $_status_var_comparsion= $status_var_comparsion; -if (`SELECT '$_status_var_comparsion' = ''`) +if (!$_status_var_comparsion) { let $_status_var_comparsion= =; } diff --git a/mysql-test/suite/rpl/t/rpl_killed_ddl.test b/mysql-test/suite/rpl/t/rpl_killed_ddl.test index 61b882efcf3..69648267ca4 100644 --- a/mysql-test/suite/rpl/t/rpl_killed_ddl.test +++ b/mysql-test/suite/rpl/t/rpl_killed_ddl.test @@ -119,7 +119,7 @@ echo [on master]; # This will block the execution of a statement at the DBUG_SYNC_POINT # with given lock name -if (`SELECT '$debug_lock' != ''`) +if ($debug_lock) { disable_query_log; disable_result_log; From 56354413f86be103ce6c30aed879562894fb28e6 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Mon, 25 Oct 2010 14:07:28 +0200 Subject: [PATCH 13/13] Revert simplified if() in mysql-test/include/show_events.inc --- mysql-test/include/show_events.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/include/show_events.inc b/mysql-test/include/show_events.inc index df17534eb82..ff5a7105c24 100644 --- a/mysql-test/include/show_events.inc +++ b/mysql-test/include/show_events.inc @@ -25,7 +25,9 @@ if ($binlog_file) --let $_statement= $_statement from $binlog_start -if ($binlog_limit) +# Cannot use if($binlog_limit) since the variable may begin with a 0 + +if (`SELECT '$binlog_limit' <> ''`) { --let $_statement= $_statement limit $binlog_limit }