All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/fchown: Make output nicer and add checks before SAFE_CLOSE(fd)
@ 2021-06-07  8:07 Xie Ziyao
  2021-06-07  8:43 ` Li Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Xie Ziyao @ 2021-06-07  8:07 UTC (permalink / raw)
  To: ltp

1. Print values not variable names in TST_EXP_PASS().
2. Check if the fd has been opened in cleanup().

Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
 testcases/kernel/syscalls/fchown/fchown01.c | 2 +-
 testcases/kernel/syscalls/fchown/fchown02.c | 8 +++++---
 testcases/kernel/syscalls/fchown/fchown03.c | 4 +++-
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/syscalls/fchown/fchown01.c b/testcases/kernel/syscalls/fchown/fchown01.c
index 77913ce32..16e1f677b 100644
--- a/testcases/kernel/syscalls/fchown/fchown01.c
+++ b/testcases/kernel/syscalls/fchown/fchown01.c
@@ -28,7 +28,7 @@ static gid_t gid;

 static void run(void)
 {
-	TST_EXP_PASS(FCHOWN(fd, uid, gid));
+	TST_EXP_PASS(FCHOWN(fd, uid, gid), "fchown(%i, %i, %i)", fd, uid, gid);
 }

 static void setup(void)
diff --git a/testcases/kernel/syscalls/fchown/fchown02.c b/testcases/kernel/syscalls/fchown/fchown02.c
index d541f0450..ec04b5c01 100644
--- a/testcases/kernel/syscalls/fchown/fchown02.c
+++ b/testcases/kernel/syscalls/fchown/fchown02.c
@@ -53,7 +53,7 @@ static void run(unsigned int i)

 	SAFE_CHMOD(tc[i].filename, tc[i].set_mode);

-	TST_EXP_PASS(FCHOWN(*tc[i].fd, uid, gid));
+	TST_EXP_PASS(FCHOWN(*tc[i].fd, uid, gid), "fchown(%i, %i, %i)", *tc[i].fd, uid, gid);

 	SAFE_STAT(tc[i].filename, &stat_buf);

@@ -78,8 +78,10 @@ static void cleanup(void)
 {
 	unsigned int i;

-	for (i = 0; i < ARRAY_SIZE(tc); i++)
-		SAFE_CLOSE(*tc[i].fd);
+	for (i = 0; i < ARRAY_SIZE(tc); i++) {
+		if (*tc[i].fd > 0)
+			SAFE_CLOSE(*tc[i].fd);
+	}
 }

 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/fchown/fchown03.c b/testcases/kernel/syscalls/fchown/fchown03.c
index 752d9c394..97d6c9d34 100644
--- a/testcases/kernel/syscalls/fchown/fchown03.c
+++ b/testcases/kernel/syscalls/fchown/fchown03.c
@@ -85,7 +85,9 @@ static void cleanup(void)
 {
 	SAFE_SETEGID(0);
 	SAFE_SETEUID(0);
-	SAFE_CLOSE(fd);
+
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 }

 static struct tst_test test = {
--
2.17.1


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

* [LTP] [PATCH] syscalls/fchown: Make output nicer and add checks before SAFE_CLOSE(fd)
  2021-06-07  8:07 [LTP] [PATCH] syscalls/fchown: Make output nicer and add checks before SAFE_CLOSE(fd) Xie Ziyao
@ 2021-06-07  8:43 ` Li Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Li Wang @ 2021-06-07  8:43 UTC (permalink / raw)
  To: ltp

Xie Ziyao <xieziyao@huawei.com> wrote:

> 1. Print values not variable names in TST_EXP_PASS().
> 2. Check if the fd has been opened in cleanup().

I helped tweak the format and pushed, thanks!

-- 
Regards,
Li Wang


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

end of thread, other threads:[~2021-06-07  8:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07  8:07 [LTP] [PATCH] syscalls/fchown: Make output nicer and add checks before SAFE_CLOSE(fd) Xie Ziyao
2021-06-07  8:43 ` Li Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.