Documentation Home
The MySQL Test Framework, Version 2.0
Download this Manual
PDF (US Ltr) - 0.5Mb
PDF (A4) - 0.5Mb
EPUB - 129.0Kb


The MySQL Test Framework, Version 2.0  /  Writing Test Cases  /  Specifying Test Case-Specific Server Options

4.10 Specifying Test Case-Specific Server Options

Within a test case, many system variables can be set by using statements such as these:

SET sql_warnings=1;
SET sql_mode='NO_AUTO_VALUE_ON_ZERO';

But sometimes you need to restart the server to use command-line options that are specific to a given test case. You can specify these options in a file named mysql-test/t/test_name-master.opt. When a file named t/test_name-master.opt exists, mysql-test-run.pl examines it for extra options that the server needs to be run with when executing the test_name test case. If no server has yet been started or the current server is running with different options, mysql-test-run.pl restarts the server with the new options.

You may refer to environment variables in the option file, using the usual $VAR_NAME syntax. From MySQL 5.6, it is also possible to refer to optional variables using the syntax $?VAR_NAME. This will be replaced with an empty string if the variable is not set.

As a special case, the option --skip-core-file will be interpreted by mysql-test-run.pl, which will then block the server from producing any core files or crash dumps during this test. This may be useful for tests that intentionally crash the server.

Another special case is --testcase-timeout=minutes which can be used to set a different, longer timeout for a particular test case. The given timeout in minutes will be used for this test if it's longer than the default.

Files in the mysql-test/t directory with names ending in -slave.opt are similar, but they are used for slave servers in replication tests.

Sometimes it's also necessary to execute some external commands before starting the server, such as creating a directory. If you add a file named t/test_name-master.sh, it will be executed by mysql-test-run.pl before it starts the server; a similar file may be created for the slave in replication tests.

Because the .sh file is executed through /bin/sh, it cannot be used on Windows, and any tests using such a file will automatically be skipped if you run on Windows. For this reason, this mechanism may be replaced with a more portable one in some future release of MySQL.