Home | Previous Page | Next Page   Debugging and Testing DataBlade Modules on UNIX > Performing Functional Tests >

Executing Functional Tests

To execute functional scripts, use the main.sh script. Execute a command in all test directories by executing the main.sh command in the top-level test directory. You can execute tests for a specific DataBlade module object by executing main.sh in that object's test directory.

The first time you execute the tests, initialize the reference files. See Initializing Reference Files for instructions.

The TESTDB environment variable must be set to the name of the test database.

Using the Functional Test Scripts

The main.sh script is a Bourne shell script that accepts one of five possible command line parameters, as described in the following table.

Command Description
main.sh build Runs user.sh with a "build" target.

Runs the setup.sql script.

main.sh clean Deletes .log files.

Runs user.sh with a "clean" target.

Executes clean.sql in the database.

main.sh run Uses DB-Access to run each SQL script generated by BladeSmith, saving the output in a .log file.

If a .req file exists, calls diff to determine the test result. It prints a message telling whether the test passed or failed.

After all BladeSmith-generated tests are run, executes user.sh with a "run" target.

main.sh save Copies all .log files to .req files, overwriting existing .req files.
main.sh all Performs the "build," "run," and "clean" actions. Use this shortcut after the .req files have been saved.

Initializing Reference Files

The first time you run tests, execute the "build" and "run" targets, as follows:

main.sh build
main.sh run

These two steps prepare the database, run the test scripts, and generate .log files. The results of all tests are unknown (no reference file).

Check the results in each .log file to determine if the test returned the correct result. The expected result (which was entered with the test data in BladeSmith) is shown in a comment.

If the results are incorrect, you might need to fix the DataBlade module C code. In other cases, the test data can be incorrect.

When the tests return correct results, create reference files by executing the "save" target, as follows:

main.sh save

After reference files have been saved, use the "all" shortcut target to build and run the tests and clean up the database and test directory.

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]