public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] open: fix directory verification and misleading test description
@ 2026-02-11 17:16 Jinseok Kim
  2026-02-17 13:21 ` Andrea Cervesato via ltp
  2026-02-19 10:31 ` Cyril Hrubis
  0 siblings, 2 replies; 29+ messages in thread
From: Jinseok Kim @ 2026-02-11 17:16 UTC (permalink / raw)
  To: ltp

The directory test treated S_IFDIR as a permission bit and verified
it using a generic st_mode bitwise check, which is not appropriate
for file type verification.

Use S_ISDIR() when verifying directories and keep bitwise checks
only for permission bits such as S_ISVTX.

The directory test case also referred to a "directory bit", which is
misleading since directories are identified by file type rather than
a permission bit.

Signed-off-by: Jinseok Kim <always.starving0@gmail.com>
---
 testcases/kernel/syscalls/open/open01.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/testcases/kernel/syscalls/open/open01.c b/testcases/kernel/syscalls/open/open01.c
index baf73ab11..1355592e1 100644
--- a/testcases/kernel/syscalls/open/open01.c
+++ b/testcases/kernel/syscalls/open/open01.c
@@ -37,7 +37,7 @@ static struct tcase {
 	char *desc;
 } tcases[] = {
 	{TEST_FILE, O_RDWR | O_CREAT, 01444, S_ISVTX, "sticky bit"},
-	{TEST_DIR, O_DIRECTORY, 0, S_IFDIR, "sirectory bit"}
+	{TEST_DIR, O_DIRECTORY, 0, S_IFDIR, "directory"}
 };

 static void verify_open(unsigned int n)
@@ -53,11 +53,17 @@ static void verify_open(unsigned int n)
 	fd = TST_RET;

 	SAFE_FSTAT(fd, &buf);
-	if (!(buf.st_mode & tc->tst_bit))
-		tst_res(TFAIL, "%s is cleared unexpectedly", tc->desc);
-	else
-		tst_res(TPASS, "%s is set as expected", tc->desc);
-
+	if (tc->tst_bit == S_ISVTX) {
+		if (!(buf.st_mode & S_ISVTX))
+			tst_res(TFAIL, "%s is cleared unexpectedly", tc->desc);
+		else
+			tst_res(TPASS, "%s is set as expected", tc->desc);
+	} else if (tc->tst_bit == S_IFDIR) {
+		if (!S_ISDIR(buf.st_mode))
+			tst_res(TFAIL, "%s is not a directory", tc->desc);
+		else
+			tst_res(TPASS, "%s is a directory", tc->desc);
+	}
 	SAFE_CLOSE(fd);
 	if (S_ISREG(buf.st_mode))
 		SAFE_UNLINK(tc->filename);
--
2.43.0

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2026-03-30  8:07 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-11 17:16 [LTP] [PATCH] open: fix directory verification and misleading test description Jinseok Kim
2026-02-17 13:21 ` Andrea Cervesato via ltp
2026-02-19 10:31 ` Cyril Hrubis
2026-02-19 14:57   ` Jinseok Kim
2026-02-20 10:49     ` Cyril Hrubis
2026-02-24  7:37       ` [LTP] [PATCH 1/2] open: remove O_DIRECTORY case (move to fstat test) Jinseok Kim
2026-02-24  7:37         ` [LTP] [PATCH 2/2] Add test for multiple file types using fstat Jinseok Kim
2026-02-24  8:17         ` [LTP] [PATCH 1/2] open: remove O_DIRECTORY case (move to fstat test) Andrea Cervesato via ltp
2026-02-24 10:07           ` [LTP] [PATCH v2 " Jinseok Kim
2026-02-24 10:07             ` [LTP] [PATCH v2 2/2] fstat: add test for multiple file types using fstat Jinseok Kim
2026-02-24 14:17               ` Andrea Cervesato via ltp
2026-02-25 13:19                 ` [LTP] [PATCH v3 1/2] open: remove O_DIRECTORY case (move to fstat test) Jinseok Kim
2026-02-25 13:19                   ` [LTP] [PATCH v3 2/2] fstat: add test for multiple file types using fstat Jinseok Kim
2026-02-25 14:30                     ` Andrea Cervesato via ltp
2026-02-26 15:32                       ` Jinseok Kim
2026-02-26 15:44                         ` Andrea Cervesato via ltp
2026-03-03 13:32                           ` [LTP] [PATCH v4 1/2] open: remove O_DIRECTORY case (move to fstat test) Jinseok Kim
2026-03-03 13:32                             ` [LTP] [PATCH v4 2/2] fstat: add test for multiple file types using fstat Jinseok Kim
2026-03-12 11:22                               ` Andrea Cervesato via ltp
2026-03-13 14:07                                 ` Jinseok Kim
2026-03-13 15:36                                   ` Andrea Cervesato via ltp
2026-03-15  7:27                                     ` [LTP] [PATCH v5 1/2] open: remove O_DIRECTORY case (move to fstat test) Jinseok Kim
2026-03-15  7:27                                       ` [LTP] [PATCH v5 2/2] fstat: add test for multiple file types using fstat Jinseok Kim
2026-03-16  7:38                                       ` [LTP] [PATCH v5 1/2] open: remove O_DIRECTORY case (move to fstat test) Andrea Cervesato via ltp
2026-03-16 15:00                                         ` [LTP] [PATCH v6 " Jinseok Kim
2026-03-16 15:00                                           ` [LTP] [PATCH v6 2/2] fstat: add test for multiple file types using fstat Jinseok Kim
2026-03-24 12:17                                             ` Andrea Cervesato via ltp
2026-03-27 15:27                                               ` [LTP] [PATCH v7] " Jinseok Kim
2026-03-30  8:07                                                 ` Andrea Cervesato via ltp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox