diff options
author | Martin Pitt <martin@piware.de> | 2017-02-15 23:37:25 +0100 |
---|---|---|
committer | Martin Pitt <martin@piware.de> | 2017-02-16 21:45:57 +0100 |
commit | cc100a5a9b135d2a033522a2ec60bec013b6ccd1 (patch) | |
tree | 01940923d7b14f8ae7e7e90962db85d59a9b3fde /src/test | |
parent | c60b6ddafbd462378073f85e4690455fc3908ad2 (diff) | |
download | systemd-cc100a5a9b135d2a033522a2ec60bec013b6ccd1.tar.gz |
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.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-cgroup-mask.c | 2 | ||||
-rw-r--r-- | src/test/test-engine.c | 2 | ||||
-rw-r--r-- | src/test/test-execute.c | 3 | ||||
-rw-r--r-- | src/test/test-helper.h | 5 | ||||
-rw-r--r-- | src/test/test-journal-importer.c | 6 | ||||
-rw-r--r-- | src/test/test-path.c | 2 | ||||
-rw-r--r-- | src/test/test-sched-prio.c | 2 |
7 files changed, 9 insertions, 13 deletions
diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c index adcff56bff..b42088c680 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 3c0c18b188..8133343fb3 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 145aa37a66..90540b884b 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 7c9eff2483..ddb10f88fd 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 1f0684863e..a61212ce7b 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 7f108440b1..70ac6b3df3 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 9a918cde20..81d9abc2d5 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)) { |