summaryrefslogtreecommitdiffstats
path: root/src/test/test-os-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-03-26 16:32:40 +0200
committerLennart Poettering <lennart@poettering.net>2018-05-24 17:01:57 +0200
commitd58ad743f98b3a88de961462fb7adedbf30f727d (patch)
tree0978f88d2e97ef6aacd032b0c6540c70906f5207 /src/test/test-os-util.c
parentfileio: add parse_env_filev() that is like parse_env_file() but takes a va_list (diff)
downloadsystemd-d58ad743f98b3a88de961462fb7adedbf30f727d.tar.xz
systemd-d58ad743f98b3a88de961462fb7adedbf30f727d.zip
os-util: add helpers for finding /etc/os-release
Place this new helpers in a new source file os-util.[ch], and move the existing and related call path_is_os_tree() to it as well.
Diffstat (limited to 'src/test/test-os-util.c')
-rw-r--r--src/test/test-os-util.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/test-os-util.c b/src/test/test-os-util.c
new file mode 100644
index 0000000000..8d8b52d7f6
--- /dev/null
+++ b/src/test/test-os-util.c
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
+#include <errno.h>
+
+#include "log.h"
+#include "os-util.h"
+
+static void test_path_is_os_tree(void) {
+ assert_se(path_is_os_tree("/") > 0);
+ assert_se(path_is_os_tree("/etc") == 0);
+ assert_se(path_is_os_tree("/idontexist") == -ENOENT);
+}
+
+int main(int argc, char *argv[]) {
+ log_set_max_level(LOG_DEBUG);
+ log_parse_environment();
+ log_open();
+
+ test_path_is_os_tree();
+
+ return 0;
+}