MySQL 9.1.0
Source Code Documentation
Using Include Files to Simplify Test Cases

The include directory contains many files intended for inclusion into test case files.

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 have_engine_name.inc, such as have_archive.inc or have_blackhole.inc. The MyISAM, MERGE, and MEMORY storage engines are always supported and need not be checked.

    • Windows specific tests: Include have_windows.inc file if a test runs only on windows machines.

    • Debugging capabilities: Include the have_debug.inc 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 wait_condition.inc 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/wait_condition.inc

  • Control the binary log format. See Controlling the Binary Log Format Used for Tests.

  • Control replication slave servers. See 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.