DejaGnu: The GNU Testing Framework
<<< Previous | Extending DejaGnu | Next >>>

# Adding A Test Case To A Testsuite.

There are two slightly different ways to add a test case. One is to add the test case to an existing directory. The other is to create a new directory to hold your test. The existing test directories represent several styles of testing, all of which are slightly different; examine the directories for the tool of interest to see which (if any) is most suitable.

Adding a GCC test can be very simple: just add the C code to any directory beginning with `gcc`. and it runs on the next

    runtest --tool
          gcc

.

To add a test to GDB, first add any source code you will need to the test directory. Then you can either create a new expect file, or add your test to an existing one (any file with a .exp suffix). Creating a new .exp file is probably a better idea if the test is significantly different from existing tests. Adding it as a separate file also makes upgrading easier. If the C code has to be already compiled before the test will run, then you'll have to add it to the `Makefile.in` file for that test directory, then run configure and make.

Adding a test by creating a new directory is very similar:

- Create the new directory. All subdirectory names begin with the name of the tool to test; e.g. G++ tests might be in a directory called `g++.other`. There can be multiple test directories that start with the same tool name (such as g++).

- Add the new directory name to the configdirs definition in the `configure.in` file for the testsuite directory. This way when make and configure next run, they include the new directory.

- Add the new test case to the directory, as above.

- To add support in the new directory for configure and make, you must also create a `Makefile.in` and a `configure.in`.

<<< Previous | Home | Next >>>
Debugging A Test Case | Up | Hints On Writing A Test Case