# The mariadb-test and mariadb-test-embedded Programs

The `mariadb-test` program runs a test case against a MariaDB or MySQL\
server and optionally compares the output with a result file. This program\
reads input written in a special test language. Typically, you invok&#x65;_&#x6D;ariadb-test_ via [mariadb-test-run.pl](https://mariadb.com/kb/en/mariadb-test-runpl) rather than invoking\
it directly.

`mariadb-test_embedded` is similar but is built with support for\
the `libmariadbd` embedded server.

Features of mariadb-test:

* Can send SQL statements to the server 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 mariadbd servers and switch\
  between connections
* Can connect to an embedded server (libmariadbd), if MariaDB is compiled\
  with support for libmariadbd. (In this case, the executable is named\
  mariadb-test\_embedded rather than mariadb-test.)

By default, mariadb-test reads the test case on the standard input. To run\
mariadb-test this way, you normally invoke it like this:

```
shell> mariadb-test **[options] [db_name]** < //test_file//
```

You can also name the test case file with a`--test-file=file_name` option.

The exit value from mariadb-test 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).

## Options

mariadb-test supports the following options:

| Option                                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --help, -?                                     | Display a help message and exit.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| --basedir=dir, -b dir                          | The base directory for tests.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| --character-sets-dir=path                      | The directory where [character sets](https://github.com/mariadb-corporation/docs-server/blob/test/general-resources/community/data-types/string-data-types/character-sets/README.md) are installed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| --compress, -C                                 | Compress all information sent between the client and the server if both support compression.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| --connect-timeout=N                            | This can be used to set the MYSQL\_OPT\_CONNECT\_TIMEOUT parameter of mysql\_options to change the number of seconds before an unsuccessful connection attempt times out.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| --continue-on-error                            | Continue test even if we got an error. This is mostly useful when testing a storage engine to see what from a test file it can execute, or to find all syntax errors in a newly created big test file                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| --cursor-protocol                              | Use cursors for prepared statements.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| --database=db\_name, -D db\_name               | The default database to use.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| --debug\[=debug\_options], -#\[debug\_options] | Write a debugging log if MariaDB is built with debugging support. The default debug\_options value is d:t:S:i:O,/tmp/mysqltest.trace on Unix and d:t:i:O,\mysqld.trace on Windows.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| --debug-check                                  | Print some debugging information when the program exits.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| --debug-info                                   | Print debugging information and memory and CPU usage statistics when the program exits.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| --host=host\_name, -h host\_name               | Connect to the server on the given host.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| --logdir=dir\_name                             | The directory to use for log files.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| --mark-progress                                | Write the line number and elapsed time to test\_file.progress.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| --max-connect-retries=num                      | The maximum number of connection attempts when connecting to server.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| --max-connections=num                          | The maximum number of simultaneous server connections per client (that is, per test). If not set, the maximum is 128. Minimum allowed limit is 8, maximum is 5120.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| --no-defaults                                  | Do not read default options from any option files. If used, this must be the first option.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| --non-blocking-api                             | Use the non-blocking client API for communication.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| --overlay-dir=name                             | Overlay directory.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| --password\[=password], -p\[password]          | 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 password value following the --password or -p option on the command line, you are prompted for one.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| plugin-dir                                     | Directory for client-side plugins.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| --port=port\_num, -P port\_num                 | The TCP/IP port number to use for the connection, or 0 for default to, in order of preference, my.cnf, $MYSQL\_TCP\_PORT, /etc/services, built-in default (3306).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| --prologue=name                                | 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 mariadb-test test files. This option has the same effect as putting a --source file\_name command as the first line of the test file.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| --protocol=name                                | The protocol to use for connection (tcp, socket, pipe, memory).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| --ps-protocol                                  | Use the prepared-statement protocol for communication.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| --quiet                                        | Suppress all normal output. This is a synonym for --silent.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| --record, -r                                   | Record the output that results from running the test file into the file named by the --result-file option, if that option is given. It is an error to use this option without also using --result-file.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| --result-file=file\_name, -R file\_name        | This option specifies the file for test case expected results. --result-file, together with --record, determines how mariadb-test treats the test actual and expected results for a test case:If the test produces no results, mariadb-test exits with an error message to that effect, unless --result-file is given and the named file is an empty file.Otherwise, if --result-file is not given, mariadb-test sends test results to the standard output. With --result-file but not --record, mariadb-test reads the expected results from the given file and compares them with the actual results. If the results do not match, mariadb-test writes a reject file in the same directory as the result file, outputs a diff of the two files, and exits with an error. With both --result-file and --record, mariadb-test updates the given file by writing the actual test results to it. |
| --result-format-version=#                      | Version of the result file format to use.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| --server-arg=value, -A value                   | Pass the argument as an argument to the embedded server. For example, --server-arg=--tmpdir=/tmp or --server-arg=--core. Up to 64 arguments can be given.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| --server-file=file\_name, -F file\_name        | Read arguments for the embedded server from the given file. The file should contain one argument per line.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| --shared-memory-base-name                      | Shared-memory name to use for Windows connections using shared memory to a local server (started with the --shared-memory option). Case-sensitive.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| --silent, -s                                   | Suppress all normal output.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| --sleep=num, -T num                            | Cause all sleep commands in the test case file to sleep num seconds. This option does not affect real\_sleep commands. An option value of 0 can be used, which effectively disables sleep commands in the test case.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| --socket=path, -S path                         | The socket file to use when connecting to localhost (which is the default host).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| --sp-protocol                                  | Execute DML statements within a stored procedure. For every DML statement, mariadb-test creates and invokes a stored procedure that executes the statement rather than executing the statement directly.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| --ssl                                          | Enable [TLS for secure connection](https://github.com/mariadb-corporation/docs-server/blob/test/general-resources/security/securing-mariadb/securing-mariadb-encryption/data-in-transit-encryption/secure-connections-overview.md) (automatically enabled with other flags). Disable with --skip-ssl.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| --ssl-ca=name                                  | CA file in PEM format (check OpenSSL docs, implies --ssl).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| --ssl-capath=name                              | CA directory (check OpenSSL docs, implies --ssl).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| --ssl-cert=name                                | X509 cert in PEM format (implies --ssl).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| --ssl-cipher=name                              | SSL cipher to use (implies --ssl).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| --ssl-key=name                                 | X509 key in PEM format (implies --ssl).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| --ssl-crl=name                                 | Certificate revocation list (implies --ssl).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| --ssl-crlpath=name                             | Certificate revocation list path (implies --ssl).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| --ssl-verify-server-cert                       | Verify server's "Common Name" in its cert against hostname used when connecting. This option is disabled by default.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| --suite-dir=name                               | Suite directory.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| --tail-lines=nn                                | Specify how many lines of the result to include in the output if the test fails because an SQL statement fails. The default is 0, meaning no lines of result printed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| --test-file=file\_name, -x file\_name          | Read test input from this file. The default is to read from the standard input.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| --timer-file=file\_name, -m file\_name         | If given, the number of microseconds spent running the test will be written to this file. This is used by [mariadb-test-run.pl](https://github.com/mariadb-corporation/docs-server/blob/test/general-resources/community/mariadb-internals/using-mariadb-with-your-programs-api/libmysqld/mariadb-test-runpl-options/README.md) for its reporting.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| --tmpdir=dir\_name, -t dir\_name               | The temporary directory where socket files are created.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| --user=user\_name, -u user\_name               | The user name to use when connecting to the server.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| --verbose, -v                                  | Verbose mode. Print out more information about what the program does.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| --version, -V                                  | Display version information and exit.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| --view-protocol                                | Every SELECT statement is wrapped inside a view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| --wait-longer-for-timeouts                     | Wait longer for timeouts. Useful when running under valgrind.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

## See Also

* [New Features for mysqltest in MariaDB](https://github.com/mariadb-corporation/docs-server/blob/test/general-resources/clients-and-utilities/mariadb-test/new-features-for-mysqltest-in-mariadb.md)

<sub>_This page is licensed: GPLv2_</sub>

{% @marketo/form formId="4316" %}
