public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] rmdir/rmdir02.c: cleanup
@ 2014-04-17 10:50 gux.fnst
  2014-04-17 10:50 ` [LTP] [PATCH 2/2] rmdir/rmdir02.c: add ELOOP, EROFS and EBUSY error value tests gux.fnst
  2014-05-15 12:12 ` [LTP] [PATCH 1/2] rmdir/rmdir02.c: cleanup chrubis
  0 siblings, 2 replies; 6+ messages in thread
From: gux.fnst @ 2014-04-17 10:50 UTC (permalink / raw)
  To: ltp-list@lists.sourceforge.net

Delete some useless comments.
Use some SAFE_* macros.
Move the test body from main() to rmdir_verify().

Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
 testcases/kernel/syscalls/rmdir/rmdir02.c | 406 +++++++-----------------------
 1 file changed, 91 insertions(+), 315 deletions(-)

diff --git a/testcases/kernel/syscalls/rmdir/rmdir02.c b/testcases/kernel/syscalls/rmdir/rmdir02.c
index dfea028..9ae919a 100644
--- a/testcases/kernel/syscalls/rmdir/rmdir02.c
+++ b/testcases/kernel/syscalls/rmdir/rmdir02.c
@@ -1,381 +1,157 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ * 07/2001 Ported by Wayne Boyer
  *
- *   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.
  */
-
 /*
- * NAME
- *	rmdir02
- *
- * DESCRIPTION
- *	This test will verify that rmdir(2) fail in
- *      1. ENOTEMPTY
- *      2. ENAMETOOLONG
- *      3. ENOENT
- *      4. ENOTDIR
- *      5. EFAULT
- *      6. EFAULT
- *
- * ALGORITHM
- *	Setup:
- *		Setup signal handling.
- *		Pause for SIGUSR1 if option specified.
- *		Create temporary directory.
- *
- *	Test:
- *		Loop if the proper options are given.
- *              1. create a directory tstdir1, create a file under it.
- *                 call rmdir(tstdir1), verify the return value is not 0
- *                 and the errno is ENOTEMPTY
- *              2. create a directory with long path,
- *                 call rmdir(tstdir1), verify the return value is not 0
- *                 and the errno is ENAMETOOLONG
- *              3. pass a pathname containing non-exist directory component
- *                 to rmdir() and check the return value and errno (expect
- *                 ENOENT
- *              4. pass a pathname containing a file component
- *                 to rmdir() and check the return value and errno (expect
- *                 ENOTDIR
- *	        5. Attempt to pass an invalid pathname with an address
- *                 pointing outside the address space of the process,
- *                 as the argument to rmdir(), and expect to get EFAULT.
- *		6. Attempt to pass an invalid pathname with NULL
- *                 as the argument to rmdir(), and expect to get EFAULT.
- *
- *	Cleanup:
- *		Print errno log and/or timing stats if options given
- *		Delete the temporary directory created.
- *
- * USAGE
- *	rmdir02 [-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 Ported by Wayne Boyer
- *
- * RESTRICTIONS
- *	None.
+ * Description:
+ *   1) create a directory tstdir1, create a file under it. call
+ *      rmdir(), verify the return value is -1 and the errno is
+ *      ENOTEMPTY.
+ *   2) create a directory with long path, call rmdir(), verify
+ *      the return value is -1 and the errno is ENAMETOOLONG.
+ *   3) pass a pathname containing non-exist directory component
+ *      to rmdir(), verify the return value is -1 and the errno
+ *      is ENOENT.
+ *   4) pass a pathname containing a file component to rmdir(),
+ *      verify the return value is -1 and the errno is ENOTDIR.
+ *   5) attempt to pass an invalid pathname with an address
+ *      pointing outside the address space of the process, as the
+ *      argument to rmdir(), verify the return value is -1 and
+ *      the errno is EFAULT.
+ *   6) attempt to pass an invalid pathname with NULL, as the
+ *      argument to rmdir(), verify the return value is -1 and
+ *      the errno is EFAULT.
  */
+
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <fcntl.h>
 #include <unistd.h>
+
 #include "test.h"
 #include "usctest.h"
+#include "safe_macros.h"
 
-void setup();
-void cleanup();
-int create_longpath();
-void remove_longpath();
-void set_condition();
-void do_file_setup(char *);
-
-#define PERMS		0777
-
-char *TCID = "rmdir02";
-
-int exp_enos[] = { ENOTEMPTY, EBUSY, ENAMETOOLONG, ENOENT, ENOTDIR, EFAULT, 0 };
+#define DIR_MODE	(S_IRWXU | S_IRWXG | S_IRWXO)
+#define FILE_MODE	(S_IRWXU | S_IRWXG | S_IRWXO)
 
-char *bad_addr = 0;
+#define TESTDIR		"testdir"
+#define TESTDIR2	"nosuchdir/testdir2"
+#define TESTDIR3	"testfile2/testdir3"
+#define TESTFILE    "testdir/testfile"
+#define TESTFILE2   "testfile2"
 
-char tstfile[255];
-char tstdir1[255];
-char tstdir2[255];
-char tstdir3[255];
-char longname[255];
-char longpath[2 * PATH_MAX];
-char cwd[255];
+static char longpathname[PATH_MAX + 2];
 
-struct test_case_t {
+static struct test_case_t {
 	char *dir;
-	int error;
-	void (*set_cond) (int);
-} TC[] = {
-	/* The directory is not empty - ENOTEMPTY */
-	{
-	tstdir1, ENOTEMPTY, set_condition},
-	    /* The directory pathname is too long - ENAMETOOLONG */
-	{
-	longpath, ENAMETOOLONG, set_condition},
-	    /* A component of the pathname does not exists - ENOENT */
-	{
-	tstdir2, ENOENT, set_condition},
-	    /* The given argument is not a directory - ENOTDIR */
-	{
-	tstdir3, ENOTDIR, set_condition},
+	int exp_errno;
+} test_cases[] =  {
+	{ TESTDIR, ENOTEMPTY },
+	{ longpathname, ENAMETOOLONG },
+	{ TESTDIR2, ENOENT },
+	{ TESTDIR3, ENOTDIR },
 #if !defined(UCLINUX)
-	    /* The argument is illegal - EFAULT */
-	{
-	(char *)-1, EFAULT, NULL},
+	{ (char *)-1, EFAULT },
 #endif
-	    /* The argument is illegal - EFAULT */
-	{
-	NULL, EFAULT, NULL}
+	{ NULL, EFAULT },
 };
 
-int TST_TOTAL = (sizeof(TC) / sizeof(*TC));
+static void setup(void);
+static void rmdir_verify(struct test_case_t *tc);
+static void cleanup(void);
+
+char *TCID = "rmdir02";
+int TST_TOTAL = ARRAY_SIZE(test_cases);
+static int exp_enos[] = { ENOTEMPTY, ENAMETOOLONG, ENOENT, ENOTDIR,
+				EFAULT, 0 };
 
 int main(int ac, char **av)
 {
-	int lc;
+	int i, lc;
 	char *msg;
-	int i;
 
-	/*
-	 * parse standard options
-	 */
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-	}
 
-	/*
-	 * perform global setup for test
-	 */
 	setup();
 
-	/* set the expected errnos... */
 	TEST_EXP_ENOS(exp_enos);
 
-	/*
-	 * check looping state if -i option given
-	 */
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
 		tst_count = 0;
 
-		/* save current working directory */
-		getcwd(cwd, 255);
-
-		/* loop through the test cases */
-		for (i = 0; i < TST_TOTAL; i++) {
-
-			/* make sure we start at the same place */
-			chdir(cwd);
-
-			if (TC[i].set_cond != NULL) {
-				TC[i].set_cond(i + 1);
-			}
-
-			TEST(rmdir(TC[i].dir));
-
-			if (TEST_RETURN != -1) {
-				tst_resm(TFAIL, "call succeeded unexpectedly");
-				continue;
-			}
-
-			TEST_ERROR_LOG(TEST_ERRNO);
-
-			if (TEST_ERRNO == TC[i].error) {
-				tst_resm(TPASS, "expected failure - "
-					 "errno = %d : %s", TEST_ERRNO,
-					 strerror(TEST_ERRNO));
-			} else {
-				tst_resm(TFAIL, "unexpected error - %d : %s - "
-					 "expected %d", TEST_ERRNO,
-					 strerror(TEST_ERRNO), TC[i].error);
-			}
-		}
-		/* clean up things in case we are looping */
-		(void)unlink(tstfile);
-
-		(void)rmdir(tstdir1);
-		(void)rmdir(tstdir2);
-		(void)rmdir(tstdir3);
-
+		for (i = 0; i < TST_TOTAL; i++)
+			rmdir_verify(&test_cases[i]);
 	}
 
-	/*
-	 * cleanup and exit
-	 */
 	cleanup();
 	tst_exit();
-
 }
 
-/*
- * set_condition - set up starting conditions for the individual tests
- */
-void set_condition(int num)
+static void setup(void)
 {
-	int fd;
-	switch (num) {
-	case 1:
-		/* set up for first test */
-		sprintf(tstdir1, "./tstdir1_%d", getpid());
-		sprintf(tstfile, "%s/tstfile_%d", tstdir1, getpid());
-
-		/* create a directory */
-		if (mkdir(tstdir1, PERMS) == -1) {
-			tst_brkm(TBROK, cleanup, "mkdir(%s, %#o) Failed",
-				 tstdir1, PERMS);
-		}
-
-		/* create a file under tstdir1 */
-		do_file_setup(tstfile);
-
-		break;
-	case 2:
-		create_longpath();
-		break;
-	case 3:
-		/* Initialize the test directory name */
-		sprintf(tstdir2, "NOSUCHADIR/tstdir2.%d", getpid());
-
-		break;
-	case 4:
-		/* Initialize the test directory name and file name */
-		sprintf(tstdir3, "%s/tstdir3", tstfile);
-
-		/* create a file */
-		if ((fd = creat(tstfile, PERMS)) == -1) {
-			tst_brkm(TBROK, cleanup, "creat() failed");
-		}
-		close(fd);
-		break;
-	default:
-		tst_brkm(TBROK, cleanup, "illegal setup case - %d", num);
-		break;
-	}
-
-}
+	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
-int create_longpath(void)
-{
-	sprintf(longname,
-		"abcdefghivwxyzabcdefgmopqrsqrsrsthmopqrsqrsrstijklmnopjklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdabcdefghijklmopqrsqrsrstmnopqrqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyz_%d/",
-		getpid());
+	TEST_PAUSE;
 
-	chdir(cwd);
+	tst_tmpdir();
 
-	while (strlen(longpath) < PATH_MAX) {
-		/*
-		 * if the longpath is not long enough
-		 * create a sub directory under it
-		 */
-		if (mkdir(longname, PERMS) == -1) {
-			tst_resm(TINFO, "mkdir failed in creae_longpath()");
-			break;
-		}
-		/*
-		 * save the path
-		 */
-		strcat(longpath, longname);
+	SAFE_MKDIR(cleanup, TESTDIR, DIR_MODE);
+	SAFE_TOUCH(cleanup, TESTFILE, FILE_MODE, NULL);
 
-		/*
-		 * cd to the sub directory
-		 */
-		if (chdir(longname) == -1) {
-			tst_resm(TINFO, "chdir failed in create_longpath()");
-			break;
-		}
-	}
+	memset(longpathname, 'a', PATH_MAX + 2);
 
-	/* resume original working directory */
-	chdir(cwd);
+	SAFE_TOUCH(cleanup, TESTFILE2, FILE_MODE, NULL);
 
-	return (strlen(longpath) >= PATH_MAX) ? 0 : -1;
+#if !defined(UCLINUX)
+	test_cases[4].dir = SAFE_MMAP(cleanup, 0, 1, PROT_NONE,
+		MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0);
+#endif
 }
 
-void remove_longpath(void)
+static void rmdir_verify(struct test_case_t *tc)
 {
-	int len, i, j;
-	int path_len;
-
-	chdir(cwd);
+	TEST(rmdir(tc->dir));
 
-	len = strlen(longname);
-	path_len = strlen(longpath);
-
-	/*
-	 * Since we can't rm directory with long pathname directly,
-	 * we remove it's sub directories one by one.
-	 */
-	for (i = (path_len / len) - 1; i >= 0; i--) {
-		for (j = 1; j <= i; j++) {
-			if (chdir(longname) == -1) {
-				tst_resm(TFAIL,
-					 "failed in chdir %s, errno: %d ",
-					 longname, errno);
-				break;
-			}
-		}
-		if (rmdir(longname) == -1) {
-			tst_resm(TFAIL,
-				 "failed in clean %s, errno: %d",
-				 longname, errno);
-			break;
-		}
-		chdir(cwd);
+	if (TEST_RETURN != -1) {
+		tst_resm(TFAIL, "rmdir() returned %ld, "
+			"expected -1, errno:%d", TEST_RETURN,
+			tc->exp_errno);
+		return;
 	}
-	/* resume original working directory */
-	chdir(cwd);
-}
 
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup(void)
-{
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	/* Create a temporary directory and make it current. */
-	tst_tmpdir();
+	TEST_ERROR_LOG(TEST_ERRNO);
 
-#if !defined(UCLINUX)
-	bad_addr = mmap(0, 1, PROT_NONE,
-			MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0);
-	if (bad_addr == MAP_FAILED) {
-		tst_brkm(TBROK, cleanup, "mmap failed");
+	if (TEST_ERRNO == tc->exp_errno) {
+		tst_resm(TPASS | TTERRNO, "rmdir() failed as expected");
+	} else {
+		tst_resm(TFAIL | TTERRNO,
+			"rmdir() failed unexpectedly; expected: %d - %s",
+			tc->exp_errno, strerror(tc->exp_errno));
 	}
-	TC[4].dir = bad_addr;
-#endif
 }
 
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *              completion or premature exit.
- */
-void cleanup(void)
+static void cleanup(void)
 {
-	/*
-	 * print timing stats if that option was specified.
-	 * print errno log if that option was specified.
-	 */
 	TEST_CLEANUP;
 
-	remove_longpath();
-
-	/*
-	 * Remove the temporary directory.
-	 */
 	tst_rmdir();
-
-	/*
-	 * Exit with return code appropriate for results.
-	 */
-
 }
-- 
1.9.0
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 2/2] rmdir/rmdir02.c: add ELOOP, EROFS and EBUSY error value tests
  2014-04-17 10:50 [LTP] [PATCH 1/2] rmdir/rmdir02.c: cleanup gux.fnst
@ 2014-04-17 10:50 ` gux.fnst
  2014-05-15 12:14   ` chrubis
  2014-05-15 12:12 ` [LTP] [PATCH 1/2] rmdir/rmdir02.c: cleanup chrubis
  1 sibling, 1 reply; 6+ messages in thread
From: gux.fnst @ 2014-04-17 10:50 UTC (permalink / raw)
  To: ltp-list@lists.sourceforge.net

Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
 testcases/kernel/syscalls/rmdir/rmdir02.c | 92 ++++++++++++++++++++++++++++---
 1 file changed, 85 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/rmdir/rmdir02.c b/testcases/kernel/syscalls/rmdir/rmdir02.c
index 9ae919a..9d55d76 100644
--- a/testcases/kernel/syscalls/rmdir/rmdir02.c
+++ b/testcases/kernel/syscalls/rmdir/rmdir02.c
@@ -18,11 +18,11 @@
  */
 /*
  * Description:
- *   1) create a directory tstdir1, create a file under it. call
- *      rmdir(), verify the return value is -1 and the errno is
- *      ENOTEMPTY.
- *   2) create a directory with long path, call rmdir(), verify
- *      the return value is -1 and the errno is ENAMETOOLONG.
+ *   1) create a directory tstdir1, create a file under it.
+ *      call rmdir(tstdir1), verify the return value is -1
+ *      and the errno is ENOTEMPTY.
+ *   2) create a directory with long path, call rmdir(tstdir1),
+ *      verify the return value is -1 and the errno is ENAMETOOLONG.
  *   3) pass a pathname containing non-exist directory component
  *      to rmdir(), verify the return value is -1 and the errno
  *      is ENOENT.
@@ -35,6 +35,14 @@
  *   6) attempt to pass an invalid pathname with NULL, as the
  *      argument to rmdir(), verify the return value is -1 and
  *      the errno is EFAULT.
+ *   7) pass a pathname with too many symbolic links to rmdir(),
+ *      verify the return value is -1 and the errno is ELOOP.
+ *   8) pass a pathname which refers to a directory on a read-only
+ *      file system to rmdir(), verify the return value is -1 and
+ *      the errno is EROFS.
+ *   9) pass a pathname which is currently used as a mount point
+ *      to rmdir(), verify the return value is -1 and the errno is
+ *      EBUSY.
  */
 
 #include <errno.h>
@@ -43,6 +51,8 @@
 #include <sys/mman.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <pwd.h>
+#include <sys/mount.h>
 
 #include "test.h"
 #include "usctest.h"
@@ -54,10 +64,24 @@
 #define TESTDIR		"testdir"
 #define TESTDIR2	"nosuchdir/testdir2"
 #define TESTDIR3	"testfile2/testdir3"
+#define TESTDIR4	"/loopdir"
+#define MNTPOINT	"mntpoint"
+#define TESTDIR5	"mntpoint/testdir5"
 #define TESTFILE    "testdir/testfile"
 #define TESTFILE2   "testfile2"
 
 static char longpathname[PATH_MAX + 2];
+static char looppathname[sizeof(TESTDIR4) * 43] = ".";
+
+static char *fstype = "ext2";
+static char *device;
+static int mount_flag;
+
+static option_t options[] = {
+	{"T:", NULL, &fstype},
+	{"D:", NULL, &device},
+	{NULL, NULL, NULL},
+};
 
 static struct test_case_t {
 	char *dir;
@@ -71,26 +95,35 @@ static struct test_case_t {
 	{ (char *)-1, EFAULT },
 #endif
 	{ NULL, EFAULT },
+	{ looppathname, ELOOP },
+	{ TESTDIR5, EROFS },
+	{ MNTPOINT, EBUSY },
 };
 
 static void setup(void);
 static void rmdir_verify(struct test_case_t *tc);
 static void cleanup(void);
+static void help(void);
 
 char *TCID = "rmdir02";
 int TST_TOTAL = ARRAY_SIZE(test_cases);
 static int exp_enos[] = { ENOTEMPTY, ENAMETOOLONG, ENOENT, ENOTDIR,
-				EFAULT, 0 };
+				EFAULT, ELOOP, EROFS, EBUSY, 0 };
 
 int main(int ac, char **av)
 {
 	int i, lc;
 	char *msg;
 
-	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(TBROK, NULL, "you must specify the device "
+			"used for mounting with -D option");
+	}
+
 	setup();
 
 	TEST_EXP_ENOS(exp_enos);
@@ -108,12 +141,34 @@ int main(int ac, char **av)
 
 static void setup(void)
 {
+	int i;
+	struct passwd *ltpuser;
+
+	tst_require_root(NULL);
+
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
 	TEST_PAUSE;
 
 	tst_tmpdir();
 
+	tst_mkfs(NULL, device, fstype, NULL);
+	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
+	if (mount(device, MNTPOINT, fstype, 0, NULL) == -1) {
+		tst_brkm(TBROK | TERRNO, cleanup,
+			"mount device:%s failed", device);
+	}
+	SAFE_MKDIR(cleanup, TESTDIR5, DIR_MODE);
+	if (mount(device, MNTPOINT, fstype, MS_REMOUNT | MS_RDONLY,
+			NULL) == -1) {
+		tst_brkm(TBROK | TERRNO, cleanup,
+			"mount device:%s failed", device);
+	}
+	mount_flag = 1;
+
+	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
+	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
+
 	SAFE_MKDIR(cleanup, TESTDIR, DIR_MODE);
 	SAFE_TOUCH(cleanup, TESTFILE, FILE_MODE, NULL);
 
@@ -125,6 +180,16 @@ static void setup(void)
 	test_cases[4].dir = SAFE_MMAP(cleanup, 0, 1, PROT_NONE,
 		MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0);
 #endif
+
+	/*
+	 * NOTE: the ELOOP test is written based on that the
+	 * consecutive symlinks limit in kernel is hardwired
+	 * to 40.
+	 */
+	SAFE_MKDIR(cleanup, "loopdir", DIR_MODE);
+	SAFE_SYMLINK(cleanup, "../loopdir", "loopdir/loopdir");
+	for (i = 0; i < 43; i++)
+		strcat(looppathname, TESTDIR4);
 }
 
 static void rmdir_verify(struct test_case_t *tc)
@@ -153,5 +218,18 @@ static void cleanup(void)
 {
 	TEST_CLEANUP;
 
+	if (seteuid(0) == -1)
+		tst_resm(TWARN | TERRNO, "seteuid(0) failed");
+
+	if (mount_flag && umount(MNTPOINT) == -1)
+		tst_resm(TWARN | TERRNO, "umount %s failed", MNTPOINT);
+
 	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.0
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/2] rmdir/rmdir02.c: cleanup
  2014-04-17 10:50 [LTP] [PATCH 1/2] rmdir/rmdir02.c: cleanup gux.fnst
  2014-04-17 10:50 ` [LTP] [PATCH 2/2] rmdir/rmdir02.c: add ELOOP, EROFS and EBUSY error value tests gux.fnst
@ 2014-05-15 12:12 ` chrubis
  2014-05-15 12:15   ` chrubis
  1 sibling, 1 reply; 6+ messages in thread
From: chrubis @ 2014-05-15 12:12 UTC (permalink / raw)
  To: gux.fnst@cn.fujitsu.com; +Cc: ltp-list@lists.sourceforge.net

Hi!
> +	memset(longpathname, 'a', PATH_MAX + 2);

I've changed this to:

memset(longpathname, 'a', PATH_MAX + 1);

So that longpathname is zero terminated sting.

> -	/* resume original working directory */
> -	chdir(cwd);
> +	SAFE_TOUCH(cleanup, TESTFILE2, FILE_MODE, NULL);
>  
> -	return (strlen(longpath) >= PATH_MAX) ? 0 : -1;
> +#if !defined(UCLINUX)
> +	test_cases[4].dir = SAFE_MMAP(cleanup, 0, 1, PROT_NONE,
> +		MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0);
> +#endif

And changed the MAP_PRIVATE_EXCEPT_UCLINUX to just MAP_PRIVATE, because
it's in #if !defined(UCLINUX) block anyway.

And pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/2] rmdir/rmdir02.c: add ELOOP, EROFS and EBUSY error value tests
  2014-04-17 10:50 ` [LTP] [PATCH 2/2] rmdir/rmdir02.c: add ELOOP, EROFS and EBUSY error value tests gux.fnst
@ 2014-05-15 12:14   ` chrubis
       [not found]     ` <53756E7A.6070009@cn.fujitsu.com>
  0 siblings, 1 reply; 6+ messages in thread
From: chrubis @ 2014-05-15 12:14 UTC (permalink / raw)
  To: gux.fnst@cn.fujitsu.com; +Cc: ltp-list@lists.sourceforge.net

Hi!
>  int main(int ac, char **av)
>  {
>  	int i, lc;
>  	char *msg;
>  
> -	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(TBROK, NULL, "you must specify the device "
> +			"used for mounting with -D option");
                 This should be TCONF rather than TBROK (I've fixed
		 that).


>  	setup();
>  
>  	TEST_EXP_ENOS(exp_enos);
> @@ -108,12 +141,34 @@ int main(int ac, char **av)
>  
>  static void setup(void)
>  {
> +	int i;
> +	struct passwd *ltpuser;
> +
> +	tst_require_root(NULL);
> +
>  	tst_sig(NOFORK, DEF_HANDLER, cleanup);
>  
>  	TEST_PAUSE;
>  
>  	tst_tmpdir();
>  
> +	tst_mkfs(NULL, device, fstype, NULL);
> +	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
> +	if (mount(device, MNTPOINT, fstype, 0, NULL) == -1) {
> +		tst_brkm(TBROK | TERRNO, cleanup,
> +			"mount device:%s failed", device);
> +	}
> +	SAFE_MKDIR(cleanup, TESTDIR5, DIR_MODE);
> +	if (mount(device, MNTPOINT, fstype, MS_REMOUNT | MS_RDONLY,
> +			NULL) == -1) {
> +		tst_brkm(TBROK | TERRNO, cleanup,
> +			"mount device:%s failed", device);
> +	}
> +	mount_flag = 1;
> +
> +	ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
> +	SAFE_SETEUID(cleanup, ltpuser->pw_uid);

I've removed the EUID changes for all because these has no effect on the
test behavior (at least I haven't figured out why they are needed).

And pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/2] rmdir/rmdir02.c: cleanup
  2014-05-15 12:12 ` [LTP] [PATCH 1/2] rmdir/rmdir02.c: cleanup chrubis
@ 2014-05-15 12:15   ` chrubis
  0 siblings, 0 replies; 6+ messages in thread
From: chrubis @ 2014-05-15 12:15 UTC (permalink / raw)
  To: gux.fnst@cn.fujitsu.com; +Cc: ltp-list@lists.sourceforge.net

Hi!
And also fixed the runtest entries to include the device, please don't
forget to do that next time.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/2] rmdir/rmdir02.c: add ELOOP, EROFS and EBUSY error value tests
       [not found]     ` <53756E7A.6070009@cn.fujitsu.com>
@ 2014-05-19 12:15       ` chrubis
  0 siblings, 0 replies; 6+ messages in thread
From: chrubis @ 2014-05-19 12:15 UTC (permalink / raw)
  To: gux.fnst; +Cc: ltp-list

Hi!
> > I've removed the EUID changes for all because these has no effect on the
> > test behavior (at least I haven't figured out why they are needed).
> 
> I tested with the UEID is aimed to prove the system call can be executed 
> right with a normal user account, to provide a more overall testcase.

I've looked at the testcase again, and it seems to me that there would
be no difference on the results of these testcases (IMHO they would
still hit the same check in the rmdir() syscall in kernel both under
privileged and unprivileged user). Did I miss somethink?

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2014-05-19 12:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-17 10:50 [LTP] [PATCH 1/2] rmdir/rmdir02.c: cleanup gux.fnst
2014-04-17 10:50 ` [LTP] [PATCH 2/2] rmdir/rmdir02.c: add ELOOP, EROFS and EBUSY error value tests gux.fnst
2014-05-15 12:14   ` chrubis
     [not found]     ` <53756E7A.6070009@cn.fujitsu.com>
2014-05-19 12:15       ` chrubis
2014-05-15 12:12 ` [LTP] [PATCH 1/2] rmdir/rmdir02.c: cleanup chrubis
2014-05-15 12:15   ` chrubis

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