]> git.ipfire.org Git - thirdparty/libvirt.git/commit
tests: guarantee abs_srcdir in all C tests
authorEric Blake <eblake@redhat.com>
Wed, 27 Nov 2013 21:31:53 +0000 (14:31 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 27 Nov 2013 21:39:56 +0000 (14:39 -0700)
commit0aa873d74118ea589f61fe46396335edeb1d955f
tree82febbb7af4f8dfbd7b600503b0f75c6186d9f38
parent69d20452cef49dcb55111248c5357b71f7ed8a74
tests: guarantee abs_srcdir in all C tests

While trying to debug a failure of virpcitest during 'make distcheck',
I noticed that with a VPATH build, 'cd tests; ./virpcitest' fails for
an entirely different reason.  To reproduce the distcheck failure, I
had to run 'cd tests; abs_srcdir=/path/to/src ./virpcitest'.  But we
document in HACKING that all of our tests are supposed to be runnable
without requiring extra environment variables.

The solution: hardcode the location of srcdir into the just-built
binaries, rather than requiring make to prepopulate environment
variables.  With this, './virpcitest' passes even in a VPATH build
(provided that $(srcdir) is writable; a followup patch will fix the
conditions required by 'make distcheck').  [Note: the makefile must
still pass on directory variables to the test environment of shell
scripts, since those aren't compiled.  So while this solves the case
of a compiled test, it still requires environment variables to pass
a VPATH build of any shell script test case that relies on srcdir.]

* tests/Makefile.am (AM_CFLAGS): Define abs_srcdir in all compiled
tests.
* tests/testutils.h (abs_srcdir): Quit declaring.
* tests/testutils.c (virtTestMain): Rely on define rather than
environment variable.
* tests/virpcimock.c (pci_device_new_from_stub): Rely on define.
* tests/cputest.c (mymain): Adjust abs_top_srcdir default.
* tests/qemuxml2argvtest.c (mymain): Likewise.
* tests/qemuxmlnstest.c (mymain): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
tests/Makefile.am
tests/cputest.c
tests/qemuxml2argvtest.c
tests/qemuxmlnstest.c
tests/testutils.c
tests/testutils.h
tests/virpcimock.c