diff options
author | Bjorn Munch <bjorn.munch@oracle.com> | 2010-11-17 11:16:13 +0100 |
---|---|---|
committer | Bjorn Munch <bjorn.munch@oracle.com> | 2010-11-17 11:16:13 +0100 |
commit | ef4458af0741dd18a407eff47ede481c816e8f07 (patch) | |
tree | 4232e7417004f49b782c05a7406b4cc2f1ed845a /mysql-test/include | |
parent | 49ce7daa947bb156daf92cd101495cfe33993afa (diff) | |
download | mariadb-git-ef4458af0741dd18a407eff47ede481c816e8f07.tar.gz |
Tests: many if/while expresissons simplified after 57276
Diffstat (limited to 'mysql-test/include')
19 files changed, 52 insertions, 30 deletions
diff --git a/mysql-test/include/check_slave_is_running.inc b/mysql-test/include/check_slave_is_running.inc index 5fbbe0d684c..51c418e6c64 100644 --- a/mysql-test/include/check_slave_is_running.inc +++ b/mysql-test/include/check_slave_is_running.inc @@ -8,10 +8,18 @@ --echo Checking that both slave threads are running. +--let $running= 1 --let $slave_sql_running = query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1) --let $slave_io_running = query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1) -if (`SELECT '$slave_sql_running' != 'Yes' OR '$slave_io_running' != 'Yes'`) { +if ($slave_sql_running != Yes) { + --let $running= 0 +} +if ($slave_io_running != Yes) { + --let $running= 0 +} + +if (!$running) { --echo Slave not running: Slave_SQL_Running = $slave_sql_running Slave_IO_Running = $slave_io_running --source include/show_rpl_debug_info.inc --die Expected slave to be running, but it was not running. diff --git a/mysql-test/include/check_slave_param.inc b/mysql-test/include/check_slave_param.inc index d82c26851ea..b27825eee6c 100644 --- a/mysql-test/include/check_slave_param.inc +++ b/mysql-test/include/check_slave_param.inc @@ -9,7 +9,7 @@ # --source include/check_slave_param.inc --let $_param_value= query_get_value(SHOW SLAVE STATUS, $slave_param, 1) -if (`SELECT '$_param_value' != '$slave_param_value'`) { +if ($_param_value != $slave_param_value) { --echo Wrong value for $slave_param. Expected '$slave_param_value', got '$_param_value' --source include/show_rpl_debug_info.inc --die Wrong value for slave parameter diff --git a/mysql-test/include/diff_tables.inc b/mysql-test/include/diff_tables.inc index d6216f3fe1e..bdd929f39a4 100644 --- a/mysql-test/include/diff_tables.inc +++ b/mysql-test/include/diff_tables.inc @@ -69,7 +69,7 @@ while ($_diff_i) { # and connect the appropriate server. let $_pos= `SELECT LOCATE(':', '$_diff_table')`; let $_diff_conn=`SELECT SUBSTR('$_diff_table', 1, $_pos-1)`; - if (`SELECT 'XX$_diff_conn' <> 'XX'`) { + if ($_diff_conn) { let $_diff_table=`SELECT SUBSTR('$_diff_table', $_pos+1)`; connection $_diff_conn; } diff --git a/mysql-test/include/have_example_plugin.inc b/mysql-test/include/have_example_plugin.inc index 3a667d2e21a..8920399555d 100644 --- a/mysql-test/include/have_example_plugin.inc +++ b/mysql-test/include/have_example_plugin.inc @@ -8,7 +8,7 @@ if (`SELECT @@have_dynamic_loading != 'YES'`) { # # Check if the variable EXAMPLE_PLUGIN is set # -if (`SELECT LENGTH('$EXAMPLE_PLUGIN') = 0`) { +if (!$EXAMPLE_PLUGIN) { --skip Example plugin requires the environment variable \$EXAMPLE_PLUGIN to be set (normally done by mtr) } diff --git a/mysql-test/include/have_semisync_plugin.inc b/mysql-test/include/have_semisync_plugin.inc index d3b42dbf5fb..95899f559aa 100644 --- a/mysql-test/include/have_semisync_plugin.inc +++ b/mysql-test/include/have_semisync_plugin.inc @@ -8,7 +8,7 @@ if (`SELECT @@have_dynamic_loading != 'YES'`) { # # Check if the variable SEMISYNC_MASTER_PLUGIN is set # -if (`select LENGTH('$SEMISYNC_MASTER_PLUGIN') = 0`) +if (!$SEMISYNC_MASTER_PLUGIN) { skip Need semisync plugins; } diff --git a/mysql-test/include/have_simple_parser.inc b/mysql-test/include/have_simple_parser.inc index 745f68603fe..d077916c5e7 100644 --- a/mysql-test/include/have_simple_parser.inc +++ b/mysql-test/include/have_simple_parser.inc @@ -8,7 +8,7 @@ if (`SELECT @@have_dynamic_loading != 'YES'`) { # # Check if the variable SIMPLE_PARSER is set # -if (`SELECT LENGTH('$SIMPLE_PARSER') = 0`) { +if (!$SIMPLE_PARSER) { --skip simple parser requires the environment variable \$SIMPLE_PARSER to be set (normally done by mtr) } diff --git a/mysql-test/include/have_udf.inc b/mysql-test/include/have_udf.inc index d9ca1450043..5c404b03729 100644 --- a/mysql-test/include/have_udf.inc +++ b/mysql-test/include/have_udf.inc @@ -8,7 +8,7 @@ if (`SELECT @@have_dynamic_loading != 'YES'`) { # # Check if the variable UDF_EXAMPLE_LIB is set # -if (`SELECT LENGTH('$UDF_EXAMPLE_LIB') = 0`) { +if (!$UDF_EXAMPLE_LIB) { --skip UDF requires the environment variable \$UDF_EXAMPLE_LIB to be set (normally done by mtr) } diff --git a/mysql-test/include/mysql_upgrade_preparation.inc b/mysql-test/include/mysql_upgrade_preparation.inc index 5de8a79d6e0..a3c81c4c1e7 100644 --- a/mysql-test/include/mysql_upgrade_preparation.inc +++ b/mysql-test/include/mysql_upgrade_preparation.inc @@ -17,7 +17,7 @@ select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade; # Therefore, truncate the log table in advance and issue a statement # that should be logged. # -if (`SELECT $VALGRIND_TEST`) +if ($VALGRIND_TEST) { --disable_query_log --disable_result_log diff --git a/mysql-test/include/no_valgrind_without_big.inc b/mysql-test/include/no_valgrind_without_big.inc index 743e974daec..ea1f2ac91ab 100644 --- a/mysql-test/include/no_valgrind_without_big.inc +++ b/mysql-test/include/no_valgrind_without_big.inc @@ -5,8 +5,9 @@ # Therefore we require that the option "--big-test" is also set. # -if (`SELECT $VALGRIND_TEST <> 0 AND '$BIG_TEST' = ''`) -{ - --skip Need "--big-test" when running with Valgrind +if ($VALGRIND_TEST) { + if (!$BIG_TEST) + { + --skip Need "--big-test" when running with Valgrind + } } - diff --git a/mysql-test/include/not_parallel.inc b/mysql-test/include/not_parallel.inc index 39432c59813..615bdf68453 100644 --- a/mysql-test/include/not_parallel.inc +++ b/mysql-test/include/not_parallel.inc @@ -1,3 +1,3 @@ -if (`SELECT '$MTR_PARALLEL' > 1`) { +if ($MTR_PARALLEL > 1) { --skip test requires --parallel=1 } diff --git a/mysql-test/include/rpl_diff_tables.inc b/mysql-test/include/rpl_diff_tables.inc index c3a45578a79..a82e094a209 100644 --- a/mysql-test/include/rpl_diff_tables.inc +++ b/mysql-test/include/rpl_diff_tables.inc @@ -8,13 +8,13 @@ # --source include/rpl_diff_tables.inc # ############################################################################# -if (`SELECT "XX$diff_table" = "XX"`) +if (!$diff_table) { --die diff_table is null. } --let $_servers= master, slave -if (`SELECT "XX$diff_server_list" <> "XX"`) +if ($diff_server_list) { --let $_servers= $diff_server_list } @@ -22,7 +22,7 @@ if (`SELECT "XX$diff_server_list" <> "XX"`) --let $_master= `SELECT SUBSTRING_INDEX('$_servers', ',', 1)` --let $_servers= `SELECT LTRIM(SUBSTRING('$_servers', LENGTH('$_master') + 2))` connection $_master; -while (`SELECT "XX$_servers" <> "XX"`) +while ($_servers) { --let $_slave= `SELECT SUBSTRING_INDEX('$_servers', ',', 1)` --let $_servers= `SELECT LTRIM(SUBSTRING('$_servers', LENGTH('$_slave') + 2))` diff --git a/mysql-test/include/setup_fake_relay_log.inc b/mysql-test/include/setup_fake_relay_log.inc index c5d709601cf..1b517862235 100644 --- a/mysql-test/include/setup_fake_relay_log.inc +++ b/mysql-test/include/setup_fake_relay_log.inc @@ -40,9 +40,16 @@ let $_fake_relay_log_printable= `SELECT REPLACE('$fake_relay_log', '$MYSQL_TEST_ --echo Setting up fake replication from $_fake_relay_log_printable # Sanity check. +let $running= 0; let $_sql_running= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1); let $_io_running= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1); -if (`SELECT "$_sql_running" = "Yes" OR "$_io_running" = "Yes"`) { +if ($_sql_running == Yes) { + let $running= 1; +} +if ($_io_running == Yes) { + let $running= 1; +} +if ($running) { --echo Error: Slave was running when test case sourced --echo include/setup_fake_replication.inc --echo Slave_IO_Running = $_io_running; Slave_SQL_Running = $_sql_running diff --git a/mysql-test/include/show_rpl_debug_info.inc b/mysql-test/include/show_rpl_debug_info.inc index 9944e6cd25f..dedf689cd19 100644 --- a/mysql-test/include/show_rpl_debug_info.inc +++ b/mysql-test/include/show_rpl_debug_info.inc @@ -50,7 +50,7 @@ eval SHOW BINLOG EVENTS IN '$binlog_name'; let $_master_con= $master_connection; if (!$_master_con) { - if (`SELECT '$_con' = 'slave'`) + if ($_con == slave) { let $_master_con= master; } @@ -80,7 +80,7 @@ if ($_master_con) --echo --echo **** SHOW BINLOG EVENTS on $_master_con **** eval SHOW BINLOG EVENTS IN '$master_binlog_name_sql'; - if (`SELECT '$master_binlog_name_io' != '$master_binlog_name_sql'`) + if ($master_binlog_name_io != $master_binlog_name_sql) { eval SHOW BINLOG EVENTS IN '$master_binlog_name_io'; } diff --git a/mysql-test/include/truncate_file.inc b/mysql-test/include/truncate_file.inc index c82108681bd..2326d6c0b94 100644 --- a/mysql-test/include/truncate_file.inc +++ b/mysql-test/include/truncate_file.inc @@ -1,6 +1,6 @@ # truncate a giving file, all contents of the file are be cleared -if (`SELECT 'x$file' = 'x'`) +if (!$file) { --echo Please assign a file name to $file!! exit; diff --git a/mysql-test/include/wait_for_slave_io_to_stop.inc b/mysql-test/include/wait_for_slave_io_to_stop.inc index f61b0db1ed7..512bb6b7243 100644 --- a/mysql-test/include/wait_for_slave_io_to_stop.inc +++ b/mysql-test/include/wait_for_slave_io_to_stop.inc @@ -14,7 +14,7 @@ # if server has not used CHANGE MASTER to initiate slave, SHOW SLAVE # STATUS will return an empty set. let $_slave_io_running= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, 1); -if (`SELECT '$_slave_io_running' != 'No such row'`) +if ($_slave_io_running != No such row) { let $slave_param= Slave_IO_Running; let $slave_param_value= No; diff --git a/mysql-test/include/wait_for_slave_sql_error.inc b/mysql-test/include/wait_for_slave_sql_error.inc index 80836f908c6..3ae34b1fb9e 100644 --- a/mysql-test/include/wait_for_slave_sql_error.inc +++ b/mysql-test/include/wait_for_slave_sql_error.inc @@ -34,7 +34,7 @@ let $slave_error_message= Failed while waiting for slave to stop the SQL thread source include/wait_for_slave_param.inc; let $_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1); -if (`SELECT '$_error' != '$slave_sql_errno'`) { +if ($_error != $slave_sql_errno) { --echo **** Slave stopped with wrong error code: $_error (expected $slave_sql_errno) **** source include/show_rpl_debug_info.inc; --echo **** Slave stopped with wrong error code: $_error (expected $slave_sql_errno) **** diff --git a/mysql-test/include/wait_for_slave_sql_to_stop.inc b/mysql-test/include/wait_for_slave_sql_to_stop.inc index 6992613b646..50bf53e421d 100644 --- a/mysql-test/include/wait_for_slave_sql_to_stop.inc +++ b/mysql-test/include/wait_for_slave_sql_to_stop.inc @@ -14,7 +14,7 @@ # if server has not used CHANGE MASTER to initiate slave, SHOW SLAVE # STATUS will return an empty set. let $_slave_io_running= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, 1); -if (`SELECT '$_slave_io_running' != 'No such row'`) +if ($_slave_io_running != No such row) { let $slave_param= Slave_SQL_Running; let $slave_param_value= No; diff --git a/mysql-test/include/wait_for_slave_to_stop.inc b/mysql-test/include/wait_for_slave_to_stop.inc index 56d0e7b0c91..618c5397cb7 100644 --- a/mysql-test/include/wait_for_slave_to_stop.inc +++ b/mysql-test/include/wait_for_slave_to_stop.inc @@ -14,7 +14,7 @@ # if server has not used CHANGE MASTER to initiate slave, SHOW SLAVE # STATUS will return an empty set. let $_slave_io_running= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, 1); -if (`SELECT '$_slave_io_running' != 'No such row'`) +if ($_slave_io_running != No such row) { let $slave_error_message= Failed while waiting for slave to stop; diff --git a/mysql-test/include/wait_show_condition.inc b/mysql-test/include/wait_show_condition.inc index f683ca7b47b..6bb89ff70b6 100644 --- a/mysql-test/include/wait_show_condition.inc +++ b/mysql-test/include/wait_show_condition.inc @@ -50,7 +50,7 @@ inc $max_run_time; let $found= 0; let $max_end_time= `SELECT UNIX_TIMESTAMP() + $max_run_time`; -if (`SELECT '$wait_for_all' != '1'`) +if ($wait_for_all != 1) { while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`) { @@ -58,24 +58,27 @@ if (`SELECT '$wait_for_all' != '1'`) real_sleep 0.2; let $rowno= 1; let $process_result= 1; - while (`SELECT $process_result = 1 AND $found = 0`) + let $do_loop= 1; + while ($do_loop) { let $field_value= query_get_value($show_statement, $field, $rowno); if (`SELECT '$field_value' $condition`) { let $found= 1; + let $do_loop= 0; } - if (`SELECT '$field_value' = 'No such row'`) + if ($field_value == No such row) { # We are behind the last row of the result set. let $process_result= 0; + let $do_loop= 0; } inc $rowno; } } } -if (`SELECT '$wait_for_all' = '1'`) +if ($wait_for_all == 1) { while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`) { @@ -83,16 +86,19 @@ if (`SELECT '$wait_for_all' = '1'`) real_sleep 0.2; let $rowno= 1; let $process_result= 1; - while (`SELECT $process_result = 1 AND $found = 0`) + let $do_loop= 1; + while ($do_loop) { let $field_value= query_get_value($show_statement, $field, $rowno); - if (`SELECT '$field_value' = 'No such row'`) + if ($field_value == No such row) { let $found= 1; + let $do_loop= 0; } if (`SELECT $found = 0 AND NOT '$field_value' $condition`) { let process_result= 0; + let $do_loop= 0; } inc $rowno; } |