Module Name:    src
Committed By:   gson
Date:           Fri Aug 29 17:39:18 UTC 2014

Modified Files:
        src/tests/fs/vfs: t_unpriv.c

Log Message:
Don't pass an uninitialized variable as the times[] argument of
rump_sys_utimes().  Instead, pass combinations of values representing
edge cases: the farthest possible past, the epoch, and the farthest
possible future.  Now the excessive runtime reported in PR bin/49144
occurs reliably, on multiple architectures, and not only with udf, but
also with msdosfs.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/fs/vfs/t_unpriv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/fs/vfs/t_unpriv.c
diff -u src/tests/fs/vfs/t_unpriv.c:1.10 src/tests/fs/vfs/t_unpriv.c:1.11
--- src/tests/fs/vfs/t_unpriv.c:1.10	Sat Mar 16 05:45:37 2013
+++ src/tests/fs/vfs/t_unpriv.c	Fri Aug 29 17:39:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_unpriv.c,v 1.10 2013/03/16 05:45:37 jmmv Exp $	*/
+/*	$NetBSD: t_unpriv.c,v 1.11 2014/08/29 17:39:18 gson Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -31,6 +31,7 @@
 
 #include <atf-c.h>
 #include <libgen.h>
+#include <limits.h>
 #include <unistd.h>
 
 #include <rump/rump_syscalls.h>
@@ -127,7 +128,13 @@ times(const atf_tc_t *tc, const char *mp
 {
 	const char *name = "file.test";
 	int fd;
+	unsigned int i, j;
 	struct timeval tmv[2];
+	static struct timeval tmvs[] = {
+		{ QUAD_MIN, 0 },
+		{ 0, 0 },
+		{ QUAD_MAX, 999999 }
+	};
 
 	FSTEST_ENTER();
 
@@ -148,15 +155,21 @@ times(const atf_tc_t *tc, const char *mp
 	if (rump_sys_utimes(name, NULL) == -1)
 		atf_tc_fail_errno("utimes");
 
-	rump_pub_lwproc_rfork(RUMP_RFCFDG);
-	if (rump_sys_setuid(1) == -1)
-		atf_tc_fail_errno("setuid");
-	if (rump_sys_utimes(name, tmv) != -1 || errno != EPERM)
-		atf_tc_fail_errno("utimes");
-	rump_pub_lwproc_releaselwp();
-
-	if (rump_sys_utimes(name, tmv) == -1)
-		atf_tc_fail_errno("utimes");
+	for (i = 0; i < sizeof(tmvs) / sizeof(tmvs[0]); i++) {
+		for (j = 0; j < sizeof(tmvs) / sizeof(tmvs[0]); j++) {
+			tmv[0] = tmvs[i];
+			tmv[1] = tmvs[j];
+			rump_pub_lwproc_rfork(RUMP_RFCFDG);
+			if (rump_sys_setuid(1) == -1)
+				atf_tc_fail_errno("setuid");
+			if (rump_sys_utimes(name, tmv) != -1 || errno != EPERM)
+				atf_tc_fail_errno("utimes");
+			rump_pub_lwproc_releaselwp();
+
+			if (rump_sys_utimes(name, tmv) == -1)
+				atf_tc_fail_errno("utimes");
+		}
+	}
 
 	if (rump_sys_unlink(name) == -1)
 		atf_tc_fail_errno("unlink");

Reply via email to