summaryrefslogtreecommitdiff
path: root/src/test/test-sd-path.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-03-26 17:40:33 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-03-27 20:12:45 +0100
commit2e09fa89068fb191010e8f927dd20463c31d7bb4 (patch)
treef5abbfa75023608885b36c84a5c3462ad3e6d209 /src/test/test-sd-path.c
parente3420558512f880c46d14d23154582e3f9b3862b (diff)
downloadsystemd-2e09fa89068fb191010e8f927dd20463c31d7bb4.tar.gz
sd-path: handle case of missing runtime dir in test
Also document it in the man page.
Diffstat (limited to 'src/test/test-sd-path.c')
-rw-r--r--src/test/test-sd-path.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/test/test-sd-path.c b/src/test/test-sd-path.c
index 5888d3b9f9..9260db5ace 100644
--- a/src/test/test-sd-path.c
+++ b/src/test/test-sd-path.c
@@ -11,9 +11,13 @@ static void test_sd_path_lookup(void) {
log_info("/* %s */", __func__);
for (uint64_t i = 0; i < _SD_PATH_MAX; i++) {
- _cleanup_free_ char *t, *s;
+ _cleanup_free_ char *t = NULL, *s = NULL;
+ int r;
- assert_se(sd_path_lookup(i, NULL, &t) == 0);
+ r = sd_path_lookup(i, NULL, &t);
+ if (i == SD_PATH_USER_RUNTIME && r == -ENXIO)
+ continue;
+ assert_se(r == 0);
assert_se(t);
log_info("%02"PRIu64": \"%s\"", i, t);
@@ -31,10 +35,14 @@ static void test_sd_path_lookup_strv(void) {
log_info("/* %s */", __func__);
for (uint64_t i = 0; i < _SD_PATH_MAX; i++) {
- _cleanup_strv_free_ char **t, **s;
+ _cleanup_strv_free_ char **t = NULL, **s = NULL;
char **item;
+ int r;
- assert_se(sd_path_lookup_strv(i, NULL, &t) == 0);
+ r = sd_path_lookup_strv(i, NULL, &t);
+ if (i == SD_PATH_USER_RUNTIME && r == -ENXIO)
+ continue;
+ assert_se(r == 0);
assert_se(t);
log_info("%02"PRIu64":", i);
STRV_FOREACH(item, t)