summaryrefslogtreecommitdiff
path: root/src/resolve
diff options
context:
space:
mode:
authorMartin Pitt <martin@piware.de>2017-02-12 23:14:43 +0100
committerMartin Pitt <martin@piware.de>2017-02-13 22:31:13 +0100
commitf853c6efb509589c8e3a82caa3af2ac5a370ae97 (patch)
tree4b5e46c4dfc6a9dfd701db8c29975d546b0b9ece /src/resolve
parentee3c7ff7c303cdbc8fea18d3a6f3c4c6e7c450d8 (diff)
test: make unit tests relocatable
It is useful to package test-* binaries and run them as root under autopkgtest or manually on particular machines. They currently have a built-in hardcoded absolute path to their test data, which does not work when running the test programs from any other path than the original build directory. By default, make the tests look for their data in <test_exe_directory>/testdata/ so that they can be called from any directory (provided that the corresponding test data is installed correctly). As we don't have a fixed static path in the build tree (as build and source tree are independent), set $TEST_DIR with "make check" to point to <srcdir>/test/, as we previously did with an automake variable.
Diffstat (limited to 'src/resolve')
-rw-r--r--src/resolve/test-dns-packet.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/resolve/test-dns-packet.c b/src/resolve/test-dns-packet.c
index 957b8677ba..3ca7e78495 100644
--- a/src/resolve/test-dns-packet.c
+++ b/src/resolve/test-dns-packet.c
@@ -31,6 +31,8 @@
#include "strv.h"
#include "unaligned.h"
+#include "test-helper.h"
+
#define HASH_KEY SD_ID128_MAKE(d3,1e,48,90,4b,fa,4c,fe,af,9d,d5,a1,d7,2e,8a,b1)
static void verify_rr_copy(DnsResourceRecord *rr) {
@@ -115,7 +117,7 @@ int main(int argc, char **argv) {
N = argc - 1;
fnames = argv + 1;
} else {
- assert_se(glob(TEST_DIR "/test-resolve/*.pkts", GLOB_NOSORT, NULL, &g) == 0);
+ assert_se(glob(TEST_DATA_DIR("/test-resolve/*.pkts"), GLOB_NOSORT, NULL, &g) == 0);
N = g.gl_pathc;
fnames = g.gl_pathv;
}