From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> Define 'abs_srcdir' in AM_CFLAGS, just as we do for 'abs_builddir'. This lets test files write code like abs_srcdir "/some/file" and thus avoid the tedium of virAsprintf() to build paths in some places. Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx> --- tests/Makefile.am | 1 + tests/testutils.c | 12 ------------ tests/testutils.h | 1 - tests/virpcimock.c | 5 ----- 4 files changed, 1 insertion(+), 18 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index e46d5f7..520fd2a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -29,6 +29,7 @@ INCLUDES = \ AM_CFLAGS = \ -Dabs_builddir="\"`pwd`\"" \ + -Dabs_srcdir="\"`cd '$(srcdir)'; pwd`\"" \ $(LIBXML_CFLAGS) \ $(GNUTLS_CFLAGS) \ $(SASL_CFLAGS) \ diff --git a/tests/testutils.c b/tests/testutils.c index 5d634b4..2a75f6c 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -69,7 +69,6 @@ static size_t testStart = 0; static size_t testEnd = 0; char *progname; -char *abs_srcdir; void virtTestResult(const char *name, int ret, const char *msg, ...) { @@ -535,17 +534,8 @@ int virtTestMain(int argc, int (*func)(void)) { int ret; - bool abs_srcdir_cleanup = false; char *testRange = NULL; - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) { - abs_srcdir = getcwd(NULL, 0); - abs_srcdir_cleanup = true; - } - if (!abs_srcdir) - return EXIT_AM_HARDFAIL; - progname = last_component(argv[0]); if (STRPREFIX(progname, "lt-")) progname += 3; @@ -599,8 +589,6 @@ int virtTestMain(int argc, ret = (func)(); - if (abs_srcdir_cleanup) - VIR_FREE(abs_srcdir); virResetLastError(); if (!virTestGetVerbose() && ret != EXIT_AM_SKIP) { if (testCounter == 0 || testCounter % 40) diff --git a/tests/testutils.h b/tests/testutils.h index 478b53c..66f25b0 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -38,7 +38,6 @@ # endif extern char *progname; -extern char *abs_srcdir; void virtTestResult(const char *name, int ret, const char *msg, ...) ATTRIBUTE_FMT_PRINTF(3,4); diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 19062c3..a0b9643 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -305,11 +305,6 @@ pci_device_new_from_stub(const struct pciDevice *data) char *configSrc, *configDst; char tmp[32]; struct stat sb; - char *abs_srcdir; - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(NULL, 0); if (VIR_ALLOC_QUIET(dev) < 0 || virAsprintfQuiet(&configSrc, "%s/virpcitestdata/%s.config", abs_srcdir, data->id) < 0 || -- 1.8.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list