How to write a test case
Store your test and run it
Say you have
foo.dyna and the corresponding C++ driver code
foo.cpp. You want to use them to make a test case.
Now there are two things you have to do:
- store them in a subdirectory of your choice under
dyna/test/. You can take one of the existing ones, like
misc/, or create your own one. It can be a deeply nested subdirectory if you want. The following description assumes that you choose the directory
- create a file
dyna/test/misc/foo.mk. It should have nothing but the following content:
NAME = misc/foo.mk include Makefile
The relative path
misc/foo.mk serves as name of your test.
Now, change up to the
dyna/test/ directory and run your test from there using the following command:
make -f misc/foo.mk run
Create expectation files and add test to CVS
If it runs as you intended (that might include a normal execution, but also any kind of intended failure that you wanted to test) you have to create the files that describe which stdin/stderr/exit code values etc are expected from this test:
It might say "Nothing to do for all" which is okay. The expectation files are now created.
Finally add it to the CVS repository with the following command, using as arguments the files you originally created. The Makefile
foo.mk and all expectation files are automatically added, too.
./add_to_cvs.pl misc/foo.cpp misc/foo.dyna
The test will always be run with
make test from the dyna root directory, and be listed in the weekly build e-mail. You can also run it yourself from the
dyna/test directory with
./runtests.pl -t misc/foo.mk
P.S.: You can also write fancier makefiles
foo.mk if you want to test something specific in the pipeline, do not have a C++ driver program, your driver program runs with certain arguments etc. For this purpose, have a look in one of the existing *.mk files under
P.P.S.: The .mk extension is optional in almost all cases: you can leave it out in the
NAME variable in
foo.mk and in the argument for