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 - we
plan to do this shortly. 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 `;' terminated statements and is similar
to the input of `mysql' command line client. A statement by
default is a query to be sent to MySQL server, unless it is
recognized as internal command ( eg. `sleep' ).
* All queries that produce results, e.g. `SELECT', `SHOW',
`EXPLAIN', etc., 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-case-name.test' from `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 and/or delete lines. If you have to insert a line, make
sure the fields are separated with a hard tab, and there is a hard
tab at the end. You may want to use `od -c' to make sure your
text editor has not messed anything up during edit. We, of
course, hope that you will never have to edit the output of
`mysqltest -r' as you only have to do it when you find a bug.
* To be consistent with our setup, you should put your result files
in `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', etc.
* If a statement returns an error, you should on the line before the
statement specify with the `--error error-number'. The error
number can be a list of possible error numbers separated with
`',''.
* If you are writing a replication test case, you should on the
first line of the test file, put `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 alternate 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 queries, use the `sleep' command. It supports
fractions of a second, so you can do `sleep 1.3;', for example, to
sleep 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, e-mail to <internals@lists.mysql.com>. As the list
does not accept attachments, you should ftp all the relevant files
to: <ftp://support.mysql.com/pub/mysql/Incoming>