MySQL 9.0.0
Source Code Documentation
Cleaning Up from a Previous Test Run

For efficiency, the mysqltest test engine does not start with a clean new database for running each test case, so a test case generally starts with a “cleaning up section”.

Assume that a test case will use two tables named t1 and t2. The test case should begin by making sure that any old tables with those names do not exist:

--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings

The disable_warnings command instructs the test engine not to log any warnings until an enable_warnings command occurs or the test case is ended. (MySQL generates a warning if the table t1 or t2 does not exist.) Surrounding this part of the test case with commands to disable and enable warnings makes its output the same regardless of whether the tables exist before the test is started. After ensuring that the tables do not exist, we are free to put in any SQL statements that create and use the tables t1 and t2. The test case should also clean up at the end of the test by dropping any tables that it creates.

Let's put in some SQL code into this test case:

--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
CREATE TABLE t1 (
  Period SMALLINT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
  Varor_period SMALLINT(4) UNSIGNED DEFAULT '0' NOT NULL
);
CREATE TABLE t2 (Period SMALLINT);

INSERT INTO t1 VALUES (9410,9412);
INSERT INTO t2 VALUES (9410),(9411),(9412),(9413);

SELECT PERIOD FROM t1;
SELECT * FROM t1;
SELECT t1.* FROM t1;
SELECT * FROM t1 INNER JOIN t2 USING (Period);

DROP TABLE t1, t2;

If a test case creates other objects such as stored programs or user accounts, it should take care to also clean those up at the beginning and end of the test. Temporary files should also be removed, either at the end or just after they have been used.