svn commit: r258876 - in user/pho/stress2: . testcases testcases/dirnprename testcases/dirrename

John-Mark Gurney jmg at FreeBSD.org
Tue Dec 3 18:27:12 UTC 2013


Author: jmg
Date: Tue Dec  3 18:27:10 2013
New Revision: 258876
URL: http://svnweb.freebsd.org/changeset/base/258876

Log:
  add two new tests...  One simply renames directories..  The other moves
  a directory between two directories...  directory renames w/ a new parent
  are more difficult to handle as you have to make sure that the . and ..
  links are correct, and all the link counts are correct...
  
  I'm not entirely happy w/ the 97 hard coded value, but with the default
  UFS sizes, it forces us into using indirect blocks for the directory
  which introduce more dependencies that softdep code has to track
  properly...
  
  add a config file dirrem.cfg which is what I used to reproduce/test a
  bug in softdep code for Kirk and Imaginary Forces...
  
  Sponsored by:	Imaginary Forces
  Reviewed by:	pho

Added:
  user/pho/stress2/dirrem.cfg
  user/pho/stress2/testcases/dirnprename/Makefile   (contents, props changed)
  user/pho/stress2/testcases/dirrename/Makefile   (contents, props changed)
Modified:
  user/pho/stress2/testcases/Makefile
  user/pho/stress2/testcases/dirnprename/dirnprename.c
  user/pho/stress2/testcases/dirrename/dirrename.c

Added: user/pho/stress2/dirrem.cfg
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/pho/stress2/dirrem.cfg	Tue Dec  3 18:27:10 2013	(r258876)
@@ -0,0 +1,14 @@
+# $FreeBSD: user/pho/stress2/marcus.cfg 253354 2013-07-15 07:00:19Z pho $
+
+# Stress Test Suite Configuration
+
+# Default values
+. ./default.cfg
+
+# Test configuration for the vop_stdvptocnp implementation
+
+export TESTPROGS="
+testcases/dirnprename/dirnprename
+testcases/dirrename/dirrename
+testcases/rename/rename
+"

Modified: user/pho/stress2/testcases/Makefile
==============================================================================
--- user/pho/stress2/testcases/Makefile	Tue Dec  3 18:18:35 2013	(r258875)
+++ user/pho/stress2/testcases/Makefile	Tue Dec  3 18:27:10 2013	(r258876)
@@ -3,6 +3,8 @@
 SUBDIR= \
 badcode \
 creat \
+dirrename \
+dirnprename \
 fts \
 link \
 lockf \

Added: user/pho/stress2/testcases/dirnprename/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/pho/stress2/testcases/dirnprename/Makefile	Tue Dec  3 18:27:10 2013	(r258876)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+PROG=dirnprename
+
+.include <bsd.prog.mk>

Modified: user/pho/stress2/testcases/dirnprename/dirnprename.c
==============================================================================
--- user/pho/stress2/testcases/dirnprename/dirnprename.c	Tue Dec  3 18:18:35 2013	(r258875)
+++ user/pho/stress2/testcases/dirnprename/dirnprename.c	Tue Dec  3 18:27:10 2013	(r258876)
@@ -36,18 +36,22 @@ __FBSDID("$FreeBSD$");
 #include <sys/stat.h>
 #include <sys/param.h>
 #include <err.h>
+#include <errno.h>
 
 #include "stress.h"
 
+static char path[128];
 static unsigned long size;
 
 int
 setup(int nb)
 {
+	char file1[512];
 	int64_t in;
 	int64_t bl;
 	int64_t reserve_in;
 	int64_t reserve_bl;
+	int i;
 
 	umask(0);
 
@@ -81,41 +85,71 @@ setup(int nb)
 	if (size == 0)
 		exit(0);
 
+	sprintf(path, "%s.%05d", getprogname(), getpid());
+	if (mkdir(path, 0770) == -1)
+		err(1, "mkdir(%s), %s:%d", path, __FILE__, __LINE__);
+
+	/* don't hard code 97 */
+	for (i = 0; i < 97; i++) {
+		sprintf(file1, "%s/%0255d", path, i);
+		if (mkdir(file1, 0770) == -1)
+			err(1, "mkdir(%s), %s:%d", file1, __FILE__, __LINE__);
+	}
 	return (0);
 }
 
 void
 cleanup(void)
 {
+	char file1[512];
+	int i;
+
+	/* don't hard code 97 */
+	for (i = 0; i < 97; i++) {
+		sprintf(file1, "%s/%0255d", path, i);
+		if (rmdir(file1) == -1)
+			warn("rmdir(%s), %s:%d", file1, __FILE__, __LINE__);
+	}
+	if (rmdir(path) == -1)
+		warn("rmdir(%s), %s:%d", path, __FILE__, __LINE__);
 }
 
 static void
 test_rename(void)
 {
 	int i, j;
+	int errnotmp;
 	pid_t pid;
 	char file1[128];
 	char file2[128];
-	int tfd;
 
 	pid = getpid();
 	for (i = 0; i < (int)size; i++) {
 		sprintf(file1,"p%05d.%05d", pid, i);
-		if ((tfd = open(file1, O_RDONLY|O_CREAT, 0660)) == -1)
-			err(1, "openat(%s), %s:%d", file1, __FILE__, __LINE__);
-		close(tfd);
+		if (mkdir(file1, 0660) == -1) {
+			j = i;
+			errnotmp = errno;
+			while (j > 0) {
+				j--;
+				sprintf(file1,"p%05d.%05d", pid, j);
+				rmdir(file1);
+			}
+			errno = errnotmp;
+			sprintf(file1,"p%05d.%05d", pid, i);
+			err(1, "mkdir(%s), %s:%d", file1, __FILE__, __LINE__);
+		}
 	}
 	for (j = 0; j < 100 && done_testing == 0; j++) {
 		for (i = 0; i < (int)size; i++) {
 			sprintf(file1,"p%05d.%05d", pid, i);
-			sprintf(file2,"p%05d.%05d.togo", pid, i);
+			sprintf(file2,"%s/p%05d.%05d.togo", path, pid, i);
 			if (rename(file1, file2) == -1)
 				err(1, "rename(%s, %s). %s:%d", file1, file2,
 						__FILE__, __LINE__);
 		}
 		for (i = 0; i < (int)size; i++) {
 			sprintf(file1,"p%05d.%05d", pid, i);
-			sprintf(file2,"p%05d.%05d.togo", pid, i);
+			sprintf(file2,"%s/p%05d.%05d.togo", path, pid, i);
 			if (rename(file2, file1) == -1)
 				err(1, "rename(%s, %s). %s:%d", file2, file1,
 						__FILE__, __LINE__);
@@ -124,8 +158,8 @@ test_rename(void)
 
 	for (i = 0; i < (int)size; i++) {
 		sprintf(file1,"p%05d.%05d", pid, i);
-		if (unlink(file1) == -1)
-			err(1, "unlink(%s), %s:%d", file1, __FILE__, __LINE__);
+		if (rmdir(file1) == -1)
+			err(1, "rmdir(%s), %s:%d", file1, __FILE__, __LINE__);
 	}
 }
 

Added: user/pho/stress2/testcases/dirrename/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/pho/stress2/testcases/dirrename/Makefile	Tue Dec  3 18:27:10 2013	(r258876)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+PROG=dirrename
+
+.include <bsd.prog.mk>

Modified: user/pho/stress2/testcases/dirrename/dirrename.c
==============================================================================
--- user/pho/stress2/testcases/dirrename/dirrename.c	Tue Dec  3 18:18:35 2013	(r258875)
+++ user/pho/stress2/testcases/dirrename/dirrename.c	Tue Dec  3 18:27:10 2013	(r258876)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/stat.h>
 #include <sys/param.h>
 #include <err.h>
+#include <errno.h>
 
 #include "stress.h"
 
@@ -93,17 +94,26 @@ static void
 test_rename(void)
 {
 	int i, j;
+	int errnotmp;
 	pid_t pid;
 	char file1[128];
 	char file2[128];
-	int tfd;
 
 	pid = getpid();
 	for (i = 0; i < (int)size; i++) {
 		sprintf(file1,"p%05d.%05d", pid, i);
-		if ((tfd = open(file1, O_RDONLY|O_CREAT, 0660)) == -1)
-			err(1, "openat(%s), %s:%d", file1, __FILE__, __LINE__);
-		close(tfd);
+		if (mkdir(file1, 0660) == -1) {
+			j = i;
+			errnotmp = errno;
+			while (j > 0) {
+				j--;
+				sprintf(file1,"p%05d.%05d", pid, j);
+				rmdir(file1);
+			}
+			errno = errnotmp;
+			sprintf(file1,"p%05d.%05d", pid, i);
+			err(1, "mkdir(%s), %s:%d", file1, __FILE__, __LINE__);
+		}
 	}
 	for (j = 0; j < 100 && done_testing == 0; j++) {
 		for (i = 0; i < (int)size; i++) {
@@ -124,7 +134,7 @@ test_rename(void)
 
 	for (i = 0; i < (int)size; i++) {
 		sprintf(file1,"p%05d.%05d", pid, i);
-		if (unlink(file1) == -1)
+		if (rmdir(file1) == -1)
 			err(1, "unlink(%s), %s:%d", file1, __FILE__, __LINE__);
 	}
 }


More information about the svn-src-user mailing list