in setup phase of chown03 testcase, it set effective gid/uid before
create tmpdir, this might cause EPERM error under some circumstance:

chown03     1  TBROK  :  chown(/tmp/ltp-1FYYTiULQl/chos2UBh3, -1, 0) failed: 
errno=EPERM(1): Operation not permitted
chown03     2  TBROK  :  Remaining cases broken
chown03     0  TWARN  :  tst_brk: Invalid Type: 4. Using TBROK
chown03     3  TBROK  :  tmpdir_cleanup: no user cleanup function called before 
exiting

This patch creates tmpdir first, then set the effective gid/uid to test.

Signed-off-by: Caspar Zhang <[email protected]>
---
 testcases/kernel/syscalls/chown/chown03.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/syscalls/chown/chown03.c b/testcases/kernel/syscalls/chown/chown03.c
index 34b2d59..e26be0d 100644
--- a/testcases/kernel/syscalls/chown/chown03.c
+++ b/testcases/kernel/syscalls/chown/chown03.c
@@ -167,6 +167,10 @@ void setup()
 
 	tst_require_root(NULL);
 
+	tst_sig(FORK, DEF_HANDLER, cleanup);
+
+	tst_tmpdir();
+
 	ltpuser = getpwnam(nobody_uid);
 	if (ltpuser == NULL)
 		tst_brkm(TBROK|TERRNO, NULL, "getpwnam(\"nobody\") failed");
@@ -177,10 +181,6 @@ void setup()
 		tst_brkm(TBROK|TERRNO, NULL, "seteuid(%d) failed",
 		    ltpuser->pw_uid);
 
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	tst_tmpdir();
-
 	/* Create a test file under temporary directory */
 	if ((fd = open(TESTFILE, O_RDWR|O_CREAT, FILE_MODE)) == -1)
 		tst_brkm(TBROK|TERRNO, cleanup,
@@ -213,4 +213,4 @@ void cleanup()
 
 	tst_rmdir();
 
-}
\ No newline at end of file
+}
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to