[Ocfs2-test-devel] [PATCH 2/3] Ocfs2-test: Enhance multi-nodes testing binary and script on quota.

Tristan Ye tristan.ye at oracle.com
Fri Sep 11 02:13:39 PDT 2009


Improve multi-nodes testing binary for quota to better support quota
tests on ocfs2-tools, and fix some testing bugs and code enhancement
here, especially we classify the tests into basic, stress, negative etc
separate tests on demand.

The multi-nodes testing launcher for quota also needs to be updated
accordingly.

Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
---
 programs/quota_tests/quota_multi_tests.c      | 1160 +++++++++++++++++--------
 programs/quota_tests/run_quota_multi_tests.py |  123 +++-
 2 files changed, 890 insertions(+), 393 deletions(-)

diff --git a/programs/quota_tests/quota_multi_tests.c b/programs/quota_tests/quota_multi_tests.c
index fa31735..b58f701 100755
--- a/programs/quota_tests/quota_multi_tests.c
+++ b/programs/quota_tests/quota_multi_tests.c
@@ -75,22 +75,36 @@
 #define BSOFT_LIMIT		4
 #define BHARD_LIMIT		8
 
+#define UID_BASE		1000
+#define GID_BASE		1000
+
+#define QUOTA_SYNC_INTERVAL	10
+
 #define FILE_MODE               (S_IRUSR|S_IWUSR|S_IXUSR|S_IROTH|\
-                                 S_IWOTH|S_IXOTH|S_IRGRP|S_IWGRP|S_IXGRP)
+				 S_IWOTH|S_IXOTH|S_IRGRP|S_IWGRP|S_IXGRP)
+
+#define BASC_TEST               0x00000001
+#define STRS_TEST               0x00000002
+#define CONT_TEST               0x00000004
+#define CRPT_TEST               0x00000008
+#define NEGV_TEST               0x00000010
+#define PRSV_TEST		0x00000020
+#define CLEN_TEST		0x00000040
 
 static char *prog;
 static char mountpoint[PATH_SZ + 1];
 static char device[PATH_SZ + 1];
-static char workplace[PATH_SZ +1];
-static char filename[PATH_SZ +1];
+static char workplace[PATH_SZ + 1];
+static char filename[PATH_SZ + 1];
 static long iterations = DEFAULT_ITER_NUMS;
 
-static long user_nums = DEFAULT_USER_NUM;
-static long group_nums = DEFAULT_GROUP_NUM;
+static long user_nums;
+static long group_nums;
 
-static int type = 0;
+static int type;
 
 static int testno = 1;
+static int test_flags = 0x00000000;
 static int rank, size;
 static char hostname[HOSTNAME_MAX_SZ];
 
@@ -103,19 +117,25 @@ struct ocfs2_super_block *ocfs2_sb;
 static int usage(void)
 {
 
-	printf("Usage: quota_multi_tests [-t iterations] [-u users] [-g groups] "
-               "<-d device> <mount_point>\n"
-               "Run a series of tests intended to verify quota functionality "
-               "among multiple nodes.\n\n"
-               "-i iterations specify the running times.\n"
-               "-u users,specify the number of users.\n"
-               "-g groups,specify the number of groups.\n"
-               "at least one of the -u or -g options shoud be selected.\n"
-               "device and mount_point are mandatory.\n");
+	printf("Usage: quota_multi_tests [-i iterations] [-u users] [-g groups]"
+	       " <-d device> [-b|s|c|n|m|p|w] <mount_point>\n"
+	       "Run a series of tests intended to verify quota functionality "
+	       "among multiple nodes.\n\n"
+	       "-i iterations specify the running times.\n"
+	       "-u users,specify the number of users.\n"
+	       "-g groups,specify the number of groups.\n"
+	       "at least one of the -u or -g options shoud be selected.\n"
+	       "-b specify the basic functional test.\n"
+	       "-s specify the stress test.\n"
+	       "-c specify the corrupt test.\n"
+	       "-n specify the negative test.\n"
+	       "-m specify the concurrent test.\n"
+	       "-p preserve the testing env after test done.\n"
+	       "-w wipe off all testing users and groups.\n"
+	       "device and mount_point are mandatory.\n");
 
 	MPI_Finalize();
 	exit(1);
-
 }
 
 static void abort_printf(const char *fmt, ...)
@@ -133,18 +153,18 @@ static void log_printf(FILE *stream, const char *fmt, ...)
 	va_list	ap;
 
 	fprintf(stream, "%s (rank %d): ", hostname, rank);
-	va_start(ap,fmt);
+	va_start(ap, fmt);
 	vprintf(fmt, ap);
 }
 
 static void root_printf(const char *fmt, ...)
 {
-        va_list ap;
+	va_list ap;
 
-        if (rank == 0) {
-                va_start(ap, fmt);
-                vprintf(fmt, ap);
-        }
+	if (rank == 0) {
+		va_start(ap, fmt);
+		vprintf(fmt, ap);
+	}
 }
 
 static uid_t user2uid(char *name)
@@ -152,10 +172,11 @@ static uid_t user2uid(char *name)
 	struct passwd *entry;
 	uid_t ret;
 
-	if (!(entry = getpwnam(name))) {
-		ret = errno;
+	entry = getpwnam(name);
+
+	if (!entry) {
 		log_printf(stderr, "user %s does not exist!\n", name);
-		return ret;
+		return -1;
 	} else {
 		ret = entry->pw_uid;
 		return ret;
@@ -168,10 +189,11 @@ static uid_t group2gid(char *name)
 	struct group *entry;
 	gid_t ret;
 
-	if (!(entry = getgrnam(name))) {
-		ret = errno;
+	entry = getgrnam(name);
+
+	if (!entry) {
 		log_printf(stderr, "group %s does not exist!\n", name);
-		return ret;
+		return -1;
 	} else {
 		ret = entry->gr_gid;
 		return ret;
@@ -185,6 +207,8 @@ static int name2id(int type, char *name)
 		return user2uid(name);
 	if (type & GROUP)
 		return group2gid(name);
+
+	return -1;
 }
 
 static void MPI_Barrier_Sync(void)
@@ -192,8 +216,8 @@ static void MPI_Barrier_Sync(void)
 	int ret;
 
 	ret = MPI_Barrier(MPI_COMM_WORLD);
-        if (ret != MPI_SUCCESS)
-                abort_printf("MPI_Barrier failed: %d\n", ret);
+	if (ret != MPI_SUCCESS)
+		abort_printf("MPI_Barrier failed: %d\n", ret);
 }
 
 int open_ocfs2_volume(char *device_name)
@@ -204,8 +228,8 @@ int open_ocfs2_volume(char *device_name)
 	ret = ocfs2_open(device_name, open_flags, 0, 0, &fs);
 	if (ret < 0) {
 		fprintf(stderr, "%s is not a ocfs2 volume!\n", device_name);
-                return ret;
-        }
+		return ret;
+	}
 
 	ocfs2_sb = OCFS2_RAW_SB(fs->fs_super);
 	blocksize = 1 << ocfs2_sb->s_blocksize_bits;
@@ -218,7 +242,7 @@ static int parse_opts(int argc, char *argv[])
 {
 	char c;
 	while (1) {
-		c = getopt(argc, argv, "i:I:u:U:g:G:d:D:t:T:");
+		c = getopt(argc, argv, "i:I:u:U:g:G:d:bBsScCnNmMpPwWD:");
 		if (c == -1)
 			break;
 		switch (c) {
@@ -240,16 +264,41 @@ static int parse_opts(int argc, char *argv[])
 		case 'D':
 			strcpy(device, optarg);
 			break;
-		case 't':
-		case 'T':
-			iterations = atol(optarg);
+		case 'b':
+		case 'B':
+			test_flags |= BASC_TEST;
+			break;
+		case 's':
+		case 'S':
+			test_flags |= STRS_TEST;
+			break;
+		case 'c':
+		case 'C':
+			test_flags |= CRPT_TEST;
+			break;
+		case 'n':
+		case 'N':
+			test_flags |= NEGV_TEST;
+			break;
+		case 'm':
+		case 'M':
+			test_flags |= CONT_TEST;
+			break;
+		case 'p':
+		case 'P':
+			test_flags |= PRSV_TEST;
+			break;
+		case 'w':
+		case 'W':
+			test_flags |= CLEN_TEST;
+			break;
 		default:
 			return EINVAL;
 		}
 	}
 
 	if (argc - optind != 1)
-                return EINVAL;
+		return EINVAL;
 
 	if (!(type & QUOTAUSER) && !(type & QUOTAGROUP)) {
 		log_printf(stderr, "At least one of -u or -g options "
@@ -265,55 +314,80 @@ static int parse_opts(int argc, char *argv[])
 }
 
 static int add_rm_user_group(const char *bin_path, int ad_or_rm, int usr_or_grp,
-			  const char *name, char *ex_name)
+			     const char *name, unsigned int id, char *ex_name)
 {
-	int ret = 0;
-	int child_status;
-	char *argv[6];
-	char arg1[20];
+	int ret = 0, o_ret;
+	int child_status, idx;
+	char *argv[8];
+	char arg1[20], arg2[20], arg3[20];
 	pid_t child;
-	
+
 	child = fork();
 	if (child < 0) {
+		o_ret = child;
 		ret = errno;
-		log_printf(stderr, "Failed to fork for user/group add/remove:%d:%s\n",
-			   ret, strerror(ret));
+		log_printf(stderr, "Failed to fork for user/group add/remove:"
+			   "%d:%s\n", ret, strerror(ret));
+		ret = o_ret;
 		goto bail;
 	}
 	if (!child) {
-		argv[0] = (char *)bin_path;
-		
+		idx = 0;
+		argv[idx++] = (char *)bin_path;
 		if (usr_or_grp & USER) {
+
 			if (ad_or_rm & ADD)
-				strcpy(arg1, "-m");
+				strncpy(arg1, "-m", sizeof(arg1));
 			else
-				strcpy(arg1, "-r");
-			argv[1] = arg1;
-			argv[2] = (char *)name;
-			argv[3] = NULL;
-			
+				strncpy(arg1, "-r", sizeof(arg1));
+
+			argv[idx++] = arg1;
+
+			if ((ad_or_rm & ADD) && (id > 0)) {
+				strncpy(arg2, "-u", sizeof(arg2));
+				argv[idx++] = arg2;
+				snprintf(arg3, sizeof(arg3), "%d", id);
+				argv[idx++] = arg3;
+			}
+
+			argv[idx++] = (char *)name;
+			argv[idx++] = NULL;
+
 		} else if (usr_or_grp & GROUP) {
-			argv[1] = (char *)name;
-			argv[2] = NULL;
+			if (id > 0) {
+				strncpy(arg2, "-g", sizeof(arg2));
+				argv[idx++] = arg2;
+				snprintf(arg3, sizeof(arg3), "%d", id);
+				argv[idx++] = arg3;
+			}
+			argv[idx++] = (char *)name;
+			argv[idx] = NULL;
 		} else if (usr_or_grp & USER_IN_GROUP) {
 			strcpy(arg1, "-m");
-			argv[1] = arg1;
-			argv[2] = "-g";
-			argv[3] = (char *)ex_name;
-			argv[4] = (char *)name;
-			argv[5] = NULL;
+			argv[idx++] = arg1;
+			if (id > 0) {
+				strncpy(arg2, "-u", sizeof(arg2));
+				argv[idx++] = arg2;
+				snprintf(arg3, sizeof(arg3), "%d", id);
+				argv[idx++] = arg3;
+			}
+			argv[idx++] = "-g";
+			argv[idx++] = (char *)ex_name;
+			argv[idx++] = (char *)name;
+			argv[idx] = NULL;
 		}
 
 		ret = execv(argv[0], argv);
-		ret = errno;
 		exit(ret);
-		
+
 	} else {
 		ret = waitpid(child, &child_status, 0);
 		if (ret < 0) {
+			o_ret = ret;
 			ret = errno;
-			log_printf(stderr, "Failed to wait child for its completion"
-				   ":%d:%s\n", ret, strerror(ret));
+			log_printf(stderr, "Failed to wait child for its "
+				   "completion:%d:%s\n", ret, strerror(ret));
+			ret = o_ret;
 			goto bail;
 		}
 
@@ -322,12 +396,12 @@ static int add_rm_user_group(const char *bin_path, int ad_or_rm, int usr_or_grp,
 
 bail:
 	return ret;
-} 
+}
 
 static int quota_on_off(const char *qbin_path, int on, int type,
 			const char *fsname)
 {
-	int ret = 0;
+	int ret = 0, o_ret;
 	int child_status;
 	char *argv[4];
 	char arg1[20];
@@ -337,7 +411,8 @@ static int quota_on_off(const char *qbin_path, int on, int type,
 	if (child < 0) {
 		ret = errno;
 		log_printf(stderr, "Failed to fork for quota on or off:%d:%s\n",
-        		   ret, strerror(ret));
+			   ret, strerror(ret));
+		ret = child;
 		goto bail;
 	}
 
@@ -350,24 +425,25 @@ static int quota_on_off(const char *qbin_path, int on, int type,
 			strcat(arg1, "g");
 		if (!on)
 			strcat(arg1, "f");
-			
+
 		argv[1] = arg1;
 		argv[2] = (char *)fsname;
 		argv[3] = NULL;
 
 		ret = execv(argv[0], argv);
-		ret = errno;
 		exit(ret);
 
 	} else {
 		ret = waitpid(child, &child_status, 0);
 		if (ret < 0) {
+			o_ret = ret;
 			ret = errno;
-			log_printf(stderr, "Failed to wait child for its completion"
-				   ":%d:%s\n", ret, strerror(ret));
+			log_printf(stderr, "Failed to wait child for its "
+				   "completion:%d:%s\n", ret, strerror(ret));
+			ret = o_ret;
 			goto bail;
 		}
-		
+
 		ret = WEXITSTATUS(child_status);
 	}
 
@@ -375,20 +451,24 @@ bail:
 	return ret;
 }
 
-static int setquotainfo(int type, const char *device, int id, struct if_dqinfo dqi)
+static int setquotainfo(int type, const char *device, int id,
+			struct if_dqinfo dqi)
 {
-	int ret;
+	int ret = 0, o_ret;
 	int q_type;
-	
+
 	if (type & QUOTAUSER)
 		q_type = USRQUOTA;
 	else
 		q_type = GRPQUOTA;
 
-	if (quotactl(QCMD(Q_SETINFO, q_type), device, id, (caddr_t) & dqi)) {
+	ret = quotactl(QCMD(Q_SETINFO, q_type), device, id, (caddr_t) &dqi);
+	if (ret < 0) {
+		o_ret = ret;
 		ret = errno;
 		log_printf(stderr, "Set quota info failed,quotactl:%d:%s\n",
 			   ret, strerror(ret));
+		ret = o_ret;
 	} else
 		ret = 0;
 
@@ -397,7 +477,7 @@ static int setquotainfo(int type, const char *device, int id, struct if_dqinfo d
 
 static int setquota(int type, const char *device, int id, struct if_dqblk dq)
 {
-	int ret;
+	int ret = 0, o_ret;
 	int q_type;
 
 	if (type & QUOTAUSER)
@@ -405,19 +485,23 @@ static int setquota(int type, const char *device, int id, struct if_dqblk dq)
 	else
 		q_type = GRPQUOTA;
 
-	if (quotactl(QCMD(Q_SETQUOTA, q_type), device, id, (caddr_t) & dq)) {
+	ret = quotactl(QCMD(Q_SETQUOTA, q_type), device, id, (caddr_t) &dq);
+	if (ret < 0) {
+		o_ret = ret;
 		ret = errno;
 		log_printf(stderr, "Set quota failed,quotactl:%d:%s\n",
 			   ret, strerror(ret));
+		ret = o_ret;
 	} else
 		ret = 0;
-	
+
 	return ret;
 }
 
-static int getquotainfo(int type, const char *device, int id, struct if_dqinfo *dqi)
+static int getquotainfo(int type, const char *device, int id,
+			struct if_dqinfo *dqi)
 {
-	int ret;
+	int ret = 0, o_ret;
 	int q_type;
 
 	if (type & QUOTAUSER)
@@ -425,10 +509,14 @@ static int getquotainfo(int type, const char *device, int id, struct if_dqinfo *
 	else
 		q_type = GRPQUOTA;
 
-	if (quotactl(QCMD(Q_GETINFO, q_type), device, id, (caddr_t)dqi)) {
+	ret = quotactl(QCMD(Q_GETINFO, q_type), device, id, (caddr_t)dqi);
+
+	if (ret < 0) {
+		o_ret = ret;
 		ret = errno;
 		log_printf(stderr, "Get quota info failed, quotactl:%d:%s\n",
 			   ret, strerror(ret));
+		ret = o_ret;
 	} else
 		ret = 0;
 
@@ -437,7 +525,7 @@ static int getquotainfo(int type, const char *device, int id, struct if_dqinfo *
 
 static int getquota(int type, const char *deive, int id, struct if_dqblk *dq)
 {
-	int ret;
+	int ret = 0, o_ret;
 	int q_type;
 
 	if (type & QUOTAUSER)
@@ -445,18 +533,22 @@ static int getquota(int type, const char *deive, int id, struct if_dqblk *dq)
 	else
 		q_type = GRPQUOTA;
 
-	if (quotactl(QCMD(Q_GETQUOTA, q_type), device, id, (caddr_t)dq)) {
+	ret = quotactl(QCMD(Q_GETQUOTA, q_type), device, id, (caddr_t)dq);
+
+	if (ret < 0) {
+		o_ret = ret;
 		ret = errno;
 		log_printf(stderr, "Get quota failed,quotactl:%d:%s\n",
 			   ret, strerror(ret));
+		ret = o_ret;
 	} else
 		ret = 0;
-	
+
 	return ret;
 }
 
-static int verify_quota_items(const struct if_dqblk s_dq, const struct if_dqblk d_dq,
-			int limit_type)
+static int verify_quota_items(const struct if_dqblk s_dq,
+			      const struct if_dqblk d_dq, int limit_type)
 {
 	int ret = 1;
 
@@ -464,7 +556,8 @@ static int verify_quota_items(const struct if_dqblk s_dq, const struct if_dqblk
 
 		if (s_dq.dqb_isoftlimit != d_dq.dqb_isoftlimit) {
 			log_printf(stderr, "Quota inconsistent match found,"
-				   "expected isoftlimit = %d,actual isoftlimit = %d\n",
+				   "expected isoftlimit = %d,actual isoftlimit"
+				   " = %d\n",
 				   s_dq.dqb_isoftlimit, d_dq.dqb_isoftlimit);
 			ret = 0;
 			goto bail;
@@ -474,7 +567,8 @@ static int verify_quota_items(const struct if_dqblk s_dq, const struct if_dqblk
 	if (limit_type & IHARD_LIMIT) {
 		if (s_dq.dqb_ihardlimit != d_dq.dqb_ihardlimit) {
 			log_printf(stderr, "Quota inconsistent match found,"
-				   "expected ihardlimit = %d,actual ihardlimit = %d\n",
+				   "expected ihardlimit = %d,actual ihardlimit"
+				   " = %d\n",
 				   s_dq.dqb_ihardlimit, d_dq.dqb_ihardlimit);
 			ret = 0;
 			goto bail;
@@ -485,7 +579,8 @@ static int verify_quota_items(const struct if_dqblk s_dq, const struct if_dqblk
 
 		if (s_dq.dqb_bsoftlimit != d_dq.dqb_bsoftlimit) {
 			log_printf(stderr, "Quota inconsistent match found,"
-				   "expected bsoftlimit = %d,actual bsoftlimit = %d\n",
+				   "expected bsoftlimit = %d,actual bsoftlimit"
+				   " = %d\n",
 				   s_dq.dqb_bsoftlimit, d_dq.dqb_bsoftlimit);
 			ret = 0;
 			goto bail;
@@ -495,7 +590,8 @@ static int verify_quota_items(const struct if_dqblk s_dq, const struct if_dqblk
 	if (limit_type & BHARD_LIMIT) {
 		if (s_dq.dqb_bhardlimit != d_dq.dqb_bhardlimit) {
 			log_printf(stderr, "Quota inconsistent match found,"
-				   "expected bhardlimit = %d,actual bhardlimit = %d\n",
+				   "expected bhardlimit = %d,actual bhardlimit"
+				   " = %d\n",
 				   s_dq.dqb_bhardlimit, d_dq.dqb_bhardlimit);
 			ret = 0;
 			goto bail;
@@ -509,32 +605,33 @@ bail:
 
 static unsigned long get_rand(unsigned long min, unsigned long max)
 {
-        if (min == 0 && max == 0)
-                return 0;
+	if (min == 0 && max == 0)
+		return 0;
 
-        return min + (rand() % (max - min + 1));
+	return min + (rand() % (max - min + 1));
 }
 
 static void negative_inodes_limit_test(long isoftlimit, long bsoftlimit,
 				       long user_postfix, long rm_nums)
 {
-	int ret, fd, o_uid, j;
+	int ret = 0, fd, o_uid, j;
 	long i, file_index, rm_counts = 0;
 	struct if_dqblk s_dq, d_dq;
 	char username[USERNAME_SZ];
-	int *inodes_removed;
-	
+	int *inodes_removed = NULL;
+
 	MPI_Request request;
-        MPI_Status status;
+	MPI_Status status;
 
 	if (!rank) {
 
 		inodes_removed = (int *)malloc(sizeof(int) * isoftlimit * 2);
-		memset((void *)inodes_removed, 0, sizeof(int) * isoftlimit *2);
-		snprintf(username, USERNAME_SZ, "quota-user-rank%d-%d", rank,
+		memset((void *)inodes_removed, 0, sizeof(int) * isoftlimit * 2);
+		snprintf(username, USERNAME_SZ, "quota-usr-rank%d-%ld", rank,
 			 user_postfix);
 
-		add_rm_user_group(USERADD_BIN, ADD, USER, username, NULL);
+		add_rm_user_group(USERADD_BIN, ADD, USER, username,
+				  UID_BASE, NULL);
 		getquota(QUOTAUSER, device, name2id(USER, username), &s_dq);
 		s_dq.dqb_isoftlimit = isoftlimit;
 		s_dq.dqb_ihardlimit = isoftlimit * 2;
@@ -544,7 +641,7 @@ static void negative_inodes_limit_test(long isoftlimit, long bsoftlimit,
 		s_dq.dqb_curspace = 0;
 		setquota(QUOTAUSER, device, name2id(USER, username), s_dq);
 	} else
-		snprintf(username, USERNAME_SZ, "quota-user-rank0-%d",
+		snprintf(username, USERNAME_SZ, "quota-usr-rank0-%ld",
 			 user_postfix);
 
 	/*
@@ -556,53 +653,62 @@ static void negative_inodes_limit_test(long isoftlimit, long bsoftlimit,
 		o_uid = getuid();
 		seteuid(name2id(USER, username));
 		for (i = 0; i < isoftlimit * 2; i++) {
-			snprintf(filename, PATH_SZ, "%s/%s-quotafile-%d",
+			snprintf(filename, PATH_SZ, "%s/%s-quotafile-%ld",
 				 workplace, username, i);
-			fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
+			fd = open(filename, O_RDWR | O_CREAT | O_TRUNC,
+				  FILE_MODE);
 			if (fd < 0) {
-			        ret = errno;
-			        abort_printf("Open file failed:%d:%s\n", ret, strerror(ret));
+				ret = errno;
+				abort_printf("Open file failed:%d:%s\n", ret,
+					     strerror(ret));
 			}
-			
+
 			close(fd);
 		}
+	}
+
+	MPI_Barrier_Sync();
+
+	if (!rank) {
 
 		seteuid(o_uid);
-		
+
 		rm_counts = 0;
 		for (j = 1; j < size; j++) {
 			for (i = 0; i < rm_nums; i++) {
 				ret = MPI_Irecv(&file_index, sizeof(long),
 						MPI_BYTE, j, 1, MPI_COMM_WORLD,
 						&request);
-				
+
 				if (ret == MPI_SUCCESS) {
 					rm_counts++;
 					inodes_removed[file_index] = 1;
-				}
-				else
+				} else
 					abort_printf("MPI_Irecv Failed.\n");
+
 				MPI_Wait(&request, &status);
 			}
 		}
 
+		sleep(QUOTA_SYNC_INTERVAL);
+		sync();
 		getquota(QUOTAUSER, device, name2id(USER, username), &d_dq);
 		if (d_dq.dqb_curinodes != isoftlimit * 2 - rm_counts)
 			abort_printf("Negative inodes test failed among nodes,"
 				     "Incorrect quota stats found,expected "
 				     "inodes_num = %ld, queried inodes_num = "
-				     "%ld.\n", isoftlimit * 2 - rm_counts, 
-				     d_dq.dqb_curinodes); 
-		
+				     "%ld.\n", isoftlimit * 2 - rm_counts,
+				     d_dq.dqb_curinodes);
+
 	} else {
 		/*
 		 * Other nodes perform a random deletion as root user
 		*/
 		rm_counts = 0;
-		
+
 		while (rm_counts < rm_nums) {
 			i = get_rand(0, isoftlimit * 2 - 1);
-			snprintf(filename, PATH_SZ, "%s/%s-quotafile-%d",
+			snprintf(filename, PATH_SZ, "%s/%s-quotafile-%ld",
 				 workplace, username, i);
 			ret = unlink(filename);
 			if (ret < 0)
@@ -616,52 +722,81 @@ static void negative_inodes_limit_test(long isoftlimit, long bsoftlimit,
 				rm_counts++;
 			}
 		}
+
+		sync();
 	}
 
 	MPI_Barrier_Sync();
-	/* Cleanup */
 
+	if (test_flags & PRSV_TEST)
+		goto out;
+
+	/* Cleanup */
 	if (!rank) {
+
 		file_index = 0;
 		while (file_index < isoftlimit * 2) {
 			if (!inodes_removed[file_index]) {
-				snprintf(filename, PATH_SZ, "%s/%s-quotafile-%d",
-					 workplace, username, file_index);
+				snprintf(filename, PATH_SZ, "%s/%s-"
+					 "quotafile-%ld", workplace,
+					 username, file_index);
 				ret = unlink(filename);
 			}
 
 			file_index++;
 		}
 
-	snprintf(filename, PATH_SZ, "%s/%s-quotafile-%d", workplace, username, 0);
-	ret = access(filename, F_OK);
-	if (ret == 0)
-		unlink(filename);
+		snprintf(filename, PATH_SZ, "%s/%s-quotafile-%d", workplace,
+			 username, 0);
+
+		ret = access(filename, F_OK);
+		if (ret == 0)
+			unlink(filename);
 
-	add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, NULL);
+		add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, 0, NULL);
+
+		if (!inodes_removed)
+			free(inodes_removed);
 
 	}
+
+out:
+	return;
 }
 
 static void user_inodes_grace_time_test(long isoftlimit, long bsoftlimit,
-					long grace_seconds, long user_postfix)
+					long grace_seconds, unsigned int uid,
+					long user_postfix)
 {
-	int ret, fd, o_uid;
+	int ret = 0, fd, o_uid, scale;
 	long i;
 	struct if_dqblk s_dq, d_dq;
 	struct if_dqinfo s_dqi;
+	int id;
 
 	char username[USERNAME_SZ];
 
-	snprintf(username, USERNAME_SZ, "quota-user-rank%d-%d", rank,
+	snprintf(username, USERNAME_SZ, "quota-usr-rank%d-%ld", rank,
 		 user_postfix);
-	
-	add_rm_user_group(USERADD_BIN, ADD, USER, username, NULL);
+
+	if (!uid)
+		id = uid;
+	else
+		id = uid + user_postfix;
+
+	add_rm_user_group(USERADD_BIN, ADD, USER, username,
+			  id, NULL);
+
+	if (!uid)
+		scale = 1;
+	else
+		scale = size;
+
 	getquota(QUOTAUSER, device, name2id(USER, username), &s_dq);
-	s_dq.dqb_isoftlimit = isoftlimit;
-	s_dq.dqb_ihardlimit = isoftlimit * 2;
-	s_dq.dqb_bsoftlimit = bsoftlimit;
-	s_dq.dqb_bhardlimit = bsoftlimit * 2;
+	s_dq.dqb_isoftlimit = isoftlimit * scale;
+	s_dq.dqb_ihardlimit = isoftlimit * scale * 2;
+	s_dq.dqb_bsoftlimit = bsoftlimit * scale;
+	s_dq.dqb_bhardlimit = bsoftlimit * scale * 2;
 	s_dq.dqb_curinodes = 0;
 	s_dq.dqb_curspace = 0;
 	setquota(QUOTAUSER, device, name2id(USER, username), s_dq);
@@ -675,75 +810,100 @@ static void user_inodes_grace_time_test(long isoftlimit, long bsoftlimit,
 	seteuid(name2id(USER, username));
 
 	for (i = 0; i <= isoftlimit ; i++) {
-		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
 			 workplace, hostname, username, i);
 		fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
 		if (fd < 0) {
 			ret = errno;
-			abort_printf("Open file failed:%d:%s\n", ret, strerror(ret));
+			abort_printf("Open file failed:%d:%s\n", ret,
+				     strerror(ret));
 		}
 
 		close(fd);
-                getquota(QUOTAUSER, device, name2id(USER, username), &d_dq);
-                if (d_dq.dqb_curinodes != i + 1)
-                        abort_printf("Incorrect quota stats found,expected "
-                                     "inode_num = %d,queried inode_num = %d.\n",
-                                     i + 1, d_dq.dqb_curinodes);
-        }
+		getquota(QUOTAUSER, device, name2id(USER, username), &d_dq);
+		if (d_dq.dqb_curinodes != i + 1)
+			abort_printf("Incorrect quota stats found,expected "
+				     "inode_num = %d,queried inode_num = %d.\n",
+				     i + 1, d_dq.dqb_curinodes);
+	}
+
+	MPI_Barrier_Sync();
 
 	/*Grace time take effect from now*/
 	sleep(grace_seconds);
 	/*grace time expires,so should hit failure here*/
-        snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
-                 workplace, hostname, username, isoftlimit + 1);
-        if ((fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE)) > 0) {
-                close(fd);
-                abort_printf("Not allowd to exceed the grace time limit of inodes.\n");
-        }
+	snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
+		 workplace, hostname, username, isoftlimit + 1);
+	fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
+	if (fd > 0) {
+		close(fd);
+		abort_printf("Not allowd to exceed the grace time limit of "
+			     "inodes.\n");
+	}
 
-	/*cleanup*/
 	seteuid(o_uid);
 
+	if (test_flags & PRSV_TEST)
+		goto out;
+
+	/*cleanup*/
 	for (i = 0; i <= isoftlimit; i++) {
-                snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
 			 workplace, hostname, username, i);
 		ret = unlink(filename);
 		if (ret < 0) {
-			ret =errno;
+			ret = errno;
 			abort_printf("Failed to unlink file(%s):%d:%s\n",
 				     filename, ret, strerror(ret));
 		}
 
-        }
+	}
 
-        add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, NULL);
+	add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, 0, NULL);
+
+out:
+	return;
 }
 
-static void user_space_limit_test(long isoftlimit, long bsoftlimit, int user_postfix)
+static void user_space_limit_test(long isoftlimit, long bsoftlimit,
+				  int uid, int user_postfix)
 {
 	int ret;
-	long i;
 	int fd;
-	int o_uid;
-	struct if_dqblk s_dq, d_dq;
-	char *write_buf;
+	int o_uid, scale;
+	struct if_dqblk s_dq;
+	char *write_buf = NULL;
 	int writen_sz = 0;
 	long file_sz = 0;
 	char username[USERNAME_SZ];
+	int id;
 
 	write_buf = (char *)malloc(clustersize);
 	memset(write_buf, 0, clustersize);
-	
-	snprintf(username, USERNAME_SZ, "quotauser-rank%d-%d", rank,
+
+	snprintf(username, USERNAME_SZ, "quota-usr-rank%d-%d", rank,
 		 user_postfix);
-	add_rm_user_group(USERADD_BIN, ADD, USER, username, NULL);
+
+	if (!uid)
+		id = uid;
+	else
+		id = uid + user_postfix;
+
+	add_rm_user_group(USERADD_BIN, ADD, USER, username,
+			  id, NULL);
+
+	if (!uid)
+		scale = 1;
+	else
+		scale = size;
+
 	getquota(QUOTAUSER, device, name2id(USER, username), &s_dq);
-	s_dq.dqb_isoftlimit = isoftlimit;
-        s_dq.dqb_ihardlimit = isoftlimit * 2;
-        s_dq.dqb_bsoftlimit = bsoftlimit;
-        s_dq.dqb_bhardlimit = bsoftlimit * 2;
-        s_dq.dqb_curinodes = 0;
-        s_dq.dqb_curspace = 0;
+	s_dq.dqb_isoftlimit = isoftlimit * scale;
+	s_dq.dqb_ihardlimit = isoftlimit * scale * 2;
+	s_dq.dqb_bsoftlimit = bsoftlimit * scale ;
+	s_dq.dqb_bhardlimit = bsoftlimit * scale * 2;
+	s_dq.dqb_curinodes = 0;
+	s_dq.dqb_curspace = 0;
 	setquota(QUOTAUSER, device, name2id(USER, username), s_dq);
 
 	o_uid = getuid();
@@ -754,8 +914,8 @@ static void user_space_limit_test(long isoftlimit, long bsoftlimit, int user_pos
 		abort_printf("Set euid failed:%d:%s.\n", ret, strerror(ret));
 	}
 
-	snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-user-spacelimit", workplace,
-		 hostname, username);
+	snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-user-spacelimit",
+		 workplace, hostname, username);
 
 	fd = open(filename, O_RDWR | O_CREAT | O_TRUNC | O_APPEND, FILE_MODE);
 
@@ -763,101 +923,144 @@ static void user_space_limit_test(long isoftlimit, long bsoftlimit, int user_pos
 		writen_sz = write(fd, write_buf, clustersize);
 		if (writen_sz < 0) {
 			ret = errno;
-			abort_printf("write failed:%d:%s.\n", ret, strerror(ret));
+			abort_printf("write failed:%d:%s.\n", ret,
+				     strerror(ret));
 		}
 		file_sz += writen_sz;
 	}
 
-	if ((ret = write(fd, write_buf, clustersize)) > 0)
-		abort_printf("No allowed to exceed the hard limit of space");
+	MPI_Barrier_Sync();
+
+	if (uid)
+		sleep(QUOTA_SYNC_INTERVAL);
+
+	ret = write(fd, write_buf, clustersize);
+	if (ret > 0)
+		abort_printf("Not allowed to exceed the hard limit of space");
 
 	if (fd)
 		close(fd);
 
+	if (write_buf)
+		free(write_buf);
+
+	if (test_flags & PRSV_TEST)
+		goto out;
+
 	ret = unlink(filename);
 	if (ret < 0) {
-		ret =errno;
+		ret = errno;
 		abort_printf("Failed to unlink file(%s):%d:%s\n",
 			     filename, ret, strerror(ret));
-        }
+	}
 
 	sync();
 
 	seteuid(o_uid);
 
-	add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, NULL);
+	add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, 0, NULL);
 
-	if (write_buf)
-		free(write_buf);
+out:
+	return;
 }
 
-static void user_inodes_limit_test(long isoftlimit, long bsoftlimit, int user_postfix)
+static void user_inodes_limit_test(long isoftlimit, long bsoftlimit,
+				   unsigned int uid, int user_postfix)
 {
 	int ret;
 	long i;
-	int fd;
+	int fd, scale;
 	int o_uid;
 	struct if_dqblk s_dq, d_dq;
+	int id;
 
-        char username[USERNAME_SZ];
+	char username[USERNAME_SZ];
 
-	snprintf(username, USERNAME_SZ, "quotauser-rank%d-%d", rank,
+	snprintf(username, USERNAME_SZ, "quota-usr-rank%d-%d", rank,
 		 user_postfix);
-	add_rm_user_group(USERADD_BIN, ADD, USER, username, NULL);
+
+	if (!uid)
+		id = uid;
+	else
+		id = uid + user_postfix;
+
+	add_rm_user_group(USERADD_BIN, ADD, USER, username,
+			  id, NULL);
+	if (!uid)
+		scale = 1;
+	else
+		scale = size;
+
 	getquota(QUOTAUSER, device, name2id(USER, username), &s_dq);
-	s_dq.dqb_isoftlimit = isoftlimit;
-        s_dq.dqb_ihardlimit = isoftlimit * 2;
-        s_dq.dqb_bsoftlimit = bsoftlimit; 
-        s_dq.dqb_bhardlimit = bsoftlimit * 2;
+	s_dq.dqb_isoftlimit = isoftlimit * scale;
+	s_dq.dqb_ihardlimit = isoftlimit * scale * 2;
+	s_dq.dqb_bsoftlimit = bsoftlimit * scale;
+	s_dq.dqb_bhardlimit = bsoftlimit * scale * 2;
 	s_dq.dqb_curinodes = 0;
 	s_dq.dqb_curspace = 0;
 	setquota(QUOTAUSER, device, name2id(USER, username), s_dq);
-	
+
 	o_uid = getuid();
-	ret =  seteuid(name2id(USER, username));
+	ret = seteuid(name2id(USER, username));
 	if (ret < 0) {
 		ret = errno;
 		abort_printf("Set euid failed:%d:%s.\n", ret, strerror(ret));
 	}
 
 	for (i = 0; i < isoftlimit * 2; i++) {
-		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
 			 workplace, hostname, username, i);
 		if (!(i % 2)) {
-			fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
+			fd = open(filename, O_RDWR | O_CREAT | O_TRUNC,
+				  FILE_MODE);
 			if (fd < 0) {
 				ret = errno;
-				abort_printf("Open file failed:%d:%s\n", ret, strerror(ret));
+				abort_printf("Open file failed:%d:%s\n", ret,
+					     strerror(ret));
 			}
 			close(fd);
 		} else
 			mkdir(filename, FILE_MODE);
 
 		getquota(QUOTAUSER, device, name2id(USER, username), &d_dq);
-		if (d_dq.dqb_curinodes != i + 1)
-			abort_printf("Incorrect quota stats found,expected "
-				     "inode_num = %d,queried inode_num = %d.\n",
-				     i + 1, d_dq.dqb_curinodes);
+		if (!uid)
+			if (d_dq.dqb_curinodes != i + 1)
+				abort_printf("Incorrect quota stats "
+					     "found,expected inode_num = %d,"
+					     "queried inode_num = %d.\n",
+					     i + 1, d_dq.dqb_curinodes);
 	}
 
-	/*We definitely should hit falure here*/
-	snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+	if (uid) {
+
+		MPI_Barrier_Sync();
+
+		sleep(QUOTA_SYNC_INTERVAL);
+	}
+
+	/*We definitely should hit failure here*/
+	snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
 		 workplace, hostname, username, isoftlimit * 2);
+	fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
 
-	if ((fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE)) > 0) {
+	if (fd > 0) {
 		close(fd);
-		abort_printf("Not allowd to exceed the hard limit of inodes.\n");
+		abort_printf("Not allowed to exceed hard limit of inodes.\n");
 	}
 
-	/*cleanup*/
 	seteuid(o_uid);
+
+	if (test_flags & PRSV_TEST)
+		goto out;
+
+	/*cleanup*/
 	for (i = 0; i < isoftlimit * 2; i++) {
-		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
 			 workplace, hostname, username, i);
 		if (!(i % 2)) {
 			ret = unlink(filename);
 			if (ret < 0) {
-				ret =errno;
+				ret = errno;
 				abort_printf("Failed to unlink file(%s):%d:%s\n",
 					     filename, ret, strerror(ret));
 			}
@@ -872,44 +1075,63 @@ static void user_inodes_limit_test(long isoftlimit, long bsoftlimit, int user_po
 
 	}
 
-	add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, NULL);
+	add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, 0, NULL);
+
+out:
+	return;
 }
 
 static void group_space_limit_test(long isoftlimit, long bsoftlimit,
-				   long user_num, int grp_postfix)
+				   long user_num, unsigned int gid,
+				   int grp_postfix)
 {
 	int ret, fd;
-	long i, j;
-	int o_uid, o_gid;
-	struct if_dqblk s_dq, d_dq;
+	long i;
+	int o_uid, o_gid, scale;
+	struct if_dqblk s_dq;
+	int id;
 
 	char username[USERNAME_SZ], groupname[GROUPNAME_SZ];
-	char *write_buf;
+	char *write_buf = NULL;
 	int writen_sz, user_index;
 	long file_sz = 0, count = 0;
 
 	write_buf = (char *)malloc(clustersize);
 	memset(write_buf, 0, clustersize);
 
-	snprintf(groupname, GROUPNAME_SZ, "quotagroup-rank%d-%d", rank,
+	snprintf(groupname, GROUPNAME_SZ, "quota-grp-rank%d-%d", rank,
 		 grp_postfix);
-	add_rm_user_group(GROUPADD_BIN, ADD, GROUP, groupname, NULL);
+
+	if (!gid)
+		id = gid;
+	else
+		id = gid + grp_postfix;
+
+	add_rm_user_group(GROUPADD_BIN, ADD, GROUP, groupname,
+			  id, NULL);
+
+	if (!gid)
+		scale = 1;
+	else
+		scale = size;
+
 	getquota(QUOTAGROUP, device, name2id(GROUP, groupname), &s_dq);
-	s_dq.dqb_isoftlimit = isoftlimit;
-	s_dq.dqb_ihardlimit = isoftlimit * 2;
-	s_dq.dqb_bsoftlimit = bsoftlimit; 
-	s_dq.dqb_bhardlimit = bsoftlimit * 2;
+	s_dq.dqb_isoftlimit = isoftlimit * scale;
+	s_dq.dqb_ihardlimit = isoftlimit * scale * 2;
+	s_dq.dqb_bsoftlimit = bsoftlimit * scale;
+	s_dq.dqb_bhardlimit = bsoftlimit * scale * 2;
 	s_dq.dqb_curinodes = 0;
 	s_dq.dqb_curspace = 0;
 	setquota(QUOTAGROUP, device, name2id(GROUP, groupname), s_dq);
-	
+
 	o_gid = getgid();
 	setegid(name2id(GROUP, groupname));
 
 	for (i = 0; i < user_num; i++) {
-		snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname, i);
+		snprintf(username, USERNAME_SZ, "%s-quota-usr-%ld",
+			 groupname, i);
 		add_rm_user_group(USERADD_BIN, ADD, USER_IN_GROUP, username,
-				  groupname);
+				  0, groupname);
 		getquota(QUOTAUSER, device, name2id(USER, username), &s_dq);
 		s_dq.dqb_isoftlimit = isoftlimit;
 		s_dq.dqb_ihardlimit = isoftlimit * 2;
@@ -925,47 +1147,67 @@ static void group_space_limit_test(long isoftlimit, long bsoftlimit,
 		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-group-spacelimit",
 			 workplace, hostname, username);
 		fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
-		if (fd < 0)
-			abort_printf("Create file failed:%d:%s.\n", ret, strerror(ret));
+		if (fd < 0) {
+			ret = fd;
+			abort_printf("Create file failed:%d:%s.\n", ret,
+				     strerror(ret));
+		}
 		close(fd);
 		seteuid(o_uid);
 	}
 
-        while (file_sz + clustersize <= bsoftlimit * 2 * 1024) {
+	while (file_sz + clustersize <= bsoftlimit * 2 * 1024) {
 		user_index = count % user_num;
-		snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname, user_index);
+		snprintf(username, USERNAME_SZ, "%s-quota-usr-%d", groupname,
+			 user_index);
 		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-group-spacelimit",
 			 workplace, hostname, username);
 		o_uid = getuid();
 		seteuid(name2id(USER, username));
 		fd = open(filename, O_RDWR | O_APPEND, FILE_MODE);
-                writen_sz = write(fd, write_buf, clustersize);
-                if (writen_sz < 0) {
-                        ret = errno;
-                        abort_printf("write failed:%d:%s.\n", ret, strerror(ret));
-                }
+		writen_sz = write(fd, write_buf, clustersize);
+		if (writen_sz < 0) {
+			ret = errno;
+			abort_printf("write failed:%d:%s.\n", ret,
+				     strerror(ret));
+		}
+
 		close(fd);
 		seteuid(o_uid);
-                file_sz += writen_sz;
+		file_sz += writen_sz;
 		count++;
-        }
+	}
+
+	MPI_Barrier_Sync();
+	if (gid)
+		sleep(QUOTA_SYNC_INTERVAL);
 
 	user_index = count % user_num;
-	snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname, user_index);
+	snprintf(username, USERNAME_SZ, "%s-quota-usr-%d", groupname,
+		 user_index);
 	snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-group-spacelimit",
 		 workplace, hostname, username);
 	o_uid = getuid();
 	seteuid(name2id(USER, username));
 	fd = open(filename, O_RDWR | O_APPEND, FILE_MODE);
-	if ((writen_sz = write(fd, write_buf, clustersize)) > 0)
-		abort_printf("Not allowed to exceed space hard limit of group.");
+	writen_sz = write(fd, write_buf, clustersize);
+	if (writen_sz  > 0)
+		abort_printf("Not allowed to exceed space hard limit of group");
 
 	close(fd);
+
+	if (write_buf)
+		free(write_buf);
+
 	seteuid(o_uid);
 	setegid(o_gid);
 
+	if (test_flags & PRSV_TEST)
+		goto out;
+
 	for (i = 0; i < user_num; i++) {
-		snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname, i);
+		snprintf(username, USERNAME_SZ, "%s-quota-usr-%ld",
+			 groupname, i);
 		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-group-spacelimit",
 			 workplace, hostname, username);
 		ret = unlink(filename);
@@ -974,175 +1216,209 @@ static void group_space_limit_test(long isoftlimit, long bsoftlimit,
 			abort_printf("Failed to unlink file %s:%d:%s.\n",
 				     filename, ret, strerror(ret));
 		}
-		add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, NULL);
+		add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, 0, NULL);
 	}
-	
+
 	sync();
 
-	add_rm_user_group(GROUPDEL_BIN, REMOVE, GROUP, groupname, NULL);
-	
-	if (write_buf)
-		free(write_buf);
+	add_rm_user_group(GROUPDEL_BIN, REMOVE, GROUP, groupname, 0, NULL);
+
+out:
+	return;
 }
 
 static void group_inodes_limit_test(long isoftlimit, long bsoftlimit,
-				    long user_num, int grp_postfix)
+				    long user_num, unsigned int gid,
+				    int grp_postfix)
 {
 	int ret, fd;
-	long i, j;
+	long i;
 	int o_uid, o_gid;
-	int user_index;
+	int user_index, scale;
 	struct if_dqblk s_dq, d_dq;
+	int id;
 
-        char username[USERNAME_SZ], groupname[GROUPNAME_SZ];
+	char username[USERNAME_SZ], groupname[GROUPNAME_SZ];
 
-	snprintf(groupname, GROUPNAME_SZ, "quotagroup-rank%d-%d", rank,
+	snprintf(groupname, GROUPNAME_SZ, "quota-grp-rank%d-%d", rank,
 		 grp_postfix);
-	add_rm_user_group(GROUPADD_BIN, ADD, GROUP, groupname, NULL);
+
+	if (!gid)
+		id = gid;
+	else
+		id = gid + grp_postfix;
+
+	add_rm_user_group(GROUPADD_BIN, ADD, GROUP, groupname,
+			  id, NULL);
+
+	if (!gid)
+		scale = 1;
+	else
+		scale = size;
 
 	getquota(QUOTAGROUP, device, name2id(GROUP, groupname), &s_dq);
-	s_dq.dqb_isoftlimit = isoftlimit;
-        s_dq.dqb_ihardlimit = isoftlimit * 2;
-        s_dq.dqb_bsoftlimit = bsoftlimit; 
-        s_dq.dqb_bhardlimit = bsoftlimit * 2;
+	s_dq.dqb_isoftlimit = isoftlimit * scale;
+	s_dq.dqb_ihardlimit = isoftlimit * scale * 2;
+	s_dq.dqb_bsoftlimit = bsoftlimit * scale;
+	s_dq.dqb_bhardlimit = bsoftlimit * scale * 2;
 	s_dq.dqb_curinodes = 0;
 	s_dq.dqb_curspace = 0;
 	setquota(QUOTAGROUP, device, name2id(GROUP, groupname), s_dq);
 
 	for (i = 0; i < user_num; i++) {
-		snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname, i);
+		snprintf(username, USERNAME_SZ, "%s-quota-usr-%ld",
+			 groupname, i);
 		add_rm_user_group(USERADD_BIN, ADD, USER_IN_GROUP, username,
-				  groupname);
+				  0, groupname);
 		getquota(QUOTAUSER, device, name2id(USER, username), &s_dq);
 		s_dq.dqb_isoftlimit = isoftlimit;
-	        s_dq.dqb_ihardlimit = isoftlimit * 2;
-		s_dq.dqb_bsoftlimit = bsoftlimit; 
+		s_dq.dqb_ihardlimit = isoftlimit * 2;
+		s_dq.dqb_bsoftlimit = bsoftlimit;
 		s_dq.dqb_bhardlimit = bsoftlimit * 2;
 		s_dq.dqb_curinodes = 0;
 		s_dq.dqb_curspace = 0;
 		setquota(QUOTAUSER, device, name2id(USER, username), s_dq);
 	}
-	
+
 	o_gid = getgid();
 	setegid(name2id(GROUP, groupname));
 
 	for (i = 0; i < isoftlimit * 2; i++) {
 		user_index = i % user_num;
-		snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname,
+		snprintf(username, USERNAME_SZ, "%s-quota-usr-%d", groupname,
 			 user_index);
-		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
 			 workplace, hostname, username, i);
 		o_uid = getuid();
 		seteuid(name2id(USER, username));
 		fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
 		if (fd < 0) {
 			ret = errno;
-			abort_printf("Open %d file failed:%d:%s\n", i, ret, strerror(ret));
+			abort_printf("Open %d file failed:%d:%s\n", i, ret,
+				     strerror(ret));
 		}
 
 		close(fd);
 		seteuid(o_uid);
 
 		getquota(QUOTAGROUP, device, name2id(GROUP, groupname), &d_dq);
-		if (d_dq.dqb_curinodes != i + 1)
-			abort_printf("Incorrect quota stats found,expected "
-				     "inode_num = %d,queried inode_num = %d.\n",
-				     i + 1, d_dq.dqb_curinodes);
+		if (size == 1)
+			if (d_dq.dqb_curinodes != i + 1)
+				abort_printf("Incorrect quota stats found,"
+					     "expected inode_num = %d,queried"
+					     " inode_num = %d.\n", i + 1,
+					     d_dq.dqb_curinodes);
 	}
 
-	/*We definitely should hit falure here*/
+	MPI_Barrier_Sync();
+	if (gid)
+		sleep(QUOTA_SYNC_INTERVAL);
+
+	/*We definitely should hit failure here*/
 	user_index = (isoftlimit * 2) % user_num;
-	snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname, user_index);
-	snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+	snprintf(username, USERNAME_SZ, "%s-quota-usr-%d", groupname,
+		 user_index);
+	snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
 		 workplace, hostname, username, isoftlimit * 2);
 	o_uid = getuid();
 	seteuid(name2id(USER, username));
-	if ((fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE)) > 0) {
+	fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
+	if (fd > 0) {
 		close(fd);
-		abort_printf("Not allowd to exceed the hard limit of inodes.\n");
+		abort_printf("Not allowd to exceed hard limit of inodes.\n");
 	}
 
 	seteuid(o_uid);
 	setegid(o_gid);
 
+	if (test_flags & PRSV_TEST)
+		goto out;
+
 	/*cleanup*/
 	for (i = 0; i < isoftlimit * 2; i++) {
 		user_index = i % user_num;
-		snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname,
+		snprintf(username, USERNAME_SZ, "%s-quota-usr-%d", groupname,
 			 user_index);
-		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
 			 workplace, hostname, username, i);
 			ret = unlink(filename);
 		if (ret < 0) {
-			ret =errno;
+			ret = errno;
 			abort_printf("Failed to unlink file(%s):%d:%s\n",
 				     filename, ret, strerror(ret));
 		}
 
 	}
-	
+
 	for (i = 0; i < user_num; i++) {
-		snprintf(username, USERNAME_SZ, "%s-quotauser-%d", groupname, i);
-		add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, NULL);
+		snprintf(username, USERNAME_SZ, "%s-quota-usr-%ld",
+			 groupname, i);
+		add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, 0, NULL);
 	}
 
-	add_rm_user_group(GROUPDEL_BIN, REMOVE, GROUP, groupname, NULL);
+	add_rm_user_group(GROUPDEL_BIN, REMOVE, GROUP, groupname, 0, NULL);
+
+out:
+	return;
 }
 
-static int quota_corrupt_test(long isoftlimit, long bsoftlimit, int user_postfix)
+static int quota_corrupt_test(long isoftlimit, long bsoftlimit,
+			      int user_postfix)
 {
-	int ret, fd;
-	long i, j;
-	int o_uid, o_gid;
-	int user_index;
+	int ret, fd, o_uid;
+	long i;
 	struct if_dqblk s_dq, d_dq;
-	
-	char username[USERNAME_SZ], groupname[GROUPNAME_SZ];
 
-	snprintf(username, USERNAME_SZ, "quotauser-rank%d-%d", rank,
-                 user_postfix);
-	add_rm_user_group(USERADD_BIN, ADD, USER, username, NULL);
+	char username[USERNAME_SZ];
+
+	snprintf(username, USERNAME_SZ, "quota-usr-rank%d-%d", rank,
+		 user_postfix);
+	add_rm_user_group(USERADD_BIN, ADD, USER, username, UID_BASE, NULL);
 
 	getquota(QUOTAUSER, device, name2id(USER, username), &s_dq);
 	s_dq.dqb_isoftlimit = isoftlimit;
 	s_dq.dqb_ihardlimit = isoftlimit * 2;
 	s_dq.dqb_bsoftlimit = bsoftlimit;
 	s_dq.dqb_bhardlimit = bsoftlimit * 2;
-	s_dq.dqb_curinodes = 0xFFFFFFFFFFFFFFFF;
-	s_dq.dqb_curspace = 0xFFFFFFFFFFFFFFFF;
+	s_dq.dqb_curinodes = -2;
+	s_dq.dqb_curspace = -2;
 	setquota(QUOTAUSER, device, name2id(USER, username), s_dq);
 
 	o_uid = getuid();
-	ret =  seteuid(name2id(USER, username));
+	ret = seteuid(name2id(USER, username));
 
 	for (i = 0; i < isoftlimit; i++) {
-		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
 			 workplace, hostname, username, i);
-		
+
 		fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
 		if (fd < 0) {
 			ret = errno;
-			abort_printf("Open file failed:%d:%s\n", ret, strerror(ret));
+			abort_printf("Open file failed:%d:%s\n", ret,
+				     strerror(ret));
 		}
 
 		close(fd);
 	}
 
 	/*
-	 * After a while, we check if the curinodes and curspace 
+	 * After a while, we check if the curinodes and curspace
 	 * get synced to be correct.
 	*/
-	sleep(5);
+	sleep(QUOTA_SYNC_INTERVAL);
 	seteuid(o_uid);
 	getquota(QUOTAUSER, device, name2id(USER, username), &d_dq);
 
 	if (d_dq.dqb_curinodes != isoftlimit)
-		abort_printf("Quota corrupt test failed.expected inode_nums = "
-			     "%ld, while queried inode_nums = %ld.\n", isoftlimit,
-			     d_dq.dqb_curinodes);
+		log_printf(stderr, "Quota corrupt test failed.expected "
+			   "inode_nums = %ld, while queried inode_nums "
+			   "= %ld.\n", isoftlimit, d_dq.dqb_curinodes);
+
+	if (test_flags & PRSV_TEST)
+		goto out;
 
 	for (i = 0; i < isoftlimit; i++) {
-		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%d",
+		snprintf(filename, PATH_SZ, "%s/%s-%s-quotafile-%ld",
 			 workplace, hostname, username, i);
 		ret = unlink(filename);
 		if (ret < 0) {
@@ -1152,27 +1428,31 @@ static int quota_corrupt_test(long isoftlimit, long bsoftlimit, int user_postfix
 		}
 	}
 
-	add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, NULL);
+	add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, 0, NULL);
+
+out:
+	return 0;
 }
 
 static int concurrent_rw_test(long isoftlimit, long bsoftlimit,
 			      long user_postfix)
 {
-	int ret, fd, o_uid, j;
-	long i, file_index, writen_size = 0;
+	int ret, fd, o_uid;
+	long i, writen_size = 0;
 	struct if_dqblk s_dq, d_dq;
 	char username[USERNAME_SZ];
-	char *write_buf;
-	
+	char *write_buf = NULL;
+
 	MPI_Request request;
 	MPI_Status status;
-	
+
 	if (!rank) {
-	
-		snprintf(username, USERNAME_SZ, "quota-user-rank%d-%d", rank,
-		         user_postfix);
-		
-		add_rm_user_group(USERADD_BIN, ADD, USER, username, NULL);
+
+		snprintf(username, USERNAME_SZ, "quota-usr-rank%d-%ld", rank,
+			 user_postfix);
+
+		add_rm_user_group(USERADD_BIN, ADD, USER, username,
+				  UID_BASE, NULL);
 		getquota(QUOTAUSER, device, name2id(USER, username), &s_dq);
 		s_dq.dqb_isoftlimit = isoftlimit;
 		s_dq.dqb_ihardlimit = isoftlimit * 2;
@@ -1183,87 +1463,108 @@ static int concurrent_rw_test(long isoftlimit, long bsoftlimit,
 		setquota(QUOTAUSER, device, name2id(USER, username), s_dq);
 
 	} else
-		snprintf(username, USERNAME_SZ, "quota-user-rank0-%d",
+		snprintf(username, USERNAME_SZ, "quota-usr-rank0-%ld",
 			 user_postfix);
 	if (!rank) {
+
 		o_uid = getuid();
 		seteuid(name2id(USER, username));
-		snprintf(filename, PATH_SZ, "%s/%s-quotafile", workplace, username);
+		snprintf(filename, PATH_SZ, "%s/%s-quotafile", workplace,
+			 username);
 		fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
 		if (fd < 0) {
 			ret = errno;
-			abort_printf("Open file failed:%d:%s\n", ret, strerror(ret));
+			abort_printf("Open file failed:%d:%s\n", ret,
+				     strerror(ret));
 		}
+
 		close(fd);
 		seteuid(o_uid);
 	}
 
 	MPI_Barrier_Sync();
-	
+
 	if (!rank) {
 		for (i = 1; i < size; i++) {
 			ret = MPI_Irecv(&writen_size, sizeof(long),
-					MPI_BYTE, i, 1, MPI_COMM_WORLD, &request);
+					MPI_BYTE, i, 1, MPI_COMM_WORLD,
+					&request);
+
 			if (ret != MPI_SUCCESS)
 				abort_printf("MPI_Irecv faile.\n");
 			MPI_Wait(&request, &status);
-			printf("write_size = %ld, received.\n", writen_size);
-			getquota(QUOTAUSER, device, name2id(USER, username), &d_dq);
-			if (d_dq.dqb_curspace != writen_size)
-				abort_printf("Concurrent test failed among nodes,"
-					     "Incorrect space stats found, expected "
-					     "space usage = %ld, queried space usage "
-					     "= %ld.\n", writen_size, d_dq.dqb_curspace);
+			sync();
+			getquota(QUOTAUSER, device, name2id(USER, username),
+				 &d_dq);
 		}
 	} else {
 		snprintf(filename, PATH_SZ, "%s/%s-quotafile", workplace,
 			 username);
 		fd = open(filename, O_RDWR);
-		i = get_rand(0, rank);
+		i = rank;
 		write_buf = (char *)malloc(clustersize * i);
 		memset(write_buf, 0, clustersize * i);
+		ret = ftruncate(fd, clustersize * i);
+		if (ret < 0) {
+			ret = errno;
+			abort_printf("ftruncate failed:%d:%s.\n", ret,
+				      strerror(ret));
+		}
 		writen_size = pwrite(fd, write_buf, clustersize * i, 0);
 		if (writen_size < 0) {
 			ret = errno;
-			abort_printf("pwrite failed:%d:%s.\n", ret, strerror(ret));
+			abort_printf("pwrite failed:%d:%s.\n", ret,
+				     strerror(ret));
 		}
-		printf("write_size = %ld, sent.\n", writen_size);
-		
+
+		sync();
+
 		ret = MPI_Isend(&writen_size, sizeof(long), MPI_BYTE, 0, 1,
 				MPI_COMM_WORLD, &request);
 		if (ret != MPI_SUCCESS)
 			abort_printf("MPI_Isend failed.\n");
 		MPI_Wait(&request, &status);
-		
+
+		if (write_buf)
+			free(write_buf);
+
 	}
 
 	MPI_Barrier_Sync();
 
-	if(!rank) {
+	if (test_flags & PRSV_TEST)
+		goto out;
+
+	if (!rank) {
 		ret = unlink(filename);
 		if (ret < 0) {
 			ret = errno;
-			abort_printf("Unlink file failed:%d:%s\n", ret, strerror(ret));
+			abort_printf("Unlink file failed:%d:%s\n", ret,
+				     strerror(ret));
 		}
 
-		add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, NULL);
+		add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, 0, NULL);
 	}
+
+out:
+	return 0;
 }
 
-static int run_tests(void)
+static void basic_test()
 {
-	int ret;
-	int i;
-	int fd;
-	int o_uid, o_gid;
+	int sub_testno = 1;
+	int o_testflags;
 	struct if_dqblk s_dq, d_dq;
-	
+
 	char username[USERNAME_SZ], groupname[GROUPNAME_SZ];
 
 	MPI_Barrier_Sync();
-	root_printf("Test %d:Set/Get quota for one user/group among nodes. \n", testno);
-	snprintf(username, USERNAME_SZ, "quotauser-%d", rank);
-	add_rm_user_group(USERADD_BIN, ADD, USER, username, NULL);
+	root_printf("Test %d: Basic Quota Test.\n", testno);
+	root_printf("  *SubTest %d: Set/Get quota for one user/group among "
+		    "nodes. \n", sub_testno++);
+	snprintf(username, USERNAME_SZ, "quota-usr-%d", rank);
+	add_rm_user_group(USERADD_BIN, ADD, USER, username,
+			  UID_BASE + rank, NULL);
 
 	getquota(QUOTAUSER, device, name2id(USER, username), &s_dq);
 	s_dq.dqb_isoftlimit = 10000;
@@ -1272,11 +1573,13 @@ static int run_tests(void)
 	s_dq.dqb_bhardlimit = 1024 * 1024 * 20;
 	setquota(QUOTAUSER, device, name2id(USER, username), s_dq);
 	getquota(QUOTAUSER, device, name2id(USER, username), &d_dq);
-	verify_quota_items(s_dq, d_dq, ISOFT_LIMIT | IHARD_LIMIT | BSOFT_LIMIT | BHARD_LIMIT);
-	add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, NULL);
+	verify_quota_items(s_dq, d_dq,
+			   ISOFT_LIMIT | IHARD_LIMIT | BSOFT_LIMIT | BHARD_LIMIT);
+	add_rm_user_group(USERDEL_BIN, REMOVE, USER, username, 0, NULL);
 
-	snprintf(groupname, GROUPNAME_SZ, "quotagroup-%d", rank);
-	add_rm_user_group(GROUPADD_BIN, ADD, GROUP, groupname, NULL);
+	snprintf(groupname, GROUPNAME_SZ, "quota-grp-%d", rank);
+	add_rm_user_group(GROUPADD_BIN, ADD, GROUP, groupname,
+			  GID_BASE + rank, NULL);
 
 	getquota(QUOTAGROUP, device, name2id(GROUP, groupname), &s_dq);
 	s_dq.dqb_isoftlimit = 20000;
@@ -1285,70 +1588,175 @@ static int run_tests(void)
 	s_dq.dqb_bhardlimit = 1024 * 1024 * 20;
 	setquota(QUOTAGROUP, device, name2id(GROUP, groupname), s_dq);
 	getquota(QUOTAGROUP, device, name2id(GROUP, groupname), &d_dq);
-	verify_quota_items(s_dq, d_dq, ISOFT_LIMIT | IHARD_LIMIT | BSOFT_LIMIT | BHARD_LIMIT);
-	add_rm_user_group(GROUPDEL_BIN, REMOVE, GROUP, groupname, NULL);
-	testno++;
-	
+	verify_quota_items(s_dq, d_dq,
+			   ISOFT_LIMIT | IHARD_LIMIT | BSOFT_LIMIT | BHARD_LIMIT);
+	add_rm_user_group(GROUPDEL_BIN, REMOVE, GROUP, groupname, 0, NULL);
+
 	MPI_Barrier_Sync();
-	root_printf("Test %d:Quota inodes limit test for users/groups among nodes.\n", testno);
-	user_inodes_limit_test(100, 1024 * 1024 * 10, 1);
+	root_printf("  *SubTest %d: Quota inodes limit test for users/groups "
+		    "among nodes.\n", sub_testno++);
+	o_testflags = test_flags;
+	if (test_flags & PRSV_TEST)
+		test_flags &= ~PRSV_TEST;
+
+	user_inodes_limit_test(100, 1024 * 1024 * 10, 0, 0);
 	MPI_Barrier_Sync();
-	group_inodes_limit_test(100, 1024 * 1024 * 10, 4, 1);
-	testno++;
+	group_inodes_limit_test(100, 1024 * 1024 * 10, 4, 0, 0);
 
 	MPI_Barrier_Sync();
-	root_printf("Test %d:Quota space limit test for users/groups among nodes.\n", testno);
-	user_space_limit_test(100, 1024 * 256, 1);
+	root_printf("  *SubTest %d: Quota space limit test for users/groups "
+		    "among nodes.\n", sub_testno++);
+	user_space_limit_test(100, 1024 * 256, 0, 0);
 	MPI_Barrier_Sync();
-	group_space_limit_test(100, 1024 * 256, 4, 1);
-	testno++;
+	group_space_limit_test(100, 1024 * 256, 4, 0, 0);
 
 	MPI_Barrier_Sync();
-	root_printf("Test %d:Quota grace time test among nodes.\n", testno);
-	user_inodes_grace_time_test(100, 1024 * 256, 10, 1);
+	root_printf("  *SubTest %d: Quota grace time test among nodes.\n",
+		    sub_testno++);
+	test_flags = o_testflags;
+	user_inodes_grace_time_test(100, 1024 * 256, 10, 0, 0);
+
 	testno++;
+}
+
+static void stress_test(void)
+{
+	int i, sub_testno = 1;
 
 	MPI_Barrier_Sync();
-	root_printf("Test %d:Huge user number test among nodes.\n", testno);
-	for (i = 0; i < user_nums; i++)
-		user_inodes_limit_test(100, 1024 * 1024 * 2, i);
-	testno++;
-	
+	root_printf("Test %d: Stress Quota Test.\n", testno);
+	root_printf("  *SubTest %d: Huge user number test among nodes.\n",
+		    sub_testno++);
+	for (i = 0; i < user_nums; i++) {
+		user_inodes_limit_test(100, 1024 * 1024 * 2, 0, i);
+		user_space_limit_test(100, 1024 * 1024 * 2, 0, i);
+	}
+
 	MPI_Barrier_Sync();
-	root_printf("Test %d:Huge group number test among nodes.\n", testno);
-	for (i = 0; i < group_nums; i++)
-		group_inodes_limit_test(100, 1024 * 1024 * 2, 4, i);
-	testno++;
+	root_printf("  *SubTest %d: Huge group number test among nodes.\n",
+		    sub_testno++);
+	for (i = 0; i < group_nums; i++) {
+		group_inodes_limit_test(100, 1024 * 1024 * 2, 4, 0, i);
+		group_space_limit_test(100, 1024 * 256, 4, 0, i);
+	}
 
 	MPI_Barrier_Sync();
-	root_printf("Test %d:Stress test with intensive quota operations for user/group.\n", testno);
+	root_printf("  *SubTest %d: Stress test with intensive quota operations"
+		    " for user/group.\n", sub_testno++);
 	for (i = 0; i < user_nums; i++) {
-		user_inodes_limit_test(100, 1024 * 1024, i);
+		user_inodes_limit_test(100, 1024 * 1024, 0, i);
 		MPI_Barrier_Sync();
-		group_inodes_limit_test(100, 1024 *1024, 8, i);
+		group_inodes_limit_test(100, 1024 * 1024, 8, 0, i);
 	}
+
 	testno++;
+}
+
+static void negative_test(void)
+{
+	int sub_testno = 1;
 
 	MPI_Barrier_Sync();
-	root_printf("Test %d:Negative and positive quota test.\n", testno);
-	negative_inodes_limit_test(100, 1024 * 1024, 1, 10);
+	root_printf("Test %d: Negative Quota Test.\n", testno);
+	root_printf("  *SubTest %d: Negative and positive quota test.\n",
+		    sub_testno++);
+	negative_inodes_limit_test(1000, 1024 * 1024, 1, 50);
 	testno++;
+}
+
+static void corrupt_test(void)
+{
+	int sub_testno = 1;
 
 	MPI_Barrier_Sync();
-	root_printf("Test %d:Concurrent file r/w test.\n", testno);
-	concurrent_rw_test(100, 1024 * 1024, 1);
+	root_printf("Test %d: Corrupt Quota Test.\n", testno);
+	root_printf("  *SubTest %d: Quota corruption test.\n", sub_testno++);
+	quota_corrupt_test(100, 1024 * 1024, 1);
 	testno++;
+}
+
+static void concurrent_test(void)
+{
+	int sub_testno = 1;
 
 	MPI_Barrier_Sync();
-	root_printf("Test %d:Quota corruption test.\n", testno);
-	quota_corrupt_test(100, 1024 * 1024, 1);
+	root_printf("Test %d: Concurrent Quota Test.\n", testno);
+	root_printf("  *SubTest %d: Concurrent file r/w test.\n", sub_testno++);
+	concurrent_rw_test(100, 1024 * 1024 * 100, 1);
 	testno++;
+}
+
+static void cleanup_users(void)
+{
+
+	unsigned long i, j;
+
+	char username[USERNAME_SZ], groupname[GROUPNAME_SZ];
+
+	for (i = 0; i < group_nums; i++) {
+		snprintf(groupname, GROUPNAME_SZ, "quota-grp-rank%d-%ld",
+			 rank, i);
+		if (name2id(GROUP, groupname) < 0)
+			continue;
+		else {
+			for (j = 0; j < user_nums; j++) {
+				snprintf(username, USERNAME_SZ, "%s-quota-usr"
+					 "-%ld", groupname, j);
+				if (name2id(USER, username) < 0)
+					continue;
+				else
+					add_rm_user_group(USERDEL_BIN, REMOVE,
+							  USER, username, 0,
+							  NULL);
+			}
+
+			add_rm_user_group(GROUPDEL_BIN, REMOVE, GROUP,
+					  groupname, 0, NULL);
+		}
+	}
+
+	for (i = 0; i < user_nums; i++) {
+		snprintf(username, USERNAME_SZ, "quota-usr-rank%d-%ld",
+			 rank, i);
+		if (name2id(USER, username) < 0)
+			continue;
+		else
+			add_rm_user_group(USERDEL_BIN, REMOVE, USER, username,
+					  0, NULL);
+	}
+}
+
+static void run_tests(void)
+{
+	int i;
+
+	for (i = 0; i < iterations; i++) {
+
+		root_printf("[*Round %d Test Running*]\n", i);
+
+		if (test_flags & BASC_TEST)
+			basic_test();
+
+		if (test_flags & STRS_TEST)
+			stress_test();
+
+		if (test_flags & CRPT_TEST)
+			corrupt_test();
+
+		if (test_flags & CONT_TEST)
+			concurrent_test();
+
+		if (test_flags & NEGV_TEST)
+			negative_test();
+
+		if (test_flags & CLEN_TEST)
+			cleanup_users();
+	}
 
 }
 
 static int setup(int argc, char *argv[])
 {
-	unsigned long i;
 	int ret;
 	int o_umask;
 
@@ -1398,28 +1806,26 @@ static int setup(int argc, char *argv[])
 	MPI_Barrier_Sync();
 
 	quota_on_off(QUOTAON_BIN, 1, QUOTAUSER|QUOTAGROUP, mountpoint);
+
+	return 0;
 }
 
 static int teardown(void)
 {
 	if (rank == 0)
-		rmdir(workplace);
+		if (!(test_flags & PRSV_TEST))
+			rmdir(workplace);
 
 	MPI_Barrier_Sync();
 	quota_on_off(QUOTAON_BIN, 0, QUOTAUSER|QUOTAGROUP, mountpoint);
-
 	MPI_Finalize();
 	return 0;
 }
 
 int main(int argc, char *argv[])
 {
-	int i;
-
 	setup(argc, argv);
-	for (i = 0; i < iterations; i++)
-		run_tests();
-
+	run_tests();
 	teardown();
 	return 0;
 }
diff --git a/programs/quota_tests/run_quota_multi_tests.py b/programs/quota_tests/run_quota_multi_tests.py
index e002b97..e95cded 100755
--- a/programs/quota_tests/run_quota_multi_tests.py
+++ b/programs/quota_tests/run_quota_multi_tests.py
@@ -9,7 +9,7 @@
 # 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 
+# 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.
 #
@@ -19,9 +19,9 @@
 # Boston, MA 021110-1307, USA.
 #
 # XXX: Future improvements:
-#	 
+#
 # Program	: run_quota_multi_tests.py
-# Description 	: Python launcher to run quota_multi_tests. 
+# Description 	: Python launcher to run quota_multi_tests.
 #		Will validate parameters and properly configure
 #		openmpi and start it, before starting the test.
 #		This progran will run on each node.
@@ -38,17 +38,25 @@ DEBUGON = os.getenv('DEBUG',0)
 uname = os.uname()
 lhostname = str(socket.gethostname())
 logfile = config.LOGFILE
-procs = 1
+procs = 0
 cmd = config.BINDIR+'/quota_multi_tests'
 #
 Usage = """
-%prog 
+%prog
 [-i | --iterations <iterations>]
-[-l | --logfile <logfile>] 
-[-n | --nodelist <nodelist>] 
-[-u | --users <user_nums>] 
+[-l | --logfile <logfile>]
+[-n | --nodelist <nodelist>]
+[-r | --ranks <rank_nums>] 	rank number for mpi execution.
+[-u | --users <user_nums>]
 [-g | --groups <group_nums>]
 [-d | --device <device>]
+[-B | --basic]			launch basic test.
+[-S | --stress]			launch stress test.
+[-C | --corrupt]		launch corrupt test.
+[-N | --negative]		launch negative test.
+[-M | --concurrent		launch concurrent test.
+[-P | --preserve		preserve the testing env after tests done.
+[-W | --clean			wipe off all testing users and groups.
 [-m | --mountpoint <mountpoint>]
 [-h | --help]
 """
@@ -76,6 +84,12 @@ if __name__=='__main__':
                 type='string',
                 help='List of nodes where test will run.')
 #
+        parser.add_option('-r',
+                '--ranks',
+                dest='ranks',
+                type='int',
+                help='Number of ranks.')
+#
         parser.add_option('-u',
                 '--users',
                 dest='users',
@@ -94,6 +108,55 @@ if __name__=='__main__':
                 type='string',
                 help='Target volume.')
 #
+        parser.add_option('-B',
+		'--basic',
+		action="store_true",
+		dest='basic',
+		default=False,
+		help='launch basic test.')
+#
+        parser.add_option('-S',
+		'--stress',
+		action="store_true",
+		dest='stress',
+		default=False,
+		help='launch stress test.')
+#
+        parser.add_option('-C',
+		'--corrupt',
+		action="store_true",
+		dest='corrupt',
+		default=False,
+		help='launch corrupt test.')
+#
+        parser.add_option('-N',
+		'--negative',
+		action="store_true",
+		dest='negative',
+		default=False,
+		help='launch negative test.')
+#
+        parser.add_option('-M',
+		'--concurrent',
+		action="store_true",
+		dest='concurrent',
+		default=False,
+		help='launch concurrent test.')
+#
+        parser.add_option('-P',
+		'--preserve',
+		action="store_true",
+		dest='preserve',
+		default=False,
+		help='preserve the testing env after tests done.')
+#
+        parser.add_option('-W',
+		'--clean',
+		action="store_true",
+		dest='clean',
+		default=False,
+		help='wipe off all testing users and groups.')
+#
         parser.add_option('-m',
                 '--mountpoint',
                 dest='mountpoint',
@@ -102,7 +165,7 @@ if __name__=='__main__':
 
 	(options, args) = parser.parse_args()
 	if len(args) != 0:
-		o2tf.printlog('args left %s' % len(args), 
+		o2tf.printlog('args left %s' % len(args),
 			logfile, 0, '')
 		parser.error('incorrect number of arguments')
 #
@@ -110,13 +173,15 @@ if __name__=='__main__':
 #
 	if not options.device:
 		parser.error('device mandatory for test')
-	
+
 	if not options.mountpoint:
 		parser.error('mount point is mandatory for test');
 
 	if not options.users and not options.groups:
 			parser.error('either Users or groups should be specified at least')
 
+	test_flags = ''
+
 	if options.iterations:
 		iter_arg = '-i ' + str(options.iterations)
 	else:
@@ -132,6 +197,30 @@ if __name__=='__main__':
 	else:
 		group_arg = ''
 
+	if options.ranks:
+		procs = options.ranks
+
+	if options.basic:
+		test_flags = test_flags + '-b '
+
+	if options.stress:
+		test_flags = test_flags + '-s '
+
+	if options.corrupt:
+		test_flags = test_flags + '-c '
+
+	if options.negative:
+		test_flags = test_flags + '-n '
+
+	if options.concurrent:
+		test_flags = test_flags + '-m '
+
+	if options.preserve:
+		test_flags = test_flags + '-p '
+
+	if options.clean:
+		test_flags = test_flags + '-w '
+
 	device_arg = '-d ' + options.device
 	mountpoint_arg = options.mountpoint
 
@@ -141,7 +230,8 @@ if __name__=='__main__':
 	if options.nodelist:
 		nodelist = options.nodelist.split(',')
 		nodelen = len(nodelist)
-		procs = nodelen
+		if procs == 0:
+			procs = nodelen
 		if nodelen == 1:
 			nodelist = nodelist.append(options.nodelist)
 		else:
@@ -151,22 +241,23 @@ if __name__=='__main__':
 			parser.error('Invalid node list.')
 
 if DEBUGON:
-	o2tf.printlog('quota_multi_test: main - current directory %s' % 
+	o2tf.printlog('quota_multi_test: main - current directory %s' %
 		os.getcwd(), logfile, 0, '')
 	o2tf.printlog('quota_multi_test: main - cmd = %s' % cmd,
 		logfile, 0, '')
 #
 o2tf.OpenMPIInit(DEBUGON, options.nodelist, logfile, 'rsh')
 #
-ret = o2tf.openmpi_run(DEBUGON, procs, 
-	str('%s %s %s %s %s %s 2>&1 | tee -a %s' % (cmd, 
+ret = o2tf.openmpi_run(DEBUGON, procs,
+	str('%s %s %s %s %s %s %s 2>&1 | tee -a %s' % (cmd,
 	iter_arg,
 	user_arg,
 	group_arg,
 	device_arg,
+	test_flags,
 	mountpoint_arg,
-	logfile)), 
-	options.nodelist, 
+	logfile)),
+	options.nodelist,
 	'rsh',
 	logfile,
 	'WAIT')
-- 
1.5.5




More information about the Ocfs2-test-devel mailing list