[LTP] [PATCH 4/5] tree: Use MNTPOINT macro instead of string

Petr Vorel pvorel@suse.cz
Wed Jan 31 19:06:58 CET 2024


Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/syscalls/creat/creat06.c     |  4 +--
 testcases/kernel/syscalls/fsync/fsync01.c     |  4 +--
 testcases/kernel/syscalls/inotify/inotify03.c | 25 ++++++++-----------
 testcases/kernel/syscalls/ioctl/ioctl04.c     | 10 ++++----
 4 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/testcases/kernel/syscalls/creat/creat06.c b/testcases/kernel/syscalls/creat/creat06.c
index 5c82e4757..eccd5e2dd 100644
--- a/testcases/kernel/syscalls/creat/creat06.c
+++ b/testcases/kernel/syscalls/creat/creat06.c
@@ -52,7 +52,7 @@
 #define	NOT_DIR		"file1/testdir"
 #define	TEST6_FILE	"dir6/file6"
 #define	TEST7_FILE	"file7"
-#define	TEST8_FILE	"mntpoint/tmp"
+#define	TEST8_FILE	MNTPOINT"/tmp"
 
 #define	MODE1		0444
 #define	MODE2		0666
@@ -153,6 +153,6 @@ static struct tst_test test = {
 	.test = verify_creat,
 	.needs_root = 1,
 	.needs_rofs = 1,
-	.mntpoint = "mntpoint",
+	.mntpoint = MNTPOINT,
 	.setup = setup,
 };
diff --git a/testcases/kernel/syscalls/fsync/fsync01.c b/testcases/kernel/syscalls/fsync/fsync01.c
index 072245fc8..cecfd6592 100644
--- a/testcases/kernel/syscalls/fsync/fsync01.c
+++ b/testcases/kernel/syscalls/fsync/fsync01.c
@@ -33,7 +33,7 @@ static void verify_fsync(void)
 
 static void setup(void)
 {
-	sprintf(fname, "mntpoint/tfile_%d", getpid());
+	sprintf(fname, "%s/tfile_%d", MNTPOINT, getpid());
 	fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700);
 }
 
@@ -49,6 +49,6 @@ static struct tst_test test = {
 	.test_all = verify_fsync,
 	.needs_root = 1,
 	.mount_device = 1,
-	.mntpoint = "mntpoint",
+	.mntpoint = MNTPOINT,
 	.all_filesystems = 1,
 };
diff --git a/testcases/kernel/syscalls/inotify/inotify03.c b/testcases/kernel/syscalls/inotify/inotify03.c
index ff025b360..5440d573c 100644
--- a/testcases/kernel/syscalls/inotify/inotify03.c
+++ b/testcases/kernel/syscalls/inotify/inotify03.c
@@ -34,17 +34,13 @@
 #define EVENT_BUF_LEN		(EVENT_MAX * (EVENT_SIZE + 16))
 
 #define BUF_SIZE 1024
+#define DIR_MODE	(S_IRWXU | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP)
+
 static char fname[BUF_SIZE];
 static int fd, fd_notify;
 static int wd;
-
 static unsigned int event_set[EVENT_MAX];
-
 static char event_buf[EVENT_BUF_LEN];
-
-#define DIR_MODE	(S_IRWXU | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP)
-
-static char *mntpoint = "mntpoint";
 static int mount_flag;
 
 void verify_inotify(void)
@@ -54,7 +50,7 @@ void verify_inotify(void)
 
 	int test_cnt = 0;
 
-	SAFE_MOUNT(tst_device->dev, mntpoint, tst_device->fs_type, 0, NULL);
+	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
 	mount_flag = 1;
 
 	wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, fname, IN_ALL_EVENTS);
@@ -68,7 +64,7 @@ void verify_inotify(void)
 	test_cnt++;
 
 	tst_res(TINFO, "umount %s", tst_device->dev);
-	TEST(tst_umount(mntpoint));
+	TEST(tst_umount(MNTPOINT));
 	if (TST_RET != 0) {
 		tst_brk(TBROK, "umount(2) Failed "
 			"while unmounting errno = %d : %s",
@@ -129,12 +125,12 @@ static void setup(void)
 {
 	int ret;
 
-	SAFE_MKDIR(mntpoint, DIR_MODE);
+	SAFE_MKDIR(MNTPOINT, DIR_MODE);
 
-	SAFE_MOUNT(tst_device->dev, mntpoint, tst_device->fs_type, 0, NULL);
+	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
 	mount_flag = 1;
 
-	sprintf(fname, "%s/tfile_%d", mntpoint, getpid());
+	sprintf(fname, "%s/tfile_%d", MNTPOINT, getpid());
 	fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700);
 
 	ret = write(fd, fname, 1);
@@ -148,7 +144,7 @@ static void setup(void)
 
 	fd_notify = SAFE_MYINOTIFY_INIT();
 
-	tst_umount(mntpoint);
+	tst_umount(MNTPOINT);
 	mount_flag = 0;
 }
 
@@ -158,10 +154,9 @@ static void cleanup(void)
 		SAFE_CLOSE(fd_notify);
 
 	if (mount_flag) {
-		TEST(tst_umount(mntpoint));
+		TEST(tst_umount(MNTPOINT));
 		if (TST_RET != 0)
-			tst_res(TWARN | TTERRNO, "umount(%s) failed",
-				mntpoint);
+			tst_res(TWARN | TTERRNO, "umount(%s) failed", MNTPOINT);
 	}
 }
 
diff --git a/testcases/kernel/syscalls/ioctl/ioctl04.c b/testcases/kernel/syscalls/ioctl/ioctl04.c
index 262c06e97..0eb433268 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl04.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl04.c
@@ -41,11 +41,11 @@ static void verify_ioctl(void)
 	else
 		tst_res(TPASS, "BLKROGET returned %i", ro);
 
-	TEST(mount(tst_device->dev, "mntpoint", tst_device->fs_type, 0, NULL));
+	TEST(mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL));
 
 	if (TST_RET != -1) {
 		tst_res(TFAIL, "Mounting RO device RW succeeded");
-		tst_umount("mntpoint");
+		tst_umount(MNTPOINT);
 		goto next;
 	}
 
@@ -58,11 +58,11 @@ static void verify_ioctl(void)
 		"Mounting RO device RW failed unexpectedly expected EACCES");
 
 next:
-	TEST(mount(tst_device->dev, "mntpoint", tst_device->fs_type, MS_RDONLY, NULL));
+	TEST(mount(tst_device->dev, MNTPOINT, tst_device->fs_type, MS_RDONLY, NULL));
 
 	if (TST_RET == 0) {
 		tst_res(TPASS, "Mounting RO device RO works");
-		tst_umount("mntpoint");
+		tst_umount(MNTPOINT);
 	} else {
 		tst_res(TFAIL | TTERRNO, "Mounting RO device RO failed");
 	}
@@ -73,7 +73,7 @@ next:
 
 static void setup(void)
 {
-	SAFE_MKDIR("mntpoint", 0777);
+	SAFE_MKDIR(MNTPOINT, 0777);
 	fd = SAFE_OPEN(tst_device->dev, O_RDONLY);
 }
 
-- 
2.43.0



More information about the ltp mailing list