All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/2] syscalls/chown: Format output and add testcases for chown05
@ 2021-06-09  9:49 Xie Ziyao
  2021-06-09  9:49 ` [LTP] [PATCH 1/2] syscalls/chown: format " Xie Ziyao
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Xie Ziyao @ 2021-06-09  9:49 UTC (permalink / raw)
  To: ltp

1. Format output and add testcases for chown05.
2. Delete duplicate header files.

Xie Ziyao (2):
  syscalls/chown: format output and add testcases for chown05
  syscalls/chown: format output and delete duplicate header files

 testcases/kernel/syscalls/chown/chown01.c |  8 +-------
 testcases/kernel/syscalls/chown/chown02.c |  9 +++------
 testcases/kernel/syscalls/chown/chown03.c |  9 ---------
 testcases/kernel/syscalls/chown/chown04.c | 20 +++++++++++---------
 testcases/kernel/syscalls/chown/chown05.c | 22 +++++++++++++++-------
 5 files changed, 30 insertions(+), 38 deletions(-)

--
2.17.1


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

* [LTP] [PATCH 1/2] syscalls/chown: format output and add testcases for chown05
  2021-06-09  9:49 [LTP] [PATCH 0/2] syscalls/chown: Format output and add testcases for chown05 Xie Ziyao
@ 2021-06-09  9:49 ` Xie Ziyao
  2021-06-09  9:49 ` [LTP] [PATCH 2/2] syscalls/chown: format output and delete duplicate header files Xie Ziyao
  2021-06-09 20:45 ` [LTP] [PATCH 0/2] syscalls/chown: Format output and add testcases for chown05 Petr Vorel
  2 siblings, 0 replies; 4+ messages in thread
From: Xie Ziyao @ 2021-06-09  9:49 UTC (permalink / raw)
  To: ltp

1. Print values not variable names in TST_EXP_PASS().
2. Add testcases that -1 does not change the value after the chown
call.

Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
 testcases/kernel/syscalls/chown/chown05.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/chown/chown05.c b/testcases/kernel/syscalls/chown/chown05.c
index ebb9e9b7c..44abdc750 100644
--- a/testcases/kernel/syscalls/chown/chown05.c
+++ b/testcases/kernel/syscalls/chown/chown05.c
@@ -2,6 +2,7 @@
 /*
  * Copyright (c) International Business Machines  Corp., 2001
  * 07/2001 Ported by Wayne Boyer
+ * Copyright (c) 2021 Xie Ziyao <xieziyao@huawei.com>
  */

 /*\
@@ -20,24 +21,31 @@
 #define TESTFILE "testfile"

 struct test_case_t {
+	char *desc;
 	uid_t uid;
 	gid_t gid;
 } tc[] = {
-	{700, 701},
-	{702, 701},
-	{702, 703},
-	{704, 705}
+	{"change owner/group ids", 700, 701},
+	{"change owner id only", 702, -1},
+	{"change owner id only", 703, 701},
+	{"change group id only", -1, 704},
+	{"change group id only", 703, 705},
+	{"no change", -1, -1}
 };

 static void run(unsigned int i)
 {
 	struct stat stat_buf;
-	TST_EXP_PASS(CHOWN(TESTFILE, tc[i].uid, tc[i].gid));
+	uid_t expect_uid = tc[i].uid == (uid_t)-1 ? tc[i - 1].uid : tc[i].uid;
+	gid_t expect_gid = tc[i].gid == (uid_t)-1 ? tc[i - 1].gid : tc[i].gid;
+
+	TST_EXP_PASS(CHOWN(TESTFILE, tc[i].uid, tc[i].gid), "chown(%s, %d, %d), %s",
+		     TESTFILE, tc[i].uid, tc[i].gid, tc[i].desc);

 	SAFE_STAT(TESTFILE, &stat_buf);
-	if (stat_buf.st_uid != tc[i].uid || stat_buf.st_gid != tc[i].gid) {
+	if (stat_buf.st_uid != expect_uid || stat_buf.st_gid != expect_gid) {
 		tst_res(TFAIL, "%s: incorrect ownership set, expected %d %d",
-			TESTFILE, tc[i].uid, tc[i].gid);
+			TESTFILE, expect_uid, expect_gid);
 	}
 }

--
2.17.1


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

* [LTP] [PATCH 2/2] syscalls/chown: format output and delete duplicate header files
  2021-06-09  9:49 [LTP] [PATCH 0/2] syscalls/chown: Format output and add testcases for chown05 Xie Ziyao
  2021-06-09  9:49 ` [LTP] [PATCH 1/2] syscalls/chown: format " Xie Ziyao
@ 2021-06-09  9:49 ` Xie Ziyao
  2021-06-09 20:45 ` [LTP] [PATCH 0/2] syscalls/chown: Format output and add testcases for chown05 Petr Vorel
  2 siblings, 0 replies; 4+ messages in thread
From: Xie Ziyao @ 2021-06-09  9:49 UTC (permalink / raw)
  To: ltp

1. Print values not variable names in the TST_EXP_PASS().
2. Delete duplicate header files.

Signed-off-by: Xie Ziyao <xieziyao@huawei.com>
---
 testcases/kernel/syscalls/chown/chown01.c |  8 +-------
 testcases/kernel/syscalls/chown/chown02.c |  9 +++------
 testcases/kernel/syscalls/chown/chown03.c |  9 ---------
 testcases/kernel/syscalls/chown/chown04.c | 20 +++++++++++---------
 4 files changed, 15 insertions(+), 31 deletions(-)

diff --git a/testcases/kernel/syscalls/chown/chown01.c b/testcases/kernel/syscalls/chown/chown01.c
index 767a2ad5c..7fbb116bd 100644
--- a/testcases/kernel/syscalls/chown/chown01.c
+++ b/testcases/kernel/syscalls/chown/chown01.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
  * AUTHOR: William Roske
  * CO-PILOT: Dave Fenner
+ * Copyright (c) 2021 Xie Ziyao <xieziyao@huawei.com>
  */

 /*\
@@ -11,13 +12,6 @@
  * Basic test for chown(). Calls chown() on a file and expects it to pass.
  */

-#include <stdio.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <signal.h>
-
 #include "tst_test.h"
 #include "compat_tst_16.h"

diff --git a/testcases/kernel/syscalls/chown/chown02.c b/testcases/kernel/syscalls/chown/chown02.c
index a92a1fd2d..7c96832a4 100644
--- a/testcases/kernel/syscalls/chown/chown02.c
+++ b/testcases/kernel/syscalls/chown/chown02.c
@@ -2,6 +2,7 @@
 /*
  * Copyright (c) International Business Machines  Corp., 2001
  * 07/2001 Ported by Wayne Boyer
+ * Copyright (c) 2021 Xie Ziyao <xieziyao@huawei.com>
  */

 /*\
@@ -12,11 +13,6 @@
  *  - preserves setgid bit set on a non-group-executable file
  */

-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
 #include "tst_test.h"
 #include "compat_tst_16.h"
 #include "tst_safe_macros.h"
@@ -46,7 +42,8 @@ static void run(unsigned int i)

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

-	TST_EXP_PASS(CHOWN(tc[i].filename, uid, gid));
+	TST_EXP_PASS(CHOWN(tc[i].filename, uid, gid), "chown(%s, %d, %d)",
+		     tc[i].filename, uid, gid);

 	struct stat stat_buf;
 	SAFE_STAT(tc[i].filename, &stat_buf);
diff --git a/testcases/kernel/syscalls/chown/chown03.c b/testcases/kernel/syscalls/chown/chown03.c
index ff6e904be..b4ca3af73 100644
--- a/testcases/kernel/syscalls/chown/chown03.c
+++ b/testcases/kernel/syscalls/chown/chown03.c
@@ -17,15 +17,6 @@
  * Also verify that chown() clears the setuid/setgid bits set on the file.
  */

-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <signal.h>
-#include <grp.h>
 #include <pwd.h>

 #include "tst_test.h"
diff --git a/testcases/kernel/syscalls/chown/chown04.c b/testcases/kernel/syscalls/chown/chown04.c
index e7afa1422..4e9188567 100644
--- a/testcases/kernel/syscalls/chown/chown04.c
+++ b/testcases/kernel/syscalls/chown/chown04.c
@@ -54,15 +54,16 @@ static char long_path[PATH_MAX + 2] = {[0 ... PATH_MAX + 1] = 'a'};
 static struct test_case_t {
 	char *pathname;
 	int exp_errno;
+	char *desc;
 } tc[] = {
-	{TEST_FILE1, EPERM},
-	{TEST_FILE2, EACCES},
-	{(char *)-1, EFAULT},
-	{long_path, ENAMETOOLONG},
-	{"", ENOENT},
-	{TEST_FILE3, ENOTDIR},
-	{TEST_FILE4, ELOOP},
-	{TEST_FILE5, EROFS}
+	{TEST_FILE1, EPERM, "without permissions"},
+	{TEST_FILE2, EACCES, "without full permissions of the path prefix"},
+	{(char *)-1, EFAULT, "with unaccessible pathname points"},
+	{long_path, ENAMETOOLONG, "when pathname is too long"},
+	{"", ENOENT, "when file does not exist"},
+	{TEST_FILE3, ENOTDIR, "when the path prefix is not a directory"},
+	{TEST_FILE4, ELOOP, "with too many symbolic links"},
+	{TEST_FILE5, EROFS, "when the named file resides on a read-only filesystem"}
 };

 static void run(unsigned int i)
@@ -73,7 +74,8 @@ static void run(unsigned int i)
 	UID16_CHECK((uid = geteuid()), "chown");
 	GID16_CHECK((gid = getegid()), "chown");

-	TST_EXP_FAIL(CHOWN(tc[i].pathname, uid, gid), tc[i].exp_errno);
+	TST_EXP_FAIL(CHOWN(tc[i].pathname, uid, gid), tc[i].exp_errno,
+		     "chown() %s", tc[i].desc);
 }

 static void setup(void)
--
2.17.1


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

* [LTP] [PATCH 0/2] syscalls/chown: Format output and add testcases for chown05
  2021-06-09  9:49 [LTP] [PATCH 0/2] syscalls/chown: Format output and add testcases for chown05 Xie Ziyao
  2021-06-09  9:49 ` [LTP] [PATCH 1/2] syscalls/chown: format " Xie Ziyao
  2021-06-09  9:49 ` [LTP] [PATCH 2/2] syscalls/chown: format output and delete duplicate header files Xie Ziyao
@ 2021-06-09 20:45 ` Petr Vorel
  2 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2021-06-09 20:45 UTC (permalink / raw)
  To: ltp

Hi Ziyao,

> 1. Format output and add testcases for chown05.
> 2. Delete duplicate header files.

> Xie Ziyao (2):
>   syscalls/chown: format output and add testcases for chown05
>   syscalls/chown: format output and delete duplicate header files

Thanks a lot, merged!

Kind regards,
Petr

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

end of thread, other threads:[~2021-06-09 20:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09  9:49 [LTP] [PATCH 0/2] syscalls/chown: Format output and add testcases for chown05 Xie Ziyao
2021-06-09  9:49 ` [LTP] [PATCH 1/2] syscalls/chown: format " Xie Ziyao
2021-06-09  9:49 ` [LTP] [PATCH 2/2] syscalls/chown: format output and delete duplicate header files Xie Ziyao
2021-06-09 20:45 ` [LTP] [PATCH 0/2] syscalls/chown: Format output and add testcases for chown05 Petr Vorel

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.