The mysqltest program runs a test case against a MySQL server and optionally compares the output with a result file. This program reads input written in a special test language. Typically, you invoke mysqltest using mysql-test-run.pl rather than invoking it directly.
mysqltest_embedded is similar but is built
with support for the
Features of mysqltest:
Can send SQL statements to MySQL servers for execution
Can execute external shell commands
Can test whether the result from an SQL statement or shell command is as expected
Can connect to one or more standalone mysqld servers and switch between connections
Can connect to an embedded server (
libmysqld), if MySQL is compiled with support for
libmysqld. (In this case, the executable is named mysqltest_embedded rather than mysqltest.)
You can also name the test case file with a
The exit value from mysqltest is 0 for success, 1 for failure, and 62 if it skips the test case (for example, if after checking some preconditions it decides not to run the test).
mysqltest supports the following options:
Display a help message and exit.
The base directory for tests.
Define the mysqltest variable
$BIG_TESTas 1. This option was removed in MySQL 4.1.23, 5.0.30, and 5.1.13.
The directory where character sets are installed. This option was added in MySQL 4.1.23, 5.0.32, and 5.1.13.
Compress all information sent between the client and the server if both support compression.
Use cursors for prepared statements (implies
--ps-protocol). This option was added in MySQL 5.0.19.
The default database to use.
Write a debugging log if MySQL is built with debugging support. The default
Print some debugging information when the program exits. This option was added in MySQL 5.1.21.
Print debugging information and memory and CPU usage statistics when the program exits. This option was added in MySQL 5.1.14.
Connect to the MySQL server on the given host.
Include the contents of the given file before processing the contents of the test file. The included file should have the same format as other mysqltest test files. This option has the same effect as putting a
--sourcecommand as the first line of the test file. This option was added in MySQL 4.1.23, 5.0.30, and 5.1.7.
The directory to use for log files. This option was added in MySQL 5.1.14.
Write the line number and elapsed time to
. This option was added in MySQL 4.1.23, 5.0.30, and 5.1.12.
The maximum number of connection attempts when connecting to server. This option was added in MySQL 4.1.23, 5.0.23, and 5.1.11.
Do not read default options from any option files.
The password to use when connecting to the server. If you use the short option form (
-p), you cannot have a space between the option and the password. If you omit the
passwordvalue following the
-poption on the command line, you are prompted for one.
The TCP/IP port number to use for the connection.
Use the prepared-statement protocol for communication.
Record the output that results from running the test file into the file named by the
--result-fileoption, if that option is given.
This option specifies the file for test case expected results.
--result-file, together with
--record, determines how mysqltest treats the test actual and expected results for a test case:
If the test produces no results, mysqltest exits with an error message to that effect.
--result-fileis not given, mysqltest sends test results to the standard output.
--record, mysqltest reads the expected results from the given file and compares them with the actual results. If the results do not match, mysqltest writes a
.rejectfile in the same directory as the result file and exits with an error.
--record, mysqltest updates the given file by writing the actual test results to it.
Pass the argument as an argument to the embedded server. For example,
--server-arg=--core. Up to 64 arguments can be given.
Read arguments for the embedded server from the given file. The file should contain one argument per line.
Suppress all normal output.
Do not use memory allocation checking.
sleepcommands in the test case file to sleep
numseconds. This option does not affect
As of MySQL 5.0.23, an option value of 0 can be used, which effectively disables
sleepcommands in the test case.
The socket file to use when connecting to
localhost(which is the default host).
Execute DML statements within a stored procedure. For every DML statement, mysqltest creates and invokes a stored procedure that executes the statement rather than executing the statement directly. This option was added in MySQL 5.0.19.
Read test input from this file. The default is to read from the standard input.
The file where the timing in microseconds is written.
The temporary directory where socket files are put.
The MySQL user name to use when connecting to the server.
Verbose mode. Print out more information what the program does.
Display version information and exit.
SELECTstatement is wrapped inside a view. This option was added in MySQL 5.0.19.