Commit dd639985 authored by Tony Chen's avatar Tony Chen Committed by Daniel Black

Simplify MTR for handling multiple invalid options

In 69a4d6ae, an MTR test was added to verify that we handled multiple invalid
options.  However, the logic to perform this test relied on a non-trivial regex
to filter out the noise in the logs.

Instead, we now just simply search for what we expect to be in the logs.

All new code of the whole pull request, including one or several files that are
either new files or modified ones, are contributed under the BSD-new license. I
am contributing on behalf of my employer Amazon Web Services, Inc.
parent a6aecbb0
......@@ -4,13 +4,13 @@ Test bad default storage engine.
Test non-numeric value passed to number option.
Test that bad value for plugin enum option is rejected correctly.
Test to see if multiple unknown options will be displayed in the error output
unknown option '--nonexistentoption'
unknown option '--alsononexistent'
unknown variable 'nonexistentvariable=1'
FOUND 1 /unknown option '--nonexistentoption2'/ in mysqltest.log
FOUND 1 /unknown option '--alsononexistent'/ in mysqltest.log
FOUND 1 /unknown variable 'nonexistentvariable=1'/ in mysqltest.log
Test to see if multiple ambiguous options and invalid arguments will be displayed in the error output
Error while setting value 'invalid_value' to 'sql_mode'
ambiguous option '--character' (character-set-client-handshake, character_sets_dir)
option '--bootstrap' cannot take an argument
FOUND 1 /Error while setting value 'invalid_value' to 'sql_mode'/ in mysqltest.log
FOUND 1 /ambiguous option '--character'/ in mysqltest.log
FOUND 1 /option '--bootstrap' cannot take an argument/ in mysqltest.log
Test that --help --verbose works
Test that --not-known-option --help --verbose gives error
Done.
......@@ -46,17 +46,29 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err;
--error 7
--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --plugin-dir=$MYSQLTEST_VARDIR/plugins --plugin-load=example=ha_example.so --plugin-example-enum-var=noexist >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
--let SEARCH_FILE = $MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log
--echo Test to see if multiple unknown options will be displayed in the error output
# Remove the noise to make the test robust
--replace_regex /^((?!nonexistent).)*$// /.*unknown/unknown/
--error 7
--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --nonexistentoption --alsononexistent --nonexistentvariable=1 2>&1
--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --nonexistentoption2 --alsononexistent --nonexistentvariable=1 >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
--let SEARCH_PATTERN=unknown option '--nonexistentoption2'
--source include/search_pattern_in_file.inc
--let SEARCH_PATTERN=unknown option '--alsononexistent'
--source include/search_pattern_in_file.inc
--let SEARCH_PATTERN=unknown variable 'nonexistentvariable=1'
--source include/search_pattern_in_file.inc
--echo Test to see if multiple ambiguous options and invalid arguments will be displayed in the error output
# Remove the noise to make the test robust
--replace_regex /^((?!('sql_mode'|'--character'|'--bootstrap')).)*$// /.*Error while setting value/Error while setting value/ /.*ambiguous option/ambiguous option/ /.*option '--bootstrap'/option '--bootstrap'/
--error 1
--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --getopt-prefix-matching --sql-mode=invalid_value --character --bootstrap=partstoob 2>&1
--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --getopt-prefix-matching --sql-mode=invalid_value --character --bootstrap=partstoob >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
--let SEARCH_PATTERN=Error while setting value 'invalid_value' to 'sql_mode'
--source include/search_pattern_in_file.inc
--let SEARCH_PATTERN=ambiguous option '--character'
--source include/search_pattern_in_file.inc
--let SEARCH_PATTERN=option '--bootstrap' cannot take an argument
--source include/search_pattern_in_file.inc
#
# Test that an wrong option with --help --verbose gives an error
......
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