summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2017-04-18 17:09:28 +0000
committerSergei Golubchik <serg@mariadb.org>2017-04-27 19:12:38 +0200
commitec68f764f6f9dc4028a0af93b78449e76e972b9a (patch)
tree7849247cb837fe86bd27e62fb6857bea1f4dc4b4
parent7bf409593e624deb00265e21e0d4579ce9fa7999 (diff)
downloadmariadb-git-ec68f764f6f9dc4028a0af93b78449e76e972b9a.tar.gz
MDEV-9566 prepare mysqltest for mariabackup
- Do not throw output of exec command, if disable_result_log is set save and dump it if exec fails. Need tha to meaningfully analyze errors from mariabackup. - rmdir now removes the entire tree. need that because xtrabackup tests clean the whole directory. - all filesystem modifying commands now require the argument to be under MYSQLTEST_VARDIR or MYSQL_TMP_DIR.
-rw-r--r--client/mysqltest.cc135
-rw-r--r--mysql-test/include/write_var_to_file.inc3
-rw-r--r--mysql-test/r/mysql_plugin.result132
-rw-r--r--mysql-test/t/mysql_plugin.test368
-rw-r--r--mysql-test/t/mysqltest.test24
-rw-r--r--storage/connect/mysql-test/connect/t/secure_file_priv.test2
6 files changed, 131 insertions, 533 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 2673db0e469..492411d49ca 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -3373,6 +3373,12 @@ void do_exec(struct st_command *command)
#endif
#endif
+ if (disable_result_log)
+ {
+ /* Collect stderr output as well, for the case app. crashes or returns error.*/
+ dynstr_append(&ds_cmd, " 2>&1");
+ }
+
DBUG_PRINT("info", ("Executing '%s' as '%s'",
command->first_argument, ds_cmd.str));
@@ -3408,16 +3414,7 @@ void do_exec(struct st_command *command)
len--;
}
#endif
- if (disable_result_log)
- {
- if (len)
- buf[len-1] = 0;
- DBUG_PRINT("exec_result",("%s", buf));
- }
- else
- {
- replace_dynstr_append_mem(ds_result, buf, len);
- }
+ replace_dynstr_append_mem(ds_result, buf, len);
}
error= pclose(res_file);
@@ -3427,7 +3424,7 @@ void do_exec(struct st_command *command)
dynstr_free(&ds_sorted);
}
- if (error > 0)
+ if (error)
{
uint status= WEXITSTATUS(error);
int i;
@@ -3473,6 +3470,12 @@ void do_exec(struct st_command *command)
}
dynstr_free(&ds_cmd);
+
+ if (disable_result_log)
+ {
+ /* Disable output in case of successful exit.*/
+ dynstr_set(&ds_res,"");
+ }
DBUG_VOID_RETURN;
}
@@ -3610,6 +3613,37 @@ void do_system(struct st_command *command)
}
+/* returns TRUE if path is inside a sandbox */
+bool is_sub_path(const char *path, size_t plen, const char *sandbox)
+{
+ size_t len= strlen(sandbox);
+ if (!sandbox || !len || plen <= len || memcmp(path, sandbox, len - 1)
+ || path[len] != '/')
+ return false;
+ return true;
+}
+
+
+/* returns TRUE if path cannot be modified */
+bool bad_path(const char *path)
+{
+ size_t plen= strlen(path);
+
+ const char *vardir= getenv("MYSQLTEST_VARDIR");
+ if (is_sub_path(path, plen, vardir))
+ return false;
+
+ const char *tmpdir= getenv("MYSQL_TMP_DIR");
+ if (is_sub_path(path, plen, tmpdir))
+ return false;
+
+ report_or_die("Path '%s' is not a subdirectory of MYSQLTEST_VARDIR '%s'"
+ "or MYSQL_TMP_DIR '%s'",
+ path, vardir, tmpdir);
+ return true;
+}
+
+
/*
SYNOPSIS
set_wild_chars
@@ -3668,6 +3702,9 @@ void do_remove_file(struct st_command *command)
rm_args, sizeof(rm_args)/sizeof(struct command_arg),
' ');
+ if (bad_path(ds_filename.str))
+ DBUG_VOID_RETURN;
+
DBUG_PRINT("info", ("removing file: %s", ds_filename.str));
error= my_delete(ds_filename.str, MYF(disable_warnings ? 0 : MY_WME)) != 0;
handle_command_error(command, error, my_errno);
@@ -3711,6 +3748,9 @@ void do_remove_files_wildcard(struct st_command *command)
' ');
fn_format(dirname, ds_directory.str, "", "", MY_UNPACK_FILENAME);
+ if (bad_path(ds_directory.str))
+ DBUG_VOID_RETURN;
+
DBUG_PRINT("info", ("listing directory: %s", dirname));
if (!(dir_info= my_dir(dirname, MYF(MY_DONT_SORT | MY_WANT_STAT | MY_WME))))
{
@@ -3785,6 +3825,9 @@ void do_copy_file(struct st_command *command)
sizeof(copy_file_args)/sizeof(struct command_arg),
' ');
+ if (bad_path(ds_to_file.str))
+ DBUG_VOID_RETURN;
+
DBUG_PRINT("info", ("Copy %s to %s", ds_from_file.str, ds_to_file.str));
/* MY_HOLD_ORIGINAL_MODES prevents attempts to chown the file */
error= (my_copy(ds_from_file.str, ds_to_file.str,
@@ -3822,6 +3865,9 @@ void do_move_file(struct st_command *command)
sizeof(move_file_args)/sizeof(struct command_arg),
' ');
+ if (bad_path(ds_to_file.str))
+ DBUG_VOID_RETURN;
+
DBUG_PRINT("info", ("Move %s to %s", ds_from_file.str, ds_to_file.str));
error= (my_rename(ds_from_file.str, ds_to_file.str,
MYF(disable_warnings ? 0 : MY_WME)) != 0);
@@ -3860,6 +3906,9 @@ void do_chmod_file(struct st_command *command)
sizeof(chmod_file_args)/sizeof(struct command_arg),
' ');
+ if (bad_path(ds_file.str))
+ DBUG_VOID_RETURN;
+
/* Parse what mode to set */
if (ds_mode.length != 4 ||
str2int(ds_mode.str, 8, 0, INT_MAX, &mode) == NullS)
@@ -3931,6 +3980,9 @@ void do_mkdir(struct st_command *command)
mkdir_args, sizeof(mkdir_args)/sizeof(struct command_arg),
' ');
+ if (bad_path(ds_dirname.str))
+ DBUG_VOID_RETURN;
+
DBUG_PRINT("info", ("creating directory: %s", ds_dirname.str));
error= my_mkdir(ds_dirname.str, 0777, MYF(MY_WME)) != 0;
handle_command_error(command, error, my_errno);
@@ -3938,6 +3990,47 @@ void do_mkdir(struct st_command *command)
DBUG_VOID_RETURN;
}
+
+/*
+ Remove directory recursively.
+*/
+static int rmtree(const char *dir)
+{
+ char path[FN_REFLEN];
+ char sep[]={ FN_LIBCHAR, 0 };
+ int err=0;
+
+ MY_DIR *dir_info= my_dir(dir, MYF(MY_DONT_SORT | MY_WANT_STAT));
+ if (!dir_info)
+ return 1;
+
+ for (uint i= 0; i < dir_info->number_of_files; i++)
+ {
+ FILEINFO *file= dir_info->dir_entry + i;
+ /* Skip "." and ".." */
+ if (!strcmp(file->name, ".") || !strcmp(file->name, ".."))
+ continue;
+
+ strxnmov(path, sizeof(path), dir, sep, file->name, NULL);
+
+ if (!MY_S_ISDIR(file->mystat->st_mode))
+ err= my_delete(path, 0);
+ else
+ err= rmtree(path);
+
+ if(err)
+ break;
+ }
+
+ my_dirend(dir_info);
+
+ if (!err)
+ err= rmdir(dir);
+
+ return err;
+}
+
+
/*
SYNOPSIS
do_rmdir
@@ -3945,12 +4038,11 @@ void do_mkdir(struct st_command *command)
DESCRIPTION
rmdir <dir_name>
- Remove the empty directory <dir_name>
+ Remove the directory tree
*/
void do_rmdir(struct st_command *command)
{
- int error;
static DYNAMIC_STRING ds_dirname;
const struct command_arg rmdir_args[] = {
{ "dirname", ARG_STRING, TRUE, &ds_dirname, "Directory to remove" }
@@ -3961,9 +4053,13 @@ void do_rmdir(struct st_command *command)
rmdir_args, sizeof(rmdir_args)/sizeof(struct command_arg),
' ');
+ if (bad_path(ds_dirname.str))
+ DBUG_VOID_RETURN;
+
DBUG_PRINT("info", ("removing directory: %s", ds_dirname.str));
- error= rmdir(ds_dirname.str) != 0;
- handle_command_error(command, error, errno);
+ if (rmtree(ds_dirname.str))
+ handle_command_error(command, 1, errno);
+
dynstr_free(&ds_dirname);
DBUG_VOID_RETURN;
}
@@ -4076,6 +4172,9 @@ static void do_list_files_write_file_command(struct st_command *command,
list_files_args,
sizeof(list_files_args)/sizeof(struct command_arg), ' ');
+ if (bad_path(ds_filename.str))
+ DBUG_VOID_RETURN;
+
init_dynamic_string(&ds_content, "", 1024, 1024);
error= get_list_files(&ds_content, &ds_dirname, &ds_wild);
handle_command_error(command, error, my_errno);
@@ -4127,7 +4226,8 @@ void read_until_delimiter(DYNAMIC_STRING *ds,
while (1)
{
c= my_getc(cur_file->file);
-
+ if (c == '\r')
+ c= my_getc(cur_file->file);
if (c == '\n')
{
cur_file->lineno++;
@@ -4178,6 +4278,9 @@ void do_write_file_command(struct st_command *command, my_bool append)
sizeof(write_file_args)/sizeof(struct command_arg),
' ');
+ if (bad_path(ds_filename.str))
+ DBUG_VOID_RETURN;
+
if (!append && access(ds_filename.str, F_OK) == 0)
{
/* The file should not be overwritten */
diff --git a/mysql-test/include/write_var_to_file.inc b/mysql-test/include/write_var_to_file.inc
index 08de195ccbb..7982c6fab31 100644
--- a/mysql-test/include/write_var_to_file.inc
+++ b/mysql-test/include/write_var_to_file.inc
@@ -43,9 +43,8 @@ if ($write_to_file == 'GENERATE')
if (`SELECT LENGTH(@@secure_file_priv) > 0`)
{
- --let $_wvtf_secure_file_priv= `SELECT @@secure_file_priv`
--let $_wvtf_suffix= `SELECT UUID()`
- --let $_wvtf_tmp_file= $_wvtf_secure_file_priv/_wvtf_$_wvtf_suffix
+ --let $_wvtf_tmp_file= $MYSQLTEST_VARDIR/_wvtf_$_wvtf_suffix
--eval SELECT '$write_var' INTO DUMPFILE '$_wvtf_tmp_file'
--copy_file $_wvtf_tmp_file $write_to_file
diff --git a/mysql-test/r/mysql_plugin.result b/mysql-test/r/mysql_plugin.result
deleted file mode 100644
index 0bcb47e4a10..00000000000
--- a/mysql-test/r/mysql_plugin.result
+++ /dev/null
@@ -1,132 +0,0 @@
-#
-# Ensure the plugin isn't loaded.
-#
-SELECT * FROM mysql.plugin WHERE dl like 'libdaemon%' ORDER BY name;
-name dl
-#
-# Enable the plugin...
-#
-#
-# Simulate loading a plugin libary with multiple entry points.
-# This will test the DISABLE to ensure all rows are removed.
-#
-INSERT INTO mysql.plugin VALUES ('wicky', 'libdaemon_example.so');
-INSERT INTO mysql.plugin VALUES ('wacky', 'libdaemon_example.so');
-INSERT INTO mysql.plugin VALUES ('wonky', 'libdaemon_example.so');
-#
-# Ensure the plugin is now loaded.
-#
-SELECT * FROM mysql.plugin WHERE dl like 'libdaemon%' ORDER BY name;
-name dl
-daemon_example libdaemon_example.so
-wacky libdaemon_example.so
-wicky libdaemon_example.so
-wonky libdaemon_example.so
-#
-# Ensure the plugin is loaded.
-#
-SELECT * FROM mysql.plugin WHERE dl like '%libdaemon%' ORDER BY name;
-name dl
-daemon_example libdaemon_example.so
-#
-# Ensure the plugin is replaced.
-#
-SELECT * FROM mysql.plugin WHERE dl like '%libdaemon%' ORDER BY name;
-name dl
-daemon_example liblibdaemon_example.so
-#
-# Disable the plugin...
-#
-#
-# Ensure the plugin isn't loaded.
-#
-SELECT * FROM mysql.plugin WHERE dl like '%libdaemon%' ORDER BY name;
-name dl
-#
-# Attempt to load non-existant plugin
-#
-ERROR: Cannot read plugin config file NOT_THERE_AT_ALL. File does not exist.
-#
-# Attempt to use non-existant plugin.ini file
-#
-ERROR: Cannot read plugin config file daemon_example. File does not exist.
-#
-# Attempt to omit the plugin
-#
-ERROR: No plugin specified.
-#
-# Attempt to omit DISABLE|ENABLE
-#
-ERROR: missing operation. Please specify either '<plugin> ENABLE' or '<plugin> DISABLE'.
-#
-# Attempt to use bad paths - datadir
-#
-ERROR: Cannot access datadir at '/data_not_there/'.
-#
-# Attempt to use bad paths - basedir
-#
-ERROR: Cannot access basedir at '/basedir_not_there/'.
-#
-# Attempt to use bad paths - plugin_dir
-#
-ERROR: Cannot read plugin config file daemon_example. File does not exist.
-#
-# Attempt to use bad paths - mysqld
-#
-ERROR: Cannot access mysqld path '/mysqld_not_there/'.
-#
-# Attempt to use bad paths - my_print_defaults
-#
-ERROR: Cannot access my-print-defaults path '/my_print_defaults_not_there/'.
-#
-# Missing library
-#
-ERROR: The plugin library is missing or in a different location.
-#
-# Bad format for config file
-#
-ERROR: Cannot read plugin config file daemon_example. Bad format in plugin configuration file.
-#
-# Missing base_dir option
-#
-ERROR: Missing --basedir option.
-#
-# Missing data_dir option
-#
-ERROR: Missing --datadir option.
-#
-# Missing plugin_dir option
-#
-ERROR: Missing --plugin_dir option.
-#
-# Show the help.
-#
-mysql_plugin Ver V.V.VV Distrib XX.XX.XX
-Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
-
-Enable or disable plugins.
-
-Usage: mysql_plugin [options] <plugin> ENABLE|DISABLE
-
-Options:
- -?, --help Display this help and exit.
- -b, --basedir=name The basedir for the server.
- -d, --datadir=name The datadir for the server.
- -p, --plugin-dir=name
- The plugin dir for the server.
- -i, --plugin-ini=name
- Read plugin information from configuration file specified
- instead of from <plugin-dir>/<plugin_name>.ini.
- -n, --no-defaults Do not read values from configuration file.
- -P, --print-defaults
- Show default values from configuration file.
- -m, --mysqld=name Path to mysqld executable. Example: /sbin/temp1/mysql/bin
- -f, --my-print-defaults=name
- Path to my_print_defaults executable. Example:
- /source/temp11/extra
- -v, --verbose More verbose output; you can use this multiple times to
- get even more verbose output.
- -V, --version Output version information and exit.
-
-
-mysql_plugin Ver V.V.VV Distrib XX.XX.XX
diff --git a/mysql-test/t/mysql_plugin.test b/mysql-test/t/mysql_plugin.test
deleted file mode 100644
index 10bc03e0f06..00000000000
--- a/mysql-test/t/mysql_plugin.test
+++ /dev/null
@@ -1,368 +0,0 @@
-#
-# Test mysql_plugin tool
-#
-# This test contains test cases for testing the mysql_plugin client with
-# the daemon_example plugin. Test cases include tests for:
-#
-# - successful enable/disable
-# - incorrect paths
-# - missing paths/options
-#
-# Implementation Notes
-#
-# The mysql_plugin tool now accepts --mysqld the path to mysqld server. The
-# mysqld path is extracted from MYSQLD_BOOTSTRAP_CMD line. We also extract
-# the path of MYSQLD_BASEDIR (where mysql exists) and use it for the errmsg
-# file. The directories differ between Windows and Unix but the Perl script
-# included below will pick as per platform.
-#
-# The test is also designed to issue the --skip directive if the location of
-# the mysqld, my_print_defaults, or daemon_example.ini files cannot be found.
-#
-
---source include/not_embedded.inc
-
-# Add the datadir, basedir, plugin_dir to the bootstrap command
-let $MYSQLD_DATADIR= `select @@datadir`;
-let $MYSQL_BASEDIR= `select @@basedir`;
-let $MYSQL_ERRMSG_BASEDIR=`select @@lc_messages_dir`;
-let $PLUGIN_DIR=`select @@plugin_dir`;
-
---disable_abort_on_error
-
-# Perl script to extract the location of the basedir from environment
-# variables. This is needed to ensure the test will run on the PB machines
-# designed to test release as well as debug builds. It also checks for the
-# location of the my_print_defaults and daemon_example.ini files.
-
-perl;
-use File::Basename;
- my ($mysqld)= split " ", $ENV{MYSQLD_BOOTSTRAP_CMD};
- my $mysqld_basedir=dirname($mysqld);
- my $my_print_defaults= $ENV{MYSQL_MY_PRINT_DEFAULTS};
- my $my_print_defaults_basedir=dirname($my_print_defaults);
- my $daemonexample_ini= "$ENV{DAEMONEXAMPLE_DIR}/daemon_example.ini";
- my $plugindir_ini= "$ENV{PLUGIN_DIR}/daemon_example.ini";
- my $notfound= "";
- open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/mysqld.inc") or die;
- print FILE "let \$MYSQLD_BASEDIR= $mysqld_basedir;\n";
- print FILE "let \$MYSQL_MY_PRINT_DEFAULTS_BASEDIR= $my_print_defaults_basedir;\n";
- if ((!-e $daemonexample_ini) || (!-r $daemonexample_ini))
- {
- print FILE "let \$DAEMONEXAMPLE_DIR= $not_found;\n";
- }
- if ((!-e $plugindir_ini) || (!-r $plugindir_ini))
- {
- print FILE "let \$PLUGIN_DIR= $not_found;\n";
- }
- close FILE;
-EOF
-
-
-source $MYSQL_TMP_DIR/mysqld.inc;
-remove_file $MYSQL_TMP_DIR/mysqld.inc;
-
-# The mysql_plugin tool expects a directory structure like in the installed
-# mysql version, so errmsg.sys will be copied to "basedir/share", we create
-# and remove this structure.
-
---mkdir $MYSQLD_BASEDIR/share
---mkdir $MYSQLD_BASEDIR/share/mysql
---copy_file $MYSQL_ERRMSG_BASEDIR/english/errmsg.sys $MYSQLD_BASEDIR/share/errmsg.sys
---copy_file $MYSQL_ERRMSG_BASEDIR/english/errmsg.sys $MYSQLD_BASEDIR/share/mysql/errmsg.sys
-
-# The mysql_plugin tool now accepts --my-print-defaults which points to the
-# executable my_print_defaults.exe we can get this path from the variable
-# $MYSQL_MY_PRINT_DEFAULTS.
-
-# Check for my_print_defaults location. Skip if not found.
-if ($MYSQL_MY_PRINT_DEFAULTS_BASEDIR == '')
-{
- --skip Test requires known location of my_print_defaults executable.
-}
-
-# Check for mysqld location. Skip if not found.
-if ($MYSQLD == '')
-{
- --skip Test requires known location of mysqld executable.
-}
-
-# Check for daemon_example.ini location. Skip if not found in either
-# the plugin_dir path or the daemon_example_dir path.
-if ($PLUGIN_DIR == '')
-{
- if ($DAEMONEXAMPLE_DIR == '')
- {
- --skip Test requires known location of daemon_example.ini file.
- }
- let $PLUGIN_DIR = $DAEMONEXAMPLE_DIR;
-}
-
-# Build client command for reuse.
-
-let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN --datadir=$MYSQLD_DATADIR --basedir=$MYSQLD_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
-
---echo #
---echo # Ensure the plugin isn't loaded.
---echo #
-SELECT * FROM mysql.plugin WHERE dl like 'libdaemon%' ORDER BY name;
-
---echo #
---echo # Enable the plugin...
---echo #
-
---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
---shutdown_server 10
---source include/wait_until_disconnected.inc
-
-#
-# Enable the plugin
-#
---exec $MYSQL_PLUGIN_CMD ENABLE daemon_example
-
-#
-# Ensure enabling an enabled plugin doesn't fail
---exec $MYSQL_PLUGIN_CMD ENABLE daemon_example
-
-#
-# Restart the server
-#
-
---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
---enable_reconnect
---source include/wait_until_connected_again.inc
-
---echo #
---echo # Simulate loading a plugin libary with multiple entry points.
---echo # This will test the DISABLE to ensure all rows are removed.
---echo #
---replace_regex /\.dll/.so/
-eval INSERT INTO mysql.plugin VALUES ('wicky', '$DAEMONEXAMPLE');
---replace_regex /\.dll/.so/
-eval INSERT INTO mysql.plugin VALUES ('wacky', '$DAEMONEXAMPLE');
---replace_regex /\.dll/.so/
-eval INSERT INTO mysql.plugin VALUES ('wonky', '$DAEMONEXAMPLE');
-
---echo #
---echo # Ensure the plugin is now loaded.
---echo #
---replace_regex /\.dll/.so/
-SELECT * FROM mysql.plugin WHERE dl like 'libdaemon%' ORDER BY name;
-
---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
---shutdown_server 10
---source include/wait_until_disconnected.inc
-
-#
-# Disable the plugin - to remove winky, wonky entries
-#
---exec $MYSQL_PLUGIN_CMD DISABLE daemon_example
-
-#
-# Enable the plugin again
-#
---exec $MYSQL_PLUGIN_CMD ENABLE daemon_example
-
-#
-# Restart the server
-#
---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
---enable_reconnect
---source include/wait_until_connected_again.inc
-
---echo #
---echo # Ensure the plugin is loaded.
---echo #
---replace_regex /\.dll/.so/
-SELECT * FROM mysql.plugin WHERE dl like '%libdaemon%' ORDER BY name;
-
---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
---shutdown_server 10
---source include/wait_until_disconnected.inc
-
-# To test the case where the same plugin is reloaded with a different soname,
-# we must copy the example daemon to a new location renaming it.
-
-let $DAEMON_RELOAD = lib$DAEMONEXAMPLE;
---copy_file $PLUGIN_DIR/$DAEMONEXAMPLE $PLUGIN_DIR/$DAEMON_RELOAD
---copy_file include/libdaemon_example.ini $PLUGIN_DIR/libdaemon_example.ini
-
-# Now reload it and see that it is a different name.
---exec $MYSQL_PLUGIN_CMD ENABLE libdaemon_example
-
-#
-# Restart the server
-#
---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
---enable_reconnect
---source include/wait_until_connected_again.inc
-
---echo #
---echo # Ensure the plugin is replaced.
---echo #
---replace_regex /\.dll/.so/
-SELECT * FROM mysql.plugin WHERE dl like '%libdaemon%' ORDER BY name;
-
---echo #
---echo # Disable the plugin...
---echo #
-
---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
---shutdown_server 10
---source include/wait_until_disconnected.inc
-
-#
-# Disable the plugin
-#
---exec $MYSQL_PLUGIN_CMD DISABLE libdaemon_example
-
-# Remove files for last test case.
-
---remove_file $PLUGIN_DIR/$DAEMON_RELOAD
---remove_file $DAEMONEXAMPLE_DIR/libdaemon_example.ini
-
-#
-# Restart the server
-#
---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
---enable_reconnect
---source include/wait_until_connected_again.inc
-
---echo #
---echo # Ensure the plugin isn't loaded.
---echo #
-SELECT * FROM mysql.plugin WHERE dl like '%libdaemon%' ORDER BY name;
-
-#
-# Stop the server for error conditions
-#
-
---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
---shutdown_server 10
---source include/wait_until_disconnected.inc
-
---echo #
---echo # Attempt to load non-existant plugin
---echo #
---error 1,2,256
---exec $MYSQL_PLUGIN_CMD DISABLE NOT_THERE_AT_ALL 2>&1
-
---echo #
---echo # Attempt to use non-existant plugin.ini file
---echo #
---error 1,2,7,256
---exec $MYSQL_PLUGIN_CMD DISABLE daemon_example --plugin-ini=/NOT/THERE/pi.ini 2>&1
-
---echo #
---echo # Attempt to omit the plugin
---echo #
---error 1,2,256
---exec $MYSQL_PLUGIN_CMD DISABLE 2>&1
-
---echo #
---echo # Attempt to omit DISABLE|ENABLE
---echo #
---error 1,2,256
---exec $MYSQL_PLUGIN_CMD daemon_example 2>&1
-
---echo #
---echo # Attempt to use bad paths - datadir
---echo #
-let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=/data_not_there/ --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
---error 1,2,256
---exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
-
---echo #
---echo # Attempt to use bad paths - basedir
---echo #
-let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=/basedir_not_there/ --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
-replace_result "/basedir_not_there//" "/basedir_not_there/";
---error 1,2,256
---exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
-
---echo #
---echo # Attempt to use bad paths - plugin_dir
---echo #
-let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=/plugin_not_there/ --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
---error 1,2,256
---exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
-
---echo #
---echo # Attempt to use bad paths - mysqld
---echo #
-let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=/mysqld_not_there/ --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
---error 1,2,256
---exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
-
---echo #
---echo # Attempt to use bad paths - my_print_defaults
---echo #
-let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=/my_print_defaults_not_there/;
---error 1,2,256
---exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
-
-
---echo #
---echo # Missing library
---echo #
-let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --plugin-ini=$MYSQL_TEST_DIR/include/daemon_example_bad_soname.ini --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
---error 1,2,256
---exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
-
---echo #
---echo # Bad format for config file
---echo #
-let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --plugin-ini=$MYSQL_TEST_DIR/include/daemon_example_bad_format.ini --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
---error 1,2,256
---exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
-
---echo #
---echo # Missing base_dir option
---echo #
-let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQLD_DATADIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
---error 1,2,139,256
---exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
-
---echo #
---echo # Missing data_dir option
---echo #
-let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --basedir=$MYSQL_BASEDIR --plugin-dir=$PLUGIN_DIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
---error 1,2,139,256
---exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
-
---echo #
---echo # Missing plugin_dir option
---echo #
-let $MYSQL_PLUGIN_CMD= $MYSQL_PLUGIN -n --datadir=$MYSQL_DATADIR --basedir=$MYSQL_BASEDIR --mysqld=$MYSQLD_BASEDIR --my-print-defaults=$MYSQL_MY_PRINT_DEFAULTS_BASEDIR;
---error 1,2,139,256
---exec $MYSQL_PLUGIN_CMD DISABLE daemon_example 2>&1
-
---echo #
---echo # Show the help.
---echo #
-replace_result $MYSQL_PLUGIN mysql_plugin;
---replace_regex /Ver [0-9.]+ Distrib [0-9.]+/Ver V.V.VV Distrib XX.XX.XX/ /XX-m[0-9]+/XX/ /XX[a-z]/XX/
---exec $MYSQL_PLUGIN --help
-
-replace_result $MYSQL_PLUGIN mysql_plugin;
---replace_regex /Ver [0-9.]+ Distrib [0-9.]+/Ver V.V.VV Distrib XX.XX.XX/ /XX-m[0-9]+/XX/ /XX[a-z]/XX/
---exec $MYSQL_PLUGIN --version
-
-#
-# Restart the server
-#
---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
---enable_reconnect
---source include/wait_until_connected_again.inc
-
-#
-# Cleanup
-
---remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-
-# Cleanup the share folder in the binary path.
---remove_file $MYSQLD_BASEDIR/share/errmsg.sys
---rmdir $MYSQLD_BASEDIR/share/mysql
---rmdir $MYSQLD_BASEDIR/share
-
---enable_abort_on_error
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index e85d793b628..1e7d8a6a8ca 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -406,7 +406,7 @@ select 3 from t1 ;
--disable_abort_on_error ONCE
garbage;
--disable_abort_on_error ONCE
---remove_file DoesNotExist
+--remove_file $MYSQLTEST_VARDIR/DoesNotExist
--disable_result_log
select 2;
@@ -1940,8 +1940,6 @@ remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result;
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.reject;
--error 0,1
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.log;
---error 0,1
-remove_file $MYSQL_TEST_DIR/r/zero_length_file.reject;
--enable_warnings
#
@@ -2194,7 +2192,7 @@ drop table t1;
--exec echo "remove_file ;" | $MYSQL_TEST 2>&1
--error 1
-remove_file non_existing_file;
+remove_file $MYSQLTEST_VARDIR/non_existing_file;
--enable_warnings
# ----------------------------------------------------------------------------
@@ -2205,10 +2203,10 @@ remove_file non_existing_file;
--exec echo "remove_files_wildcard ;" | $MYSQL_TEST 2>&1
--error 1
-remove_files_wildcard non_existing_dir;
+remove_files_wildcard $MYSQLTEST_VARDIR/non_existing_dir;
--error 1
-remove_files_wildcard non_existing_dir non_existing_file;
+remove_files_wildcard $MYSQLTEST_VARDIR/non_existing_dir non_existing_file;
# ----------------------------------------------------------------------------
# test for write_file
@@ -2217,7 +2215,7 @@ remove_files_wildcard non_existing_dir non_existing_file;
--exec echo "write_file ;" | $MYSQL_TEST 2>&1
--error 1
---exec echo "write_file filename ;" | $MYSQL_TEST 2>&1
+--exec echo "write_file $MYSQLTEST_VARDIR/filename ;" | $MYSQL_TEST 2>&1
# Comment out this test as it confuses cmd.exe with unmatched "
#--error 1
@@ -2463,19 +2461,19 @@ remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp;
--exec echo "chmod ;" | $MYSQL_TEST 2>&1
--error 1
---exec echo "chmod 0 from_file;" | $MYSQL_TEST 2>&1
+--exec echo "chmod 0 $MYSQLTEST_VARDIR/from_file;" | $MYSQL_TEST 2>&1
--error 1
---exec echo "chmod 08 from_file;" | $MYSQL_TEST 2>&1
+--exec echo "chmod 08 $MYSQLTEST_VARDIR/from_file;" | $MYSQL_TEST 2>&1
--error 1
---exec echo "chmod from_file;" | $MYSQL_TEST 2>&1
+--exec echo "chmod $MYSQLTEST_VARDIR/from_file;" | $MYSQL_TEST 2>&1
--error 1
---exec echo "chmod ABZD from_file;" | $MYSQL_TEST 2>&1
+--exec echo "chmod ABZD $MYSQLTEST_VARDIR/from_file;" | $MYSQL_TEST 2>&1
--error 1
---exec echo "chmod 06789 from_file;" | $MYSQL_TEST 2>&1
+--exec echo "chmod 06789 $MYSQLTEST_VARDIR/from_file;" | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
@@ -2876,8 +2874,6 @@ list_files_append_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR
list_files_write_file $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir file?.txt;
list_files_append_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt $MYSQLTEST_VARDIR/tmp/testdir file*.txt;
diff_files $MYSQLTEST_VARDIR/tmp/testdir/file2.txt $MYSQLTEST_VARDIR/tmp/testdir/file3.txt;
---error 1
-rmdir $MYSQLTEST_VARDIR/tmp/testdir;
cat_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt;
diff --git a/storage/connect/mysql-test/connect/t/secure_file_priv.test b/storage/connect/mysql-test/connect/t/secure_file_priv.test
index 46633502034..f7792536892 100644
--- a/storage/connect/mysql-test/connect/t/secure_file_priv.test
+++ b/storage/connect/mysql-test/connect/t/secure_file_priv.test
@@ -10,4 +10,4 @@ let $SECUREDIR= `select @@secure_file_priv`;
INSERT INTO t1 VALUES (10);
SELECT * FROM t1;
DROP TABLE t1;
---remove_file $SECUREDIR/t1.dbf
+--remove_file $MYSQL_TMP_DIR/t1.dbf