my autotools project has a couple of unit-tests. one of these tests (filereader
) needs to read a file (data/test1.bin
)
Here's my filesystem layout: - libfoo/tests/filereader.c - libfoo/tests/data/test1.bin
and my libfoo/tests/Makefile.am:
AUTOMAKE_OPTIONS = foreign
AM_CPPFLAGS = -I$(top_srcdir)/foo
LDADD = $(top_builddir)/src/libfoo.la
EXTRA_DIST = data/file1.bin
TESTS = filereader
check_PROGRAMS= filereader
filereader_SOURCES = filereader.c
this works great, as long as i do in-tree builds. However, when running the test-suite out-of-tree (e.g. make distcheck
), the filereader
test cannot find the input file anymore.
This is obviously because only the source tree contains the input file, but not the build tree.
i wonder what is the canonical way to fix this problem?
- compile the directory of the test-file into the unittest (
AM_CPPFLAGS+=-DSRCDIR=$(srcdir)
) - pass the qualified input file as a cmdline argument to the test? (e.g.
$(builddir)/filereader $(srcdir)/data/file1.bin
) - copy the input file from the source tree to the build tree? (
cp $(srcdir)/data/file1.bin $(builddir)/data/file1.bin
? how would a proper make-rule look like??)
Aucun commentaire:
Enregistrer un commentaire