diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-02-06 17:35:53 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-02-06 19:29:33 -0500 |
commit | c5e33bf8342daa6bab22f495ef774741184de09d (patch) | |
tree | be7c25b203db65fb9cdde0277ebfe0e6b44b92c4 /src | |
parent | 10ddd913f0d13584e13b5e6bbcb381f1618c90c0 (diff) |
tests: skip tests if manager cannot be created
When running without a user session, tests fail.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test-sched-prio.c | 10 | ||||
-rw-r--r-- | src/test/test-unit-name.c | 10 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c index 63f7ebda08..c57f6a3671 100644 --- a/src/test/test-sched-prio.c +++ b/src/test/test-sched-prio.c @@ -30,10 +30,16 @@ int main(int argc, char *argv[]) { Service *ser; FILE *serial = NULL; FDSet *fdset = NULL; + int r; /* prepare the test */ assert_se(set_unit_path(TEST_DIR) >= 0); - assert_se(manager_new(SYSTEMD_USER, &m) >= 0); + r = manager_new(SYSTEMD_USER, &m); + if (r == -EPERM) { + puts("manager_new: Permission denied. Skipping test."); + return EXIT_SUCCESS; + } + assert(r >= 0); assert_se(manager_startup(m, serial, fdset) >= 0); /* load idle ok */ @@ -82,5 +88,5 @@ int main(int argc, char *argv[]) { assert_se(ser->exec_context.cpu_sched_policy == SCHED_RR); assert_se(ser->exec_context.cpu_sched_priority == 99); - return 0; + return EXIT_SUCCESS; } diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c index 3c0a416dfa..7bd99d31c8 100644 --- a/src/test/test-unit-name.c +++ b/src/test/test-unit-name.c @@ -111,6 +111,7 @@ static void test_replacements(void) { static void test_unit_printf(void) { Manager *m; Unit *u, *u2; + int r; char _cleanup_free_ *mid, *bid, *host, *root_uid; struct passwd *root; @@ -122,14 +123,19 @@ static void test_unit_printf(void) { assert_se((root = getpwnam("root"))); assert_se(asprintf(&root_uid, "%d", (int) root->pw_uid) > 0); - assert_se(manager_new(SYSTEMD_USER, &m) == 0); + r = manager_new(SYSTEMD_USER, &m); + if (r == -EPERM) { + puts("manager_new: Permission denied. Skipping test."); + return; + } + assert(r == 0); #define expect(unit, pattern, expected) \ { \ char *e; \ char _cleanup_free_ *t = \ unit_full_printf(unit, pattern); \ - printf("result: %s\n", t); \ + printf("result: %s\nexpect: %s\n", t, expected); \ if ((e = endswith(expected, "*"))) \ assert(strncmp(t, e, e-expected)); \ else \ |