uml*_*ute 5 automake unit-testing autotools
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
Run Code Online (Sandbox Code Playgroud)
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?
AM_CPPFLAGS+=-DSRCDIR=$(srcdir))$(builddir)/filereader $(srcdir)/data/file1.bin)cp $(srcdir)/data/file1.bin $(builddir)/data/file1.bin?一个合适的制作规则会是什么样的??)按照规范,解决方案是将文件的路径定义到单元测试中,因此您提出的第一个选项。第二种也是可能的,但它需要使用中间驱动程序脚本。
我建议避免第三种,但如果您确实想走那条路,请使用$(LN_S)而不是cp; 这样可以减少测试的 I/O 负载。
| 归档时间: |
|
| 查看次数: |
358 次 |
| 最近记录: |