CVS commit: src/tests/syscall

2011-07-07 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Thu Jul  7 06:17:01 UTC 2011

Removed Files:
src/tests/syscall: Makefile t_access.c t_chroot.c t_dup.c t_fsync.c
t_getgroups.c t_getlogin.c t_getpid.c t_getrusage.c t_getsid.c
t_gettimeofday.c t_issetugid.c t_itimer.c t_kill.c t_link.c
t_mincore.c t_mkfifo.c t_mknod.c t_mmap.c t_mprotect.c t_msync.c
t_nanosleep.c t_poll.c t_pollts.c t_pselect.c t_revoke.c
t_setrlimit.c t_setuid.c t_stat.c t_timer.c t_truncate.c t_umask.c
t_unlink.c

Log Message:
Deprecate tests/sycall. The tests will be added back to tests/libc/sys.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r0 src/tests/syscall/Makefile
cvs rdiff -u -r1.4 -r0 src/tests/syscall/t_access.c src/tests/syscall/t_dup.c \
src/tests/syscall/t_mmap.c src/tests/syscall/t_msync.c \
src/tests/syscall/t_pollts.c
cvs rdiff -u -r1.1 -r0 src/tests/syscall/t_chroot.c \
src/tests/syscall/t_getgroups.c src/tests/syscall/t_getlogin.c \
src/tests/syscall/t_gettimeofday.c src/tests/syscall/t_issetugid.c \
src/tests/syscall/t_itimer.c src/tests/syscall/t_kill.c \
src/tests/syscall/t_link.c src/tests/syscall/t_mkfifo.c \
src/tests/syscall/t_poll.c src/tests/syscall/t_setuid.c \
src/tests/syscall/t_unlink.c
cvs rdiff -u -r1.2 -r0 src/tests/syscall/t_fsync.c \
src/tests/syscall/t_getpid.c src/tests/syscall/t_getsid.c \
src/tests/syscall/t_mincore.c src/tests/syscall/t_revoke.c \
src/tests/syscall/t_timer.c
cvs rdiff -u -r1.7 -r0 src/tests/syscall/t_getrusage.c \
src/tests/syscall/t_mprotect.c
cvs rdiff -u -r1.8 -r0 src/tests/syscall/t_mknod.c
cvs rdiff -u -r1.6 -r0 src/tests/syscall/t_nanosleep.c
cvs rdiff -u -r1.5 -r0 src/tests/syscall/t_pselect.c \
src/tests/syscall/t_setrlimit.c src/tests/syscall/t_stat.c
cvs rdiff -u -r1.3 -r0 src/tests/syscall/t_truncate.c \
src/tests/syscall/t_umask.c

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



CVS commit: src/tests/syscall

2011-07-04 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Mon Jul  4 09:29:37 UTC 2011

Modified Files:
src/tests/syscall: t_mknod.c

Log Message:
Adjust the EEXIST-check once more. (This failed incorrectly in the Qemu-runs.)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/syscall/t_mknod.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/syscall/t_mknod.c
diff -u src/tests/syscall/t_mknod.c:1.6 src/tests/syscall/t_mknod.c:1.7
--- src/tests/syscall/t_mknod.c:1.6	Mon Jul  4 04:10:34 2011
+++ src/tests/syscall/t_mknod.c	Mon Jul  4 09:29:37 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mknod.c,v 1.6 2011/07/04 04:10:34 jruoho Exp $ */
+/* $NetBSD: t_mknod.c,v 1.7 2011/07/04 09:29:37 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mknod.c,v 1.6 2011/07/04 04:10:34 jruoho Exp $);
+__RCSID($NetBSD: t_mknod.c,v 1.7 2011/07/04 09:29:37 jruoho Exp $);
 
 #include sys/stat.h
 
@@ -85,7 +85,7 @@
 	(void)unlink(path);
 }
 
-ATF_TC(mknod_exist);
+ATF_TC_WITH_CLEANUP(mknod_exist);
 ATF_TC_HEAD(mknod_exist, tc)
 {
 	atf_tc_set_md_var(tc, descr, Test EEXIST from mknod(2));
@@ -96,16 +96,28 @@
 {
 	int fd;
 
-	fd = open(_PATH_DEVNULL, O_RDONLY);
+	fd = open(/etc/passwd, O_RDONLY);
+
+	if (fd = 0) {
 
-	if (fd  0)
-		return;
-	else {
 		(void)close(fd);
+
+		errno = 0;
+		ATF_REQUIRE_ERRNO(EEXIST,
+		mknod(/etc/passwd, S_IFCHR, 0) == -1);
 	}
 
+	ATF_REQUIRE(mknod(path, S_IFCHR, 0) == 0);
+
 	errno = 0;
-	ATF_REQUIRE_ERRNO(EEXIST, mknod(_PATH_DEVNULL, S_IFCHR, 0) == -1);
+	ATF_REQUIRE_ERRNO(EEXIST, mknod(path, S_IFCHR, 0) == -1);
+
+	ATF_REQUIRE(unlink(path) == 0);
+}
+
+ATF_TC_CLEANUP(mknod_exist, tc)
+{
+	(void)unlink(path);
 }
 
 ATF_TC_WITH_CLEANUP(mknod_perm);



CVS commit: src/tests/syscall

2011-07-04 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Tue Jul  5 04:33:23 UTC 2011

Modified Files:
src/tests/syscall: t_mknod.c

Log Message:
Remove the xfail check after all (PR kern/45113 is bogus or fs-dependent).


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/syscall/t_mknod.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/syscall/t_mknod.c
diff -u src/tests/syscall/t_mknod.c:1.7 src/tests/syscall/t_mknod.c:1.8
--- src/tests/syscall/t_mknod.c:1.7	Mon Jul  4 09:29:37 2011
+++ src/tests/syscall/t_mknod.c	Tue Jul  5 04:33:23 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mknod.c,v 1.7 2011/07/04 09:29:37 jruoho Exp $ */
+/* $NetBSD: t_mknod.c,v 1.8 2011/07/05 04:33:23 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mknod.c,v 1.7 2011/07/04 09:29:37 jruoho Exp $);
+__RCSID($NetBSD: t_mknod.c,v 1.8 2011/07/05 04:33:23 jruoho Exp $);
 
 #include sys/stat.h
 
@@ -57,13 +57,6 @@
 
 	(void)memset(buf, 'x', sizeof(buf));
 
-	errno = 0;
-
-	if (mknod(path, -1, 0) != -1 || errno != EINVAL) {
-		atf_tc_expect_fail(PR kern/45113);
-		atf_tc_fail(mknod(2) did not fail properly);
-	}
-
 	/*
 	 * See the old PR kern/45111.
 	 */



CVS commit: src/tests/syscall

2011-07-03 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Sun Jul  3 14:45:07 UTC 2011

Modified Files:
src/tests/syscall: t_truncate.c

Log Message:
Do not play with master.passwd(5). Just in case the test actually succeeds...


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/syscall/t_truncate.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/syscall/t_truncate.c
diff -u src/tests/syscall/t_truncate.c:1.2 src/tests/syscall/t_truncate.c:1.3
--- src/tests/syscall/t_truncate.c:1.2	Tue Jun 21 01:45:26 2011
+++ src/tests/syscall/t_truncate.c	Sun Jul  3 14:45:07 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_truncate.c,v 1.2 2011/06/21 01:45:26 jruoho Exp $ */
+/* $NetBSD: t_truncate.c,v 1.3 2011/07/03 14:45:07 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_truncate.c,v 1.2 2011/06/21 01:45:26 jruoho Exp $);
+__RCSID($NetBSD: t_truncate.c,v 1.3 2011/07/03 14:45:07 jruoho Exp $);
 
 #include sys/stat.h
 
@@ -160,7 +160,7 @@
 	ATF_REQUIRE_ERRNO(ENOENT, truncate(/a/b/c/d/e/f/g, 999) == -1);
 
 	errno = 0;
-	ATF_REQUIRE_ERRNO(EACCES, truncate(/etc/master.passwd, 999) == -1);
+	ATF_REQUIRE_ERRNO(EACCES, truncate(/root/.profile, 999) == -1);
 }
 
 ATF_TP_ADD_TCS(tp)



CVS commit: src/tests/syscall

2011-07-03 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Sun Jul  3 15:42:07 UTC 2011

Modified Files:
src/tests/syscall: t_mknod.c

Log Message:
The PR was fixed. Remove atf_tc_skip().


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_mknod.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/syscall/t_mknod.c
diff -u src/tests/syscall/t_mknod.c:1.1 src/tests/syscall/t_mknod.c:1.2
--- src/tests/syscall/t_mknod.c:1.1	Sun Jul  3 14:34:22 2011
+++ src/tests/syscall/t_mknod.c	Sun Jul  3 15:42:07 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mknod.c,v 1.1 2011/07/03 14:34:22 jruoho Exp $ */
+/* $NetBSD: t_mknod.c,v 1.2 2011/07/03 15:42:07 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mknod.c,v 1.1 2011/07/03 14:34:22 jruoho Exp $);
+__RCSID($NetBSD: t_mknod.c,v 1.2 2011/07/03 15:42:07 jruoho Exp $);
 
 #include sys/stat.h
 
@@ -59,10 +59,8 @@
 	ATF_REQUIRE_ERRNO(EINVAL, mknod(path, -1, 0) == -1);
 
 	/*
-	 * The following case triggers an assertion with tmpfs.
+	 * See the old PR kern/45111.
 	 */
-	atf_tc_skip(the test case may cause a panic; see PR kern/45111);
-
 	errno = 0;
 	ATF_REQUIRE_ERRNO(EINVAL, mknod(path, S_IFCHR, -1) == -1);
 



CVS commit: src/tests/syscall

2011-07-03 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Sun Jul  3 19:02:00 UTC 2011

Modified Files:
src/tests/syscall: t_mknod.c

Log Message:
Fix copy-pasto.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/syscall/t_mknod.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/syscall/t_mknod.c
diff -u src/tests/syscall/t_mknod.c:1.2 src/tests/syscall/t_mknod.c:1.3
--- src/tests/syscall/t_mknod.c:1.2	Sun Jul  3 15:42:07 2011
+++ src/tests/syscall/t_mknod.c	Sun Jul  3 19:02:00 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mknod.c,v 1.2 2011/07/03 15:42:07 jruoho Exp $ */
+/* $NetBSD: t_mknod.c,v 1.3 2011/07/03 19:02:00 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mknod.c,v 1.2 2011/07/03 15:42:07 jruoho Exp $);
+__RCSID($NetBSD: t_mknod.c,v 1.3 2011/07/03 19:02:00 jruoho Exp $);
 
 #include sys/stat.h
 
@@ -121,7 +121,7 @@
 	ATF_REQUIRE(stat(path, st) == 0);
 
 	if (S_ISCHR(st.st_mode) == 0)
-		atf_tc_fail_nonfatal(invalid mode from mknod(2) (S_IFBLK));
+		atf_tc_fail_nonfatal(invalid mode from mknod(2) (S_IFCHR));
 
 	ATF_REQUIRE(unlink(path) == 0);
 



CVS commit: src/tests/syscall

2011-07-03 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Sun Jul  3 20:22:51 UTC 2011

Modified Files:
src/tests/syscall: t_mknod.c

Log Message:
Remove wrong check.

XXX: Why does this fail on tmpfs but not ffs?


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/syscall/t_mknod.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/syscall/t_mknod.c
diff -u src/tests/syscall/t_mknod.c:1.3 src/tests/syscall/t_mknod.c:1.4
--- src/tests/syscall/t_mknod.c:1.3	Sun Jul  3 19:02:00 2011
+++ src/tests/syscall/t_mknod.c	Sun Jul  3 20:22:51 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mknod.c,v 1.3 2011/07/03 19:02:00 jruoho Exp $ */
+/* $NetBSD: t_mknod.c,v 1.4 2011/07/03 20:22:51 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mknod.c,v 1.3 2011/07/03 19:02:00 jruoho Exp $);
+__RCSID($NetBSD: t_mknod.c,v 1.4 2011/07/03 20:22:51 jruoho Exp $);
 
 #include sys/stat.h
 
@@ -55,9 +55,6 @@
 
 	(void)memset(buf, 'x', sizeof(buf));
 
-	errno = 0;
-	ATF_REQUIRE_ERRNO(EINVAL, mknod(path, -1, 0) == -1);
-
 	/*
 	 * See the old PR kern/45111.
 	 */



CVS commit: src/tests/syscall

2011-07-03 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Mon Jul  4 03:23:31 UTC 2011

Modified Files:
src/tests/syscall: t_revoke.c

Log Message:
Require an unprivileged run.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_revoke.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/syscall/t_revoke.c
diff -u src/tests/syscall/t_revoke.c:1.1 src/tests/syscall/t_revoke.c:1.2
--- src/tests/syscall/t_revoke.c:1.1	Sun Jul  3 21:06:56 2011
+++ src/tests/syscall/t_revoke.c	Mon Jul  4 03:23:31 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_revoke.c,v 1.1 2011/07/03 21:06:56 jruoho Exp $ */
+/* $NetBSD: t_revoke.c,v 1.2 2011/07/04 03:23:31 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_revoke.c,v 1.1 2011/07/03 21:06:56 jruoho Exp $);
+__RCSID($NetBSD: t_revoke.c,v 1.2 2011/07/04 03:23:31 jruoho Exp $);
 
 #include sys/resource.h
 #include sys/wait.h
@@ -98,6 +98,7 @@
 ATF_TC_HEAD(revoke_err, tc)
 {
 	atf_tc_set_md_var(tc, descr, Test errors from revoke(2));
+	atf_tc_set_md_var(tc, require.user, unprivileged);
 }
 
 ATF_TC_BODY(revoke_err, tc)



CVS commit: src/tests/syscall

2011-07-03 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Mon Jul  4 03:52:11 UTC 2011

Modified Files:
src/tests/syscall: t_mknod.c

Log Message:
Put the previous check back and point to PR kern/45113. Also check whether
_PATH_DEVNULL exists before attempting to obtain EEXIST from mknod(2).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/syscall/t_mknod.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/syscall/t_mknod.c
diff -u src/tests/syscall/t_mknod.c:1.4 src/tests/syscall/t_mknod.c:1.5
--- src/tests/syscall/t_mknod.c:1.4	Sun Jul  3 20:22:51 2011
+++ src/tests/syscall/t_mknod.c	Mon Jul  4 03:52:11 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mknod.c,v 1.4 2011/07/03 20:22:51 jruoho Exp $ */
+/* $NetBSD: t_mknod.c,v 1.5 2011/07/04 03:52:11 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,13 +29,15 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mknod.c,v 1.4 2011/07/03 20:22:51 jruoho Exp $);
+__RCSID($NetBSD: t_mknod.c,v 1.5 2011/07/04 03:52:11 jruoho Exp $);
 
 #include sys/stat.h
 
 #include atf-c.h
 #include errno.h
+#include fcntl.h
 #include limits.h
+#include paths.h
 #include stdio.h
 #include string.h
 #include unistd.h
@@ -52,9 +54,17 @@
 ATF_TC_BODY(mknod_err, tc)
 {
 	char buf[PATH_MAX + 1];
+	int fd;
 
 	(void)memset(buf, 'x', sizeof(buf));
 
+	errno = 0;
+
+	if (mknod(path, -1, 0) != -1 || errno != EINVAL) {
+		atf_tc_expect_fail(PR kern/45113);
+		atf_tc_fail(mknod(2) did not fail properly);
+	}
+
 	/*
 	 * See the old PR kern/45111.
 	 */
@@ -68,10 +78,18 @@
 	ATF_REQUIRE_ERRNO(EFAULT, mknod((char *)-1, S_IFCHR, 0) == -1);
 
 	errno = 0;
-	ATF_REQUIRE_ERRNO(EEXIST, mknod(/dev/null, S_IFCHR, 0) == -1);
-
-	errno = 0;
 	ATF_REQUIRE_ERRNO(ENOENT, mknod(/a/b/c/d/e/f/g, S_IFCHR, 0) == -1);
+
+	fd = open(_PATH_DEVNULL, O_RDONLY);
+
+	if (fd = 0) {
+
+		errno = 0;
+		ATF_REQUIRE_ERRNO(EEXIST,
+		mknod(_PATH_DEVNULL, S_IFCHR, 0) == -1);
+
+		(void)close(fd);
+	}
 }
 
 ATF_TC_CLEANUP(mknod_err, tc)



CVS commit: src/tests/syscall

2011-07-03 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Mon Jul  4 04:10:34 UTC 2011

Modified Files:
src/tests/syscall: t_mknod.c

Log Message:
For granularity, split the EEXIST-check to a separate test case.
It appears that yet another bug was caught.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/syscall/t_mknod.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/syscall/t_mknod.c
diff -u src/tests/syscall/t_mknod.c:1.5 src/tests/syscall/t_mknod.c:1.6
--- src/tests/syscall/t_mknod.c:1.5	Mon Jul  4 03:52:11 2011
+++ src/tests/syscall/t_mknod.c	Mon Jul  4 04:10:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mknod.c,v 1.5 2011/07/04 03:52:11 jruoho Exp $ */
+/* $NetBSD: t_mknod.c,v 1.6 2011/07/04 04:10:34 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mknod.c,v 1.5 2011/07/04 03:52:11 jruoho Exp $);
+__RCSID($NetBSD: t_mknod.c,v 1.6 2011/07/04 04:10:34 jruoho Exp $);
 
 #include sys/stat.h
 
@@ -54,7 +54,6 @@
 ATF_TC_BODY(mknod_err, tc)
 {
 	char buf[PATH_MAX + 1];
-	int fd;
 
 	(void)memset(buf, 'x', sizeof(buf));
 
@@ -79,22 +78,34 @@
 
 	errno = 0;
 	ATF_REQUIRE_ERRNO(ENOENT, mknod(/a/b/c/d/e/f/g, S_IFCHR, 0) == -1);
+}
 
-	fd = open(_PATH_DEVNULL, O_RDONLY);
+ATF_TC_CLEANUP(mknod_err, tc)
+{
+	(void)unlink(path);
+}
 
-	if (fd = 0) {
+ATF_TC(mknod_exist);
+ATF_TC_HEAD(mknod_exist, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test EEXIST from mknod(2));
+	atf_tc_set_md_var(tc, require.user, root);
+}
 
-		errno = 0;
-		ATF_REQUIRE_ERRNO(EEXIST,
-		mknod(_PATH_DEVNULL, S_IFCHR, 0) == -1);
+ATF_TC_BODY(mknod_exist, tc)
+{
+	int fd;
 
+	fd = open(_PATH_DEVNULL, O_RDONLY);
+
+	if (fd  0)
+		return;
+	else {
 		(void)close(fd);
 	}
-}
 
-ATF_TC_CLEANUP(mknod_err, tc)
-{
-	(void)unlink(path);
+	errno = 0;
+	ATF_REQUIRE_ERRNO(EEXIST, mknod(_PATH_DEVNULL, S_IFCHR, 0) == -1);
 }
 
 ATF_TC_WITH_CLEANUP(mknod_perm);
@@ -170,6 +181,7 @@
 {
 
 	ATF_TP_ADD_TC(tp, mknod_err);
+	ATF_TP_ADD_TC(tp, mknod_exist);
 	ATF_TP_ADD_TC(tp, mknod_perm);
 	ATF_TP_ADD_TC(tp, mknod_stat);
 



CVS commit: src/tests/syscall

2011-06-20 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Tue Jun 21 01:45:26 UTC 2011

Modified Files:
src/tests/syscall: t_truncate.c

Log Message:
Require unprivileged runs when appropriate.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_truncate.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/syscall/t_truncate.c
diff -u src/tests/syscall/t_truncate.c:1.1 src/tests/syscall/t_truncate.c:1.2
--- src/tests/syscall/t_truncate.c:1.1	Mon Jun 20 18:03:41 2011
+++ src/tests/syscall/t_truncate.c	Tue Jun 21 01:45:26 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_truncate.c,v 1.1 2011/06/20 18:03:41 jruoho Exp $ */
+/* $NetBSD: t_truncate.c,v 1.2 2011/06/21 01:45:26 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_truncate.c,v 1.1 2011/06/20 18:03:41 jruoho Exp $);
+__RCSID($NetBSD: t_truncate.c,v 1.2 2011/06/21 01:45:26 jruoho Exp $);
 
 #include sys/stat.h
 
@@ -84,6 +84,7 @@
 ATF_TC_HEAD(ftruncate_err, tc)
 {
 	atf_tc_set_md_var(tc, descr, Test errors from ftruncate(2));
+	atf_tc_set_md_var(tc, require.user, unprivileged);
 }
 
 ATF_TC_BODY(ftruncate_err, tc)
@@ -143,6 +144,7 @@
 ATF_TC_HEAD(truncate_err, tc)
 {
 	atf_tc_set_md_var(tc, descr, Test errors from truncate(2));
+	atf_tc_set_md_var(tc, require.user, unprivileged);
 }
 
 ATF_TC_BODY(truncate_err, tc)



CVS commit: src/tests/syscall

2011-06-07 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Tue Jun  7 19:06:39 UTC 2011

Modified Files:
src/tests/syscall: t_stat.c

Log Message:
Temporarily comment out the 'stat_dir' test. It panics QEMU/i386 guests.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/syscall/t_stat.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/syscall/t_stat.c
diff -u src/tests/syscall/t_stat.c:1.3 src/tests/syscall/t_stat.c:1.4
--- src/tests/syscall/t_stat.c:1.3	Sun Jun  5 13:49:46 2011
+++ src/tests/syscall/t_stat.c	Tue Jun  7 19:06:39 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_stat.c,v 1.3 2011/06/05 13:49:46 jruoho Exp $ */
+/* $NetBSD: t_stat.c,v 1.4 2011/06/07 19:06:39 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_stat.c,v 1.3 2011/06/05 13:49:46 jruoho Exp $);
+__RCSID($NetBSD: t_stat.c,v 1.4 2011/06/07 19:06:39 jruoho Exp $);
 
 #include sys/stat.h
 #include sys/types.h
@@ -85,6 +85,10 @@
 
 ATF_TC_BODY(stat_dir, tc)
 {
+	/*
+	 * XXX: This panics qemu/i386 guest.
+	 */
+#if 0
 	const short depth = 3;
 	struct stat sa, sb;
 	char *argv[2];
@@ -144,6 +148,7 @@
 	}
 
 	(void)fts_close(fts);
+#endif
 }
 
 ATF_TC(stat_err);



CVS commit: src/tests/syscall

2011-06-07 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Wed Jun  8 05:28:03 UTC 2011

Modified Files:
src/tests/syscall: t_stat.c

Log Message:
Use atf_tc_skip() instead of #if 0.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/syscall/t_stat.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/syscall/t_stat.c
diff -u src/tests/syscall/t_stat.c:1.4 src/tests/syscall/t_stat.c:1.5
--- src/tests/syscall/t_stat.c:1.4	Tue Jun  7 19:06:39 2011
+++ src/tests/syscall/t_stat.c	Wed Jun  8 05:28:03 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_stat.c,v 1.4 2011/06/07 19:06:39 jruoho Exp $ */
+/* $NetBSD: t_stat.c,v 1.5 2011/06/08 05:28:03 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_stat.c,v 1.4 2011/06/07 19:06:39 jruoho Exp $);
+__RCSID($NetBSD: t_stat.c,v 1.5 2011/06/08 05:28:03 jruoho Exp $);
 
 #include sys/stat.h
 #include sys/types.h
@@ -42,6 +42,8 @@
 #include string.h
 #include unistd.h
 
+#include stdio.h
+
 static const char *path = stat;
 
 ATF_TC_WITH_CLEANUP(stat_chflags);
@@ -85,10 +87,6 @@
 
 ATF_TC_BODY(stat_dir, tc)
 {
-	/*
-	 * XXX: This panics qemu/i386 guest.
-	 */
-#if 0
 	const short depth = 3;
 	struct stat sa, sb;
 	char *argv[2];
@@ -96,6 +94,11 @@
 	FTS *fts;
 	int ops;
 
+	/*
+	 * XXX: This is verified to panic at least a qemu/i386 guest.
+	 */
+	atf_tc_skip(the test may cause a panic);
+
 	argv[1] = NULL;
 	argv[0] = __UNCONST(/);
 
@@ -148,7 +151,6 @@
 	}
 
 	(void)fts_close(fts);
-#endif
 }
 
 ATF_TC(stat_err);



CVS commit: src/tests/syscall

2011-06-05 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Sun Jun  5 13:49:46 UTC 2011

Modified Files:
src/tests/syscall: t_stat.c

Log Message:
Remove the dirent(3) check entirely.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/syscall/t_stat.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/syscall/t_stat.c
diff -u src/tests/syscall/t_stat.c:1.2 src/tests/syscall/t_stat.c:1.3
--- src/tests/syscall/t_stat.c:1.2	Sat Jun  4 15:45:55 2011
+++ src/tests/syscall/t_stat.c	Sun Jun  5 13:49:46 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_stat.c,v 1.2 2011/06/04 15:45:55 jruoho Exp $ */
+/* $NetBSD: t_stat.c,v 1.3 2011/06/05 13:49:46 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,13 +29,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_stat.c,v 1.2 2011/06/04 15:45:55 jruoho Exp $);
+__RCSID($NetBSD: t_stat.c,v 1.3 2011/06/05 13:49:46 jruoho Exp $);
 
 #include sys/stat.h
 #include sys/types.h
 
 #include atf-c.h
-#include dirent.h
 #include errno.h
 #include fcntl.h
 #include fts.h
@@ -88,11 +87,9 @@
 {
 	const short depth = 3;
 	struct stat sa, sb;
-	struct dirent *dr;
 	char *argv[2];
 	FTSENT *ftse;
 	FTS *fts;
-	DIR *dir;
 	int ops;
 
 	argv[1] = NULL;
@@ -139,22 +136,6 @@
 			if (sb.st_ino != ftse-fts_statp-st_ino)
 atf_tc_fail(stat(2) and fts(3) differ);
 
-			/*
-			 * Verify that the last stat(2) call
-			 * matches the corresponding dirent(3).
-			 */
-			dir = opendir(ftse-fts_path);
-			ATF_REQUIRE(dir != NULL);
-
-			dr = readdir(dir);
-
-			if (dr == NULL)
-break;
-
-			if (sb.st_ino != dr-d_fileno)
-atf_tc_fail(stat(2) and readdir(3) differ);
-
-			ATF_REQUIRE(closedir(dir) == 0);
 			break;
 
 		default:



CVS commit: src/tests/syscall

2011-06-04 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Sat Jun  4 15:45:56 UTC 2011

Modified Files:
src/tests/syscall: t_stat.c

Log Message:
Do not fail if readdir(3) fails, probably due fts(3).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_stat.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/syscall/t_stat.c
diff -u src/tests/syscall/t_stat.c:1.1 src/tests/syscall/t_stat.c:1.2
--- src/tests/syscall/t_stat.c:1.1	Sat Jun  4 09:29:44 2011
+++ src/tests/syscall/t_stat.c	Sat Jun  4 15:45:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_stat.c,v 1.1 2011/06/04 09:29:44 jruoho Exp $ */
+/* $NetBSD: t_stat.c,v 1.2 2011/06/04 15:45:55 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_stat.c,v 1.1 2011/06/04 09:29:44 jruoho Exp $);
+__RCSID($NetBSD: t_stat.c,v 1.2 2011/06/04 15:45:55 jruoho Exp $);
 
 #include sys/stat.h
 #include sys/types.h
@@ -147,7 +147,9 @@
 			ATF_REQUIRE(dir != NULL);
 
 			dr = readdir(dir);
-			ATF_REQUIRE(dr != NULL);
+
+			if (dr == NULL)
+break;
 
 			if (sb.st_ino != dr-d_fileno)
 atf_tc_fail(stat(2) and readdir(3) differ);



CVS commit: src/tests/syscall

2011-06-04 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Sat Jun  4 15:51:45 UTC 2011

Modified Files:
src/tests/syscall: t_getrusage.c

Log Message:
Until PR bin/44837 is fixed, use atf_tc_fail(anticipated error did not
occur) even if the bug did not trigger.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/syscall/t_getrusage.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/syscall/t_getrusage.c
diff -u src/tests/syscall/t_getrusage.c:1.6 src/tests/syscall/t_getrusage.c:1.7
--- src/tests/syscall/t_getrusage.c:1.6	Fri Apr  8 10:36:09 2011
+++ src/tests/syscall/t_getrusage.c	Sat Jun  4 15:51:45 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_getrusage.c,v 1.6 2011/04/08 10:36:09 jruoho Exp $ */
+/* $NetBSD: t_getrusage.c,v 1.7 2011/06/04 15:51:45 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_getrusage.c,v 1.6 2011/04/08 10:36:09 jruoho Exp $);
+__RCSID($NetBSD: t_getrusage.c,v 1.7 2011/06/04 15:51:45 jruoho Exp $);
 
 #include sys/resource.h
 #include sys/time.h
@@ -142,6 +142,8 @@
 		if (timercmp(ru2.ru_utime, ru1.ru_utime, ) != 0)
 			atf_tc_fail(user time went backwards);
 	}
+
+	atf_tc_fail(anticipated error did not occur);
 }
 
 ATF_TC(getrusage_utime_zero);
@@ -174,6 +176,8 @@
 		if (ru.ru_utime.tv_sec == 0  ru.ru_utime.tv_usec == 0)
 			atf_tc_fail(zero user time from getrusage(2));
 	}
+
+	atf_tc_fail(anticipated error did not occur);
 }
 
 ATF_TP_ADD_TCS(tp)



CVS commit: src/tests/syscall

2011-06-01 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Wed Jun  1 19:32:51 UTC 2011

Modified Files:
src/tests/syscall: t_pollts.c

Log Message:
pollts(2) is supposed to return -1 in particular and not a random
non-zero value in case of an error.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/syscall/t_pollts.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/syscall/t_pollts.c
diff -u src/tests/syscall/t_pollts.c:1.3 src/tests/syscall/t_pollts.c:1.4
--- src/tests/syscall/t_pollts.c:1.3	Wed Jun  1 03:39:45 2011
+++ src/tests/syscall/t_pollts.c	Wed Jun  1 19:32:50 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_pollts.c,v 1.3 2011/06/01 03:39:45 jruoho Exp $	*/
+/*	$NetBSD: t_pollts.c,v 1.4 2011/06/01 19:32:50 tron Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -131,13 +131,13 @@
 	timeout.tv_nsec = 0;
 
 	errno = 0;
-	ATF_REQUIRE_ERRNO(EFAULT, pollts((void *)-1, 1, timeout, NULL) != 0);
+	ATF_REQUIRE_ERRNO(EFAULT, pollts((void *)-1, 1, timeout, NULL) == -1);
 
 	timeout.tv_sec = -1;
 	timeout.tv_nsec = -1;
 
 	errno = 0;
-	ATF_REQUIRE_ERRNO(EINVAL, pollts(pfd, 1, timeout, NULL) != 0);
+	ATF_REQUIRE_ERRNO(EINVAL, pollts(pfd, 1, timeout, NULL) == -1);
 }
 
 ATF_TC(pollts_sigmask);



CVS commit: src/tests/syscall

2011-06-01 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Wed Jun  1 19:43:10 UTC 2011

Modified Files:
src/tests/syscall: Makefile
Added Files:
src/tests/syscall: t_poll.c

Log Message:
Add a regression test for poll(2) based on the test for pollts(2).


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/tests/syscall/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/syscall/t_poll.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/syscall/Makefile
diff -u src/tests/syscall/Makefile:1.28 src/tests/syscall/Makefile:1.29
--- src/tests/syscall/Makefile:1.28	Sat May 28 16:12:56 2011
+++ src/tests/syscall/Makefile	Wed Jun  1 19:43:10 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.28 2011/05/28 16:12:56 tron Exp $
+# $NetBSD: Makefile,v 1.29 2011/06/01 19:43:10 tron Exp $
 
 .include bsd.own.mk
 
@@ -6,7 +6,7 @@
 
 TESTS_C+=	t_access t_cmsg t_dup t_fsync
 TESTS_C+=	t_getgroups t_getpid t_getrusage t_getsid t_gettimeofday
-TESTS_C+=	t_itimer t_kill t_mmap t_mprotect t_msync t_nanosleep
+TESTS_C+=	t_itimer t_kill t_mmap t_mprotect t_msync t_nanosleep t_poll
 TESTS_C+=	t_pollts t_pselect t_setrlimit t_setuid t_timer t_umask
 
 LDADD.t_getpid+=	-lpthread

Added files:

Index: src/tests/syscall/t_poll.c
diff -u /dev/null src/tests/syscall/t_poll.c:1.1
--- /dev/null	Wed Jun  1 19:43:10 2011
+++ src/tests/syscall/t_poll.c	Wed Jun  1 19:43:10 2011
@@ -0,0 +1,135 @@
+/*	$NetBSD: t_poll.c,v 1.1 2011/06/01 19:43:10 tron Exp $	*/
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matthias Scheler.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include errno.h
+#include fcntl.h
+#include paths.h
+#include poll.h
+#include unistd.h
+
+#include atf-c.h
+
+ATF_TC(poll_basic);
+ATF_TC_HEAD(poll_basic, tc)
+{
+	atf_tc_set_md_var(tc, timeout, 10);
+	atf_tc_set_md_var(tc, descr,
+	Basis functionality test for poll(2));
+}
+
+ATF_TC_BODY(poll_basic, tc)
+{
+	int fds[2];
+	struct pollfd pfds[2];
+	int ret;
+
+	ATF_REQUIRE_EQ(pipe(fds), 0);
+
+	pfds[0].fd = fds[0];
+	pfds[0].events = POLLIN;
+	pfds[1].fd = fds[1];
+	pfds[1].events = POLLOUT;
+
+	/*
+	 * Check that we get a timeout waiting for data on the read end
+	 * of our pipe.
+	 */
+	pfds[0].revents = -1;
+	pfds[1].revents = -1;
+	ATF_REQUIRE_EQ_MSG(ret = poll(pfds[0], 1, 1), 0,
+	got: %d, ret);
+	ATF_REQUIRE_EQ_MSG(pfds[0].revents, 0, got: %d, pfds[0].revents);
+	ATF_REQUIRE_EQ_MSG(pfds[1].revents, -1, got: %d, pfds[1].revents);
+
+	/* Check that the write end of the pipe as reported as ready. */
+	pfds[0].revents = -1;
+	pfds[1].revents = -1;
+	ATF_REQUIRE_EQ_MSG(ret = poll(pfds[1], 1, 1), 1,
+	got: %d, ret);
+	ATF_REQUIRE_EQ_MSG(pfds[0].revents, -1, got: %d, pfds[0].revents);
+	ATF_REQUIRE_EQ_MSG(pfds[1].revents, POLLOUT, got: %d,\
+	pfds[1].revents);
+
+	/* Check that only the write end of the pipe as reported as ready. */
+	pfds[0].revents = -1;
+	pfds[1].revents = -1;
+	ATF_REQUIRE_EQ_MSG(ret = poll(pfds, 2, 1), 1,
+	got: %d, ret);
+	ATF_REQUIRE_EQ_MSG(pfds[0].revents, 0, got: %d, pfds[0].revents);
+	ATF_REQUIRE_EQ_MSG(pfds[1].revents, POLLOUT, got: %d,
+	pfds[1].revents);
+
+	/* Write data to our pipe. */
+	ATF_REQUIRE_EQ(write(fds[1], , 1), 1);
+
+	/* Check that both ends of our pipe are reported as ready. */
+	pfds[0].revents = -1;
+	pfds[1].revents = -1;
+	ATF_REQUIRE_EQ_MSG(ret = poll(pfds, 2, 1), 2,
+	got: %d, ret);
+	ATF_REQUIRE_EQ_MSG(pfds[0].revents, POLLIN, got: %d,
+	pfds[0].revents);
+	ATF_REQUIRE_EQ_MSG(pfds[1].revents, POLLOUT, 

CVS commit: src/tests/syscall

2011-05-31 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Wed Jun  1 03:39:45 UTC 2011

Modified Files:
src/tests/syscall: t_pollts.c

Log Message:
Check also basic EFAULT and EINVAL from bogus calls to pollts(2).


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/syscall/t_pollts.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/syscall/t_pollts.c
diff -u src/tests/syscall/t_pollts.c:1.2 src/tests/syscall/t_pollts.c:1.3
--- src/tests/syscall/t_pollts.c:1.2	Sun May 29 12:57:14 2011
+++ src/tests/syscall/t_pollts.c	Wed Jun  1 03:39:45 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_pollts.c,v 1.2 2011/05/29 12:57:14 tron Exp $	*/
+/*	$NetBSD: t_pollts.c,v 1.3 2011/06/01 03:39:45 jruoho Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -31,6 +31,7 @@
 
 #include sys/time.h
 
+#include errno.h
 #include fcntl.h
 #include paths.h
 #include poll.h
@@ -39,23 +40,15 @@
 
 #include atf-c.h
 
-ATF_TC(pollts);
-ATF_TC_HEAD(pollts, tc)
+ATF_TC(pollts_basic);
+ATF_TC_HEAD(pollts_basic, tc)
 {
 	atf_tc_set_md_var(tc, timeout, 10);
 	atf_tc_set_md_var(tc, descr,
 	Basis functionality test for pollts(2));
 }
 
-ATF_TC(pollts_sigmask);
-ATF_TC_HEAD(pollts_sigmask, tc)
-{
-	atf_tc_set_md_var(tc, timeout, 10);
-	atf_tc_set_md_var(tc, descr,
-	Check that pollts_sigmask(2) restores the signal mask);
-}
-
-ATF_TC_BODY(pollts, tc)
+ATF_TC_BODY(pollts_basic, tc)
 {
 	int fds[2];
 	struct pollfd pfds[2];
@@ -119,6 +112,42 @@
 	ATF_REQUIRE_EQ(close(fds[1]), 0);
 }
 
+ATF_TC(pollts_err);
+ATF_TC_HEAD(pollts_err, tc)
+{
+	atf_tc_set_md_var(tc, descr, Check errors from pollts(2));
+}
+
+ATF_TC_BODY(pollts_err, tc)
+{
+	struct timespec timeout;
+	struct pollfd pfd;
+	int fd = 0;
+
+	pfd.fd = fd;
+	pfd.events = POLLIN;
+
+	timeout.tv_sec = 1;
+	timeout.tv_nsec = 0;
+
+	errno = 0;
+	ATF_REQUIRE_ERRNO(EFAULT, pollts((void *)-1, 1, timeout, NULL) != 0);
+
+	timeout.tv_sec = -1;
+	timeout.tv_nsec = -1;
+
+	errno = 0;
+	ATF_REQUIRE_ERRNO(EINVAL, pollts(pfd, 1, timeout, NULL) != 0);
+}
+
+ATF_TC(pollts_sigmask);
+ATF_TC_HEAD(pollts_sigmask, tc)
+{
+	atf_tc_set_md_var(tc, timeout, 10);
+	atf_tc_set_md_var(tc, descr,
+	Check that pollts(2) restores the signal mask);
+}
+
 ATF_TC_BODY(pollts_sigmask, tc)
 {
 	int fd;
@@ -143,7 +172,7 @@
 	ATF_REQUIRE_EQ(sigfillset(mask), 0);
 	ATF_REQUIRE_EQ(sigprocmask(SIG_UNBLOCK, mask, NULL), 0);
 
-	/* 
+	/*
 	 * Check that pollts(2) immediately returns. We block *all*
 	 * signals during pollts(2).
 	 */
@@ -160,7 +189,9 @@
 
 ATF_TP_ADD_TCS(tp)
 {
-	ATF_TP_ADD_TC(tp, pollts);
+
+	ATF_TP_ADD_TC(tp, pollts_basic);
+	ATF_TP_ADD_TC(tp, pollts_err);
 	ATF_TP_ADD_TC(tp, pollts_sigmask);
 
 	return atf_no_error();



CVS commit: src/tests/syscall

2011-05-29 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Sun May 29 12:57:14 UTC 2011

Modified Files:
src/tests/syscall: t_pollts.c

Log Message:
Don't use assert(3) for expressions with side effects on request by
by Christos Zoulas. Use ATF_REQUIRE() and ATF_REQUIRE_EQ() instead.

Also use ATF_REQUIRE_EQ_MSG() instead of ATF_REQUIRE_MSG() to avoid
crashes if one of the required conditions isn't met.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_pollts.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/syscall/t_pollts.c
diff -u src/tests/syscall/t_pollts.c:1.1 src/tests/syscall/t_pollts.c:1.2
--- src/tests/syscall/t_pollts.c:1.1	Sat May 28 16:12:56 2011
+++ src/tests/syscall/t_pollts.c	Sun May 29 12:57:14 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_pollts.c,v 1.1 2011/05/28 16:12:56 tron Exp $	*/
+/*	$NetBSD: t_pollts.c,v 1.2 2011/05/29 12:57:14 tron Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -31,7 +31,6 @@
 
 #include sys/time.h
 
-#include assert.h
 #include fcntl.h
 #include paths.h
 #include poll.h
@@ -63,7 +62,7 @@
 	struct timespec timeout;
 	int ret;
 
-	assert(pipe(fds) == 0);
+	ATF_REQUIRE_EQ(pipe(fds), 0);
 
 	pfds[0].fd = fds[0];
 	pfds[0].events = POLLIN;
@@ -104,7 +103,7 @@
 	pfds[1].revents);
 
 	/* Write data to our pipe. */
-	assert(write(fds[1], , 1) == 1);
+	ATF_REQUIRE_EQ(write(fds[1], , 1), 1);
 
 	/* Check that both ends of our pipe are reported as ready. */
 	pfds[0].revents = -1;
@@ -116,8 +115,8 @@
 	ATF_REQUIRE_EQ_MSG(pfds[1].revents, POLLOUT, got: %d,
 	pfds[1].revents);
 
-	assert(close(fds[0]) == 0);
-	assert(close(fds[1]) == 0);
+	ATF_REQUIRE_EQ(close(fds[0]), 0);
+	ATF_REQUIRE_EQ(close(fds[1]), 0);
 }
 
 ATF_TC_BODY(pollts_sigmask, tc)
@@ -131,7 +130,7 @@
 	/* Cf kern/44986 */
 
 	fd = open(_PATH_DEVNULL, O_RDONLY);
-	assert(fd = 0);
+	ATF_REQUIRE(fd = 0);
 
 	pfd.fd = fd;
 	pfd.events = POLLIN;
@@ -141,8 +140,8 @@
 	timeout.tv_nsec = 0;
 
 	/* Unblock all signals. */
-	assert(sigfillset(mask) == 0);
-	assert(sigprocmask(SIG_UNBLOCK, mask, NULL) == 0);
+	ATF_REQUIRE_EQ(sigfillset(mask), 0);
+	ATF_REQUIRE_EQ(sigprocmask(SIG_UNBLOCK, mask, NULL), 0);
 
 	/* 
 	 * Check that pollts(2) immediately returns. We block *all*
@@ -152,11 +151,11 @@
 	got: %d, ret);
 
 	/* Check that signals are now longer blocked. */
-	assert(sigprocmask(SIG_SETMASK, NULL, mask) == 0);
-	ATF_REQUIRE_MSG(sigismember(mask, SIGUSR1) == 0,
+	ATF_REQUIRE_EQ(sigprocmask(SIG_SETMASK, NULL, mask), 0);
+	ATF_REQUIRE_EQ_MSG(sigismember(mask, SIGUSR1), 0,
 	signal mask was changed.);
 
-	assert(close(fd) == 0);
+	ATF_REQUIRE_EQ(close(fd), 0);
 }
 
 ATF_TP_ADD_TCS(tp)



CVS commit: src/tests/syscall

2011-05-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 29 22:12:32 UTC 2011

Modified Files:
src/tests/syscall: t_pselect.c

Log Message:
Modify the test to be more robust. Still getting fork interrupted somehow,
but the tests work (after my kernel changes).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/syscall/t_pselect.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/syscall/t_pselect.c
diff -u src/tests/syscall/t_pselect.c:1.3 src/tests/syscall/t_pselect.c:1.4
--- src/tests/syscall/t_pselect.c:1.3	Sat May 28 11:34:49 2011
+++ src/tests/syscall/t_pselect.c	Sun May 29 18:12:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_pselect.c,v 1.3 2011/05/28 15:34:49 christos Exp $ */
+/*	$NetBSD: t_pselect.c,v 1.4 2011/05/29 22:12:32 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,6 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include assert.h
 #include sys/types.h
 #include sys/select.h
 #include sys/wait.h
@@ -51,11 +52,42 @@
 	keep_going = 0;
 }
 
-static void __attribute__((__noreturn__))
+static void
+sigchld(int signum)
+{
+}
+
+static char
+xtoa(uint8_t n)
+{
+	static const char xarray[] = 0123456789abcdef;
+	assert(n  sizeof(xarray));
+	return xarray[n];
+}
+
+static const char *
+prmask(const sigset_t *m, char *buf, size_t len)
+{
+	size_t j = 2;
+	assert(len = 3 + sizeof(*m));
+	buf[0] = '0';
+	buf[1] = 'x';
+#define N(p, a)	(((p)  ((a) * 4))  0xf)
+	for (size_t i = __arraycount(m-__bits); i  0; i--) {
+		uint32_t p = m-__bits[i - 1];
+		for (size_t k = sizeof(p); k  0; k--) 
+			buf[j++] = xtoa(N(p, k - 1)); 
+	}
+	buf[j] = '\0';
+	return buf;
+}
+
+static void 
 child(const struct timespec *ts)
 {
 	struct sigaction sa;
-	sigset_t set;
+	sigset_t set, oset, nset;
+	char obuf[sizeof(oset) + 3], nbuf[sizeof(nset) + 3];
 	int fd;
 
 	memset(sa, 0, sizeof(sa));
@@ -68,7 +100,10 @@
 
 	sigfillset(set);
 	if (sigprocmask(SIG_BLOCK, set, NULL) == -1)
-		err(1, procmask);
+		err(1, sigprocmask);
+
+	if (sigprocmask(SIG_BLOCK, NULL, oset) == -1)
+		err(1, sigprocmask);
 
 	sigemptyset(set);
 
@@ -79,10 +114,19 @@
 		if (pselect(1, rset, NULL, NULL, ts, set) == -1) {
 			if(errno == EINTR) {
 if (!keep_going)
-	exit(0);
+	break;
 			}
 		}
-   }
+		if (ts)
+			break;
+	}
+	if (sigprocmask(SIG_BLOCK, NULL, nset) == -1)
+		err(1, sigprocmask);
+	if (memcmp(oset, nset, sizeof(oset)) != 0)
+		atf_tc_fail(pselect() masks don't match 
+		after timeout %s != %s,
+		prmask(nset, nbuf, sizeof(nbuf)),
+		prmask(oset, obuf, sizeof(obuf)));
 }
 
 ATF_TC(pselect_signal_mask_with_signal);
@@ -99,13 +143,15 @@
 	pid_t pid;
 	int status;
 
+	signal(SIGCHLD, sigchld);
+
 	switch (pid = fork()) {
 	case 0:
 		child(NULL);
 	case -1:
 		err(1, fork);
 	default:
-		usleep(500);
+		usleep(1);
 		if (kill(pid, SIGTERM) == -1)
 			err(1, kill);
 		usleep(500);
@@ -130,28 +176,23 @@
 	atf_tc_set_md_var(tc, descr, Checks pselect's temporary mask 
 	setting when a timeout occurs);
 }
+
 ATF_TC_BODY(pselect_signal_mask_with_timeout, tc)
 {
 	pid_t pid;
 	int status;
-	sigset_t oset, nset;
 	static const struct timespec zero = { 0, 0 };
 
+	signal(SIGCHLD, sigchld);
+
 	switch (pid = fork()) {
 	case 0:
-		if (sigprocmask(SIG_BLOCK, NULL, oset) == -1)
-			err(1, sigprocmask);
 		child(zero);
-		if (sigprocmask(SIG_BLOCK, NULL, nset) == -1)
-			err(1, sigprocmask);
-		if (memcmp(oset, nset, sizeof(oset)) != 0)
-			atf_tc_fail(pselect() masks don't match 
-			after timeout);
 		break;
 	case -1:
 		err(1, fork);
 	default:
-		usleep(500);
+		usleep(5000);
 		switch (waitpid(pid, status, WNOHANG)) {
 		case -1:
 			err(1, wait);



CVS commit: src/tests/syscall

2011-05-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May 28 15:34:49 UTC 2011

Modified Files:
src/tests/syscall: t_pselect.c

Log Message:
add a timeout test


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/syscall/t_pselect.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/syscall/t_pselect.c
diff -u src/tests/syscall/t_pselect.c:1.2 src/tests/syscall/t_pselect.c:1.3
--- src/tests/syscall/t_pselect.c:1.2	Tue May 17 23:15:12 2011
+++ src/tests/syscall/t_pselect.c	Sat May 28 11:34:49 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_pselect.c,v 1.2 2011/05/18 03:15:12 christos Exp $ */
+/*	$NetBSD: t_pselect.c,v 1.3 2011/05/28 15:34:49 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
 }
 
 static void __attribute__((__noreturn__))
-child(void)
+child(const struct timespec *ts)
 {
 	struct sigaction sa;
 	sigset_t set;
@@ -76,7 +76,7 @@
 		fd_set rset;
 		FD_ZERO(rset);
 		FD_SET(fd, rset);
-		if (pselect(1, rset, NULL, NULL, NULL, set) == -1) {
+		if (pselect(1, rset, NULL, NULL, ts, set) == -1) {
 			if(errno == EINTR) {
 if (!keep_going)
 	exit(0);
@@ -85,23 +85,23 @@
}
 }
 
-ATF_TC(pselect_signal_mask);
-ATF_TC_HEAD(pselect_signal_mask, tc)
+ATF_TC(pselect_signal_mask_with_signal);
+ATF_TC_HEAD(pselect_signal_mask_with_signal, tc)
 {
 
 	/* Cf. PR lib/43625. */
-	atf_tc_set_md_var(tc, descr,
-	Checks pselect's temporary mask setting);
+	atf_tc_set_md_var(tc, descr, Checks pselect's temporary mask 
+	setting when a signal is received);
 }
 
-ATF_TC_BODY(pselect_signal_mask, tc)
+ATF_TC_BODY(pselect_signal_mask_with_signal, tc)
 {
 	pid_t pid;
 	int status;
 
 	switch (pid = fork()) {
 	case 0:
-		child();
+		child(NULL);
 	case -1:
 		err(1, fork);
 	default:
@@ -123,11 +123,54 @@
 	}
 }
 
+ATF_TC(pselect_signal_mask_with_timeout);
+ATF_TC_HEAD(pselect_signal_mask_with_timeout, tc)
+{
+
+	atf_tc_set_md_var(tc, descr, Checks pselect's temporary mask 
+	setting when a timeout occurs);
+}
+ATF_TC_BODY(pselect_signal_mask_with_timeout, tc)
+{
+	pid_t pid;
+	int status;
+	sigset_t oset, nset;
+	static const struct timespec zero = { 0, 0 };
+
+	switch (pid = fork()) {
+	case 0:
+		if (sigprocmask(SIG_BLOCK, NULL, oset) == -1)
+			err(1, sigprocmask);
+		child(zero);
+		if (sigprocmask(SIG_BLOCK, NULL, nset) == -1)
+			err(1, sigprocmask);
+		if (memcmp(oset, nset, sizeof(oset)) != 0)
+			atf_tc_fail(pselect() masks don't match 
+			after timeout);
+		break;
+	case -1:
+		err(1, fork);
+	default:
+		usleep(500);
+		switch (waitpid(pid, status, WNOHANG)) {
+		case -1:
+			err(1, wait);
+		case 0:
+			if (kill(pid, SIGKILL) == -1)
+err(1, kill);
+			atf_tc_fail(pselect() did not receive signal);
+			break;
+		default:
+			break;
+		}
+	}
+}
 
 ATF_TP_ADD_TCS(tp)
 {
 
-	ATF_TP_ADD_TC(tp, pselect_signal_mask);
+	ATF_TP_ADD_TC(tp, pselect_signal_mask_with_signal);
+	ATF_TP_ADD_TC(tp, pselect_signal_mask_with_timeout);
 
 	return atf_no_error();
 }



CVS commit: src/tests/syscall

2011-05-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 18 02:57:49 UTC 2011

Modified Files:
src/tests/syscall: Makefile
Added Files:
src/tests/syscall: t_pselect.c

Log Message:
Add a test for signal delivery during pselect, with temporary mask change.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/tests/syscall/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/syscall/t_pselect.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/syscall/Makefile
diff -u src/tests/syscall/Makefile:1.26 src/tests/syscall/Makefile:1.27
--- src/tests/syscall/Makefile:1.26	Mon May  2 13:26:23 2011
+++ src/tests/syscall/Makefile	Tue May 17 22:57:48 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.26 2011/05/02 17:26:23 jruoho Exp $
+# $NetBSD: Makefile,v 1.27 2011/05/18 02:57:48 christos Exp $
 
 .include bsd.own.mk
 
@@ -7,7 +7,7 @@
 TESTS_C+=	t_access t_cmsg t_dup t_fsync
 TESTS_C+=	t_getgroups t_getpid t_getrusage t_getsid t_gettimeofday
 TESTS_C+=	t_itimer t_kill t_mmap t_mprotect t_msync t_nanosleep
-TESTS_C+=	t_setrlimit t_setuid t_timer t_umask
+TESTS_C+=	t_pselect t_setrlimit t_setuid t_timer t_umask
 
 LDADD.t_getpid+=	-lpthread
 LDADD.t_timer+=		-lpthread

Added files:

Index: src/tests/syscall/t_pselect.c
diff -u /dev/null src/tests/syscall/t_pselect.c:1.1
--- /dev/null	Tue May 17 22:57:49 2011
+++ src/tests/syscall/t_pselect.c	Tue May 17 22:57:48 2011
@@ -0,0 +1,125 @@
+/*	$NetBSD: t_pselect.c,v 1.1 2011/05/18 02:57:48 christos Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundatiom
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include sys/types.h
+#include sys/select.h
+#include sys/wait.h
+#include err.h
+#include stdio.h
+#include string.h
+#include signal.h
+#include stdlib.h
+#include unistd.h
+#include errno.h
+#include fcntl.h
+
+#include atf-c.h
+
+static sig_atomic_t keep_going = 1;
+
+static void
+sig_handler(int signum)
+{
+	keep_going = 0;
+}
+
+static void __attribute__((__noreturn__))
+child(void)
+{
+	struct sigaction sa;
+	sigset_t set;
+	int fd;
+
+	memset(sa, 0, sizeof(sa));
+	sa.sa_handler = sig_handler;
+	if ((fd = open(/dev/null, O_RDONLY)) == -1)
+		err(1, open);
+
+	if (sigaction(SIGTERM, sa, NULL) == -1)
+		err(1, sigaction);
+
+	sigfillset(set);
+	if (sigprocmask(SIG_BLOCK, set, NULL) == -1)
+		err(1, procmask);
+
+	sigemptyset(set);
+
+	for (;;) {
+		fd_set rset;
+		FD_ZERO(rset);
+		FD_SET(fd, rset);
+		if (pselect(1, rset, NULL, NULL, NULL, set) == -1) {
+			if(errno == EINTR) {
+if (!keep_going)
+	exit(0);
+			}
+		}
+   }
+}
+
+ATF_TC(pselect_signal_mask);
+ATF_TC_HEAD(pselect_signal_mask, tc)
+{
+
+	/* Cf. PR lib/43625. */
+	atf_tc_set_md_var(tc, descr,
+	Checks pselect's temporary mask setting);
+	atf_tc_set_md_var(tc, timeout, 2);
+}
+
+ATF_TC_BODY(pselect_signal_mask, tc)
+{
+	pid_t pid;
+	int status;
+
+	switch (pid = fork()) {
+	case 0:
+		child();
+	case -1:
+		err(1, fork);
+	default:
+		usleep(500);
+		if (kill(pid, SIGTERM) == -1)
+			err(1, kill);
+		if (waitpid(pid, status, 0) == -1)
+			err(1, wait);
+		break;
+	}
+}
+
+
+ATF_TP_ADD_TCS(tp)
+{
+
+	ATF_TP_ADD_TC(tp, pselect_signal_mask);
+
+	return atf_no_error();
+}



CVS commit: src/tests/syscall

2011-05-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 18 03:15:12 UTC 2011

Modified Files:
src/tests/syscall: t_pselect.c

Log Message:
Don't depend on the atf timeout stuff, do it ourselves.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_pselect.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/syscall/t_pselect.c
diff -u src/tests/syscall/t_pselect.c:1.1 src/tests/syscall/t_pselect.c:1.2
--- src/tests/syscall/t_pselect.c:1.1	Tue May 17 22:57:48 2011
+++ src/tests/syscall/t_pselect.c	Tue May 17 23:15:12 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_pselect.c,v 1.1 2011/05/18 02:57:48 christos Exp $ */
+/*	$NetBSD: t_pselect.c,v 1.2 2011/05/18 03:15:12 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -92,7 +92,6 @@
 	/* Cf. PR lib/43625. */
 	atf_tc_set_md_var(tc, descr,
 	Checks pselect's temporary mask setting);
-	atf_tc_set_md_var(tc, timeout, 2);
 }
 
 ATF_TC_BODY(pselect_signal_mask, tc)
@@ -109,9 +108,18 @@
 		usleep(500);
 		if (kill(pid, SIGTERM) == -1)
 			err(1, kill);
-		if (waitpid(pid, status, 0) == -1)
+		usleep(500);
+		switch (waitpid(pid, status, WNOHANG)) {
+		case -1:
 			err(1, wait);
-		break;
+		case 0:
+			if (kill(pid, SIGKILL) == -1)
+err(1, kill);
+			atf_tc_fail(pselect() did not receive signal);
+			break;
+		default:
+			break;
+		}
 	}
 }
 



CVS commit: src/tests/syscall

2011-05-06 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Fri May  6 21:51:19 UTC 2011

Modified Files:
src/tests/syscall: t_mprotect.c

Log Message:
write-only mapping is not portable, change it to read/write. Unbreaks
mprotect_write testcase on alpha.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/syscall/t_mprotect.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/syscall/t_mprotect.c
diff -u src/tests/syscall/t_mprotect.c:1.4 src/tests/syscall/t_mprotect.c:1.5
--- src/tests/syscall/t_mprotect.c:1.4	Mon Apr 25 22:29:35 2011
+++ src/tests/syscall/t_mprotect.c	Fri May  6 21:51:19 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mprotect.c,v 1.4 2011/04/25 22:29:35 njoly Exp $ */
+/* $NetBSD: t_mprotect.c,v 1.5 2011/05/06 21:51:19 njoly Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mprotect.c,v 1.4 2011/04/25 22:29:35 njoly Exp $);
+__RCSID($NetBSD: t_mprotect.c,v 1.5 2011/05/06 21:51:19 njoly Exp $);
 
 #include sys/param.h
 #include sys/mman.h
@@ -236,11 +236,11 @@
 	int sta;
 
 	/*
-	 * Map a page write-only, change the protection
+	 * Map a page read/write, change the protection
 	 * to read-only with mprotect(2), and try to write
 	 * to the page. This should generate a SIGSEGV.
 	 */
-	map = mmap(NULL, page, PROT_WRITE, MAP_ANON, -1, 0);
+	map = mmap(NULL, page, PROT_WRITE|PROT_READ, MAP_ANON, -1, 0);
 
 	if (map == MAP_FAILED)
 		return;



CVS commit: src/tests/syscall

2011-05-06 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Fri May  6 22:24:41 UTC 2011

Modified Files:
src/tests/syscall: t_mprotect.c

Log Message:
Do not return for early failures; otherwise the testcase will be
reported as passed, even if not really run.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/syscall/t_mprotect.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/syscall/t_mprotect.c
diff -u src/tests/syscall/t_mprotect.c:1.5 src/tests/syscall/t_mprotect.c:1.6
--- src/tests/syscall/t_mprotect.c:1.5	Fri May  6 21:51:19 2011
+++ src/tests/syscall/t_mprotect.c	Fri May  6 22:24:41 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mprotect.c,v 1.5 2011/05/06 21:51:19 njoly Exp $ */
+/* $NetBSD: t_mprotect.c,v 1.6 2011/05/06 22:24:41 njoly Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mprotect.c,v 1.5 2011/05/06 21:51:19 njoly Exp $);
+__RCSID($NetBSD: t_mprotect.c,v 1.6 2011/05/06 22:24:41 njoly Exp $);
 
 #include sys/param.h
 #include sys/mman.h
@@ -116,9 +116,7 @@
 	int fd;
 
 	fd = open(path, O_RDONLY | O_CREAT);
-
-	if (fd  0)
-		return;
+	ATF_REQUIRE(fd = 0);
 
 	/*
 	 * The call should fail with EACCES if we try to mark
@@ -241,9 +239,7 @@
 	 * to the page. This should generate a SIGSEGV.
 	 */
 	map = mmap(NULL, page, PROT_WRITE|PROT_READ, MAP_ANON, -1, 0);
-
-	if (map == MAP_FAILED)
-		return;
+	ATF_REQUIRE(map != MAP_FAILED);
 
 	ATF_REQUIRE(strlcpy(map, XXX, 3) == 3);
 	ATF_REQUIRE(mprotect(map, page, PROT_READ) == 0);



CVS commit: src/tests/syscall

2011-05-02 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Mon May  2 07:02:09 UTC 2011

Modified Files:
src/tests/syscall: t_nanosleep.c

Log Message:
Verify that nanosleep(2) can suspend for one nanosecond (or longer).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/syscall/t_nanosleep.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/syscall/t_nanosleep.c
diff -u src/tests/syscall/t_nanosleep.c:1.4 src/tests/syscall/t_nanosleep.c:1.5
--- src/tests/syscall/t_nanosleep.c:1.4	Sun May  1 09:44:26 2011
+++ src/tests/syscall/t_nanosleep.c	Mon May  2 07:02:09 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_nanosleep.c,v 1.4 2011/05/01 09:44:26 jruoho Exp $ */
+/* $NetBSD: t_nanosleep.c,v 1.5 2011/05/02 07:02:09 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_nanosleep.c,v 1.4 2011/05/01 09:44:26 jruoho Exp $);
+__RCSID($NetBSD: t_nanosleep.c,v 1.5 2011/05/02 07:02:09 jruoho Exp $);
 
 #include sys/time.h
 #include sys/wait.h
@@ -58,14 +58,14 @@
 
 ATF_TC_BODY(nanosleep_basic, tc)
 {
-	static const size_t maxiter = 100;
+	static const size_t maxiter = 10;
 	struct timespec ts1, ts2, tsn;
 	size_t i;
 
-	for (i = 0; i  maxiter; i++) {
+	for (i = 1; i  maxiter; i++) {
 
 		tsn.tv_sec = 0;
-		tsn.tv_nsec = 1;
+		tsn.tv_nsec = i;
 
 		(void)memset(ts1, 0, sizeof(struct timespec));
 		(void)memset(ts2, 0, sizeof(struct timespec));
@@ -74,8 +74,22 @@
 		ATF_REQUIRE(nanosleep(tsn, NULL) == 0);
 		ATF_REQUIRE(clock_gettime(CLOCK_MONOTONIC, ts2) == 0);
 
-		if (timespeccmp(ts2, ts1, ) != 0)
-			atf_tc_fail(inaccuracies in sleep time);
+		/*
+		 * Verify that we slept at least one nanosecond.
+		 */
+		if (timespeccmp(ts2, ts1, =) != 0) {
+
+			(void)fprintf(stderr,
+			sleep time:: sec %lu, nsec %lu\n\t\t
+			ts1: sec %lu, nsec %lu\n\t\t
+			ts2: sec %lu, nsec %lu\n,
+			tsn.tv_sec, tsn.tv_nsec,
+			ts1.tv_sec, ts1.tv_nsec,
+			ts2.tv_sec, ts2.tv_nsec);
+
+			atf_tc_fail_nonfatal(inaccuracies in sleep time 
+			(resolution = %lu nsec), tsn.tv_nsec);
+		}
 	}
 }
 



CVS commit: src/tests/syscall

2011-05-02 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Mon May  2 11:14:29 UTC 2011

Modified Files:
src/tests/syscall: t_nanosleep.c

Log Message:
Don't print a time_t with %lu


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/syscall/t_nanosleep.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/syscall/t_nanosleep.c
diff -u src/tests/syscall/t_nanosleep.c:1.5 src/tests/syscall/t_nanosleep.c:1.6
--- src/tests/syscall/t_nanosleep.c:1.5	Mon May  2 07:02:09 2011
+++ src/tests/syscall/t_nanosleep.c	Mon May  2 11:14:29 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_nanosleep.c,v 1.5 2011/05/02 07:02:09 jruoho Exp $ */
+/* $NetBSD: t_nanosleep.c,v 1.6 2011/05/02 11:14:29 gson Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_nanosleep.c,v 1.5 2011/05/02 07:02:09 jruoho Exp $);
+__RCSID($NetBSD: t_nanosleep.c,v 1.6 2011/05/02 11:14:29 gson Exp $);
 
 #include sys/time.h
 #include sys/wait.h
@@ -80,12 +80,12 @@
 		if (timespeccmp(ts2, ts1, =) != 0) {
 
 			(void)fprintf(stderr,
-			sleep time:: sec %lu, nsec %lu\n\t\t
-			ts1: sec %lu, nsec %lu\n\t\t
-			ts2: sec %lu, nsec %lu\n,
-			tsn.tv_sec, tsn.tv_nsec,
-			ts1.tv_sec, ts1.tv_nsec,
-			ts2.tv_sec, ts2.tv_nsec);
+			sleep time:: sec %llu, nsec %lu\n\t\t
+			ts1: sec %llu, nsec %lu\n\t\t
+			ts2: sec %llu, nsec %lu\n,
+			(unsigned long long)tsn.tv_sec, tsn.tv_nsec,
+			(unsigned long long)ts1.tv_sec, ts1.tv_nsec,
+			(unsigned long long)ts2.tv_sec, ts2.tv_nsec);
 
 			atf_tc_fail_nonfatal(inaccuracies in sleep time 
 			(resolution = %lu nsec), tsn.tv_nsec);



CVS commit: src/tests/syscall

2011-05-01 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Sun May  1 09:15:14 UTC 2011

Modified Files:
src/tests/syscall: t_nanosleep.c

Log Message:
Simplify the previous. (Apparently the sleep time is not that accurate.)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_nanosleep.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/syscall/t_nanosleep.c
diff -u src/tests/syscall/t_nanosleep.c:1.1 src/tests/syscall/t_nanosleep.c:1.2
--- src/tests/syscall/t_nanosleep.c:1.1	Sun May  1 09:09:35 2011
+++ src/tests/syscall/t_nanosleep.c	Sun May  1 09:15:14 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_nanosleep.c,v 1.1 2011/05/01 09:09:35 jruoho Exp $ */
+/* $NetBSD: t_nanosleep.c,v 1.2 2011/05/01 09:15:14 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_nanosleep.c,v 1.1 2011/05/01 09:09:35 jruoho Exp $);
+__RCSID($NetBSD: t_nanosleep.c,v 1.2 2011/05/01 09:15:14 jruoho Exp $);
 
 #include sys/time.h
 #include sys/wait.h
@@ -58,7 +58,7 @@
 
 ATF_TC_BODY(nanosleep_basic, tc)
 {
-	static const size_t maxiter = 1; /* XXX */
+	static const size_t maxiter = 10;
 	struct timespec ts1, ts2, tsn;
 	pid_t pid;
 	size_t i;
@@ -68,15 +68,15 @@
 	 * Fork a child, suspend the execution of it,
 	 * and verify that it was actually suspended.
 	 */
-	for (i = 0; i  maxiter; i++) {
+	for (i = 1; i  maxiter; i++) {
 
 		pid = fork();
 		ATF_REQUIRE(pid = 0);
 
 		if (pid == 0) {
 
-			tsn.tv_sec = 1;
-			tsn.tv_nsec = i * 1;
+			tsn.tv_sec = 0;
+			tsn.tv_nsec = i * 1000;
 
 			(void)memset(ts1, 0, sizeof(struct timespec));
 			(void)memset(ts2, 0, sizeof(struct timespec));
@@ -98,13 +98,7 @@
 			ts1.tv_sec, ts1.tv_nsec,
 			ts2.tv_sec, ts2.tv_nsec);
 
-			/*
-			 * Assume accuracy of the resolution in seconds.
-			 */
-			if (ts2.tv_sec - tsn.tv_sec != ts1.tv_sec)
-_exit(EX_DATAERR);
-
-			if (ts2.tv_nsec - tsn.tv_nsec  ts1.tv_nsec)
+			if (timespeccmp(ts2, ts1, ) != 0)
 _exit(EX_DATAERR);
 
 			_exit(EXIT_SUCCESS);



CVS commit: src/tests/syscall

2011-05-01 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Sun May  1 09:19:12 UTC 2011

Modified Files:
src/tests/syscall: t_nanosleep.c

Log Message:
Actually, as this is nanosleep(2), test 1-10 nano second sleep times.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/syscall/t_nanosleep.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/syscall/t_nanosleep.c
diff -u src/tests/syscall/t_nanosleep.c:1.2 src/tests/syscall/t_nanosleep.c:1.3
--- src/tests/syscall/t_nanosleep.c:1.2	Sun May  1 09:15:14 2011
+++ src/tests/syscall/t_nanosleep.c	Sun May  1 09:19:12 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_nanosleep.c,v 1.2 2011/05/01 09:15:14 jruoho Exp $ */
+/* $NetBSD: t_nanosleep.c,v 1.3 2011/05/01 09:19:12 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_nanosleep.c,v 1.2 2011/05/01 09:15:14 jruoho Exp $);
+__RCSID($NetBSD: t_nanosleep.c,v 1.3 2011/05/01 09:19:12 jruoho Exp $);
 
 #include sys/time.h
 #include sys/wait.h
@@ -76,7 +76,7 @@
 		if (pid == 0) {
 
 			tsn.tv_sec = 0;
-			tsn.tv_nsec = i * 1000;
+			tsn.tv_nsec = i;
 
 			(void)memset(ts1, 0, sizeof(struct timespec));
 			(void)memset(ts2, 0, sizeof(struct timespec));



CVS commit: src/tests/syscall

2011-05-01 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Sun May  1 09:44:26 UTC 2011

Modified Files:
src/tests/syscall: t_nanosleep.c

Log Message:
Improve further so that this might actually fail.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/syscall/t_nanosleep.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/syscall/t_nanosleep.c
diff -u src/tests/syscall/t_nanosleep.c:1.3 src/tests/syscall/t_nanosleep.c:1.4
--- src/tests/syscall/t_nanosleep.c:1.3	Sun May  1 09:19:12 2011
+++ src/tests/syscall/t_nanosleep.c	Sun May  1 09:44:26 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_nanosleep.c,v 1.3 2011/05/01 09:19:12 jruoho Exp $ */
+/* $NetBSD: t_nanosleep.c,v 1.4 2011/05/01 09:44:26 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_nanosleep.c,v 1.3 2011/05/01 09:19:12 jruoho Exp $);
+__RCSID($NetBSD: t_nanosleep.c,v 1.4 2011/05/01 09:44:26 jruoho Exp $);
 
 #include sys/time.h
 #include sys/wait.h
@@ -58,61 +58,24 @@
 
 ATF_TC_BODY(nanosleep_basic, tc)
 {
-	static const size_t maxiter = 10;
+	static const size_t maxiter = 100;
 	struct timespec ts1, ts2, tsn;
-	pid_t pid;
 	size_t i;
-	int sta;
-
-	/*
-	 * Fork a child, suspend the execution of it,
-	 * and verify that it was actually suspended.
-	 */
-	for (i = 1; i  maxiter; i++) {
-
-		pid = fork();
-		ATF_REQUIRE(pid = 0);
-
-		if (pid == 0) {
-
-			tsn.tv_sec = 0;
-			tsn.tv_nsec = i;
-
-			(void)memset(ts1, 0, sizeof(struct timespec));
-			(void)memset(ts2, 0, sizeof(struct timespec));
-
-			if (clock_gettime(CLOCK_MONOTONIC, ts1) != 0)
-_exit(EX_OSERR);
-
-			if (nanosleep(tsn, NULL) != 0)
-_exit(EX_OSERR);
-
-			if (clock_gettime(CLOCK_MONOTONIC, ts2) != 0)
-_exit(EX_OSERR);
-
-			(void)fprintf(stderr,
-			tsn: sec = %lu, nsec = %lu\n\t
-			ts1: sec = %lu, nsec = %lu\n\t
-			ts2: sec = %lu, nsec = %lu\n,
-			tsn.tv_sec, tsn.tv_nsec,
-			ts1.tv_sec, ts1.tv_nsec,
-			ts2.tv_sec, ts2.tv_nsec);
-
-			if (timespeccmp(ts2, ts1, ) != 0)
-_exit(EX_DATAERR);
 
-			_exit(EXIT_SUCCESS);
-		}
+	for (i = 0; i  maxiter; i++) {
 
-		(void)wait(sta);
+		tsn.tv_sec = 0;
+		tsn.tv_nsec = 1;
 
-		if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS) {
+		(void)memset(ts1, 0, sizeof(struct timespec));
+		(void)memset(ts2, 0, sizeof(struct timespec));
 
-			if (WEXITSTATUS(sta) == EX_DATAERR)
-atf_tc_fail(inaccuracies in sleep time);
+		ATF_REQUIRE(clock_gettime(CLOCK_MONOTONIC, ts1) == 0);
+		ATF_REQUIRE(nanosleep(tsn, NULL) == 0);
+		ATF_REQUIRE(clock_gettime(CLOCK_MONOTONIC, ts2) == 0);
 
-			atf_tc_fail(system call failed);
-		}
+		if (timespeccmp(ts2, ts1, ) != 0)
+			atf_tc_fail(inaccuracies in sleep time);
 	}
 }
 



CVS commit: src/tests/syscall

2011-04-25 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Mon Apr 25 22:29:35 UTC 2011

Modified Files:
src/tests/syscall: t_access.c t_dup.c t_mmap.c t_mprotect.c t_msync.c
t_setrlimit.c t_umask.c

Log Message:
Avoid creating test files oustide atf-run temporary tree.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/syscall/t_access.c \
src/tests/syscall/t_dup.c src/tests/syscall/t_mmap.c \
src/tests/syscall/t_mprotect.c src/tests/syscall/t_setrlimit.c
cvs rdiff -u -r1.2 -r1.3 src/tests/syscall/t_msync.c
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_umask.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/syscall/t_access.c
diff -u src/tests/syscall/t_access.c:1.3 src/tests/syscall/t_access.c:1.4
--- src/tests/syscall/t_access.c:1.3	Mon Apr  4 07:16:29 2011
+++ src/tests/syscall/t_access.c	Mon Apr 25 22:29:35 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_access.c,v 1.3 2011/04/04 07:16:29 jruoho Exp $ */
+/* $NetBSD: t_access.c,v 1.4 2011/04/25 22:29:35 njoly Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_access.c,v 1.3 2011/04/04 07:16:29 jruoho Exp $);
+__RCSID($NetBSD: t_access.c,v 1.4 2011/04/25 22:29:35 njoly Exp $);
 
 #include errno.h
 #include fcntl.h
@@ -40,7 +40,7 @@
 
 #include atf-c.h
 
-static const char path[] = /tmp/access;
+static const char path[] = access;
 static const int mode[4] = { R_OK, W_OK, X_OK, F_OK };
 
 ATF_TC_WITH_CLEANUP(access_access);
Index: src/tests/syscall/t_dup.c
diff -u src/tests/syscall/t_dup.c:1.3 src/tests/syscall/t_dup.c:1.4
--- src/tests/syscall/t_dup.c:1.3	Fri Apr  8 15:35:49 2011
+++ src/tests/syscall/t_dup.c	Mon Apr 25 22:29:35 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_dup.c,v 1.3 2011/04/08 15:35:49 jruoho Exp $ */
+/* $NetBSD: t_dup.c,v 1.4 2011/04/25 22:29:35 njoly Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_dup.c,v 1.3 2011/04/08 15:35:49 jruoho Exp $);
+__RCSID($NetBSD: t_dup.c,v 1.4 2011/04/25 22:29:35 njoly Exp $);
 
 #include sys/resource.h
 #include sys/stat.h
@@ -42,7 +42,7 @@
 
 #include atf-c.h
 
-static char	 path[] = /tmp/dup;
+static char	 path[] = dup;
 
 ATF_TC(dup_err);
 ATF_TC_HEAD(dup_err, tc)
Index: src/tests/syscall/t_mmap.c
diff -u src/tests/syscall/t_mmap.c:1.3 src/tests/syscall/t_mmap.c:1.4
--- src/tests/syscall/t_mmap.c:1.3	Tue Apr 19 10:21:51 2011
+++ src/tests/syscall/t_mmap.c	Mon Apr 25 22:29:35 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mmap.c,v 1.3 2011/04/19 10:21:51 martin Exp $ */
+/* $NetBSD: t_mmap.c,v 1.4 2011/04/25 22:29:35 njoly Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mmap.c,v 1.3 2011/04/19 10:21:51 martin Exp $);
+__RCSID($NetBSD: t_mmap.c,v 1.4 2011/04/25 22:29:35 njoly Exp $);
 
 #include sys/param.h
 #include sys/mman.h
@@ -46,7 +46,7 @@
 #include atf-c.h
 
 static long	page = 0;
-static char	path[] = /tmp/mmap;
+static char	path[] = mmap;
 static void	map_check(void *, int);
 static void	map_sighandler(int);
 
Index: src/tests/syscall/t_mprotect.c
diff -u src/tests/syscall/t_mprotect.c:1.3 src/tests/syscall/t_mprotect.c:1.4
--- src/tests/syscall/t_mprotect.c:1.3	Mon Apr  4 10:30:29 2011
+++ src/tests/syscall/t_mprotect.c	Mon Apr 25 22:29:35 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mprotect.c,v 1.3 2011/04/04 10:30:29 jruoho Exp $ */
+/* $NetBSD: t_mprotect.c,v 1.4 2011/04/25 22:29:35 njoly Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mprotect.c,v 1.3 2011/04/04 10:30:29 jruoho Exp $);
+__RCSID($NetBSD: t_mprotect.c,v 1.4 2011/04/25 22:29:35 njoly Exp $);
 
 #include sys/param.h
 #include sys/mman.h
@@ -47,7 +47,7 @@
 static long	page = 0;
 static int	pax_global = -1;
 static int	pax_enabled = -1;
-static char	path[] = /tmp/mmap;
+static char	path[] = mmap;
 
 static void	sighandler(int);
 static bool	paxinit(void);
Index: src/tests/syscall/t_setrlimit.c
diff -u src/tests/syscall/t_setrlimit.c:1.3 src/tests/syscall/t_setrlimit.c:1.4
--- src/tests/syscall/t_setrlimit.c:1.3	Wed Apr  6 03:47:14 2011
+++ src/tests/syscall/t_setrlimit.c	Mon Apr 25 22:29:35 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_setrlimit.c,v 1.3 2011/04/06 03:47:14 jruoho Exp $ */
+/* $NetBSD: t_setrlimit.c,v 1.4 2011/04/25 22:29:35 njoly Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_setrlimit.c,v 1.3 2011/04/06 03:47:14 jruoho Exp $);
+__RCSID($NetBSD: t_setrlimit.c,v 1.4 2011/04/25 22:29:35 njoly Exp $);
 
 #include sys/resource.h
 #include sys/mman.h

CVS commit: src/tests/syscall

2011-04-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 19 10:21:51 UTC 2011

Modified Files:
src/tests/syscall: t_mmap.c t_msync.c

Log Message:
Add MAP_PRIVATE to mmap() flags where missing.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/syscall/t_mmap.c
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_msync.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/syscall/t_mmap.c
diff -u src/tests/syscall/t_mmap.c:1.2 src/tests/syscall/t_mmap.c:1.3
--- src/tests/syscall/t_mmap.c:1.2	Mon Apr  4 10:30:29 2011
+++ src/tests/syscall/t_mmap.c	Tue Apr 19 10:21:51 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mmap.c,v 1.2 2011/04/04 10:30:29 jruoho Exp $ */
+/* $NetBSD: t_mmap.c,v 1.3 2011/04/19 10:21:51 martin Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mmap.c,v 1.2 2011/04/04 10:30:29 jruoho Exp $);
+__RCSID($NetBSD: t_mmap.c,v 1.3 2011/04/19 10:21:51 martin Exp $);
 
 #include sys/param.h
 #include sys/mman.h
@@ -81,19 +81,19 @@
 	void *map;
 
 	errno = 0;
-	map = mmap(NULL, 3, PROT_READ, MAP_FILE, -1, 0);
+	map = mmap(NULL, 3, PROT_READ, MAP_FILE|MAP_PRIVATE, -1, 0);
 
 	ATF_REQUIRE(map == MAP_FAILED);
 	ATF_REQUIRE(errno == EBADF);
 
 	errno = 0;
-	map = mmap(addr, page, PROT_READ, MAP_FIXED, -1, 0);
+	map = mmap(addr, page, PROT_READ, MAP_FIXED|MAP_PRIVATE, -1, 0);
 
 	ATF_REQUIRE(map == MAP_FAILED);
 	ATF_REQUIRE(errno == EINVAL);
 
 	errno = 0;
-	map = mmap(NULL, page, PROT_READ, MAP_ANON, INT_MAX, 0);
+	map = mmap(NULL, page, PROT_READ, MAP_ANON|MAP_PRIVATE, INT_MAX, 0);
 
 	ATF_REQUIRE(map == MAP_FAILED);
 	ATF_REQUIRE(errno == EINVAL);
@@ -121,10 +121,10 @@
 
 	ATF_REQUIRE(write(fd, XXX, 3) == 3);
 
-	map = mmap(NULL, 3, PROT_READ, MAP_FILE, fd, 0);
+	map = mmap(NULL, 3, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0);
 	map_check(map, 1);
 
-	map = mmap(NULL, 3, PROT_WRITE, MAP_FILE, fd, 0);
+	map = mmap(NULL, 3, PROT_WRITE, MAP_FILE|MAP_PRIVATE, fd, 0);
 	map_check(map, 0);
 
 	ATF_REQUIRE(close(fd) == 0);
@@ -152,7 +152,7 @@
 	 * Make a PROT_NONE mapping and try to access it.
 	 * If we catch a SIGSEGV, all works as expected.
 	 */
-	map = mmap(NULL, page, PROT_NONE, MAP_ANON, -1, 0);
+	map = mmap(NULL, page, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0);
 	ATF_REQUIRE(map != MAP_FAILED);
 
 	pid = fork();
@@ -248,7 +248,8 @@
 	 */
 	ATF_REQUIRE(ftruncate(fd, page) == 0);
 
-	map = mmap(NULL, page, PROT_READ | PROT_WRITE, MAP_FILE, fd, 0);
+	map = mmap(NULL, page, PROT_READ | PROT_WRITE, MAP_FILE|MAP_PRIVATE,
+	 fd, 0);
 	ATF_REQUIRE(map != MAP_FAILED);
 
 	for (i = 0; i  page; i++)

Index: src/tests/syscall/t_msync.c
diff -u src/tests/syscall/t_msync.c:1.1 src/tests/syscall/t_msync.c:1.2
--- src/tests/syscall/t_msync.c:1.1	Thu Apr  7 17:38:02 2011
+++ src/tests/syscall/t_msync.c	Tue Apr 19 10:21:51 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_msync.c,v 1.1 2011/04/07 17:38:02 jruoho Exp $ */
+/* $NetBSD: t_msync.c,v 1.2 2011/04/19 10:21:51 martin Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_msync.c,v 1.1 2011/04/07 17:38:02 jruoho Exp $);
+__RCSID($NetBSD: t_msync.c,v 1.2 2011/04/19 10:21:51 martin Exp $);
 
 #include sys/mman.h
 
@@ -89,7 +89,8 @@
 		tot += rv;
 	}
 
-	map = mmap(NULL, page, PROT_READ | PROT_WRITE, MAP_FILE, fd, 0);
+	map = mmap(NULL, page, PROT_READ | PROT_WRITE, MAP_FILE|MAP_PRIVATE,
+	 fd, 0);
 
 	if (map == MAP_FAILED) {
 		str = failed to map;



CVS commit: src/tests/syscall

2011-04-08 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Fri Apr  8 10:36:09 UTC 2011

Modified Files:
src/tests/syscall: t_getrusage.c

Log Message:
Adjust for the tracker PR kern/30115 for this over 15 year old bug.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/syscall/t_getrusage.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/syscall/t_getrusage.c
diff -u src/tests/syscall/t_getrusage.c:1.5 src/tests/syscall/t_getrusage.c:1.6
--- src/tests/syscall/t_getrusage.c:1.5	Thu Apr  7 17:33:11 2011
+++ src/tests/syscall/t_getrusage.c	Fri Apr  8 10:36:09 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_getrusage.c,v 1.5 2011/04/07 17:33:11 jruoho Exp $ */
+/* $NetBSD: t_getrusage.c,v 1.6 2011/04/08 10:36:09 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_getrusage.c,v 1.5 2011/04/07 17:33:11 jruoho Exp $);
+__RCSID($NetBSD: t_getrusage.c,v 1.6 2011/04/08 10:36:09 jruoho Exp $);
 
 #include sys/resource.h
 #include sys/time.h
@@ -158,10 +158,12 @@
 	/*
 	 * Test that getrusage(2) does not return
 	 * zero user time for the calling process.
+	 *
+	 * See also (duplicate) PR port-amd64/41734.
 	 */
-	for (i = 0; i  maxiter; i++) {
+	atf_tc_expect_fail(PR kern/30115);
 
-		atf_tc_expect_fail(PR port-amd64/41734);
+	for (i = 0; i  maxiter; i++) {
 
 		work();
 



CVS commit: src/tests/syscall

2011-04-07 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Thu Apr  7 17:33:12 UTC 2011

Modified Files:
src/tests/syscall: t_getrusage.c

Log Message:
Improve the test further so that it might trigger more often.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/syscall/t_getrusage.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/syscall/t_getrusage.c
diff -u src/tests/syscall/t_getrusage.c:1.4 src/tests/syscall/t_getrusage.c:1.5
--- src/tests/syscall/t_getrusage.c:1.4	Wed Apr  6 19:09:16 2011
+++ src/tests/syscall/t_getrusage.c	Thu Apr  7 17:33:11 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_getrusage.c,v 1.4 2011/04/06 19:09:16 jruoho Exp $ */
+/* $NetBSD: t_getrusage.c,v 1.5 2011/04/07 17:33:11 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_getrusage.c,v 1.4 2011/04/06 19:09:16 jruoho Exp $);
+__RCSID($NetBSD: t_getrusage.c,v 1.5 2011/04/07 17:33:11 jruoho Exp $);
 
 #include sys/resource.h
 #include sys/time.h
@@ -40,8 +40,10 @@
 #include signal.h
 #include string.h
 
-static void	work(void);
-static void	sighandler(int);
+static void		work(void);
+static void		sighandler(int);
+
+static const size_t	maxiter = 2000;
 
 static void
 sighandler(int signo)
@@ -52,7 +54,7 @@
 static void
 work(void)
 {
-	size_t n = UINT16_MAX * 100;
+	size_t n = UINT16_MAX * 10;
 
 	while (n  0) {
 		 asm volatile(nop);	/* Do something. */
@@ -117,14 +119,14 @@
 ATF_TC_BODY(getrusage_utime_back, tc)
 {
 	struct rusage ru1, ru2;
-	size_t i, n = 100;
+	size_t i;
 
 	/*
 	 * Test that two consecutive calls are sane.
 	 */
 	atf_tc_expect_fail(PR kern/30115);
 
-	for (i = 0; i  n; i++) {
+	for (i = 0; i  maxiter; i++) {
 
 		(void)memset(ru1, 0, sizeof(struct rusage));
 		(void)memset(ru2, 0, sizeof(struct rusage));
@@ -151,21 +153,25 @@
 ATF_TC_BODY(getrusage_utime_zero, tc)
 {
 	struct rusage ru;
+	size_t i;
 
 	/*
 	 * Test that getrusage(2) does not return
 	 * zero user time for the calling process.
 	 */
-	atf_tc_expect_fail(PR port-amd64/41734);
+	for (i = 0; i  maxiter; i++) {
 
-	work();
+		atf_tc_expect_fail(PR port-amd64/41734);
 
-	(void)memset(ru, 0, sizeof(struct rusage));
+		work();
 
-	ATF_REQUIRE(getrusage(RUSAGE_SELF, ru) == 0);
+		(void)memset(ru, 0, sizeof(struct rusage));
+
+		ATF_REQUIRE(getrusage(RUSAGE_SELF, ru) == 0);
 
-	if (ru.ru_utime.tv_sec == 0  ru.ru_utime.tv_usec == 0)
-		atf_tc_fail(zero user time from getrusage(2));
+		if (ru.ru_utime.tv_sec == 0  ru.ru_utime.tv_usec == 0)
+			atf_tc_fail(zero user time from getrusage(2));
+	}
 }
 
 ATF_TP_ADD_TCS(tp)



CVS commit: src/tests/syscall

2011-04-06 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Wed Apr  6 06:46:15 UTC 2011

Modified Files:
src/tests/syscall: t_getrusage.c

Log Message:
Add heuristic evaluation of PR kern/30115.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/syscall/t_getrusage.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/syscall/t_getrusage.c
diff -u src/tests/syscall/t_getrusage.c:1.2 src/tests/syscall/t_getrusage.c:1.3
--- src/tests/syscall/t_getrusage.c:1.2	Wed Apr  6 05:56:05 2011
+++ src/tests/syscall/t_getrusage.c	Wed Apr  6 06:46:14 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_getrusage.c,v 1.2 2011/04/06 05:56:05 jruoho Exp $ */
+/* $NetBSD: t_getrusage.c,v 1.3 2011/04/06 06:46:14 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,9 +29,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_getrusage.c,v 1.2 2011/04/06 05:56:05 jruoho Exp $);
+__RCSID($NetBSD: t_getrusage.c,v 1.3 2011/04/06 06:46:14 jruoho Exp $);
 
 #include sys/resource.h
+#include sys/time.h
 
 #include atf-c.h
 #include errno.h
@@ -39,6 +40,7 @@
 #include signal.h
 #include string.h
 
+static void	work(void);
 static void	sighandler(int);
 
 static const int who[] = {
@@ -52,6 +54,17 @@
 	/* Nothing. */
 }
 
+static void
+work(void)
+{
+	size_t n = UINT16_MAX * 100;
+
+	while (n  0) {
+		 asm volatile(nop);	/* Do something. */
+		 n--;
+	}
+}
+
 ATF_TC(getrusage_err);
 ATF_TC_HEAD(getrusage_err, tc)
 {
@@ -104,30 +117,60 @@
 		atf_tc_fail(getrusage(2) did not record signals);
 }
 
-ATF_TC(getrusage_utime);
-ATF_TC_HEAD(getrusage_utime, tc)
+ATF_TC(getrusage_utime_back);
+ATF_TC_HEAD(getrusage_utime_back, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test bogus values from getrusage(2));
+}
+
+ATF_TC_BODY(getrusage_utime_back, tc)
+{
+	struct rusage ru1, ru2;
+	size_t i, n = 100;
+
+	/*
+	 * Test that two consecutive calls are sane.
+	 */
+	atf_tc_expect_fail(PR kern/30115);
+
+	for (i = 0; i  n; i++) {
+
+		(void)memset(ru1, 0, sizeof(struct rusage));
+		(void)memset(ru1, 0, sizeof(struct rusage));
+
+		work();
+
+		ATF_REQUIRE(getrusage(RUSAGE_SELF, ru1) == 0);
+
+		work();
+
+		ATF_REQUIRE(getrusage(RUSAGE_SELF, ru2) == 0);
+
+		if (timercmp(ru2.ru_utime, ru1.ru_utime, ) != 0)
+			atf_tc_fail(user time went backwards);
+	}
+}
+
+ATF_TC(getrusage_utime_zero);
+ATF_TC_HEAD(getrusage_utime_zero, tc)
 {
 	atf_tc_set_md_var(tc, descr, Test zero utime from getrusage(2));
 }
 
-ATF_TC_BODY(getrusage_utime, tc)
+ATF_TC_BODY(getrusage_utime_zero, tc)
 {
-	size_t n = UINT16_MAX * 100;
 	struct rusage ru;
 
 	/*
 	 * Test that getrusage(2) does not return
 	 * zero user time for the calling process.
-	 * Note that this does not trigger always.
 	 */
 	atf_tc_expect_fail(PR port-amd64/41734);
 
-	while (n  0) {
-		 asm volatile(nop);	/* Do something. */
-		 n--;
-	}
+	work();
 
 	(void)memset(ru, 0, sizeof(struct rusage));
+
 	ATF_REQUIRE(getrusage(RUSAGE_SELF, ru) == 0);
 
 	if (ru.ru_utime.tv_sec == 0  ru.ru_utime.tv_usec == 0)
@@ -139,7 +182,8 @@
 
 	ATF_TP_ADD_TC(tp, getrusage_err);
 	ATF_TP_ADD_TC(tp, getrusage_sig);
-	ATF_TP_ADD_TC(tp, getrusage_utime);
+	ATF_TP_ADD_TC(tp, getrusage_utime_back);
+	ATF_TP_ADD_TC(tp, getrusage_utime_zero);
 
 	return atf_no_error();
 }



CVS commit: src/tests/syscall

2011-04-06 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Wed Apr  6 19:09:16 UTC 2011

Modified Files:
src/tests/syscall: t_getrusage.c

Log Message:
Fix and improve as per suggestions from njoly@.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/syscall/t_getrusage.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/syscall/t_getrusage.c
diff -u src/tests/syscall/t_getrusage.c:1.3 src/tests/syscall/t_getrusage.c:1.4
--- src/tests/syscall/t_getrusage.c:1.3	Wed Apr  6 06:46:14 2011
+++ src/tests/syscall/t_getrusage.c	Wed Apr  6 19:09:16 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_getrusage.c,v 1.3 2011/04/06 06:46:14 jruoho Exp $ */
+/* $NetBSD: t_getrusage.c,v 1.4 2011/04/06 19:09:16 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_getrusage.c,v 1.3 2011/04/06 06:46:14 jruoho Exp $);
+__RCSID($NetBSD: t_getrusage.c,v 1.4 2011/04/06 19:09:16 jruoho Exp $);
 
 #include sys/resource.h
 #include sys/time.h
@@ -43,11 +43,6 @@
 static void	work(void);
 static void	sighandler(int);
 
-static const int who[] = {
-	RUSAGE_SELF,
-	RUSAGE_CHILDREN
-};
-
 static void
 sighandler(int signo)
 {
@@ -74,20 +69,16 @@
 ATF_TC_BODY(getrusage_err, tc)
 {
 	struct rusage ru;
-	size_t i;
-
-	for (i = 0; i  __arraycount(who); i++) {
 
-		errno = 0;
+	errno = 0;
 
-		ATF_REQUIRE(getrusage(INT_MAX, ru) != 0);
-		ATF_REQUIRE(errno == EINVAL);
+	ATF_REQUIRE(getrusage(INT_MAX, ru) != 0);
+	ATF_REQUIRE(errno == EINVAL);
 
-		errno = 0;
+	errno = 0;
 
-		ATF_REQUIRE(getrusage(who[i], (void *)0) != 0);
-		ATF_REQUIRE(errno == EFAULT);
-	}
+	ATF_REQUIRE(getrusage(RUSAGE_SELF, (void *)0) != 0);
+	ATF_REQUIRE(errno == EFAULT);
 }
 
 ATF_TC(getrusage_sig);
@@ -136,7 +127,7 @@
 	for (i = 0; i  n; i++) {
 
 		(void)memset(ru1, 0, sizeof(struct rusage));
-		(void)memset(ru1, 0, sizeof(struct rusage));
+		(void)memset(ru2, 0, sizeof(struct rusage));
 
 		work();
 



CVS commit: src/tests/syscall

2011-04-05 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Tue Apr  5 19:06:09 UTC 2011

Modified Files:
src/tests/syscall: t_setrlimit.c

Log Message:
Fix small boolean oversight.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_setrlimit.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/syscall/t_setrlimit.c
diff -u src/tests/syscall/t_setrlimit.c:1.1 src/tests/syscall/t_setrlimit.c:1.2
--- src/tests/syscall/t_setrlimit.c:1.1	Tue Apr  5 19:02:23 2011
+++ src/tests/syscall/t_setrlimit.c	Tue Apr  5 19:06:09 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_setrlimit.c,v 1.1 2011/04/05 19:02:23 jruoho Exp $ */
+/* $NetBSD: t_setrlimit.c,v 1.2 2011/04/05 19:06:09 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_setrlimit.c,v 1.1 2011/04/05 19:02:23 jruoho Exp $);
+__RCSID($NetBSD: t_setrlimit.c,v 1.2 2011/04/05 19:06:09 jruoho Exp $);
 
 #include sys/resource.h
 #include sys/mman.h
@@ -277,7 +277,7 @@
 
 		(void)munlock(buf, page);
 
-		_exit(EXIT_SUCCESS);
+		_exit(EXIT_FAILURE);
 	}
 
 	free(buf);



CVS commit: src/tests/syscall

2011-04-05 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Wed Apr  6 03:47:14 UTC 2011

Modified Files:
src/tests/syscall: t_setrlimit.c

Log Message:
Remove redundant memset(3) calls.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/syscall/t_setrlimit.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/syscall/t_setrlimit.c
diff -u src/tests/syscall/t_setrlimit.c:1.2 src/tests/syscall/t_setrlimit.c:1.3
--- src/tests/syscall/t_setrlimit.c:1.2	Tue Apr  5 19:06:09 2011
+++ src/tests/syscall/t_setrlimit.c	Wed Apr  6 03:47:14 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_setrlimit.c,v 1.2 2011/04/05 19:06:09 jruoho Exp $ */
+/* $NetBSD: t_setrlimit.c,v 1.3 2011/04/06 03:47:14 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_setrlimit.c,v 1.2 2011/04/05 19:06:09 jruoho Exp $);
+__RCSID($NetBSD: t_setrlimit.c,v 1.3 2011/04/06 03:47:14 jruoho Exp $);
 
 #include sys/resource.h
 #include sys/mman.h
@@ -187,8 +187,6 @@
 
 	if (pid == 0) {
 
-		(void)memset(res, 0, sizeof(struct rlimit));
-
 		res.rlim_cur = 2;
 		res.rlim_max = 2;
 
@@ -416,8 +414,6 @@
 		/*
 		 * Set RLIMIT_NPROC to zero and try to fork.
 		 */
-		(void)memset(res, 0, sizeof(struct rlimit));
-
 		res.rlim_cur = 0;
 		res.rlim_max = 0;
 



CVS commit: src/tests/syscall

2011-04-05 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Wed Apr  6 05:56:05 UTC 2011

Modified Files:
src/tests/syscall: t_getrusage.c

Log Message:
Fix comment due explicit atf_tc_expect_fail().


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_getrusage.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/syscall/t_getrusage.c
diff -u src/tests/syscall/t_getrusage.c:1.1 src/tests/syscall/t_getrusage.c:1.2
--- src/tests/syscall/t_getrusage.c:1.1	Wed Apr  6 05:53:17 2011
+++ src/tests/syscall/t_getrusage.c	Wed Apr  6 05:56:05 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_getrusage.c,v 1.1 2011/04/06 05:53:17 jruoho Exp $ */
+/* $NetBSD: t_getrusage.c,v 1.2 2011/04/06 05:56:05 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_getrusage.c,v 1.1 2011/04/06 05:53:17 jruoho Exp $);
+__RCSID($NetBSD: t_getrusage.c,v 1.2 2011/04/06 05:56:05 jruoho Exp $);
 
 #include sys/resource.h
 
@@ -117,9 +117,8 @@
 
 	/*
 	 * Test that getrusage(2) does not return
-	 * zero user time for the calling process;
-	 * cf. PR port-xen/41734. Note that this
-	 * does not trigger always.
+	 * zero user time for the calling process.
+	 * Note that this does not trigger always.
 	 */
 	atf_tc_expect_fail(PR port-amd64/41734);
 



CVS commit: src/tests/syscall

2011-04-04 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Mon Apr  4 07:16:29 UTC 2011

Modified Files:
src/tests/syscall: t_access.c

Log Message:
Require an unprivileged run with atf_tc_set_md_var(). Pointed out by njoly@.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/syscall/t_access.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/syscall/t_access.c
diff -u src/tests/syscall/t_access.c:1.2 src/tests/syscall/t_access.c:1.3
--- src/tests/syscall/t_access.c:1.2	Mon Apr  4 01:49:45 2011
+++ src/tests/syscall/t_access.c	Mon Apr  4 07:16:29 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_access.c,v 1.2 2011/04/04 01:49:45 jruoho Exp $ */
+/* $NetBSD: t_access.c,v 1.3 2011/04/04 07:16:29 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_access.c,v 1.2 2011/04/04 01:49:45 jruoho Exp $);
+__RCSID($NetBSD: t_access.c,v 1.3 2011/04/04 07:16:29 jruoho Exp $);
 
 #include errno.h
 #include fcntl.h
@@ -47,6 +47,7 @@
 ATF_TC_HEAD(access_access, tc)
 {
 	atf_tc_set_md_var(tc, descr, Test access(2) for EACCES);
+	atf_tc_set_md_var(tc, require.user, unprivileged);
 }
 
 ATF_TC_BODY(access_access, tc)
@@ -55,9 +56,6 @@
 	size_t i;
 	int fd;
 
-	if (getuid() == 0)
-		return;
-
 	fd = open(path, O_RDONLY | O_CREAT);
 
 	if (fd  0)



CVS commit: src/tests/syscall

2011-04-04 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Mon Apr  4 08:05:37 UTC 2011

Modified Files:
src/tests/syscall: Makefile

Log Message:
Link the 't_timer' -test with pthread(3). Should fix the test failures.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/syscall/Makefile

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

Modified files:

Index: src/tests/syscall/Makefile
diff -u src/tests/syscall/Makefile:1.14 src/tests/syscall/Makefile:1.15
--- src/tests/syscall/Makefile:1.14	Mon Apr  4 06:48:05 2011
+++ src/tests/syscall/Makefile	Mon Apr  4 08:05:37 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.14 2011/04/04 06:48:05 jruoho Exp $
+# $NetBSD: Makefile,v 1.15 2011/04/04 08:05:37 jruoho Exp $
 
 .include bsd.own.mk
 
@@ -8,6 +8,7 @@
 TESTS_C+=	t_mmap t_mprotect t_timer
 
 LDADD.t_getpid+=-lpthread
+LDADD.t_timer+=	-lpthread
 
 LDADD.t_cmsg+=	-lrumpnet_local -lrumpnet_net -lrumpnet
 LDADD.t_cmsg+=	-lrumpvfs -lrump -lrumpuser -lpthread



CVS commit: src/tests/syscall

2011-04-03 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Sun Apr  3 16:22:16 UTC 2011

Modified Files:
src/tests/syscall: t_dup.c t_mprotect.c

Log Message:
Remove leftover stdio.h include.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_dup.c \
src/tests/syscall/t_mprotect.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/syscall/t_dup.c
diff -u src/tests/syscall/t_dup.c:1.1 src/tests/syscall/t_dup.c:1.2
--- src/tests/syscall/t_dup.c:1.1	Thu Mar 31 15:47:56 2011
+++ src/tests/syscall/t_dup.c	Sun Apr  3 16:22:15 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_dup.c,v 1.1 2011/03/31 15:47:56 jruoho Exp $ */
+/* $NetBSD: t_dup.c,v 1.2 2011/04/03 16:22:15 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_dup.c,v 1.1 2011/03/31 15:47:56 jruoho Exp $);
+__RCSID($NetBSD: t_dup.c,v 1.2 2011/04/03 16:22:15 jruoho Exp $);
 
 #include sys/stat.h
 
@@ -39,8 +39,6 @@
 #include string.h
 #include unistd.h
 
-#include stdio.h
-
 #include atf-c.h
 
 static char	 path[] = /tmp/dup;
Index: src/tests/syscall/t_mprotect.c
diff -u src/tests/syscall/t_mprotect.c:1.1 src/tests/syscall/t_mprotect.c:1.2
--- src/tests/syscall/t_mprotect.c:1.1	Sun Apr  3 16:12:46 2011
+++ src/tests/syscall/t_mprotect.c	Sun Apr  3 16:22:15 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mprotect.c,v 1.1 2011/04/03 16:12:46 jruoho Exp $ */
+/* $NetBSD: t_mprotect.c,v 1.2 2011/04/03 16:22:15 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mprotect.c,v 1.1 2011/04/03 16:12:46 jruoho Exp $);
+__RCSID($NetBSD: t_mprotect.c,v 1.2 2011/04/03 16:22:15 jruoho Exp $);
 
 #include sys/param.h
 #include sys/mman.h
@@ -42,8 +42,6 @@
 #include string.h
 #include unistd.h
 
-#include stdio.h		/* XXX. */
-
 #include atf-c.h
 
 static long	page = 0;



CVS commit: src/tests/syscall

2011-04-03 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Mon Apr  4 01:49:45 UTC 2011

Modified Files:
src/tests/syscall: t_access.c

Log Message:
Check for getuid(2) == 0.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_access.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/syscall/t_access.c
diff -u src/tests/syscall/t_access.c:1.1 src/tests/syscall/t_access.c:1.2
--- src/tests/syscall/t_access.c:1.1	Sun Apr  3 16:12:46 2011
+++ src/tests/syscall/t_access.c	Mon Apr  4 01:49:45 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_access.c,v 1.1 2011/04/03 16:12:46 jruoho Exp $ */
+/* $NetBSD: t_access.c,v 1.2 2011/04/04 01:49:45 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_access.c,v 1.1 2011/04/03 16:12:46 jruoho Exp $);
+__RCSID($NetBSD: t_access.c,v 1.2 2011/04/04 01:49:45 jruoho Exp $);
 
 #include errno.h
 #include fcntl.h
@@ -55,6 +55,9 @@
 	size_t i;
 	int fd;
 
+	if (getuid() == 0)
+		return;
+
 	fd = open(path, O_RDONLY | O_CREAT);
 
 	if (fd  0)



CVS commit: src/tests/syscall

2010-08-27 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Aug 27 10:03:14 UTC 2010

Modified Files:
src/tests/syscall: t_cmsg.c

Log Message:
Set the cmsg_len and msg_controllen in cmsg_sendfd testcase to match
the usage in the cmsg_sendfd_bounds case.  This test now passes on an
amd64 machine.

Change suggested by and OK'd by pooka@


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/syscall/t_cmsg.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/syscall/t_cmsg.c
diff -u src/tests/syscall/t_cmsg.c:1.13 src/tests/syscall/t_cmsg.c:1.14
--- src/tests/syscall/t_cmsg.c:1.13	Fri Dec 18 21:24:13 2009
+++ src/tests/syscall/t_cmsg.c	Fri Aug 27 10:03:14 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_cmsg.c,v 1.13 2009/12/18 21:24:13 pooka Exp $	*/
+/*	$NetBSD: t_cmsg.c,v 1.14 2010/08/27 10:03:14 pgoyette Exp $	*/
 
 #include sys/types.h
 #include sys/mount.h
@@ -135,14 +135,14 @@
 
 	cmp-cmsg_level = SOL_SOCKET;
 	cmp-cmsg_type = SCM_RIGHTS;
-	cmp-cmsg_len = CMSG_SPACE(sizeof(int));
+	cmp-cmsg_len = CMSG_LEN(sizeof(int));
 
 	msg.msg_iov = iov;
 	msg.msg_iovlen = 1;
 	msg.msg_name = NULL;
 	msg.msg_namelen = 0;
 	msg.msg_control = cmp;
-	msg.msg_controllen = CMSG_LEN(sizeof(int));
+	msg.msg_controllen = CMSG_SPACE(sizeof(int));
 	*(int *)CMSG_DATA(cmp) = fd[0];
 
 	/* pass the fd */



CVS commit: src/tests/syscall

2009-12-18 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Dec 18 21:24:13 UTC 2009

Modified Files:
src/tests/syscall: t_cmsg.c

Log Message:
Must use CMSG_SPACE instead of CMSG_LEN for control message buffer.
Fixes test on sparc64 (and possible other alignment-picky ports).
from mlelstv


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/syscall/t_cmsg.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/syscall/t_cmsg.c
diff -u src/tests/syscall/t_cmsg.c:1.12 src/tests/syscall/t_cmsg.c:1.13
--- src/tests/syscall/t_cmsg.c:1.12	Thu Nov 26 17:33:23 2009
+++ src/tests/syscall/t_cmsg.c	Fri Dec 18 21:24:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_cmsg.c,v 1.12 2009/11/26 17:33:23 pooka Exp $	*/
+/*	$NetBSD: t_cmsg.c,v 1.13 2009/12/18 21:24:13 pooka Exp $	*/
 
 #include sys/types.h
 #include sys/mount.h
@@ -40,7 +40,7 @@
 	if (rump_sys_socketpair(AF_LOCAL, SOCK_STREAM, 0, s) == -1)
 		atf_tc_fail(rump_sys_socket);
 
-	cmp = malloc(CMSG_LEN(sizeof(int)));
+	cmp = malloc(CMSG_SPACE(sizeof(int)));
 
 	iov.iov_base = fd;
 	iov.iov_len = sizeof(int);
@@ -54,7 +54,7 @@
 	msg.msg_name = NULL;
 	msg.msg_namelen = 0;
 	msg.msg_control = cmp;
-	msg.msg_controllen = CMSG_LEN(sizeof(int));
+	msg.msg_controllen = CMSG_SPACE(sizeof(int));
 
 	/*
 	 * ERROR HERE: trying to pass invalid fd
@@ -128,14 +128,14 @@
 	sizeof(MAGICSTRING))
 		atf_tc_fail_errno(pipe write); /* XXX: errno */
 
-	cmp = malloc(CMSG_LEN(sizeof(int)));
+	cmp = malloc(CMSG_SPACE(sizeof(int)));
 
 	iov.iov_base = storage;
 	iov.iov_len = sizeof(int);
 
 	cmp-cmsg_level = SOL_SOCKET;
 	cmp-cmsg_type = SCM_RIGHTS;
-	cmp-cmsg_len = CMSG_LEN(sizeof(int));
+	cmp-cmsg_len = CMSG_SPACE(sizeof(int));
 
 	msg.msg_iov = iov;
 	msg.msg_iovlen = 1;
@@ -149,6 +149,13 @@
 	if (rump_sys_sendmsg(s2, msg, 0) == -1)
 		atf_tc_fail_errno(sendmsg failed);
 
+	/*
+	 * We will read to the same cmsg space.  Overwrite the space
+	 * with an invalid fd to make sure we get an explicit error
+	 * if we don't manage to read the fd.
+	 */
+	*(int *)CMSG_DATA(cmp) = -1;
+
 	/* switch back to original proc */
 	rump_pub_lwp_switch(l1);
 



CVS commit: src/tests/syscall

2009-11-26 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Nov 26 17:33:23 UTC 2009

Modified Files:
src/tests/syscall: Makefile t_cmsg.c

Log Message:
Since rumpfs has supported file system sockets for quite a while
now, we don't need tmpfs here.  But, rumpfs doesn't support regular
files, so pass a pipe descriptor instead of an open file fd.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/syscall/Makefile
cvs rdiff -u -r1.11 -r1.12 src/tests/syscall/t_cmsg.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/syscall/Makefile
diff -u src/tests/syscall/Makefile:1.7 src/tests/syscall/Makefile:1.8
--- src/tests/syscall/Makefile:1.7	Wed Nov 25 16:17:11 2009
+++ src/tests/syscall/Makefile	Thu Nov 26 17:33:23 2009
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 2009/11/25 16:17:11 pooka Exp $
+# $NetBSD: Makefile,v 1.8 2009/11/26 17:33:23 pooka Exp $
 
 .include bsd.own.mk
 
@@ -7,7 +7,7 @@
 TESTS_C+=	t_cmsg
 
 LDADD+=	-lrumpnet_local -lrumpnet_net -lrumpnet
-LDADD+=	-lrumpfs_tmpfs -lrumpvfs -lrump -lrumpuser -lpthread
+LDADD+=	-lrumpvfs -lrump -lrumpuser -lpthread
 
 WARNS=		4
 

Index: src/tests/syscall/t_cmsg.c
diff -u src/tests/syscall/t_cmsg.c:1.11 src/tests/syscall/t_cmsg.c:1.12
--- src/tests/syscall/t_cmsg.c:1.11	Fri Nov  6 15:28:21 2009
+++ src/tests/syscall/t_cmsg.c	Thu Nov 26 17:33:23 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_cmsg.c,v 1.11 2009/11/06 15:28:21 pooka Exp $	*/
+/*	$NetBSD: t_cmsg.c,v 1.12 2009/11/26 17:33:23 pooka Exp $	*/
 
 #include sys/types.h
 #include sys/mount.h
@@ -8,8 +8,6 @@
 #include rump/rump.h
 #include rump/rump_syscalls.h
 
-#include fs/tmpfs/tmpfs_args.h
-
 #include atf-c.h
 #include fcntl.h
 #include err.h
@@ -84,25 +82,14 @@
 	char buf[128];
 	struct cmsghdr *cmp;
 	struct msghdr msg;
-	struct tmpfs_args args;
 	struct sockaddr_un sun;
 	struct lwp *l1, *l2;
 	struct iovec iov;
 	socklen_t sl;
 	int s1, s2, sgot;
-	int rfd, fd, storage;
-
-	memset(args, 0, sizeof(args));
-	args.ta_version = TMPFS_ARGS_VERSION;
-	args.ta_root_mode = 0777;
+	int rfd, fd[2], storage;
 
 	rump_init();
-	/*
-	 * mount tmpfs as root -- rump root file system does not support
-	 * unix domain sockets.
-	 */
-	if (rump_sys_mount(MOUNT_TMPFS, /, 0, args, sizeof(args)) == -1)
-		atf_tc_fail_errno(mount tmpfs);
 
 	/* create first (non-proc0) process to be used in test */
 	l1 = rump_pub_newproc_switch();
@@ -133,16 +120,13 @@
 	if (rump_sys_connect(s2, (struct sockaddr *)sun, SUN_LEN(sun)) == -1)
 		atf_tc_fail_errno(socket 2 connect);
 
-	/* open a file and write stuff to it */
-	fd = rump_sys_open(/foobie, O_RDWR | O_CREAT, 0777);
-	if (fd == -1)
-		atf_tc_fail_errno(can't open file);
+	/* open a pipe and write stuff to it */
+	if (rump_sys_pipe(fd) == -1)
+		atf_tc_fail_errno(can't open pipe);
 #define MAGICSTRING duam xnaht
-	if (rump_sys_write(fd, MAGICSTRING, sizeof(MAGICSTRING)) !=
+	if (rump_sys_write(fd[1], MAGICSTRING, sizeof(MAGICSTRING)) !=
 	sizeof(MAGICSTRING))
-		atf_tc_fail_errno(file write); /* XXX: errno */
-	/* reset offset */
-	rump_sys_lseek(fd, 0, SEEK_SET);
+		atf_tc_fail_errno(pipe write); /* XXX: errno */
 
 	cmp = malloc(CMSG_LEN(sizeof(int)));
 
@@ -159,7 +143,7 @@
 	msg.msg_namelen = 0;
 	msg.msg_control = cmp;
 	msg.msg_controllen = CMSG_LEN(sizeof(int));
-	*(int *)CMSG_DATA(cmp) = fd;
+	*(int *)CMSG_DATA(cmp) = fd[0];
 
 	/* pass the fd */
 	if (rump_sys_sendmsg(s2, msg, 0) == -1)



CVS commit: src/tests/syscall

2009-11-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Nov 25 16:17:11 UTC 2009

Modified Files:
src/tests/syscall: Makefile

Log Message:
Don't use LDADD.progname because it duplicates all the libs.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/syscall/Makefile

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

Modified files:

Index: src/tests/syscall/Makefile
diff -u src/tests/syscall/Makefile:1.6 src/tests/syscall/Makefile:1.7
--- src/tests/syscall/Makefile:1.6	Fri Nov  6 15:28:21 2009
+++ src/tests/syscall/Makefile	Wed Nov 25 16:17:11 2009
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.6 2009/11/06 15:28:21 pooka Exp $
+# $NetBSD: Makefile,v 1.7 2009/11/25 16:17:11 pooka Exp $
 
 .include bsd.own.mk
 
@@ -6,8 +6,8 @@
 
 TESTS_C+=	t_cmsg
 
-LDADD.t_cmsg+=	-lrumpnet_local -lrumpnet_net -lrumpnet
-LDADD.t_cmsg+=	-lrumpfs_tmpfs -lrumpvfs -lrump -lrumpuser -lpthread
+LDADD+=	-lrumpnet_local -lrumpnet_net -lrumpnet
+LDADD+=	-lrumpfs_tmpfs -lrumpvfs -lrump -lrumpuser -lpthread
 
 WARNS=		4
 



CVS commit: src/tests/syscall

2009-10-15 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Oct 15 16:47:23 UTC 2009

Modified Files:
src/tests/syscall: t_cmsg.c

Log Message:
fix test for new-world rump lwp usage


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/syscall/t_cmsg.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/syscall/t_cmsg.c
diff -u src/tests/syscall/t_cmsg.c:1.8 src/tests/syscall/t_cmsg.c:1.9
--- src/tests/syscall/t_cmsg.c:1.8	Wed Oct 14 18:22:50 2009
+++ src/tests/syscall/t_cmsg.c	Thu Oct 15 16:47:23 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_cmsg.c,v 1.8 2009/10/14 18:22:50 pooka Exp $	*/
+/*	$NetBSD: t_cmsg.c,v 1.9 2009/10/15 16:47:23 pooka Exp $	*/
 
 #include sys/types.h
 #include sys/mount.h
@@ -104,6 +104,9 @@
 	if (rump_sys_mount(MOUNT_TMPFS, /, 0, args, sizeof(args)) == -1)
 		atf_tc_fail_errno(mount tmpfs);
 
+	/* store our current lwp/proc */
+	l1 = rump_pub_newproc_switch();
+
 	/* create unix socket and bind it to a path */
 	memset(sun, 0, sizeof(sun));
 	sun.sun_family = AF_LOCAL;
@@ -117,9 +120,6 @@
 	if (rump_sys_listen(s1, 1) == -1)
 		atf_tc_fail_errno(socket 1 listen);
 
-	/* store our current lwp/proc */
-	l1 = rump_pub_get_curlwp();
-
 	/* create new process */
 	l2 = rump_pub_newproc_switch();
 
@@ -166,7 +166,7 @@
 		atf_tc_fail_errno(sendmsg failed);
 
 	/* switch back to original proc */
-	rump_set_curlwp(l1);
+	rump_pub_lwp_switch(l1);
 
 	/* accept connection and read fd */
 	sl = sizeof(sun);



CVS commit: src/tests/syscall

2009-10-15 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Oct 15 16:50:00 UTC 2009

Modified Files:
src/tests/syscall: t_cmsg.c

Log Message:
comment adjustment.  hardly any functional change involved.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/syscall/t_cmsg.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/syscall/t_cmsg.c
diff -u src/tests/syscall/t_cmsg.c:1.9 src/tests/syscall/t_cmsg.c:1.10
--- src/tests/syscall/t_cmsg.c:1.9	Thu Oct 15 16:47:23 2009
+++ src/tests/syscall/t_cmsg.c	Thu Oct 15 16:50:00 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_cmsg.c,v 1.9 2009/10/15 16:47:23 pooka Exp $	*/
+/*	$NetBSD: t_cmsg.c,v 1.10 2009/10/15 16:50:00 pooka Exp $	*/
 
 #include sys/types.h
 #include sys/mount.h
@@ -104,7 +104,7 @@
 	if (rump_sys_mount(MOUNT_TMPFS, /, 0, args, sizeof(args)) == -1)
 		atf_tc_fail_errno(mount tmpfs);
 
-	/* store our current lwp/proc */
+	/* create first (non-proc0) process to be used in test */
 	l1 = rump_pub_newproc_switch();
 
 	/* create unix socket and bind it to a path */
@@ -120,7 +120,7 @@
 	if (rump_sys_listen(s1, 1) == -1)
 		atf_tc_fail_errno(socket 1 listen);
 
-	/* create new process */
+	/* create second process for test */
 	l2 = rump_pub_newproc_switch();
 
 	/* connect to unix domain socket */



CVS commit: src/tests/syscall

2009-05-08 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri May  8 13:03:46 UTC 2009

Modified Files:
src/tests/syscall: t_cmsg.c

Log Message:
lseek fd to start before sending, creates a clearer test case.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/syscall/t_cmsg.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/syscall/t_cmsg.c
diff -u src/tests/syscall/t_cmsg.c:1.5 src/tests/syscall/t_cmsg.c:1.6
--- src/tests/syscall/t_cmsg.c:1.5	Thu May  7 16:19:30 2009
+++ src/tests/syscall/t_cmsg.c	Fri May  8 13:03:46 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_cmsg.c,v 1.5 2009/05/07 16:19:30 pooka Exp $	*/
+/*	$NetBSD: t_cmsg.c,v 1.6 2009/05/08 13:03:46 pooka Exp $	*/
 
 #include sys/types.h
 #include sys/mount.h
@@ -141,6 +141,8 @@
 	if (rump_sys_write(fd, MAGICSTRING, sizeof(MAGICSTRING)) !=
 	sizeof(MAGICSTRING))
 		atf_tc_fail_errno(file write); /* XXX: errno */
+	/* reset offset */
+	rump_sys_lseek(fd, 0, 0, SEEK_SET);
 
 	cmp = malloc(CMSG_LEN(sizeof(int)));
 
@@ -175,9 +177,8 @@
 		atf_tc_fail_errno(recvmsg failed);
 	rfd = *(int *)CMSG_DATA(cmp);
 
-	/* set offset to 0 and read from the fd */
+	/* read from the fd */
 	memset(buf, 0, sizeof(buf));
-	rump_sys_lseek(rfd, 0, 0, SEEK_SET);
 	if (rump_sys_read(rfd, buf, sizeof(buf)) == -1)
 		atf_tc_fail_errno(read rfd);
 



CVS commit: src/tests/syscall

2009-05-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun May  3 23:19:59 UTC 2009

Modified Files:
src/tests/syscall: t_cmsg.c

Log Message:
In addition to testing the fd passing doesn't crash the kernel,
also check that it actually works.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/syscall/t_cmsg.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/syscall/t_cmsg.c
diff -u src/tests/syscall/t_cmsg.c:1.1 src/tests/syscall/t_cmsg.c:1.2
--- src/tests/syscall/t_cmsg.c:1.1	Tue Feb 10 13:43:54 2009
+++ src/tests/syscall/t_cmsg.c	Sun May  3 23:19:59 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_cmsg.c,v 1.1 2009/02/10 13:43:54 pooka Exp $	*/
+/*	$NetBSD: t_cmsg.c,v 1.2 2009/05/03 23:19:59 pooka Exp $	*/
 
 #include sys/types.h
 #include sys/socket.h
@@ -15,14 +15,16 @@
 #include unistd.h
 #include util.h
 
-ATF_TC(cmsg_sendfd);
-ATF_TC_HEAD(cmsg_sendfd, tc)
+#include ../h_macros.h
+
+ATF_TC(cmsg_sendfd_bounds);
+ATF_TC_HEAD(cmsg_sendfd_bounds, tc)
 {
 	atf_tc_set_md_var(tc, descr, Checks that attempting to pass an 
 	invalid fd returns an error);
 }
 
-ATF_TC_BODY(cmsg_sendfd, tc)
+ATF_TC_BODY(cmsg_sendfd_bounds, tc)
 {
 	struct cmsghdr *cmp;
 	struct msghdr msg;
@@ -66,7 +68,64 @@
 		got %d\n(%s), errno, strerror(errno));
 }
 
+
+ATF_TC(cmsg_sendfd);
+ATF_TC_HEAD(cmsg_sendfd, tc)
+{
+	atf_tc_set_md_var(tc, descr, Checks that fd passing works);
+	atf_tc_set_md_var(tc, timeout, 2);
+}
+
+ATF_TC_BODY(cmsg_sendfd, tc)
+{
+	struct cmsghdr *cmp;
+	struct msghdr msg;
+	struct iovec iov;
+	ssize_t n;
+	int s[2], sgot;
+	int rv, error = 0;
+	int v1, v2;
+
+	rump_init();
+
+	if (rump_sys_socketpair(AF_LOCAL, SOCK_STREAM, 0, s) == -1)
+		atf_tc_fail(rump_sys_socketpair);
+
+	rv = 0;
+	cmp = malloc(CMSG_LEN(sizeof(int)));
+
+	iov.iov_base = error;
+	iov.iov_len = sizeof(int);
+
+	cmp-cmsg_level = SOL_SOCKET;
+	cmp-cmsg_type = SCM_RIGHTS;
+	cmp-cmsg_len = CMSG_LEN(sizeof(int));
+
+	msg.msg_iov = iov;
+	msg.msg_iovlen = 1;
+	msg.msg_name = NULL;
+	msg.msg_namelen = 0;
+	msg.msg_control = cmp;
+	msg.msg_controllen = CMSG_LEN(sizeof(int));
+	*(int *)CMSG_DATA(cmp) = s[1];
+
+	if (rump_sys_sendmsg(s[0], msg, 0) == -1)
+		atf_tc_fail_errno(sendmsg failed);
+	if (rump_sys_recvmsg(s[1], msg, 0) == -1)
+		atf_tc_fail_errno(recvmsg failed);
+	sgot = *(int *)CMSG_DATA(cmp);
+
+	/* test that we really got the fd by writing something thought it */
+	v1 = 37;
+	v2 = -1;
+	rump_sys_write(s[0], v1, sizeof(v1));
+	rump_sys_read(sgot, v2, sizeof(v1));
+	if (v1 != v2)
+		atf_tc_fail(value mismatch: %d vs. %d, v1, v2);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, cmsg_sendfd);
+	ATF_TP_ADD_TC(tp, cmsg_sendfd_bounds);
 }



CVS commit: src/tests/syscall

2009-05-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon May  4 00:14:59 UTC 2009

Modified Files:
src/tests/syscall: t_cmsg.c

Log Message:
g/c unused variables


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/syscall/t_cmsg.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/syscall/t_cmsg.c
diff -u src/tests/syscall/t_cmsg.c:1.2 src/tests/syscall/t_cmsg.c:1.3
--- src/tests/syscall/t_cmsg.c:1.2	Sun May  3 23:19:59 2009
+++ src/tests/syscall/t_cmsg.c	Mon May  4 00:14:59 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_cmsg.c,v 1.2 2009/05/03 23:19:59 pooka Exp $	*/
+/*	$NetBSD: t_cmsg.c,v 1.3 2009/05/04 00:14:59 pooka Exp $	*/
 
 #include sys/types.h
 #include sys/socket.h
@@ -29,16 +29,14 @@
 	struct cmsghdr *cmp;
 	struct msghdr msg;
 	struct iovec iov;
-	ssize_t n;
 	int s[2];
-	int rv, error = 0;
+	int error = 0;
 
 	rump_init();
 
 	if (rump_sys_socketpair(AF_LOCAL, SOCK_STREAM, 0, s) == -1)
 		atf_tc_fail(rump_sys_socket);
 
-	rv = 0;
 	cmp = malloc(CMSG_LEN(sizeof(int)));
 
 	iov.iov_base = error;
@@ -81,9 +79,8 @@
 	struct cmsghdr *cmp;
 	struct msghdr msg;
 	struct iovec iov;
-	ssize_t n;
 	int s[2], sgot;
-	int rv, error = 0;
+	int error = 0;
 	int v1, v2;
 
 	rump_init();
@@ -91,7 +88,6 @@
 	if (rump_sys_socketpair(AF_LOCAL, SOCK_STREAM, 0, s) == -1)
 		atf_tc_fail(rump_sys_socketpair);
 
-	rv = 0;
 	cmp = malloc(CMSG_LEN(sizeof(int)));
 
 	iov.iov_base = error;