]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-path: handle case of missing runtime dir in test 15217/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 26 Mar 2020 16:40:33 +0000 (17:40 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 27 Mar 2020 19:12:45 +0000 (20:12 +0100)
Also document it in the man page.

man/sd_path_lookup.xml
src/test/test-sd-path.c

index 35a1109af381bb0e16c2b7bb38c1a97984ed699d..68c6812ab17403d6a436e802218a8255dceb7141 100644 (file)
           <listitem><para>Output argument is <constant>NULL</constant>.</para></listitem>
         </varlistentry>
 
+        <varlistentry>
+          <term><constant>-ENXIO</constant></term>
+
+          <listitem><para>Query failed because of an undefined environment variable (e.g. for
+          <constant>SD_PATH_USER_RUNTIME</constant> when <varname>$XDG_RUNTIME_DIR</varname> is not
+          defined).</para></listitem>
+        </varlistentry>
+
         <varlistentry>
           <term><constant>-ENOMEM</constant></term>
 
index 5888d3b9f942318994d4402ff6f3088b9a37e1af..9260db5aceefd9df3a9868e73d179424939a6210 100644 (file)
@@ -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)