All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/3] syscalls: fix returning TCONF without device
@ 2014-06-13  1:58 Zeng Linggang
  2014-06-13  1:59 ` [LTP] [PATCH 2/3] utime/utime06.c: cleanup Zeng Linggang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Zeng Linggang @ 2014-06-13  1:58 UTC (permalink / raw)
  To: ltp-list

The cases are:
1. mknod07
2. lchown03
3. mkdir03
4. linkat02
5. mknodat02
6. fchown04
7. mkdirat02
8. link08

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/fchown/fchown04.c   | 2 +-
 testcases/kernel/syscalls/lchown/lchown03.c   | 2 +-
 testcases/kernel/syscalls/link/link08.c       | 2 +-
 testcases/kernel/syscalls/linkat/linkat02.c   | 2 +-
 testcases/kernel/syscalls/mkdir/mkdir03.c     | 2 +-
 testcases/kernel/syscalls/mkdirat/mkdirat02.c | 2 +-
 testcases/kernel/syscalls/mknod/mknod07.c     | 2 +-
 testcases/kernel/syscalls/mknodat/mknodat02.c | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/testcases/kernel/syscalls/fchown/fchown04.c b/testcases/kernel/syscalls/fchown/fchown04.c
index 68f6611..2a8b8c6 100644
--- a/testcases/kernel/syscalls/fchown/fchown04.c
+++ b/testcases/kernel/syscalls/fchown/fchown04.c
@@ -91,7 +91,7 @@ int main(int ac, char **av)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 
 	if (!device) {
-		tst_brkm(TBROK, NULL,
+		tst_brkm(TCONF, NULL,
 			 "you must specify the device used for mounting with "
 			 "-D option");
 	}
diff --git a/testcases/kernel/syscalls/lchown/lchown03.c b/testcases/kernel/syscalls/lchown/lchown03.c
index ea8f38a..391afb4 100644
--- a/testcases/kernel/syscalls/lchown/lchown03.c
+++ b/testcases/kernel/syscalls/lchown/lchown03.c
@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 
 	if (!device) {
-		tst_brkm(TBROK, NULL,
+		tst_brkm(TCONF, NULL,
 			 "you must specify the device used for mounting with "
 			 "-D option");
 	}
diff --git a/testcases/kernel/syscalls/link/link08.c b/testcases/kernel/syscalls/link/link08.c
index aed5479..48274b4 100644
--- a/testcases/kernel/syscalls/link/link08.c
+++ b/testcases/kernel/syscalls/link/link08.c
@@ -99,7 +99,7 @@ int main(int ac, char **av)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 
 	if (!device) {
-		tst_brkm(TBROK, NULL,
+		tst_brkm(TCONF, NULL,
 			 "you must specify the device used for mounting with "
 			 "-D option");
 	}
diff --git a/testcases/kernel/syscalls/linkat/linkat02.c b/testcases/kernel/syscalls/linkat/linkat02.c
index b899fa6..984ede6 100644
--- a/testcases/kernel/syscalls/linkat/linkat02.c
+++ b/testcases/kernel/syscalls/linkat/linkat02.c
@@ -109,7 +109,7 @@ int main(int ac, char **av)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 
 	if (!device) {
-		tst_brkm(TBROK, NULL,
+		tst_brkm(TCONF, NULL,
 			 "you must specify the device used for mounting with "
 			 "-D option");
 	}
diff --git a/testcases/kernel/syscalls/mkdir/mkdir03.c b/testcases/kernel/syscalls/mkdir/mkdir03.c
index b037ad3..e897c2e 100644
--- a/testcases/kernel/syscalls/mkdir/mkdir03.c
+++ b/testcases/kernel/syscalls/mkdir/mkdir03.c
@@ -96,7 +96,7 @@ int main(int ac, char **av)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 
 	if (!device) {
-		tst_brkm(TBROK, NULL,
+		tst_brkm(TCONF, NULL,
 			 "you must specify the device used for mounting with "
 			 "-D option");
 	}
diff --git a/testcases/kernel/syscalls/mkdirat/mkdirat02.c b/testcases/kernel/syscalls/mkdirat/mkdirat02.c
index 827ad54..27de4e9 100644
--- a/testcases/kernel/syscalls/mkdirat/mkdirat02.c
+++ b/testcases/kernel/syscalls/mkdirat/mkdirat02.c
@@ -83,7 +83,7 @@ int main(int ac, char **av)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 
 	if (!device) {
-		tst_brkm(TBROK, NULL,
+		tst_brkm(TCONF, NULL,
 			 "you must specify the device used for mounting with "
 			 "-D option");
 	}
diff --git a/testcases/kernel/syscalls/mknod/mknod07.c b/testcases/kernel/syscalls/mknod/mknod07.c
index 5311cfc..df9f8d7 100644
--- a/testcases/kernel/syscalls/mknod/mknod07.c
+++ b/testcases/kernel/syscalls/mknod/mknod07.c
@@ -106,7 +106,7 @@ int main(int ac, char **av)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 
 	if (!device) {
-		tst_brkm(TBROK, NULL, "you must specify the device "
+		tst_brkm(TCONF, NULL, "you must specify the device "
 			 "used for mounting with -D option");
 	}
 
diff --git a/testcases/kernel/syscalls/mknodat/mknodat02.c b/testcases/kernel/syscalls/mknodat/mknodat02.c
index 3de049b..eec5b98 100644
--- a/testcases/kernel/syscalls/mknodat/mknodat02.c
+++ b/testcases/kernel/syscalls/mknodat/mknodat02.c
@@ -103,7 +103,7 @@ int main(int ac, char **av)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 
 	if (!device) {
-		tst_brkm(TBROK, NULL, "you must specify the device "
+		tst_brkm(TCONF, NULL, "you must specify the device "
 			 "used for mounting with -D option");
 	}
 
-- 
1.9.3




------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 2/3] utime/utime06.c: cleanup
  2014-06-13  1:58 [LTP] [PATCH 1/3] syscalls: fix returning TCONF without device Zeng Linggang
@ 2014-06-13  1:59 ` Zeng Linggang
  2014-06-13  2:01 ` [LTP] [PATCH 3/3] utime/utime06.c: add EPERM and EROFS errno testes Zeng Linggang
  2014-06-13 11:56 ` [LTP] [PATCH 1/3] syscalls: fix returning TCONF without device Jan Stancek
  2 siblings, 0 replies; 7+ messages in thread
From: Zeng Linggang @ 2014-06-13  1:59 UTC (permalink / raw)
  To: ltp-list

* Delete some useless comments.

* Delete some useless variable value.

* Test without fork().

* Some cleanup.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/utime/utime06.c | 290 ++++++------------------------
 1 file changed, 53 insertions(+), 237 deletions(-)

diff --git a/testcases/kernel/syscalls/utime/utime06.c b/testcases/kernel/syscalls/utime/utime06.c
index a1a9230..2dd68d8 100644
--- a/testcases/kernel/syscalls/utime/utime06.c
+++ b/testcases/kernel/syscalls/utime/utime06.c
@@ -1,78 +1,31 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ *	07/2001 John George
  *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   This program is free software;  you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
+ * This program is free software;  you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- *   the GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY;  without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+ * the GNU General Public License for more details.
  *
- *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program;  if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /*
- * Test Name: utime06
- *
  * Test Description:
  * 1. Verify that the system call utime() fails to set the modification
  *    and access times of a file to the current time, under the following
  *    constraints,
  *	 - The times argument is null.
  *	 - The user ID of the process is not "root".
- *	 - The file is not owned by the user ID of the process.
- *	 - The user ID of the process does not have write access to the
- *	   file.
  * 2. Verify that the system call utime() fails to set the modification
  *    and access times of a file if the specified file doesn't exist.
- *
- * Expected Result:
- * 1. utime should fail with -1 return value and sets errno EACCES.
- * 2. utime should fail with -1 return value and sets errno ENOENT.
- *
- * Algorithm:
- *  Setup:
- *   Setup signal handling.
- *   Create temporary directory.
- *   Pause for SIGUSR1 if option specified.
- *
- *  Test:
- *   Loop if the proper options are given.
- *   Execute system call
- *   Check return code, if system call failed (return=-1)
- *	if errno set == expected errno
- *		Issue sys call fails with expected return value and errno.
- *	Otherwise,
- *		Issue sys call fails with unexpected errno.
- *   Otherwise,
- *	Issue sys call returns unexpected value.
- *
- *  Cleanup:
- *   Print errno log and/or timing stats if options given
- *   Delete the temporary directory(s)/file(s) created.
- *
- * Usage:  <for command-line>
- *  utime06 [-c n] [-e] [-i n] [-I x] [-p x] [-t]
- *	where,  -c n : Run n copies concurrently.
- *		-e   : Turn on errno logging.
- *		-i n : Execute test n times.
- *		-I x : Execute test for x seconds.
- *		-P x : Pause for x seconds between iterations.
- *		-t   : Turn on syscall timing.
- *
- * History
- *	07/2001 John George
- *		-Ported
- *
- * Restrictions:
- *  This test must be executed by root.
- *   nobody and bin must be valid users.
  */
 
 #include <errno.h>
@@ -90,230 +43,93 @@
 
 #include "test.h"
 #include "usctest.h"
+#include "safe_macros.h"
 
-#define LTPUSER1        "nobody"
-#define LTPUSER2        "bin"
 #define TEMP_FILE	"tmp_file"
-#define FILE_MODE	S_IRUSR | S_IRGRP | S_IROTH
 
 char *TCID = "utime06";
-int TST_TOTAL = 2;
-time_t curr_time;		/* current time in seconds */
-time_t tloc;			/* argument var. for time() */
-int exp_enos[] = { EACCES, ENOENT, 0 };
+static int exp_enos[] = { EACCES, ENOENT, 0 };
 
-struct passwd *ltpuser;		/* password struct for ltpusers */
-uid_t user_uid;			/* user id of ltpuser */
-gid_t group_gid;		/* group id of ltpuser */
-int status;
+static struct passwd *ltpuser;
 
-int setup1();			/* setup function to test error EACCES */
-int no_setup();
-
-struct test_case_t {		/* test case struct. to hold ref. test cond's */
+struct test_case_t {
 	char *pathname;
-	char *desc;
 	int exp_errno;
-	int (*setupfunc) ();
 } Test_cases[] = {
-	{
-	TEMP_FILE, "Permission denied to modify file time", EACCES, setup1},
-	{
-	"", "Specified file doesn't exist", ENOENT, no_setup}, {
-	NULL, NULL, 0, NULL}
+	{TEMP_FILE, EACCES},
+	{"", ENOENT},
 };
 
-void setup();			/* Main setup function of test */
-void cleanup();			/* cleanup function for the test */
+int TST_TOTAL = ARRAY_SIZE(Test_cases);
+static void setup(void);
+static void utime_verify(const struct test_case_t *);
+static void cleanup(void);
 
 int main(int ac, char **av)
 {
 	int lc;
 	const char *msg;
-	char *file_name;	/* testfile name */
-	char *test_desc;	/* test specific error message */
-	int ind;		/* counter to test different test conditions */
-	int pid;
+	int i;
 
 	msg = parse_opts(ac, av, NULL, NULL);
-	if (msg != NULL) {
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 
-	}
-
 	setup();
 
-	/* set the expected errnos... */
-	TEST_EXP_ENOS(exp_enos);
-
-	pid = FORK_OR_VFORK();
-
-	if (pid == -1) {
-		tst_brkm(TBROK, cleanup, "fork() failed");
-	} else if (pid == 0) {
-		if ((ltpuser = getpwnam(LTPUSER1)) == NULL) {
-			tst_brkm(TBROK, cleanup, "%s not found in /etc/passwd",
-				 LTPUSER1);
-		}
-
-		/* get uid of user */
-		user_uid = ltpuser->pw_uid;
-
-		seteuid(user_uid);
-
-		for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-			tst_count = 0;
-
-			for (ind = 0; Test_cases[ind].desc != NULL; ind++) {
-				file_name = Test_cases[ind].pathname;
-				test_desc = Test_cases[ind].desc;
-
-				/*
-				 * Call utime(2) to test different test
-				 * conditions. Verify that it fails with -1
-				 * return value and sets appropriate errno.
-				 */
-				TEST(utime(file_name, NULL));
-
-				/* Check return code from utime(2) */
-				if (TEST_RETURN == -1) {
-					TEST_ERROR_LOG(TEST_ERRNO);
-					if (TEST_ERRNO ==
-					    Test_cases[ind].exp_errno) {
-						tst_resm(TPASS, "utime() "
-							 "fails, %s, errno:%d",
-							 test_desc, TEST_ERRNO);
-					} else {
-						tst_resm(TFAIL, "utime(2) "
-							 "fails, %s, errno:%d, "
-							 "expected errno:%d",
-							 test_desc, TEST_ERRNO,
-							 Test_cases
-							 [ind].exp_errno);
-					}
-				} else {
-					tst_resm(TFAIL,
-						 "utime(2) returned %ld, "
-						 "expected -1, errno:%d",
-						 TEST_RETURN,
-						 Test_cases[ind].exp_errno);
-				}
-			}
-
-			tst_count++;	/* incr TEST_LOOP counter */
-
-		}
-	} else {
-		waitpid(pid, &status, 0);
-		_exit(0);	/*
-				 * Exit here and let the child clean up.
-				 * This allows the errno information set
-				 * by the TEST_ERROR_LOG macro and the
-				 * PASS/FAIL status to be preserved for
-				 * use during cleanup.
-				 */
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		tst_count = 0;
+		for (i = 0; i < TST_TOTAL; i++)
+			utime_verify(&Test_cases[i]);
 	}
 
 	cleanup();
 	tst_exit();
-
 }
 
-/*
- * void
- * setup() - performs all ONE TIME setup for this test.
- *  Create a temporary directory and change directory to it.
- *  Invoke individual test setup functions according to the order
- *  set in test struct. definition.
- */
-void setup(void)
+static void setup(void)
 {
-	int ind;
+	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	/* Check that the test process id is non-super/root  */
-	if (geteuid() != 0) {
-		tst_brkm(TBROK, NULL, "Must be root for this test!");
-		tst_exit();
-	}
+	tst_require_root(NULL);
 
 	TEST_PAUSE;
 
 	tst_tmpdir();
 
-	/* call individual setup functions */
-	for (ind = 0; Test_cases[ind].desc != NULL; ind++) {
-		Test_cases[ind].setupfunc();
-	}
-}
+	SAFE_TOUCH(cleanup, TEMP_FILE, 0644, NULL);
 
-/*
- * int
- * no_setup() - Some test conditions for utime(2) do not any setup.
- *              Hence, this function just returns 0.
- */
-int no_setup(void)
-{
-	return 0;
-}
+	TEST_EXP_ENOS(exp_enos);
 
-/*
- * int
- * setup1() - setup function for a test condition for which utime(2)
- *		returns -1 and sets errno to EACCES.
- *  Create a testfile under temporary directory and change the ownership of
- *  testfile to "bin".
- */
-int setup1(void)
-{
-	int fildes;		/* file handle for temp file */
+	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
 
-	/* Creat a temporary file under above directory */
-	if ((fildes = creat(TEMP_FILE, FILE_MODE)) == -1) {
-		tst_brkm(TBROK, cleanup, "creat(%s, %#o) Failed, errno=%d :%s",
-			 TEMP_FILE, FILE_MODE, errno, strerror(errno));
-	}
+	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
+}
 
-	/* Close the temporary file created */
-	if (close(fildes) < 0) {
-		tst_brkm(TBROK, cleanup, "close(%s) Failed, errno=%d : %s:",
-			 TEMP_FILE, errno, strerror(errno));
-	}
+static void utime_verify(const struct test_case_t *test)
+{
+	TEST(utime(test->pathname, NULL));
 
-	if ((ltpuser = getpwnam(LTPUSER2)) == NULL) {
-		tst_brkm(TBROK, cleanup, "%s not found in /etc/passwd",
-			 LTPUSER2);
+	if (TEST_RETURN != -1) {
+		tst_resm(TFAIL, "utime succeeded unexpectedly");
+		return;
 	}
 
-	/* get uid/gid of user accordingly */
-	user_uid = ltpuser->pw_uid;
-	group_gid = ltpuser->pw_gid;
-
-	if (chown(TEMP_FILE, user_uid, group_gid) < 0) {
-		tst_brkm(TBROK, cleanup, "chown() of %s failed, error %d",
-			 TEMP_FILE, errno);
+	if (TEST_ERRNO == test->exp_errno) {
+		tst_resm(TPASS | TTERRNO, "utime failed as expected");
+	} else {
+		tst_resm(TFAIL | TTERRNO,
+			 "utime failed unexpectedly; expected: %d - %s",
+			 test->exp_errno, strerror(test->exp_errno));
 	}
-
-	return 0;
 }
 
-/*
- * void
- * cleanup() - performs all ONE TIME cleanup for this test at
- *             completion or premature exit.
- *  Remove the test directory and testfile created in the setup.
- */
-void cleanup(void)
+static void cleanup(void)
 {
-	seteuid(0);
-	/*
-	 * print timing stats if that option was specified.
-	 * print errno log if that option was specified.
-	 */
+	if (seteuid(0) != 0)
+		tst_resm(TWARN | TERRNO, "seteuid failed");
+
 	TEST_CLEANUP;
 
 	tst_rmdir();
-
 }
-- 
1.9.3




------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 3/3] utime/utime06.c: add EPERM and EROFS errno testes
  2014-06-13  1:58 [LTP] [PATCH 1/3] syscalls: fix returning TCONF without device Zeng Linggang
  2014-06-13  1:59 ` [LTP] [PATCH 2/3] utime/utime06.c: cleanup Zeng Linggang
@ 2014-06-13  2:01 ` Zeng Linggang
  2014-06-13 11:56 ` [LTP] [PATCH 1/3] syscalls: fix returning TCONF without device Jan Stancek
  2 siblings, 0 replies; 7+ messages in thread
From: Zeng Linggang @ 2014-06-13  2:01 UTC (permalink / raw)
  To: ltp-list

Add EPERM and EROFS errno testes for utime(2).

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 runtest/ltplite                           |  2 +-
 runtest/stress.part3                      |  2 +-
 runtest/syscalls                          |  2 +-
 testcases/kernel/syscalls/utime/utime06.c | 84 +++++++++++++++++++++++++++----
 4 files changed, 76 insertions(+), 14 deletions(-)

diff --git a/runtest/ltplite b/runtest/ltplite
index d71f137..c8ac0ce 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -973,7 +973,7 @@ utime02 utime02
 utime03 utime03
 utime04 utime04
 utime05 utime05
-utime06 utime06
+utime06 utime06 -D $LTP_DEV -T $LTP_DEV_FS_TYPE
 
 vfork01 vfork01
 vfork02 vfork02
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index bc71013..6340445 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -851,7 +851,7 @@ utime02 utime02
 utime03 utime03
 utime04 utime04
 utime05 utime05
-utime06 utime06
+utime06 utime06 -D $LTP_DEV -T $LTP_DEV_FS_TYPE
 
 vfork01 vfork01
 vfork02 vfork02
diff --git a/runtest/syscalls b/runtest/syscalls
index 3db5f2a..af11801 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1312,7 +1312,7 @@ utime02 utime02
 utime03 utime03
 utime04 utime04
 utime05 utime05
-utime06 utime06
+utime06 utime06 -D $LTP_DEV -T $LTP_DEV_FS_TYPE
 
 utimes01 utimes01
 
diff --git a/testcases/kernel/syscalls/utime/utime06.c b/testcases/kernel/syscalls/utime/utime06.c
index 2dd68d8..2eed21c 100644
--- a/testcases/kernel/syscalls/utime/utime06.c
+++ b/testcases/kernel/syscalls/utime/utime06.c
@@ -26,6 +26,13 @@
  *	 - The user ID of the process is not "root".
  * 2. Verify that the system call utime() fails to set the modification
  *    and access times of a file if the specified file doesn't exist.
+ * 3. Verify that the system call utime() fails to set the modification
+ *    and access times of a file to the current time, under the following
+ *    constraints,
+ *	 - The times argument is not null.
+ *	 - The user ID of the process is not "root".
+ * 4. Verify that the system call utime() fails to set the modification
+ *    and access times of a file that resides on a read-only file system.
  */
 
 #include <errno.h>
@@ -40,30 +47,50 @@
 #include <wait.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/mount.h>
 
 #include "test.h"
 #include "usctest.h"
 #include "safe_macros.h"
 
 #define TEMP_FILE	"tmp_file"
+#define MNT_POINT	"mntpoint"
 
 char *TCID = "utime06";
-static int exp_enos[] = { EACCES, ENOENT, 0 };
-
+static int exp_enos[] = { EACCES, ENOENT, EPERM, EROFS, 0 };
 static struct passwd *ltpuser;
+static const struct utimbuf times;
+static char *fstype = "ext2";
+static char *device;
+static int mount_flag;
+
+static void setup_nobody(void);
+static void cleanup_nobody(void);
+
+static option_t options[] = {
+	{"T:", NULL, &fstype},
+	{"D:", NULL, &device},
+	{NULL, NULL, NULL}
+};
 
 struct test_case_t {
 	char *pathname;
 	int exp_errno;
+	const struct utimbuf *times;
+	void (*setup_func)(void);
+	void (*cleanup_func)(void);
 } Test_cases[] = {
-	{TEMP_FILE, EACCES},
-	{"", ENOENT},
+	{TEMP_FILE, EACCES, NULL, setup_nobody, cleanup_nobody},
+	{"", ENOENT, NULL, NULL, NULL},
+	{TEMP_FILE, EPERM, &times, setup_nobody, cleanup_nobody},
+	{MNT_POINT, EROFS, NULL, NULL, NULL},
 };
 
 int TST_TOTAL = ARRAY_SIZE(Test_cases);
 static void setup(void);
 static void utime_verify(const struct test_case_t *);
 static void cleanup(void);
+static void help(void);
 
 int main(int ac, char **av)
 {
@@ -71,10 +98,16 @@ int main(int ac, char **av)
 	const char *msg;
 	int i;
 
-	msg = parse_opts(ac, av, NULL, NULL);
+	msg = parse_opts(ac, av, options, help);
 	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 
+	if (!device) {
+		tst_brkm(TCONF, NULL,
+			 "you must specify the device used for mounting with "
+			 "-D option");
+	}
+
 	setup();
 
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
@@ -101,14 +134,26 @@ static void setup(void)
 
 	TEST_EXP_ENOS(exp_enos);
 
-	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
+	tst_mkfs(NULL, device, fstype, NULL);
+	SAFE_MKDIR(cleanup, MNT_POINT, 0644);
+	if (mount(device, MNT_POINT, fstype, MS_RDONLY, NULL) < 0) {
+		tst_brkm(TBROK | TERRNO, cleanup,
+			 "mount device:%s failed", device);
+	}
+	mount_flag = 1;
 
-	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
+	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
 }
 
 static void utime_verify(const struct test_case_t *test)
 {
-	TEST(utime(test->pathname, NULL));
+	if (test->setup_func != NULL)
+		test->setup_func();
+
+	TEST(utime(test->pathname, test->times));
+
+	if (test->cleanup_func != NULL)
+		test->cleanup_func();
 
 	if (TEST_RETURN != -1) {
 		tst_resm(TFAIL, "utime succeeded unexpectedly");
@@ -124,12 +169,29 @@ static void utime_verify(const struct test_case_t *test)
 	}
 }
 
-static void cleanup(void)
+static void setup_nobody(void)
+{
+	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
+}
+
+static void cleanup_nobody(void)
 {
-	if (seteuid(0) != 0)
-		tst_resm(TWARN | TERRNO, "seteuid failed");
+	SAFE_SETEUID(cleanup, 0);
+}
 
+static void cleanup(void)
+{
 	TEST_CLEANUP;
 
+	if (mount_flag && umount(MNT_POINT) < 0)
+		tst_resm(TWARN | TERRNO, "umount device:%s failed", device);
+
 	tst_rmdir();
 }
+
+static void help(void)
+{
+	printf("-T type   : specifies the type of filesystem to be mounted. "
+	       "Default ext2.\n");
+	printf("-D device : device used for mounting.\n");
+}
-- 
1.9.3




------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/3] syscalls: fix returning TCONF without device
  2014-06-13  1:58 [LTP] [PATCH 1/3] syscalls: fix returning TCONF without device Zeng Linggang
  2014-06-13  1:59 ` [LTP] [PATCH 2/3] utime/utime06.c: cleanup Zeng Linggang
  2014-06-13  2:01 ` [LTP] [PATCH 3/3] utime/utime06.c: add EPERM and EROFS errno testes Zeng Linggang
@ 2014-06-13 11:56 ` Jan Stancek
       [not found]   ` <1402972112.2294.26.camel@G08JYZSD130126>
  2 siblings, 1 reply; 7+ messages in thread
From: Jan Stancek @ 2014-06-13 11:56 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list





----- Original Message -----
> From: "Zeng Linggang" <zenglg.jy@cn.fujitsu.com>
> To: "ltp-list" <ltp-list@lists.sourceforge.net>
> Sent: Friday, 13 June, 2014 3:58:17 AM
> Subject: [LTP] [PATCH 1/3] syscalls: fix returning TCONF without device
> 
> The cases are:
> 1. mknod07
> 2. lchown03
> 3. mkdir03
> 4. linkat02
> 5. mknodat02
> 6. fchown04
> 7. mkdirat02
> 8. link08
> 
> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>

Hi,

sorry if I missed some previous discussion, but what's the purpose
of this change?

I like TBROK here, because if you forget the required parameter,
testcase will end with non-zero exit code, which should be
easily visible for any test harness, while with TCONF the
problem can go unnoticed (with retcode == 0).

Regards,
Jan

> ---
>  testcases/kernel/syscalls/fchown/fchown04.c   | 2 +-
>  testcases/kernel/syscalls/lchown/lchown03.c   | 2 +-
>  testcases/kernel/syscalls/link/link08.c       | 2 +-
>  testcases/kernel/syscalls/linkat/linkat02.c   | 2 +-
>  testcases/kernel/syscalls/mkdir/mkdir03.c     | 2 +-
>  testcases/kernel/syscalls/mkdirat/mkdirat02.c | 2 +-
>  testcases/kernel/syscalls/mknod/mknod07.c     | 2 +-
>  testcases/kernel/syscalls/mknodat/mknodat02.c | 2 +-
>  8 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/fchown/fchown04.c
> b/testcases/kernel/syscalls/fchown/fchown04.c
> index 68f6611..2a8b8c6 100644
> --- a/testcases/kernel/syscalls/fchown/fchown04.c
> +++ b/testcases/kernel/syscalls/fchown/fchown04.c
> @@ -91,7 +91,7 @@ int main(int ac, char **av)
>  		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
>  
>  	if (!device) {
> -		tst_brkm(TBROK, NULL,
> +		tst_brkm(TCONF, NULL,
>  			 "you must specify the device used for mounting with "
>  			 "-D option");
>  	}
> diff --git a/testcases/kernel/syscalls/lchown/lchown03.c
> b/testcases/kernel/syscalls/lchown/lchown03.c
> index ea8f38a..391afb4 100644
> --- a/testcases/kernel/syscalls/lchown/lchown03.c
> +++ b/testcases/kernel/syscalls/lchown/lchown03.c
> @@ -84,7 +84,7 @@ int main(int argc, char *argv[])
>  		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
>  
>  	if (!device) {
> -		tst_brkm(TBROK, NULL,
> +		tst_brkm(TCONF, NULL,
>  			 "you must specify the device used for mounting with "
>  			 "-D option");
>  	}
> diff --git a/testcases/kernel/syscalls/link/link08.c
> b/testcases/kernel/syscalls/link/link08.c
> index aed5479..48274b4 100644
> --- a/testcases/kernel/syscalls/link/link08.c
> +++ b/testcases/kernel/syscalls/link/link08.c
> @@ -99,7 +99,7 @@ int main(int ac, char **av)
>  		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
>  
>  	if (!device) {
> -		tst_brkm(TBROK, NULL,
> +		tst_brkm(TCONF, NULL,
>  			 "you must specify the device used for mounting with "
>  			 "-D option");
>  	}
> diff --git a/testcases/kernel/syscalls/linkat/linkat02.c
> b/testcases/kernel/syscalls/linkat/linkat02.c
> index b899fa6..984ede6 100644
> --- a/testcases/kernel/syscalls/linkat/linkat02.c
> +++ b/testcases/kernel/syscalls/linkat/linkat02.c
> @@ -109,7 +109,7 @@ int main(int ac, char **av)
>  		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
>  
>  	if (!device) {
> -		tst_brkm(TBROK, NULL,
> +		tst_brkm(TCONF, NULL,
>  			 "you must specify the device used for mounting with "
>  			 "-D option");
>  	}
> diff --git a/testcases/kernel/syscalls/mkdir/mkdir03.c
> b/testcases/kernel/syscalls/mkdir/mkdir03.c
> index b037ad3..e897c2e 100644
> --- a/testcases/kernel/syscalls/mkdir/mkdir03.c
> +++ b/testcases/kernel/syscalls/mkdir/mkdir03.c
> @@ -96,7 +96,7 @@ int main(int ac, char **av)
>  		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
>  
>  	if (!device) {
> -		tst_brkm(TBROK, NULL,
> +		tst_brkm(TCONF, NULL,
>  			 "you must specify the device used for mounting with "
>  			 "-D option");
>  	}
> diff --git a/testcases/kernel/syscalls/mkdirat/mkdirat02.c
> b/testcases/kernel/syscalls/mkdirat/mkdirat02.c
> index 827ad54..27de4e9 100644
> --- a/testcases/kernel/syscalls/mkdirat/mkdirat02.c
> +++ b/testcases/kernel/syscalls/mkdirat/mkdirat02.c
> @@ -83,7 +83,7 @@ int main(int ac, char **av)
>  		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
>  
>  	if (!device) {
> -		tst_brkm(TBROK, NULL,
> +		tst_brkm(TCONF, NULL,
>  			 "you must specify the device used for mounting with "
>  			 "-D option");
>  	}
> diff --git a/testcases/kernel/syscalls/mknod/mknod07.c
> b/testcases/kernel/syscalls/mknod/mknod07.c
> index 5311cfc..df9f8d7 100644
> --- a/testcases/kernel/syscalls/mknod/mknod07.c
> +++ b/testcases/kernel/syscalls/mknod/mknod07.c
> @@ -106,7 +106,7 @@ int main(int ac, char **av)
>  		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
>  
>  	if (!device) {
> -		tst_brkm(TBROK, NULL, "you must specify the device "
> +		tst_brkm(TCONF, NULL, "you must specify the device "
>  			 "used for mounting with -D option");
>  	}
>  
> diff --git a/testcases/kernel/syscalls/mknodat/mknodat02.c
> b/testcases/kernel/syscalls/mknodat/mknodat02.c
> index 3de049b..eec5b98 100644
> --- a/testcases/kernel/syscalls/mknodat/mknodat02.c
> +++ b/testcases/kernel/syscalls/mknodat/mknodat02.c
> @@ -103,7 +103,7 @@ int main(int ac, char **av)
>  		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
>  
>  	if (!device) {
> -		tst_brkm(TBROK, NULL, "you must specify the device "
> +		tst_brkm(TCONF, NULL, "you must specify the device "
>  			 "used for mounting with -D option");
>  	}
>  
> --
> 1.9.3
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
> Find What Matters Most in Your Big Data with HPCC Systems
> Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
> Leverages Graph Analysis for Fast Processing & Easy Data Exploration
> http://p.sf.net/sfu/hpccsystems
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/3] syscalls: fix returning TCONF without device
       [not found]   ` <1402972112.2294.26.camel@G08JYZSD130126>
@ 2014-06-17 11:11     ` chrubis
  2014-06-18 15:58       ` chrubis
  0 siblings, 1 reply; 7+ messages in thread
From: chrubis @ 2014-06-17 11:11 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
> > I like TBROK here, because if you forget the required parameter,
> > testcase will end with non-zero exit code, which should be
> > easily visible for any test harness, while with TCONF the
> > problem can go unnoticed (with retcode == 0).

Yes, I think that this should be TCONF rather than TBROK because the
conditions for the test weren't met.

However I understand your concerns as well and this is a one of the
reasons I was thinking of changing the library to propagate the TCONF to
the test exit value as well.

Ideally we should fix the GitHub issue #11 which would change the code
so that we don't have to do the check in the first place.
(https://github.com/linux-test-project/ltp/issues/11)

I was thinking of adding a function that would either get the LTP_DEV
env variable or create a loop0 device if LTP_DEV is not set and will
format it with LTP_DEV_FS_TYPE or a default passed value and it's
counter part that does the cleanup.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/3] syscalls: fix returning TCONF without device
  2014-06-17 11:11     ` chrubis
@ 2014-06-18 15:58       ` chrubis
       [not found]         ` <1403144011.10350.8.camel@G08JYZSD130126>
  0 siblings, 1 reply; 7+ messages in thread
From: chrubis @ 2014-06-18 15:58 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
> I was thinking of adding a function that would either get the LTP_DEV
> env variable or create a loop0 device if LTP_DEV is not set and will
> format it with LTP_DEV_FS_TYPE or a default passed value and it's
> counter part that does the cleanup.

I've pushed the function implementation + documentation in
test-writing-guidelines. Have a look if you are interested.

It turned out to be a bit more challenging than I expected because the
loop ioctls() and are poorly documented...

The next step would rewriting all testcases that gets the device as
parameters to use the new interface. I will have a look at these
tomorrow.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH v2 2/2] utime/utime06.c: add EPERM and EROFS errno testes
       [not found]           ` <1403144473.10350.12.camel@G08JYZSD130126>
@ 2014-06-24 13:06             ` chrubis
  0 siblings, 0 replies; 7+ messages in thread
From: chrubis @ 2014-06-24 13:06 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list

Hi!
> +	dev = tst_acquire_device(cleanup);
> +	if (!dev)
> +		tst_brkm(TCONF, cleanup, "Failed to acquire test device");
>  
> -	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
> +	tst_mkfs(cleanup, dev, "ext2", NULL);
> +
> +	SAFE_MKDIR(cleanup, MNT_POINT, 0644);
> +	if (mount(dev, MNT_POINT, "ext2", MS_RDONLY, NULL) < 0) {
> +		tst_brkm(TBROK | TERRNO, cleanup,
> +			 "mount device:%s failed", dev);
> +	}
> +	mount_flag = 1;
> +
> +	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
>  }

I've changed this part to use the tst_dev_fs_type() function to
determine the filesystem type (that I've added for this purpose) and
pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2014-06-24 13:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-13  1:58 [LTP] [PATCH 1/3] syscalls: fix returning TCONF without device Zeng Linggang
2014-06-13  1:59 ` [LTP] [PATCH 2/3] utime/utime06.c: cleanup Zeng Linggang
2014-06-13  2:01 ` [LTP] [PATCH 3/3] utime/utime06.c: add EPERM and EROFS errno testes Zeng Linggang
2014-06-13 11:56 ` [LTP] [PATCH 1/3] syscalls: fix returning TCONF without device Jan Stancek
     [not found]   ` <1402972112.2294.26.camel@G08JYZSD130126>
2014-06-17 11:11     ` chrubis
2014-06-18 15:58       ` chrubis
     [not found]         ` <1403144011.10350.8.camel@G08JYZSD130126>
     [not found]           ` <1403144473.10350.12.camel@G08JYZSD130126>
2014-06-24 13:06             ` [LTP] [PATCH v2 2/2] utime/utime06.c: add EPERM and EROFS errno testes chrubis

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.