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

The MySQL Test Framework, Version 2.0  /  Writing Test Cases  /  Using Include Files to Simplify Test Cases

4.12 Using Include Files to Simplify Test Cases

The include directory contains many files intended for inclusion into test case files. For example, if a test case needs to verify that the server supports the CSV storage engine, use this line in the test case file:

--source include/

These include files serve many purposes, but in general, they encapsulate operations of varying complexity into single files so that you can perform each operation in a single step. Include files are available for operations such as these:

  • Ensure that a given feature is available. The file checks to make sure that the feature is available and exits if not.

    • Storage engine tests: These files have names of the form, such as or The MyISAM, MERGE, and MEMORY storage engines are always supported and need not be checked.

    • Character set tests: These files have names of the form, such as or

    • Debugging capabilities: Include the file if a test requires that the server was built for debugging (that is, that the MySQL distribution was configured with the --with-debug option).

  • Wait for a condition to become true. Set the $wait_condition variable to an SQL statement that selects a value and then include the file. The include file executes the statement in a loop with a 0.1 second sleep between executions until the select value is nonzero. For example:

    let $wait_condition= SELECT c = 3 FROM t;
    --source include/
  • Control the binary log format. See Section 4.13, “Controlling the Binary Log Format Used for Tests”.

  • Control replication slave servers. See Section 4.14, “Writing Replication Tests”.

You can think of an include file as a rudimentary form of subroutine that is called at the point of inclusion. You can pass parameters by setting variables before including the file and referring to them within the file. You can return values by setting variables within the file and referring them following inclusion of the file.