![]() | Makefile.am for automated tests |
| Prev | The Makefile.am Howto | Next |
This is an example Makefile.am for an automated test program.
METASOURCES = AUTO check_PROGRAMS = mytestprog.cpp TESTS = mytestprog mytestprog_SOURCES = mytestprog.cpp mytestprog_LDFLAGS = $all_libraries) $(KDE_RPATH) mytestprog_LDADD = ../libcommon.la AM_CPPFLAGES = -I$(srcdir)/..$(all_includes)
A common way of adding automated tests to your application is to create a subdirectory called tests. Add tests to the SUBDIRS line in parent Makefile.am and create a Makefile.am in the new tests directory. Use create_makefile to create the new Makefile, and now when you type make check the test program will be compiled (due to check_PROGRAMS) and run (due to TESTS). If the test program returns a non-zero value, make prints out an error message and stops. If the test program shouldn't run automatically (e.g. because it's interactive), omit the TESTS line.
Note that the test program needs to link to a library (either shared or convenience lib) containing the code it's testing. Don't link to a part, plugin or binary...
In case your test program needs command-line arguments, use a check-local target to launch it instead of TESTS:
check-local: mytestprog ./mytestprog $(srcdir)/datafile
This is Makefile syntax, the second line needs to start with a tab.
| Prev | Home | Next |
| Sharing code: convenience libs | Up | Installing data |