summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-03-26 16:32:40 +0200
committerSven Eden <yamakuzure@gmx.net>2018-08-24 16:47:08 +0200
commit2cefb09ff69c3595e98c55f0da1bd137c612276c (patch)
tree413850b2eb4d2cd031c2d31ef66b657baf5d66d4 /src/test
parent1049fbda947f856942a693f011fe013a2ee798f0 (diff)
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')
-rw-r--r--src/test/meson.build11
-rw-r--r--src/test/test-os-util.c22
-rw-r--r--src/test/test-stat-util.c7
3 files changed, 33 insertions, 7 deletions
diff --git a/src/test/meson.build b/src/test/meson.build
index 833634ffa..8d694b379 100644
--- a/src/test/meson.build
+++ b/src/test/meson.build
@@ -264,6 +264,10 @@ tests += [
[],
[]],
+ [['src/test/test-os-util.c'],
+ [],
+ []],
+
[['src/test/test-escape.c'],
[],
[]],
@@ -956,6 +960,7 @@ tests += [
# 'src/libsystemd-network/dhcp-internal.h'],
# [libshared,
# libelogind_network],
+# libsystemd_network],
# []],
#
# [['src/libsystemd-network/test-sd-dhcp-lease.c',
@@ -970,11 +975,13 @@ tests += [
# 'src/systemd/sd-dhcp-client.h'],
# [libshared,
# libelogind_network],
+# libsystemd_network],
# []],
#
# [['src/libelogind-network/test-dhcp-server.c'],
# [libshared,
# libelogind_network],
+# libsystemd_network],
# []],
#
# [['src/libsystemd-network/test-ipv4ll.c',
@@ -982,12 +989,14 @@ tests += [
# 'src/systemd/sd-ipv4ll.h'],
# [libshared,
# libelogind_network],
+# libsystemd_network],
# []],
#
# [['src/libelogind-network/test-ipv4ll-manual.c',
# 'src/systemd/sd-ipv4ll.h'],
# [libshared,
# libelogind_network],
+# libsystemd_network],
# [],
# '', 'manual'],
#
@@ -1006,6 +1015,7 @@ tests += [
# 'src/systemd/sd-ndisc.h'],
# [libshared,
# libelogind_network],
+# libsystemd_network],
# []],
#
# [['src/libsystemd-network/test-ndisc-ra.c',
@@ -1022,6 +1032,7 @@ tests += [
# 'src/systemd/sd-dhcp6-client.h'],
# [libshared,
# libelogind_network],
+# libsystemd_network],
# []],
#
# [['src/libelogind-network/test-lldp.c'],
diff --git a/src/test/test-os-util.c b/src/test/test-os-util.c
new file mode 100644
index 000000000..1e78f352a
--- /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;
+}
diff --git a/src/test/test-stat-util.c b/src/test/test-stat-util.c
index 3d8d911ac..52142a53f 100644
--- a/src/test/test-stat-util.c
+++ b/src/test/test-stat-util.c
@@ -53,12 +53,6 @@ static void test_is_symlink(void) {
unlink(name_link);
}
-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);
-}
-
static void test_path_is_fs_type(void) {
/* run might not be a mount point in build chroots */
if (path_is_mount_point("/run", NULL, AT_SYMLINK_FOLLOW) > 0) {
@@ -84,7 +78,6 @@ int main(int argc, char *argv[]) {
test_files_same();
#if 0 /// UNNEEDED by elogind
test_is_symlink();
- test_path_is_os_tree();
test_path_is_fs_type();
test_path_is_temporary_fs();
#endif // 0