diff options
author | Daniel Mack <daniel@zonque.org> | 2014-09-26 17:50:24 +0200 |
---|---|---|
committer | Daniel Mack <daniel@zonque.org> | 2014-09-26 19:52:08 +0200 |
commit | 45f1b67a70a749ca14a7df256a177de74a3e73f6 (patch) | |
tree | 1d005cc5ca02c44718a15504824060747e459a88 | |
parent | 9ed2a35e93f4a9e82585f860f54cdcbbdf3e1f86 (diff) |
test-bus-policy: load policy files from TEST_DIR
'make distcheck' calls test-bus-policy outside of the source tree, so it
must consider the TEST_DIR variable to access its files.
-rw-r--r-- | src/bus-proxyd/test-bus-policy.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/bus-proxyd/test-bus-policy.c b/src/bus-proxyd/test-bus-policy.c index 37e66274f0..900e4d2b06 100644 --- a/src/bus-proxyd/test-bus-policy.c +++ b/src/bus-proxyd/test-bus-policy.c @@ -44,6 +44,23 @@ #include <bus-proxyd/bus-policy.h> +static int test_policy_load(Policy *p, const char *name) +{ + char *path; + int r = 0; + + path = strjoin(TEST_DIR, "/bus-policy/", name, NULL); + + if (access(path, R_OK) == 0) + policy_load(p, STRV_MAKE(path)); + else + r = -ENOENT; + + free(path); + + return r; +} + int main(int argc, char *argv[]) { Policy p = {}; @@ -52,7 +69,7 @@ int main(int argc, char *argv[]) { Hashmap *names_hash; /* Ownership tests */ - assert_se(policy_load(&p, STRV_MAKE("test/bus-policy/ownerships.conf")) == 0); + assert_se(test_policy_load(&p, "ownerships.conf") == 0); ucred.uid = 0; assert_se(policy_check_own(&p, &ucred, "org.test.test1") == true); @@ -77,7 +94,7 @@ int main(int argc, char *argv[]) { policy_free(&p); /* Signaltest */ - assert_se(policy_load(&p, STRV_MAKE("test/bus-policy/signals.conf")) == 0); + assert_se(test_policy_load(&p, "signals.conf") == 0); names_strv = STRV_MAKE("bli.bla.blubb"); ucred.uid = 0; @@ -89,7 +106,7 @@ int main(int argc, char *argv[]) { policy_free(&p); /* Method calls */ - assert_se(policy_load(&p, STRV_MAKE("test/bus-policy/methods.conf")) == 0); + assert_se(test_policy_load(&p, "methods.conf") == 0); names_strv = STRV_MAKE("org.test.test1"); policy_dump(&p); @@ -108,7 +125,7 @@ int main(int argc, char *argv[]) { policy_free(&p); /* User and groups */ - assert_se(policy_load(&p, STRV_MAKE("test/bus-policy/hello.conf")) == 0); + assert_se(test_policy_load(&p, "hello.conf") == 0); policy_dump(&p); ucred.uid = 0; |