From dd639985c179e484115bfabd83dbbd2c4ab3f392 Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Fri, 8 Mar 2024 22:56:14 +0000 Subject: [PATCH] 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. --- mysql-test/main/mysqld_option_err.result | 12 ++++++------ mysql-test/main/mysqld_option_err.test | 24 ++++++++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/mysql-test/main/mysqld_option_err.result b/mysql-test/main/mysqld_option_err.result index e2c7b0bd213..13a004b77d1 100644 --- a/mysql-test/main/mysqld_option_err.result +++ b/mysql-test/main/mysqld_option_err.result @@ -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. diff --git a/mysql-test/main/mysqld_option_err.test b/mysql-test/main/mysqld_option_err.test index ad4df61b0f8..2c77b868ebf 100644 --- a/mysql-test/main/mysqld_option_err.test +++ b/mysql-test/main/mysqld_option_err.test @@ -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