Developers/System Tests

From Dyna
Jump to: navigation, search

Contents

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 dyna/test/misc.
  • 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:

./create_expectation_files.sh misc/foo.mk

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

That's it!

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 dyna/test/.

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 create_expectation_files.sh, add_to_cvs.pl and runtests.pl.

Personal tools
Namespaces

Variants
Actions
Navigation
Tools