From 28d6adfcbd1d532e233d3da197cb4d819d1bdd8f Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Tue, 14 Feb 2017 05:38:51 +0100 Subject: [PATCH 1/9] build-sys: fix "make install-tests" when srcdir != builddir Follow-up for 4f8425b8d5a3fb2e5ec24b77f1a7a95db55f532c --- Makefile.am | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 10839e922a1..dbd45754b20 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6714,14 +6714,14 @@ tests += \ .PHONY: install-tests install-tests: $(tests) $(TEST_DATA_FILES) for f in $(tests); do \ - if [ -x .libs/$$f ]; then \ - install -D -m 755 .libs/$$f $(DESTDIR)/$(testsdir)/$$f; \ + if [ -x $(top_builddir)/.libs/$$f ]; then \ + install -D -m 755 $(top_builddir)/.libs/$$f $(DESTDIR)/$(testsdir)/$$f; \ else \ - install -D -m 755 $$f $(DESTDIR)/$(testsdir)/$$f; \ + install -D -m 755 $(top_builddir)/$$f $(DESTDIR)/$(testsdir)/$$f; \ fi; \ done for f in $(TEST_DATA_FILES); do \ - install -D -m 644 $$f $(DESTDIR)/$(testsdir)/testdata/$${f#test/}; \ + install -D -m 644 $(top_srcdir)/$$f $(DESTDIR)/$(testsdir)/testdata/$${f#test/}; \ done From 916b5002861473879088dfa3bb6dfaac9cfdcc68 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 14 Feb 2017 08:47:29 +0100 Subject: [PATCH 2/9] test: run valgrind-tests under $TESTS_ENVIRONMENT Otherwise we are missing $TEST_DIR for the test data and run the test against the system-installed binaries and keyboard/locale maps. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index dbd45754b20..c725d6d1ace 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6613,7 +6613,7 @@ valgrind-tests: $(TESTS) if $(LIBTOOL) --mode=execute file $$f | grep -q shell; then \ echo -e "$${x}Skipping non-binary $$f"; else \ echo -e "$${x}Running $$f"; \ - $(LIBTOOL) --mode=execute valgrind -q --leak-check=full --max-stackframe=5242880 --error-exitcode=55 $(builddir)/$$f ; fi; \ + $(AM_TESTS_ENVIRONMENT) $(LIBTOOL) --mode=execute valgrind -q --leak-check=full --max-stackframe=5242880 --error-exitcode=55 $(builddir)/$$f ; fi; \ x="\n\n"; \ done From 31f8b331c77160019bb282c8b722ace5c9c290d4 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 14 Feb 2017 08:58:19 +0100 Subject: [PATCH 3/9] test: clarify error message if test data directory does not exist When trying to directly run a test executable in the build tree without setting $TEST_DIR, some tests fail with a non-obvious error message. Print an useful one instead. --- src/shared/tests.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/shared/tests.c b/src/shared/tests.c index 70346877251..189aa36bc69 100644 --- a/src/shared/tests.c +++ b/src/shared/tests.c @@ -42,5 +42,9 @@ const char* get_exe_relative_testdata_dir(void) { assert_se(readlink_and_make_absolute("/proc/self/exe", &exedir) >= 0); assert_se(snprintf(testdir, sizeof(testdir), "%s/testdata", dirname(exedir)) > 0); + if (access(testdir, F_OK) < 0) { + fprintf(stderr, "Test data directory '%s' does not exist, set $TEST_DIR\n", testdir); + exit(1); + } return testdir; } From 3e29e810ae48c96c17fdaca7ce9da9378eb4056d Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 14 Feb 2017 22:33:52 +0100 Subject: [PATCH 4/9] test: setup test data dir before fake runtime dir That way, if the test directory does not exist we don't leave behind temporary files (as in that case or on test failure the cleanup actions don't run). --- src/test/test-cgroup-mask.c | 4 ++-- src/test/test-engine.c | 3 +-- src/test/test-path.c | 2 +- src/test/test-sched-prio.c | 3 +-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c index 630587aaf18..adcff56bffe 100644 --- a/src/test/test-cgroup-mask.c +++ b/src/test/test-cgroup-mask.c @@ -27,6 +27,7 @@ #include "unit.h" static int test_cgroup_mask(void) { + _cleanup_(rm_rf_physical_and_freep) char *runtime_dir = NULL; Manager *m = NULL; Unit *son, *daughter, *parent, *root, *grandchild, *parent_deep; FILE *serial = NULL; @@ -35,6 +36,7 @@ static int test_cgroup_mask(void) { /* Prepare the manager. */ assert_se(set_unit_path(TEST_DATA_DIR("")) >= 0); + assert_se(runtime_dir = setup_fake_runtime_dir()); r = manager_new(UNIT_FILE_USER, true, &m); if (r == -EPERM || r == -EACCES) { puts("manager_new: Permission denied. Skipping test."); @@ -110,10 +112,8 @@ static int test_cgroup_mask(void) { } int main(int argc, char* argv[]) { - _cleanup_(rm_rf_physical_and_freep) char *runtime_dir = NULL; int rc = 0; - assert_se(runtime_dir = setup_fake_runtime_dir()); TEST_REQ_RUNNING_SYSTEMD(rc = test_cgroup_mask()); return rc; diff --git a/src/test/test-engine.c b/src/test/test-engine.c index 3ec2dfe10ef..3c0c18b188d 100644 --- a/src/test/test-engine.c +++ b/src/test/test-engine.c @@ -37,10 +37,9 @@ int main(int argc, char *argv[]) { Job *j; int r; - assert_se(runtime_dir = setup_fake_runtime_dir()); - /* prepare the test */ assert_se(set_unit_path(TEST_DATA_DIR("")) >= 0); + assert_se(runtime_dir = setup_fake_runtime_dir()); r = manager_new(UNIT_FILE_USER, true, &m); if (MANAGER_SKIP_TEST(r)) { log_notice_errno(r, "Skipping test: manager_new: %m"); diff --git a/src/test/test-path.c b/src/test/test-path.c index d09df3e8a5f..7f108440b1d 100644 --- a/src/test/test-path.c +++ b/src/test/test-path.c @@ -262,8 +262,8 @@ int main(int argc, char *argv[]) { log_parse_environment(); log_open(); - assert_se(runtime_dir = setup_fake_runtime_dir()); assert_se(set_unit_path(TEST_DATA_DIR("/test-path/")) >= 0); + assert_se(runtime_dir = setup_fake_runtime_dir()); for (test = tests; test && *test; test++) { int r; diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c index dab64fea575..9a918cde20b 100644 --- a/src/test/test-sched-prio.c +++ b/src/test/test-sched-prio.c @@ -34,10 +34,9 @@ int main(int argc, char *argv[]) { FDSet *fdset = NULL; int r; - assert_se(runtime_dir = setup_fake_runtime_dir()); - /* prepare the test */ assert_se(set_unit_path(TEST_DATA_DIR("")) >= 0); + assert_se(runtime_dir = setup_fake_runtime_dir()); r = manager_new(UNIT_FILE_USER, true, &m); if (MANAGER_SKIP_TEST(r)) { log_notice_errno(r, "Skipping test: manager_new: %m"); From 94fa1497ba98bb083632bd4d3f6cfcf6db8cff03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 14 Feb 2017 19:17:38 -0500 Subject: [PATCH 5/9] Rename $TEST_DIR to $SYSTEMD_TEST_DATA, document it TEST_DIR is rather generic, and we prefix all variables used by installed executables with "SYSTEMD_". --- ENVIRONMENT.md | 5 +++++ Makefile.am | 2 +- src/shared/tests.c | 2 +- src/test/test-helper.h | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ENVIRONMENT.md b/ENVIRONMENT.md index 1ad2addfeef..e542d4ec6fd 100644 --- a/ENVIRONMENT.md +++ b/ENVIRONMENT.md @@ -59,3 +59,8 @@ systemd-logind: * `$SYSTEMD_BYPASS_HIBERNATION_MEMORY_CHECK=1` — if set, report that hibernation is available even if the swap devices do not provide enough room for it. + +installed systemd tests: + +* `$SYSTEMD_TEST_DATA` — override the location of test data. This is useful if + a test executable is moved to an arbitrary location. diff --git a/Makefile.am b/Makefile.am index c725d6d1ace..a0eda73cb41 100644 --- a/Makefile.am +++ b/Makefile.am @@ -152,7 +152,7 @@ endif AM_TESTS_ENVIRONMENT = \ export SYSTEMD_KBD_MODEL_MAP=$(abs_top_srcdir)/src/locale/kbd-model-map; \ export SYSTEMD_LANGUAGE_FALLBACK_MAP=$(abs_top_srcdir)/src/locale/language-fallback-map; \ - export TEST_DIR=$(abs_top_srcdir)/test; \ + export SYSTEMD_TEST_DATA=$(abs_top_srcdir)/test; \ export PATH=$(abs_top_builddir):$$PATH; if ENABLE_BASH_COMPLETION diff --git a/src/shared/tests.c b/src/shared/tests.c index 189aa36bc69..bae113bdc8f 100644 --- a/src/shared/tests.c +++ b/src/shared/tests.c @@ -43,7 +43,7 @@ const char* get_exe_relative_testdata_dir(void) { assert_se(readlink_and_make_absolute("/proc/self/exe", &exedir) >= 0); assert_se(snprintf(testdir, sizeof(testdir), "%s/testdata", dirname(exedir)) > 0); if (access(testdir, F_OK) < 0) { - fprintf(stderr, "Test data directory '%s' does not exist, set $TEST_DIR\n", testdir); + fprintf(stderr, "Test data directory '%s' does not exist, set $SYSTEMD_TEST_DATA\n", testdir); exit(1); } return testdir; diff --git a/src/test/test-helper.h b/src/test/test-helper.h index 4e633ae6d81..02608434be4 100644 --- a/src/test/test-helper.h +++ b/src/test/test-helper.h @@ -43,4 +43,4 @@ ) #define TEST_DATA_DIR(subdir) \ - strjoina(getenv("TEST_DIR") ?: get_exe_relative_testdata_dir(), subdir) + strjoina(getenv("SYSTEMD_TEST_DATA") ?: get_exe_relative_testdata_dir(), subdir) From 1f35a3b2a4a6bdc97c0eacfee208e05b2f67f523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 14 Feb 2017 19:43:51 -0500 Subject: [PATCH 6/9] tests: look for tests relative to source dir when running from build dir automake helpfully sets a few variables for during build. When our executable is in a directory underneath $(abs_top_builddir), we know that we're in the build environment $(abs_top_srcdir) contains the sources, and test data is under $(abs_top_srcdir)/test. This remains true no matter where the build directory is relative to the source directory. It also works if the test executable is invoked as ./test-whatever or .libs/test-whatever, since the relative path is not used at all. When running from outside of the build directory, we should be running from the installed location and we can look for ../testdata relative to the location of the exe file. Of course, $SYSTEMD_TEST_DATA always overrides this logic. --- Makefile.am | 2 ++ src/shared/tests.c | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index a0eda73cb41..c8c8d31ef05 100644 --- a/Makefile.am +++ b/Makefile.am @@ -252,6 +252,8 @@ AM_CPPFLAGS = \ -I $(top_srcdir)/src/libsystemd/sd-device \ -I $(top_srcdir)/src/libsystemd/sd-id128 \ -I $(top_srcdir)/src/libsystemd-network \ + -DABS_SRC_DIR=\"$(abs_top_srcdir)\" \ + -DABS_BUILD_DIR=\"$(abs_top_builddir)\" \ $(OUR_CPPFLAGS) AM_CFLAGS = $(OUR_CFLAGS) diff --git a/src/shared/tests.c b/src/shared/tests.c index bae113bdc8f..f11b93bee72 100644 --- a/src/shared/tests.c +++ b/src/shared/tests.c @@ -24,6 +24,7 @@ #include #include "tests.h" +#include "path-util.h" char* setup_fake_runtime_dir(void) { char t[] = "/tmp/fake-xdg-runtime-XXXXXX", *p; @@ -41,10 +42,16 @@ const char* get_exe_relative_testdata_dir(void) { static char testdir[PATH_MAX]; assert_se(readlink_and_make_absolute("/proc/self/exe", &exedir) >= 0); + + /* Check if we're running from the builddir. If so, use the compiled in path. */ + if (path_startswith(exedir, ABS_BUILD_DIR)) + return ABS_SRC_DIR "/test"; + + /* Try relative path, according to the install-test layout */ assert_se(snprintf(testdir, sizeof(testdir), "%s/testdata", dirname(exedir)) > 0); - if (access(testdir, F_OK) < 0) { - fprintf(stderr, "Test data directory '%s' does not exist, set $SYSTEMD_TEST_DATA\n", testdir); - exit(1); - } - return testdir; + if (access(testdir, F_OK) >= 0) + return testdir; + + fputs("ERROR: Cannot find testdata directory, set $SYSTEMD_TEST_DATA\n", stderr); + exit(1); } From c60b6ddafbd462378073f85e4690455fc3908ad2 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 15 Feb 2017 08:52:17 +0100 Subject: [PATCH 7/9] test: show error message if $SYSTEMD_TEST_DATA does not exist Rename get_exe_relative_testdata_dir() to get_testdata_dir() and move the env var check into that, so that everything interesting happens at the same place. --- src/shared/tests.c | 13 ++++++++++++- src/shared/tests.h | 2 +- src/test/test-helper.h | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/shared/tests.c b/src/shared/tests.c index f11b93bee72..be098b304cb 100644 --- a/src/shared/tests.c +++ b/src/shared/tests.c @@ -36,11 +36,22 @@ char* setup_fake_runtime_dir(void) { return p; } -const char* get_exe_relative_testdata_dir(void) { +const char* get_testdata_dir(void) { + const char *env; _cleanup_free_ char *exedir = NULL; /* convenience: caller does not need to free result */ static char testdir[PATH_MAX]; + /* if the env var is set, use that */ + env = getenv("SYSTEMD_TEST_DATA"); + if (env) { + if (access(env, F_OK) >= 0) + return env; + + fputs("ERROR: $SYSTEMD_TEST_DATA directory does not exist\n", stderr); + exit(1); + } + assert_se(readlink_and_make_absolute("/proc/self/exe", &exedir) >= 0); /* Check if we're running from the builddir. If so, use the compiled in path. */ diff --git a/src/shared/tests.h b/src/shared/tests.h index 0100b489374..927b9fc2bb7 100644 --- a/src/shared/tests.h +++ b/src/shared/tests.h @@ -20,4 +20,4 @@ ***/ char* setup_fake_runtime_dir(void); -const char* get_exe_relative_testdata_dir(void); +const char* get_testdata_dir(void); diff --git a/src/test/test-helper.h b/src/test/test-helper.h index 02608434be4..7c9eff24835 100644 --- a/src/test/test-helper.h +++ b/src/test/test-helper.h @@ -42,5 +42,5 @@ -ENOMEDIUM /* cannot determine cgroup */ \ ) -#define TEST_DATA_DIR(subdir) \ - strjoina(getenv("SYSTEMD_TEST_DATA") ?: get_exe_relative_testdata_dir(), subdir) +#define TEST_DATA_DIR(subdir) \ + strjoina(get_testdata_dir(), subdir) From cc100a5a9b135d2a033522a2ec60bec013b6ccd1 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 15 Feb 2017 23:37:25 +0100 Subject: [PATCH 8/9] test: drop TEST_DATA_DIR, fold into get_testdata_dir() Drop the TEST_DATA_DIR macro as this was using alloca() within a function call which is allegedly unsafe. So add a "suffix" argument to get_testdata_dir() instead and call that directly. --- src/resolve/test-dns-packet.c | 5 ++-- src/shared/tests.c | 43 ++++++++++++++++++-------------- src/shared/tests.h | 2 +- src/test/test-cgroup-mask.c | 2 +- src/test/test-engine.c | 2 +- src/test/test-execute.c | 3 ++- src/test/test-helper.h | 5 ---- src/test/test-journal-importer.c | 6 ++--- src/test/test-path.c | 2 +- src/test/test-sched-prio.c | 2 +- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/resolve/test-dns-packet.c b/src/resolve/test-dns-packet.c index 3ca7e784956..8cbe492526e 100644 --- a/src/resolve/test-dns-packet.c +++ b/src/resolve/test-dns-packet.c @@ -29,10 +29,9 @@ #include "resolved-dns-rr.h" #include "string-util.h" #include "strv.h" +#include "tests.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) { @@ -117,7 +116,7 @@ int main(int argc, char **argv) { N = argc - 1; fnames = argv + 1; } else { - assert_se(glob(TEST_DATA_DIR("/test-resolve/*.pkts"), GLOB_NOSORT, NULL, &g) == 0); + assert_se(glob(get_testdata_dir("/test-resolve/*.pkts"), GLOB_NOSORT, NULL, &g) == 0); N = g.gl_pathc; fnames = g.gl_pathv; } diff --git a/src/shared/tests.c b/src/shared/tests.c index be098b304cb..f300bbc66f3 100644 --- a/src/shared/tests.c +++ b/src/shared/tests.c @@ -36,33 +36,38 @@ char* setup_fake_runtime_dir(void) { return p; } -const char* get_testdata_dir(void) { +const char* get_testdata_dir(const char *suffix) { const char *env; - _cleanup_free_ char *exedir = NULL; /* convenience: caller does not need to free result */ static char testdir[PATH_MAX]; /* if the env var is set, use that */ env = getenv("SYSTEMD_TEST_DATA"); + testdir[sizeof(testdir) - 1] = '\0'; if (env) { - if (access(env, F_OK) >= 0) - return env; + if (access(env, F_OK) < 0) { + fputs("ERROR: $SYSTEMD_TEST_DATA directory does not exist\n", stderr); + exit(1); + } + strncpy(testdir, env, sizeof(testdir) - 1); + } else { + _cleanup_free_ char *exedir = NULL; + assert_se(readlink_and_make_absolute("/proc/self/exe", &exedir) >= 0); - fputs("ERROR: $SYSTEMD_TEST_DATA directory does not exist\n", stderr); - exit(1); + /* Check if we're running from the builddir. If so, use the compiled in path. */ + if (path_startswith(exedir, ABS_BUILD_DIR)) + assert_se(snprintf(testdir, sizeof(testdir), "%s/test", ABS_SRC_DIR) > 0); + else + /* Try relative path, according to the install-test layout */ + assert_se(snprintf(testdir, sizeof(testdir), "%s/testdata", dirname(exedir)) > 0); + + /* test this without the suffix, as it may contain a glob */ + if (access(testdir, F_OK) < 0) { + fputs("ERROR: Cannot find testdata directory, set $SYSTEMD_TEST_DATA\n", stderr); + exit(1); + } } - assert_se(readlink_and_make_absolute("/proc/self/exe", &exedir) >= 0); - - /* Check if we're running from the builddir. If so, use the compiled in path. */ - if (path_startswith(exedir, ABS_BUILD_DIR)) - return ABS_SRC_DIR "/test"; - - /* Try relative path, according to the install-test layout */ - assert_se(snprintf(testdir, sizeof(testdir), "%s/testdata", dirname(exedir)) > 0); - if (access(testdir, F_OK) >= 0) - return testdir; - - fputs("ERROR: Cannot find testdata directory, set $SYSTEMD_TEST_DATA\n", stderr); - exit(1); + strncpy(testdir + strlen(testdir), suffix, sizeof(testdir) - strlen(testdir) - 1); + return testdir; } diff --git a/src/shared/tests.h b/src/shared/tests.h index 927b9fc2bb7..70551249908 100644 --- a/src/shared/tests.h +++ b/src/shared/tests.h @@ -20,4 +20,4 @@ ***/ char* setup_fake_runtime_dir(void); -const char* get_testdata_dir(void); +const char* get_testdata_dir(const char *suffix); diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c index adcff56bffe..b42088c680a 100644 --- a/src/test/test-cgroup-mask.c +++ b/src/test/test-cgroup-mask.c @@ -35,7 +35,7 @@ static int test_cgroup_mask(void) { int r; /* Prepare the manager. */ - assert_se(set_unit_path(TEST_DATA_DIR("")) >= 0); + assert_se(set_unit_path(get_testdata_dir("")) >= 0); assert_se(runtime_dir = setup_fake_runtime_dir()); r = manager_new(UNIT_FILE_USER, true, &m); if (r == -EPERM || r == -EACCES) { diff --git a/src/test/test-engine.c b/src/test/test-engine.c index 3c0c18b188d..8133343fb37 100644 --- a/src/test/test-engine.c +++ b/src/test/test-engine.c @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) { int r; /* prepare the test */ - assert_se(set_unit_path(TEST_DATA_DIR("")) >= 0); + assert_se(set_unit_path(get_testdata_dir("")) >= 0); assert_se(runtime_dir = setup_fake_runtime_dir()); r = manager_new(UNIT_FILE_USER, true, &m); if (MANAGER_SKIP_TEST(r)) { diff --git a/src/test/test-execute.c b/src/test/test-execute.c index 145aa37a668..90540b884bf 100644 --- a/src/test/test-execute.c +++ b/src/test/test-execute.c @@ -35,6 +35,7 @@ #endif #include "stat-util.h" #include "test-helper.h" +#include "tests.h" #include "unit.h" #include "util.h" #include "virt.h" @@ -516,7 +517,7 @@ int main(int argc, char *argv[]) { } assert_se(setenv("XDG_RUNTIME_DIR", "/tmp/", 1) == 0); - assert_se(set_unit_path(TEST_DATA_DIR("/test-execute/")) >= 0); + assert_se(set_unit_path(get_testdata_dir("/test-execute")) >= 0); /* Unset VAR1, VAR2 and VAR3 which are used in the PassEnvironment test * cases, otherwise (and if they are present in the environment), diff --git a/src/test/test-helper.h b/src/test/test-helper.h index 7c9eff24835..ddb10f88fd1 100644 --- a/src/test/test-helper.h +++ b/src/test/test-helper.h @@ -20,8 +20,6 @@ ***/ #include "sd-daemon.h" -#include "string-util.h" -#include "tests.h" #include "macro.h" @@ -41,6 +39,3 @@ -ENOENT, \ -ENOMEDIUM /* cannot determine cgroup */ \ ) - -#define TEST_DATA_DIR(subdir) \ - strjoina(get_testdata_dir(), subdir) diff --git a/src/test/test-journal-importer.c b/src/test/test-journal-importer.c index 1f0684863e9..a61212ce7b7 100644 --- a/src/test/test-journal-importer.c +++ b/src/test/test-journal-importer.c @@ -24,7 +24,7 @@ #include "log.h" #include "journal-importer.h" #include "string-util.h" -#include "test-helper.h" +#include "tests.h" static void assert_iovec_entry(const struct iovec *iovec, const char* content) { assert_se(strlen(content) == iovec->iov_len); @@ -39,7 +39,7 @@ static void test_basic_parsing(void) { _cleanup_(journal_importer_cleanup) JournalImporter imp = {}; int r; - imp.fd = open(TEST_DATA_DIR("/journal-data/journal-1.txt"), O_RDONLY|O_CLOEXEC); + imp.fd = open(get_testdata_dir("/journal-data/journal-1.txt"), O_RDONLY|O_CLOEXEC); assert_se(imp.fd >= 0); do @@ -68,7 +68,7 @@ static void test_bad_input(void) { _cleanup_(journal_importer_cleanup) JournalImporter imp = {}; int r; - imp.fd = open(TEST_DATA_DIR("/journal-data/journal-2.txt"), O_RDONLY|O_CLOEXEC); + imp.fd = open(get_testdata_dir("/journal-data/journal-2.txt"), O_RDONLY|O_CLOEXEC); assert_se(imp.fd >= 0); do diff --git a/src/test/test-path.c b/src/test/test-path.c index 7f108440b1d..70ac6b3df35 100644 --- a/src/test/test-path.c +++ b/src/test/test-path.c @@ -262,7 +262,7 @@ int main(int argc, char *argv[]) { log_parse_environment(); log_open(); - assert_se(set_unit_path(TEST_DATA_DIR("/test-path/")) >= 0); + assert_se(set_unit_path(get_testdata_dir("/test-path")) >= 0); assert_se(runtime_dir = setup_fake_runtime_dir()); for (test = tests; test && *test; test++) { diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c index 9a918cde20b..81d9abc2d51 100644 --- a/src/test/test-sched-prio.c +++ b/src/test/test-sched-prio.c @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) { int r; /* prepare the test */ - assert_se(set_unit_path(TEST_DATA_DIR("")) >= 0); + assert_se(set_unit_path(get_testdata_dir("")) >= 0); assert_se(runtime_dir = setup_fake_runtime_dir()); r = manager_new(UNIT_FILE_USER, true, &m); if (MANAGER_SKIP_TEST(r)) { From e53bcabb4b885ec998cc693e0788c3d68617bef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 16 Feb 2017 23:00:03 -0500 Subject: [PATCH 9/9] build-sys: drop now-unneeded $SYSTEMD_TEST_DATA when running tests --- Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index c8c8d31ef05..87923691612 100644 --- a/Makefile.am +++ b/Makefile.am @@ -152,7 +152,6 @@ endif AM_TESTS_ENVIRONMENT = \ export SYSTEMD_KBD_MODEL_MAP=$(abs_top_srcdir)/src/locale/kbd-model-map; \ export SYSTEMD_LANGUAGE_FALLBACK_MAP=$(abs_top_srcdir)/src/locale/language-fallback-map; \ - export SYSTEMD_TEST_DATA=$(abs_top_srcdir)/test; \ export PATH=$(abs_top_builddir):$$PATH; if ENABLE_BASH_COMPLETION