summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-06-21 19:44:35 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-06-23 10:34:58 +0200
commit9c6535367d07650bb531beb6cce57497862a36da (patch)
treeb1d70708e39b8bb4c214816582a7ddbdf56b3b8b /src/test
parentf69c2926f896d628426447f2a0a81bfcd1f4a75d (diff)
downloadsystemd-9c6535367d07650bb531beb6cce57497862a36da.tar.gz
basic,shared: move make_mount_point_inode_*() to shared/
Those pull in selinux for labelling, and we should avoid selinux in basic/.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-mount-util.c49
-rw-r--r--src/test/test-mountpoint-util.c49
2 files changed, 49 insertions, 49 deletions
diff --git a/src/test/test-mount-util.c b/src/test/test-mount-util.c
index 0cbf68aa00..d3d004071b 100644
--- a/src/test/test-mount-util.c
+++ b/src/test/test-mount-util.c
@@ -7,7 +7,9 @@
#include "capability-util.h"
#include "fd-util.h"
#include "fileio.h"
+#include "fs-util.h"
#include "missing_mount.h"
+#include "mkdir.h"
#include "mount-util.h"
#include "namespace-util.h"
#include "path-util.h"
@@ -217,6 +219,52 @@ static void test_bind_remount_one(void) {
assert_se(wait_for_terminate_and_check("test-remount-one", pid, WAIT_LOG) == EXIT_SUCCESS);
}
+static void test_make_mount_point_inode(void) {
+ _cleanup_(rm_rf_physical_and_freep) char *d = NULL;
+ const char *src_file, *src_dir, *dst_file, *dst_dir;
+ struct stat st;
+
+ log_info("/* %s */", __func__);
+
+ assert_se(mkdtemp_malloc(NULL, &d) >= 0);
+
+ src_file = strjoina(d, "/src/file");
+ src_dir = strjoina(d, "/src/dir");
+ dst_file = strjoina(d, "/dst/file");
+ dst_dir = strjoina(d, "/dst/dir");
+
+ assert_se(mkdir_p(src_dir, 0755) >= 0);
+ assert_se(mkdir_parents(dst_file, 0755) >= 0);
+ assert_se(touch(src_file) >= 0);
+
+ assert_se(make_mount_point_inode_from_path(src_file, dst_file, 0755) >= 0);
+ assert_se(make_mount_point_inode_from_path(src_dir, dst_dir, 0755) >= 0);
+
+ assert_se(stat(dst_dir, &st) == 0);
+ assert_se(S_ISDIR(st.st_mode));
+ assert_se(stat(dst_file, &st) == 0);
+ assert_se(S_ISREG(st.st_mode));
+ assert_se(!(S_IXUSR & st.st_mode));
+ assert_se(!(S_IXGRP & st.st_mode));
+ assert_se(!(S_IXOTH & st.st_mode));
+
+ assert_se(unlink(dst_file) == 0);
+ assert_se(rmdir(dst_dir) == 0);
+
+ assert_se(stat(src_file, &st) == 0);
+ assert_se(make_mount_point_inode_from_stat(&st, dst_file, 0755) >= 0);
+ assert_se(stat(src_dir, &st) == 0);
+ assert_se(make_mount_point_inode_from_stat(&st, dst_dir, 0755) >= 0);
+
+ assert_se(stat(dst_dir, &st) == 0);
+ assert_se(S_ISDIR(st.st_mode));
+ assert_se(stat(dst_file, &st) == 0);
+ assert_se(S_ISREG(st.st_mode));
+ assert_se(!(S_IXUSR & st.st_mode));
+ assert_se(!(S_IXGRP & st.st_mode));
+ assert_se(!(S_IXOTH & st.st_mode));
+}
+
int main(int argc, char *argv[]) {
test_setup_logging(LOG_DEBUG);
@@ -224,6 +272,7 @@ int main(int argc, char *argv[]) {
test_mount_flags_to_string();
test_bind_remount_recursive();
test_bind_remount_one();
+ test_make_mount_point_inode();
return 0;
}
diff --git a/src/test/test-mountpoint-util.c b/src/test/test-mountpoint-util.c
index 128daa6de8..983e1842d6 100644
--- a/src/test/test-mountpoint-util.c
+++ b/src/test/test-mountpoint-util.c
@@ -8,10 +8,8 @@
#include "def.h"
#include "fd-util.h"
#include "fileio.h"
-#include "fs-util.h"
#include "hashmap.h"
#include "log.h"
-#include "mkdir.h"
#include "mountpoint-util.h"
#include "path-util.h"
#include "rm-rf.h"
@@ -290,52 +288,6 @@ static void test_fd_is_mount_point(void) {
assert_se(IN_SET(fd_is_mount_point(fd, "root/", 0), -ENOENT, 0));
}
-static void test_make_mount_point_inode(void) {
- _cleanup_(rm_rf_physical_and_freep) char *d = NULL;
- const char *src_file, *src_dir, *dst_file, *dst_dir;
- struct stat st;
-
- log_info("/* %s */", __func__);
-
- assert_se(mkdtemp_malloc(NULL, &d) >= 0);
-
- src_file = strjoina(d, "/src/file");
- src_dir = strjoina(d, "/src/dir");
- dst_file = strjoina(d, "/dst/file");
- dst_dir = strjoina(d, "/dst/dir");
-
- assert_se(mkdir_p(src_dir, 0755) >= 0);
- assert_se(mkdir_parents(dst_file, 0755) >= 0);
- assert_se(touch(src_file) >= 0);
-
- assert_se(make_mount_point_inode_from_path(src_file, dst_file, 0755) >= 0);
- assert_se(make_mount_point_inode_from_path(src_dir, dst_dir, 0755) >= 0);
-
- assert_se(stat(dst_dir, &st) == 0);
- assert_se(S_ISDIR(st.st_mode));
- assert_se(stat(dst_file, &st) == 0);
- assert_se(S_ISREG(st.st_mode));
- assert_se(!(S_IXUSR & st.st_mode));
- assert_se(!(S_IXGRP & st.st_mode));
- assert_se(!(S_IXOTH & st.st_mode));
-
- assert_se(unlink(dst_file) == 0);
- assert_se(rmdir(dst_dir) == 0);
-
- assert_se(stat(src_file, &st) == 0);
- assert_se(make_mount_point_inode_from_stat(&st, dst_file, 0755) >= 0);
- assert_se(stat(src_dir, &st) == 0);
- assert_se(make_mount_point_inode_from_stat(&st, dst_dir, 0755) >= 0);
-
- assert_se(stat(dst_dir, &st) == 0);
- assert_se(S_ISDIR(st.st_mode));
- assert_se(stat(dst_file, &st) == 0);
- assert_se(S_ISREG(st.st_mode));
- assert_se(!(S_IXUSR & st.st_mode));
- assert_se(!(S_IXGRP & st.st_mode));
- assert_se(!(S_IXOTH & st.st_mode));
-}
-
int main(int argc, char *argv[]) {
test_setup_logging(LOG_DEBUG);
@@ -360,7 +312,6 @@ int main(int argc, char *argv[]) {
test_mnt_id();
test_path_is_mount_point();
test_fd_is_mount_point();
- test_make_mount_point_inode();
return 0;
}