(mysql.info) extending-mysqltest
Info Catalog
(mysql.info) running-mysqltest
(mysql.info) mysql-test-suite
(mysql.info) reporting-mysqltest-bugs
24.1.2.2 Extending the MySQL Test Suite
.......................................
You can use the `mysqltest' language to write your own test cases.
Unfortunately, we have not yet written full documentation for it. You
can, however, look at our current test cases and use them as an
example. The following points should help you get started:
* The tests are located in `mysql-test/t/*.test'
* A test case consists of statements terminated by `;' and is
similar to the input of `mysql' command-line client. A statement
by default is an SQL statement to be sent to MySQL server, unless
it is recognized as an internal `mysqltest' command (for example,
`sleep').
* All statements that produce results--for example, `SELECT',
`SHOW', or `EXPLAIN'--must be preceded with @/PATH/TO/RESULT/FILE.
The file must contain the expected results. An easy way to generate
the result file is to run `mysqltest -r < t/TEST_NAME.test' from
the `mysql-test' directory, and then edit the generated result
files, if needed, to adjust them to the expected output. In that
case, be very careful about not adding or deleting any invisible
characters. Make sure to only change the text or delete lines. If
you have to insert a line, make sure that the fields are separated
by a hard tab, and that there is a hard tab at the end. You may
want to use `od -c' to make sure that your text editor has not
messed up anything during editing. We hope that you never have to
edit the output of `mysqltest -r' because this should be necessary
only when you find a bug.
* To be consistent with our setup, you should put your result files
in the `mysql-test/r' directory and name them `TEST_NAME.result'.
If the test produces more than one result, you should use
`TEST_NAME.a.result', `TEST_NAME.b.result', and so forth.
* If a statement is expected to return an error, you should specify
it with -error ERROR_NUMBER on the line before the statement. You
can specify more than one error number, separated by commas.
* If you are writing a replication test case, the first line of the
test file should be `source include/master-slave.inc;'. To switch
between master and slave, use `connection master;' and `connection
slave;'. If you need to do something on an alternative connection,
you can do `connection master1;' for the master, and `connection
slave1;' for the slave.
* If you need to do something in a loop, you can use something like
this:
let $1=1000;
while ($1)
{
# do your queries here
dec $1;
}
* To sleep between statements, use the `sleep' command. It supports
fractions of a second. For example, `sleep 1.3;' sleeps 1.3
seconds.
* To run the slave with additional options for your test case, put
them in the command-line format in
`mysql-test/t/TEST_NAME-slave.opt'. For the master, put them in
`mysql-test/t/TEST_NAME-master.opt'.
* If you have a question about the test suite, or have a test case
to contribute, send an email message to the MySQL `internals'
mailing list. See mailing-lists. This list does not accept
attachments, so you should FTP all the relevant files to:
`ftp://ftp.mysql.com/pub/mysql/upload/'
Info Catalog
(mysql.info) running-mysqltest
(mysql.info) mysql-test-suite
(mysql.info) reporting-mysqltest-bugs
automatically generated byinfo2html