chiark / gitweb /
tree-wide: drop 'This file is part of systemd' blurb
[elogind.git] / src / test / test-stat-util.c
index 93d025dac861d190dc2d403a0046614d301d1d72..2afc973c2bb3a50b07276b383bf184640d1684d2 100644 (file)
@@ -1,20 +1,6 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
-  This file is part of systemd.
-
   Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
 #include <fcntl.h>
@@ -38,8 +24,10 @@ static void test_files_same(void) {
         assert_se(fd >= 0);
         assert_se(symlink(name, name_alias) >= 0);
 
-        assert_se(files_same(name, name));
-        assert_se(files_same(name, name_alias));
+        assert_se(files_same(name, name, 0));
+        assert_se(files_same(name, name, AT_SYMLINK_NOFOLLOW));
+        assert_se(files_same(name, name_alias, 0));
+        assert_se(!files_same(name, name_alias, AT_SYMLINK_NOFOLLOW));
 
         unlink(name);
         unlink(name_alias);
@@ -59,27 +47,20 @@ static void test_is_symlink(void) {
         assert_se(is_symlink(name_link) == 1);
         assert_se(is_symlink("/a/file/which/does/not/exist/i/guess") < 0);
 
-
         unlink(name);
         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_check_fstype(void) {
+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) {
-                assert_se(path_check_fstype("/run", TMPFS_MAGIC) > 0);
-                assert_se(path_check_fstype("/run", BTRFS_SUPER_MAGIC) == 0);
+                assert_se(path_is_fs_type("/run", TMPFS_MAGIC) > 0);
+                assert_se(path_is_fs_type("/run", BTRFS_SUPER_MAGIC) == 0);
         }
-        assert_se(path_check_fstype("/proc", PROC_SUPER_MAGIC) > 0);
-        assert_se(path_check_fstype("/proc", BTRFS_SUPER_MAGIC) == 0);
-        assert_se(path_check_fstype("/proc", BTRFS_SUPER_MAGIC) == 0);
-        assert_se(path_check_fstype("/i-dont-exist", BTRFS_SUPER_MAGIC) == -ENOENT);
+        assert_se(path_is_fs_type("/proc", PROC_SUPER_MAGIC) > 0);
+        assert_se(path_is_fs_type("/proc", BTRFS_SUPER_MAGIC) == 0);
+        assert_se(path_is_fs_type("/proc", BTRFS_SUPER_MAGIC) == 0);
+        assert_se(path_is_fs_type("/i-dont-exist", BTRFS_SUPER_MAGIC) == -ENOENT);
 }
 
 static void test_path_is_temporary_fs(void) {
@@ -95,8 +76,7 @@ int main(int argc, char *argv[]) {
         test_files_same();
 #if 0 /// UNNEEDED by elogind
         test_is_symlink();
-        test_path_is_os_tree();
-        test_path_check_fstype();
+        test_path_is_fs_type();
         test_path_is_temporary_fs();
 #endif // 0