summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-cgroup-mask.c6
-rw-r--r--src/test/test-engine.c5
-rw-r--r--src/test/test-execute.c3
-rw-r--r--src/test/test-helper.h5
-rw-r--r--src/test/test-journal-importer.c6
-rw-r--r--src/test/test-path.c2
-rw-r--r--src/test/test-sched-prio.c5
7 files changed, 13 insertions, 19 deletions
diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c
index 630587aaf1..b42088c680 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;
@@ -34,7 +35,8 @@ 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) {
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 3ec2dfe10e..8133343fb3 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(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)) {
log_notice_errno(r, "Skipping test: manager_new: %m");
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 4e633ae6d8..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(getenv("TEST_DIR") ?: get_exe_relative_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 d09df3e8a5..70ac6b3df3 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(set_unit_path(get_testdata_dir("/test-path")) >= 0);
assert_se(runtime_dir = setup_fake_runtime_dir());
- assert_se(set_unit_path(TEST_DATA_DIR("/test-path/")) >= 0);
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 dab64fea57..81d9abc2d5 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(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)) {
log_notice_errno(r, "Skipping test: manager_new: %m");