CVS commit: src/tests/fs/tmpfs

2021-06-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Jun 17 00:03:05 UTC 2021

Modified Files:
src/tests/fs/tmpfs: t_times.sh

Log Message:
tests/fs/tmpfs: Print bad values on failure for diagnosis.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/fs/tmpfs/t_times.sh

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

Modified files:

Index: src/tests/fs/tmpfs/t_times.sh
diff -u src/tests/fs/tmpfs/t_times.sh:1.5 src/tests/fs/tmpfs/t_times.sh:1.6
--- src/tests/fs/tmpfs/t_times.sh:1.5	Sun Nov  7 17:51:18 2010
+++ src/tests/fs/tmpfs/t_times.sh	Thu Jun 17 00:03:05 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_times.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+# $NetBSD: t_times.sh,v 1.6 2021/06/17 00:03:05 riastradh Exp $
 #
 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -40,23 +40,32 @@ empty_body() {
 
 	atf_check -s eq:0 -o empty -e empty touch a
 	eval $(stat -s a | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
-	[ ${ost_birthtime} -eq ${ost_atime} ] || atf_fail "Incorrect atime"
-	[ ${ost_birthtime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
-	[ ${ost_birthtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
+	[ ${ost_birthtime} -eq ${ost_atime} ] || \
+	atf_fail "Incorrect atime: ${ost_birthtime} != ${ost_atime}"
+	[ ${ost_birthtime} -eq ${ost_ctime} ] || \
+	atf_fail "Incorrect ctime: ${ost_birthtime} != ${ost_ctime}"
+	[ ${ost_birthtime} -eq ${ost_mtime} ] || \
+	atf_fail "Incorrect mtime: ${ost_birthtime} != ${ost_mtime}"
 
 	sleep 1
 	atf_check -s eq:0 -o ignore -e empty cat a
 	eval $(stat -s a) || atf_fail "stat failed"
-	[ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
-	[ ${st_ctime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
-	[ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
+	[ ${st_atime} -gt ${ost_atime} ] || \
+	atf_fail "Incorrect atime: ${st_atime} <= ${ost_atime}"
+	[ ${st_ctime} -eq ${ost_ctime} ] || \
+	atf_fail "Incorrect ctime: ${st_ctime} != ${ost_ctime}"
+	[ ${st_mtime} -eq ${ost_mtime} ] || \
+	atf_fail "Incorrect mtime: ${st_mtime} != ${ost_mtime}"
 
 	sleep 1
 	echo foo >a || atf_fail "Write failed"
 	eval $(stat -s a) || atf_fail "stat failed"
-	[ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
-	[ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
-	[ ${st_mtime} -gt ${ost_mtime} ] || atf_fail "Incorrect mtime"
+	[ ${st_atime} -gt ${ost_atime} ] || \
+	atf_fail "Incorrect atime: ${st_atime} <= ${ost_atime}"
+	[ ${st_ctime} -gt ${ost_ctime} ] || \
+	atf_fail "Incorrect ctime: ${st_ctime} <= ${ost_ctime}"
+	[ ${st_mtime} -gt ${ost_mtime} ] || \
+	atf_fail "Incorrect mtime: ${st_mtime} <= ${ost_mtime}"
 
 	test_unmount
 }
@@ -76,9 +85,12 @@ non_empty_body() {
 	sleep 1
 	atf_check -s eq:0 -o ignore -e empty cat b
 	eval $(stat -s b) || atf_fail "stat failed"
-	[ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
-	[ ${st_ctime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
-	[ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
+	[ ${st_atime} -gt ${ost_atime} ] || \
+	atf_fail "Incorrect atime: ${st_atime} <= ${ost_atime}"
+	[ ${st_ctime} -eq ${ost_ctime} ] || \
+	atf_fail "Incorrect ctime: ${st_ctime} != ${ost_ctime}"
+	[ ${st_mtime} -eq ${ost_mtime} ] || \
+	atf_fail "Incorrect mtime: ${st_mtime} != ${ost_mtime}"
 
 	test_unmount
 }
@@ -98,9 +110,12 @@ link_body() {
 	sleep 1
 	atf_check -s eq:0 -o empty -e empty ln c d
 	eval $(stat -s c) || atf_fail "stat failed"
-	[ ${st_atime} -eq ${ost_atime} ] || atf_fail "Incorrect atime"
-	[ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
-	[ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
+	[ ${st_atime} -eq ${ost_atime} ] || \
+	atf_fail "Incorrect atime: ${st_atime} != ${ost_atime}"
+	[ ${st_ctime} -gt ${ost_ctime} ] || \
+	atf_fail "Incorrect ctime: ${st_ctime} <= ${ost_ctime}"
+	[ ${st_mtime} -eq ${ost_mtime} ] || \
+	atf_fail "Incorrect mtime: ${st_mtime} != ${ost_mtime}"
 
 	test_unmount
 }
@@ -122,10 +137,14 @@ rename_body() {
 	atf_check -s eq:0 -o empty -e empty mv e/a e/b
 	eval $(stat -s e | sed -e 's|st_|dst_|g') || atf_fail "stat failed"
 	eval $(stat -s e/b) || atf_fail "stat failed"
-	[ ${st_atime} -eq ${ost_atime} ] || atf_fail "Incorrect atime"
-	[ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
-	[ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
-	[ ${dst_mtime} -gt ${dost_mtime} ] || atf_fail "Incorrect mtime"
+	[ ${st_atime} -eq ${ost_atime} ] || \
+	atf_fail "Incorrect atime: ${st_atime} != ${ost_atime}"
+	[ ${st_ctime} -gt ${ost_ctime} ] || \
+	atf_fail "Incorrect ctime: ${st_ctime} <= ${ost_ctime}"
+	[ ${st_mtime} -eq ${ost_mtime} ] || \
+	atf_fail "Incorrect mtime: ${st_mtime} != ${ost_mtime}"
+	[ ${dst_mtime} -gt ${dost_mtime} ] || \
+	atf_fail "Incorrect 

CVS commit: src/tests/fs/tmpfs

2021-06-05 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sat Jun  5 06:40:59 UTC 2021

Modified Files:
src/tests/fs/tmpfs: t_vnd.sh

Log Message:
Use the correct pathname when cleaning up the inner mount on test
failure.  Fixes the ATF crash reported in PR bin/56221, but not
the issue causing the test to fail in the first place.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/fs/tmpfs/t_vnd.sh

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

Modified files:

Index: src/tests/fs/tmpfs/t_vnd.sh
diff -u src/tests/fs/tmpfs/t_vnd.sh:1.10 src/tests/fs/tmpfs/t_vnd.sh:1.11
--- src/tests/fs/tmpfs/t_vnd.sh:1.10	Thu Mar 23 08:18:17 2017
+++ src/tests/fs/tmpfs/t_vnd.sh	Sat Jun  5 06:40:59 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_vnd.sh,v 1.10 2017/03/23 08:18:17 martin Exp $
+# $NetBSD: t_vnd.sh,v 1.11 2021/06/05 06:40:59 gson Exp $
 #
 # Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -69,7 +69,7 @@ basic_body() {
 }
 basic_cleanup() {
 	if [ ! -f done ]; then
-		umount mnt 2>/dev/null 1>&2
+		umount mntpt/mnt 2>/dev/null 1>&2
 		vndconfig -u ${vnddev} 2>/dev/null 1>&2
 	fi
 }



CVS commit: src/tests/fs/tmpfs

2018-01-16 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Jan 17 00:23:17 UTC 2018

Modified Files:
src/tests/fs/tmpfs: t_sizes.sh t_statvfs.sh t_vnode_leak.sh

Log Message:
Use sysctl -n rather than parse the output.

>From Ngie Cooper in PR bin/51870


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/fs/tmpfs/t_sizes.sh
cvs rdiff -u -r1.4 -r1.5 src/tests/fs/tmpfs/t_statvfs.sh
cvs rdiff -u -r1.6 -r1.7 src/tests/fs/tmpfs/t_vnode_leak.sh

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

Modified files:

Index: src/tests/fs/tmpfs/t_sizes.sh
diff -u src/tests/fs/tmpfs/t_sizes.sh:1.5 src/tests/fs/tmpfs/t_sizes.sh:1.6
--- src/tests/fs/tmpfs/t_sizes.sh:1.5	Sun Nov  7 17:51:18 2010
+++ src/tests/fs/tmpfs/t_sizes.sh	Wed Jan 17 00:23:17 2018
@@ -1,4 +1,4 @@
-# $NetBSD: t_sizes.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $
+# $NetBSD: t_sizes.sh,v 1.6 2018/01/17 00:23:17 maya Exp $
 #
 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -54,7 +54,7 @@ big_head() {
 big_body() {
 	test_mount -o -s10M
 
-	pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 3)
+	pagesize=$(sysctl -n hw.pagesize)
 	eval $($(atf_get_srcdir)/h_tools statvfs . | sed -e 's|^f_|cf_|')
 	cf_bused=$((${cf_blocks} - ${cf_bfree}))
 

Index: src/tests/fs/tmpfs/t_statvfs.sh
diff -u src/tests/fs/tmpfs/t_statvfs.sh:1.4 src/tests/fs/tmpfs/t_statvfs.sh:1.5
--- src/tests/fs/tmpfs/t_statvfs.sh:1.4	Sun Nov  7 17:51:18 2010
+++ src/tests/fs/tmpfs/t_statvfs.sh	Wed Jan 17 00:23:17 2018
@@ -1,4 +1,4 @@
-# $NetBSD: t_statvfs.sh,v 1.4 2010/11/07 17:51:18 jmmv Exp $
+# $NetBSD: t_statvfs.sh,v 1.5 2018/01/17 00:23:17 maya Exp $
 #
 # Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -38,7 +38,7 @@ values_head() {
 values_body() {
 	test_mount -o -s10M
 
-	pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 3)
+	pagesize=$(sysctl -n hw.pagesize)
 	eval $($(atf_get_srcdir)/h_tools statvfs .)
 	[ ${pagesize} -eq ${f_bsize} ] || \
 	atf_fail "Invalid bsize"

Index: src/tests/fs/tmpfs/t_vnode_leak.sh
diff -u src/tests/fs/tmpfs/t_vnode_leak.sh:1.6 src/tests/fs/tmpfs/t_vnode_leak.sh:1.7
--- src/tests/fs/tmpfs/t_vnode_leak.sh:1.6	Sun Nov  7 17:51:18 2010
+++ src/tests/fs/tmpfs/t_vnode_leak.sh	Wed Jan 17 00:23:17 2018
@@ -1,4 +1,4 @@
-# $NetBSD: t_vnode_leak.sh,v 1.6 2010/11/07 17:51:18 jmmv Exp $
+# $NetBSD: t_vnode_leak.sh,v 1.7 2018/01/17 00:23:17 maya Exp $
 #
 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -36,7 +36,7 @@ main_head() {
 }
 main_body() {
 	echo "Lowering kern.maxvnodes to 2000"
-	sysctl kern.maxvnodes | awk '{ print $3; }' >oldvnodes
+	sysctl -n kern.maxvnodes >oldvnodes
 	atf_check -s eq:0 -o ignore -e empty sysctl -w kern.maxvnodes=2000
 
 	test_mount -o -s$(((4000 + 2) * 4096))



CVS commit: src/tests/fs/tmpfs

2018-01-16 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Jan 17 00:22:29 UTC 2018

Modified Files:
src/tests/fs/tmpfs: h_tools.c

Log Message:
- Add inttypes.h #include for PR* macros.
- close fd when done to prevent leak.
- use correct socket length when calling bind(2).

>From Ngie Cooper in PR bin/51870


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/fs/tmpfs/h_tools.c

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

Modified files:

Index: src/tests/fs/tmpfs/h_tools.c
diff -u src/tests/fs/tmpfs/h_tools.c:1.4 src/tests/fs/tmpfs/h_tools.c:1.5
--- src/tests/fs/tmpfs/h_tools.c:1.4	Sat Jun 11 18:03:17 2011
+++ src/tests/fs/tmpfs/h_tools.c	Wed Jan 17 00:22:29 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_tools.c,v 1.4 2011/06/11 18:03:17 christos Exp $	*/
+/*	$NetBSD: h_tools.c,v 1.5 2018/01/17 00:22:29 maya Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -45,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -230,12 +231,13 @@ sockets_main(int argc, char **argv)
 		return EXIT_FAILURE;
 	}
 
+	memset(, 0, sizeof(addr));
 	(void)strlcpy(addr.sun_path, argv[1], sizeof(addr.sun_path));
 	addr.sun_family = PF_UNIX;
-
-	error = bind(fd, (struct sockaddr *), sizeof(addr));
+	error = bind(fd, (struct sockaddr *), SUN_LEN());
 	if (error == -1) {
 		warn("connect");
+		(void)close(fd);
 		return EXIT_FAILURE;
 	}
 



CVS commit: src/tests/fs/tmpfs

2017-03-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Mar 23 08:18:17 UTC 2017

Modified Files:
src/tests/fs/tmpfs: t_vnd.sh

Log Message:
Do not assume anything about the pseudo-disklabel of a completely zeroed
disk image. Use the raw partition and newfs -I instead.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/fs/tmpfs/t_vnd.sh

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

Modified files:

Index: src/tests/fs/tmpfs/t_vnd.sh
diff -u src/tests/fs/tmpfs/t_vnd.sh:1.9 src/tests/fs/tmpfs/t_vnd.sh:1.10
--- src/tests/fs/tmpfs/t_vnd.sh:1.9	Fri Jul 29 05:23:24 2016
+++ src/tests/fs/tmpfs/t_vnd.sh	Thu Mar 23 08:18:17 2017
@@ -1,4 +1,4 @@
-# $NetBSD: t_vnd.sh,v 1.9 2016/07/29 05:23:24 pgoyette Exp $
+# $NetBSD: t_vnd.sh,v 1.10 2017/03/23 08:18:17 martin Exp $
 #
 # Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -28,6 +28,10 @@
 # Verifies that vnd works with files stored in tmpfs.
 #
 
+vnddev=vnd3
+rawpart=$( sysctl -n kern.rawpartition | tr '01234' 'abcde' )
+vnd=/dev/${vnddev}${rawpart}
+
 atf_test_case basic cleanup
 basic_head() {
 	atf_set "descr" "Verifies that vnd works with files stored in tmpfs"
@@ -38,12 +42,12 @@ basic_body() {
 
 	atf_check -s eq:0 -o ignore -e ignore \
 	dd if=/dev/zero of=disk.img bs=1m count=10
-	atf_check -s eq:0 -o empty -e empty vndconfig /dev/vnd3 disk.img
+	atf_check -s eq:0 -o empty -e empty vndconfig -c ${vnddev} disk.img
 
-	atf_check -s eq:0 -o ignore -e ignore newfs /dev/rvnd3a
+	atf_check -s eq:0 -o ignore -e ignore newfs -I ${vnd}
 
 	atf_check -s eq:0 -o empty -e empty mkdir mnt
-	atf_check -s eq:0 -o empty -e empty mount /dev/vnd3a mnt
+	atf_check -s eq:0 -o empty -e empty mount ${vnd} mnt
 
 	echo "Creating test files"
 	for f in $(jot -w %u 100 | uniq); do
@@ -58,7 +62,7 @@ basic_body() {
 	done
 
 	atf_check -s eq:0 -o empty -e empty umount mnt
-	atf_check -s eq:0 -o empty -e empty vndconfig -u /dev/vnd3
+	atf_check -s eq:0 -o empty -e empty vndconfig -u ${vnddev}
 
 	test_unmount
 	touch done
@@ -66,7 +70,7 @@ basic_body() {
 basic_cleanup() {
 	if [ ! -f done ]; then
 		umount mnt 2>/dev/null 1>&2
-		vndconfig -u /dev/vnd3 2>/dev/null 1>&2
+		vndconfig -u ${vnddev} 2>/dev/null 1>&2
 	fi
 }
 



CVS commit: src/tests/fs/tmpfs

2016-07-28 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Jul 29 05:23:24 UTC 2016

Modified Files:
src/tests/fs/tmpfs: t_vnd.sh

Log Message:
Update the test - the "official" name of the vnd configuration utility
was changed in NetBSD 7 to vndconfig(8).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/fs/tmpfs/t_vnd.sh

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

Modified files:

Index: src/tests/fs/tmpfs/t_vnd.sh
diff -u src/tests/fs/tmpfs/t_vnd.sh:1.8 src/tests/fs/tmpfs/t_vnd.sh:1.9
--- src/tests/fs/tmpfs/t_vnd.sh:1.8	Thu Apr 21 22:26:46 2011
+++ src/tests/fs/tmpfs/t_vnd.sh	Fri Jul 29 05:23:24 2016
@@ -1,4 +1,4 @@
-# $NetBSD: t_vnd.sh,v 1.8 2011/04/21 22:26:46 haad Exp $
+# $NetBSD: t_vnd.sh,v 1.9 2016/07/29 05:23:24 pgoyette Exp $
 #
 # Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -38,7 +38,7 @@ basic_body() {
 
 	atf_check -s eq:0 -o ignore -e ignore \
 	dd if=/dev/zero of=disk.img bs=1m count=10
-	atf_check -s eq:0 -o empty -e empty vnconfig /dev/vnd3 disk.img
+	atf_check -s eq:0 -o empty -e empty vndconfig /dev/vnd3 disk.img
 
 	atf_check -s eq:0 -o ignore -e ignore newfs /dev/rvnd3a
 
@@ -58,7 +58,7 @@ basic_body() {
 	done
 
 	atf_check -s eq:0 -o empty -e empty umount mnt
-	atf_check -s eq:0 -o empty -e empty vnconfig -u /dev/vnd3
+	atf_check -s eq:0 -o empty -e empty vndconfig -u /dev/vnd3
 
 	test_unmount
 	touch done
@@ -66,7 +66,7 @@ basic_body() {
 basic_cleanup() {
 	if [ ! -f done ]; then
 		umount mnt 2>/dev/null 1>&2
-		vnconfig -u /dev/vnd3 2>/dev/null 1>&2
+		vndconfig -u /dev/vnd3 2>/dev/null 1>&2
 	fi
 }
 



CVS commit: src/tests/fs/tmpfs

2013-03-16 Thread Julio Merino
Module Name:src
Committed By:   jmmv
Date:   Sun Mar 17 01:16:45 UTC 2013

Modified Files:
src/tests/fs/tmpfs: h_funcs.subr

Log Message:
Simplify test_mount and log errors.

If mount_tmpfs fails, show what the stderr output of the command was instead
of failing without details.

While doing this, remove the stupidity to deal with the optional arguments
to the test_mount routine.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/fs/tmpfs/h_funcs.subr

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

Modified files:

Index: src/tests/fs/tmpfs/h_funcs.subr
diff -u src/tests/fs/tmpfs/h_funcs.subr:1.4 src/tests/fs/tmpfs/h_funcs.subr:1.5
--- src/tests/fs/tmpfs/h_funcs.subr:1.4	Mon Feb 21 10:14:29 2011
+++ src/tests/fs/tmpfs/h_funcs.subr	Sun Mar 17 01:16:45 2013
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: h_funcs.subr,v 1.4 2011/02/21 10:14:29 pooka Exp $
+# $NetBSD: h_funcs.subr,v 1.5 2013/03/17 01:16:45 jmmv Exp $
 #
 # Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -40,25 +40,17 @@ test_mount() {
 	require_fs tmpfs
 
 	Mount_Point=$(pwd)/mntpt
-	atf_check -s eq:0 -o empty -e empty mkdir ${Mount_Point}
-	if [ $# -gt 0 ]; then
-		mount -t tmpfs $* tmpfs ${Mount_Point} 2 mounterr
-		if [ $? -ne 0 ]; then
-			if grep 'Operation not supp' mounterr  /dev/null ; then
-atf_skip tmpfs not supported
-			fi 
-			atf_fail mount tmpfs
-		fi
-else
-		mount -t tmpfs tmpfs ${Mount_Point} 2 mounterr
-		if [ $? -ne 0 ]; then
-			if grep 'Operation not supp' mounterr  /dev/null ; then
-atf_skip tmpfs not supported
-			fi 
-			atf_fail mount tmpfs
-		fi
+	atf_check -s eq:0 -o empty -e empty mkdir ${Mount_Point}
+	echo mount -t tmpfs ${*} tmpfs ${Mount_Point}
+	mount -t tmpfs ${@} tmpfs ${Mount_Point} 2mounterr
+	if [ ${?} -ne 0 ]; then
+		cat mounterr 12
+		if grep 'Operation not supported' mounterr  /dev/null; then
+			atf_skip tmpfs not supported
+		fi 
+		atf_fail Failed to mount a tmpfs file system
 	fi
-	cd ${Mount_Point}
+	cd ${Mount_Point}
 }
 
 #



CVS commit: src/tests/fs/tmpfs

2011-08-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Aug 18 21:44:55 UTC 2011

Modified Files:
src/tests/fs/tmpfs: t_renamerace.c

Log Message:
No more xfail for PR kern/36681.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/fs/tmpfs/t_renamerace.c

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

Modified files:

Index: src/tests/fs/tmpfs/t_renamerace.c
diff -u src/tests/fs/tmpfs/t_renamerace.c:1.12 src/tests/fs/tmpfs/t_renamerace.c:1.13
--- src/tests/fs/tmpfs/t_renamerace.c:1.12	Tue Jan  4 18:46:21 2011
+++ src/tests/fs/tmpfs/t_renamerace.c	Thu Aug 18 21:44:55 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_renamerace.c,v 1.12 2011/01/04 18:46:21 pooka Exp $	*/
+/*	$NetBSD: t_renamerace.c,v 1.13 2011/08/18 21:44:55 riastradh Exp $	*/
 
 /*
  * Modified for rump and atf from a program supplied
@@ -103,8 +103,6 @@
 	sleep(4);
 	quittingtime = 1;
 
-	atf_tc_expect_timeout(PR kern/36681);
-
 	pthread_join(pt[0], NULL);
 	pthread_join(pt[1], NULL);
 }



CVS commit: src/tests/fs/tmpfs

2011-04-21 Thread Adam Hamsik
Module Name:src
Committed By:   haad
Date:   Thu Apr 21 22:26:46 UTC 2011

Modified Files:
src/tests/fs/tmpfs: t_vnd.sh

Log Message:
Workaround problem with qemu where jot 100 produce garbage otput like this

93
94
:+
:,
:-
:.
:/
100

This can't be used as name of file, change jot cmd to work in all cases.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/fs/tmpfs/t_vnd.sh

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

Modified files:

Index: src/tests/fs/tmpfs/t_vnd.sh
diff -u src/tests/fs/tmpfs/t_vnd.sh:1.7 src/tests/fs/tmpfs/t_vnd.sh:1.8
--- src/tests/fs/tmpfs/t_vnd.sh:1.7	Thu Mar 24 21:52:51 2011
+++ src/tests/fs/tmpfs/t_vnd.sh	Thu Apr 21 22:26:46 2011
@@ -1,4 +1,4 @@
-# $NetBSD: t_vnd.sh,v 1.7 2011/03/24 21:52:51 jmmv Exp $
+# $NetBSD: t_vnd.sh,v 1.8 2011/04/21 22:26:46 haad Exp $
 #
 # Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -46,12 +46,12 @@
 	atf_check -s eq:0 -o empty -e empty mount /dev/vnd3a mnt
 
 	echo Creating test files
-	for f in $(jot 100); do
+	for f in $(jot -w %u 100 | uniq); do
 		jot 1000 mnt/${f} || atf_fail Failed to create file ${f}
 	done
 
 	echo Verifying created files
-	for f in $(jot 100); do
+	for f in $(jot -w %u 100 | uniq); do
 		[ $(md5 mnt/${f} | cut -d ' ' -f 4) = \
 		53d025127ae99ab79e8502aae2d9bea6 ] || \
 		atf_fail Invalid checksum for file ${f}



CVS commit: src/tests/fs/tmpfs

2011-03-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sat Mar  5 07:41:12 UTC 2011

Modified Files:
src/tests/fs/tmpfs: t_create.sh t_mkdir.sh

Log Message:
chown the workdir to unpriv user instead of chmod 711.  Otherwise,
if your (root's) login shell is {t,}csh, su -m gets outoutsmarted.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/fs/tmpfs/t_create.sh \
src/tests/fs/tmpfs/t_mkdir.sh

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

Modified files:

Index: src/tests/fs/tmpfs/t_create.sh
diff -u src/tests/fs/tmpfs/t_create.sh:1.7 src/tests/fs/tmpfs/t_create.sh:1.8
--- src/tests/fs/tmpfs/t_create.sh:1.7	Tue Nov  9 13:01:33 2010
+++ src/tests/fs/tmpfs/t_create.sh	Sat Mar  5 07:41:11 2011
@@ -1,4 +1,4 @@
-# $NetBSD: t_create.sh,v 1.7 2010/11/09 13:01:33 jmmv Exp $
+# $NetBSD: t_create.sh,v 1.8 2011/03/05 07:41:11 pooka Exp $
 #
 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -52,8 +52,9 @@
 	atf_set require.user root
 }
 attrs_body() {
+	user=$(atf_config_get unprivileged-user)
 	# Allow the unprivileged user to access the work directory.
-	chmod 711 .
+	chown ${user} .
 
 	test_mount
 
@@ -70,8 +71,6 @@
 	test ${st_gid} -eq ${dst_gid} || atf_fail Incorrect gid
 	test ${st_mode} = 0100644 || atf_fail Incorrect mode
 
-	user=$(atf_config_get unprivileged-user)
-
 	atf_check -s eq:0 -o empty -e empty mkdir b c
 
 	atf_check -s eq:0 -o empty -e empty chown ${user}:0 b
Index: src/tests/fs/tmpfs/t_mkdir.sh
diff -u src/tests/fs/tmpfs/t_mkdir.sh:1.7 src/tests/fs/tmpfs/t_mkdir.sh:1.8
--- src/tests/fs/tmpfs/t_mkdir.sh:1.7	Mon Nov  8 15:25:50 2010
+++ src/tests/fs/tmpfs/t_mkdir.sh	Sat Mar  5 07:41:11 2011
@@ -1,4 +1,4 @@
-# $NetBSD: t_mkdir.sh,v 1.7 2010/11/08 15:25:50 pooka Exp $
+# $NetBSD: t_mkdir.sh,v 1.8 2011/03/05 07:41:11 pooka Exp $
 #
 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -92,13 +92,12 @@
 	atf_set require.user root
 }
 attrs_body() {
+	user=$(atf_config_get unprivileged-user)
 	# Allow the unprivileged user to access the work directory.
-	chmod 711 .
+	chown ${user} .
 
 	test_mount
 
-	user=$(atf_config_get unprivileged-user)
-
 	atf_check -s eq:0 -o empty -e empty mkdir b c
 
 	atf_check -s eq:0 -o empty -e empty chown ${user}:0 b



CVS commit: src/tests/fs/tmpfs

2011-01-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jan 15 20:16:58 UTC 2011

Modified Files:
src/tests/fs/tmpfs: h_tools.c

Log Message:
Fix off by one that made most of these tests die with a bus error in the
sparc64 runs.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/fs/tmpfs/h_tools.c

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

Modified files:

Index: src/tests/fs/tmpfs/h_tools.c
diff -u src/tests/fs/tmpfs/h_tools.c:1.2 src/tests/fs/tmpfs/h_tools.c:1.3
--- src/tests/fs/tmpfs/h_tools.c:1.2	Mon Apr 28 20:24:12 2008
+++ src/tests/fs/tmpfs/h_tools.c	Sat Jan 15 20:16:57 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_tools.c,v 1.2 2008/04/28 20:24:12 martin Exp $	*/
+/*	$NetBSD: h_tools.c,v 1.3 2011/01/15 20:16:57 martin Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -124,7 +124,7 @@
 	argc--;
 	argv++;
 
-	changes = malloc(sizeof(struct kevent) * (argc - 1));
+	changes = malloc(sizeof(struct kevent) * argc);
 	if (changes == NULL)
 		errx(EXIT_FAILURE, not enough memory);
 



CVS commit: src/tests/fs/tmpfs

2011-01-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Jan  4 16:25:20 UTC 2011

Modified Files:
src/tests/fs/tmpfs: t_renamerace.c

Log Message:
Remove arch check now that rump smp is available on all host archs.


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

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

Modified files:

Index: src/tests/fs/tmpfs/t_renamerace.c
diff -u src/tests/fs/tmpfs/t_renamerace.c:1.10 src/tests/fs/tmpfs/t_renamerace.c:1.11
--- src/tests/fs/tmpfs/t_renamerace.c:1.10	Sun Jan  2 12:58:17 2011
+++ src/tests/fs/tmpfs/t_renamerace.c	Tue Jan  4 16:25:20 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_renamerace.c,v 1.10 2011/01/02 12:58:17 pooka Exp $	*/
+/*	$NetBSD: t_renamerace.c,v 1.11 2011/01/04 16:25:20 pooka Exp $	*/
 
 /*
  * Modified for rump and atf from a program supplied
@@ -80,16 +80,6 @@
 	pthread_t pt[2];
 
 	/*
-	 * Check that we are running on an SMP-capable arch.  It should
-	 * be a rump capability, but after the CPU_INFO_FOREACH is
-	 * fixed, it will be every arch (for rump), so don't bother.
-	 */
-	if (uname(un) == -1)
-		atf_tc_fail_errno(uname);
-	if (strcmp(un.machine, i386) != 0  strcmp(un.machine, amd64) != 0)
-		atf_tc_skip(i386 or amd64 required (have %s), un.machine);
-
-	/*
 	 * Force SMP regardless of how many host CPUs there are.
 	 * Deadlock is highly unlikely to trigger otherwise.
 	 */



CVS commit: src/tests/fs/tmpfs

2010-11-09 Thread Julio Merino
Module Name:src
Committed By:   jmmv
Date:   Tue Nov  9 13:01:34 UTC 2010

Modified Files:
src/tests/fs/tmpfs: t_create.sh

Log Message:
Remove ugly workaround to skip this if unprivileged-user=_atf and just use
'su -m' as pooka@ did in t_mkdir.sh.  As he says this may still fail if
root's shell is csh; we need a better solution.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/fs/tmpfs/t_create.sh

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

Modified files:

Index: src/tests/fs/tmpfs/t_create.sh
diff -u src/tests/fs/tmpfs/t_create.sh:1.6 src/tests/fs/tmpfs/t_create.sh:1.7
--- src/tests/fs/tmpfs/t_create.sh:1.6	Sun Nov  7 17:51:18 2010
+++ src/tests/fs/tmpfs/t_create.sh	Tue Nov  9 13:01:33 2010
@@ -1,4 +1,4 @@
-# $NetBSD: t_create.sh,v 1.6 2010/11/07 17:51:18 jmmv Exp $
+# $NetBSD: t_create.sh,v 1.7 2010/11/09 13:01:33 jmmv Exp $
 #
 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -84,17 +84,12 @@
 	[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail Incorrect owner
 	[ ${st_gid} -eq 100 ] || atf_fail Incorrect group
 
-	if [ ${user} = _atf ]; then
-		atf_expect_fail We can't 'su ${user}' to run a test command \
-		because it doesn't have a login shell
-	fi
-
-	atf_check -s eq:0 -o empty -e empty su ${user} -c 'touch b/a'
+	atf_check -s eq:0 -o empty -e empty su -m ${user} -c 'touch b/a'
 	eval $(stat -s b/a)
 	[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail Incorrect owner
 	[ ${st_gid} -eq 0 ] || atf_fail Incorrect group
 
-	atf_check -s eq:0 -o empty -e empty su ${user} -c 'touch c/a'
+	atf_check -s eq:0 -o empty -e empty su -m ${user} -c 'touch c/a'
 	eval $(stat -s c/a)
 	[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail Incorrect owner
 	[ ${st_gid} -eq 100 ] || atf_fail Incorrect group



CVS commit: src/tests/fs/tmpfs

2010-11-08 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Nov  8 15:25:50 UTC 2010

Modified Files:
src/tests/fs/tmpfs: t_mkdir.sh

Log Message:
Use su -m since _atf has nologin as its shell.
XXX: this will still fail if root's shell is csh


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/fs/tmpfs/t_mkdir.sh

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

Modified files:

Index: src/tests/fs/tmpfs/t_mkdir.sh
diff -u src/tests/fs/tmpfs/t_mkdir.sh:1.6 src/tests/fs/tmpfs/t_mkdir.sh:1.7
--- src/tests/fs/tmpfs/t_mkdir.sh:1.6	Sun Nov  7 17:51:18 2010
+++ src/tests/fs/tmpfs/t_mkdir.sh	Mon Nov  8 15:25:50 2010
@@ -1,4 +1,4 @@
-# $NetBSD: t_mkdir.sh,v 1.6 2010/11/07 17:51:18 jmmv Exp $
+# $NetBSD: t_mkdir.sh,v 1.7 2010/11/08 15:25:50 pooka Exp $
 #
 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -111,12 +111,12 @@
 	[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail Incorrect owner
 	[ ${st_gid} -eq 100 ] || atf_fail Incorrect group
 
-	atf_check -s eq:0 -o empty -e empty su ${user} -c 'mkdir b/a'
+	atf_check -s eq:0 -o empty -e empty su -m ${user} -c 'mkdir b/a'
 	eval $(stat -s b/a)
 	[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail Incorrect owner
 	[ ${st_gid} -eq 0 ] || atf_fail Incorrect group
 
-	atf_check -s eq:0 -o empty -e empty su ${user} -c 'mkdir c/a'
+	atf_check -s eq:0 -o empty -e empty su -m ${user} -c 'mkdir c/a'
 	eval $(stat -s c/a)
 	[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail Incorrect owner
 	[ ${st_gid} -eq 100 ] || atf_fail Incorrect group



CVS commit: src/tests/fs/tmpfs

2010-07-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sun Jul  4 12:43:23 UTC 2010

Modified Files:
src/tests/fs/tmpfs: t_renamerace.c

Log Message:
Add a test case for PR kern/36681 demonstrating how easy it is to
get tmpfs rename to tstile.

Note1: triggering this on any non-SMP system is not as easy (because
one system call tends to run from start to finish in one go) and
therefore I've limited it to i386 and amd64.  Incidentally, I'm
still waiting for the eternally elusive MI CPU_INFO_FOREACH (or at
least something else than a stupid macro) ...

Note2: this is a race condition test.  I tested it on my development
host and in qemu and it triggers pretty instantly.  But YMMV.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/fs/tmpfs/t_renamerace.c

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

Modified files:

Index: src/tests/fs/tmpfs/t_renamerace.c
diff -u src/tests/fs/tmpfs/t_renamerace.c:1.6 src/tests/fs/tmpfs/t_renamerace.c:1.7
--- src/tests/fs/tmpfs/t_renamerace.c:1.6	Sun Apr 26 15:15:38 2009
+++ src/tests/fs/tmpfs/t_renamerace.c	Sun Jul  4 12:43:23 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_renamerace.c,v 1.6 2009/04/26 15:15:38 pooka Exp $	*/
+/*	$NetBSD: t_renamerace.c,v 1.7 2010/07/04 12:43:23 pooka Exp $	*/
 
 /*
  * Modified for rump and atf from a program supplied
@@ -7,14 +7,16 @@
 
 #include sys/types.h
 #include sys/mount.h
+#include sys/utsname.h
 
 #include atf-c.h
 #include errno.h
 #include fcntl.h
 #include pthread.h
 #include stdio.h
-#include unistd.h
+#include stdlib.h
 #include string.h
+#include unistd.h
 
 #include rump/rump.h
 #include rump/rump_syscalls.h
@@ -73,8 +75,102 @@
 	sleep(10);
 }
 
+ATF_TC(renamerace2);
+ATF_TC_HEAD(renamerace2, tc)
+{
+	atf_tc_set_md_var(tc, descr, rename(2) lock order inversion);
+	atf_tc_set_md_var(tc, timeout, 6);
+}
+
+static volatile int quittingtime = 0;
+
+static void *
+r2w1(void *arg)
+{
+	int fd;
+
+	rump_pub_lwp_alloc_and_switch(0, 0);
+
+	fd = rump_sys_open(/file, O_CREAT | O_RDWR, 0777);
+	if (fd == -1)
+		atf_tc_fail_errno(creat);
+	rump_sys_close(fd);
+
+	while (!quittingtime) {
+		if (rump_sys_rename(/file, /dir/file) == -1)
+			atf_tc_fail_errno(rename 1);
+		if (rump_sys_rename(/dir/file, /file) == -1)
+			atf_tc_fail_errno(rename 2);
+	}
+
+	return NULL;
+}
+
+static void *
+r2w2(void *arg)
+{
+	int fd;
+
+	rump_pub_lwp_alloc_and_switch(0, 0);
+
+	while (!quittingtime) {
+		fd = rump_sys_open(/dir/file1, O_RDWR);
+		if (fd != -1)
+			rump_sys_close(fd);
+	}
+
+	return NULL;
+}
+
+ATF_TC_BODY(renamerace2, tc)
+{
+	struct tmpfs_args args;
+	struct utsname un;
+	pthread_t pt[2];
+
+	/*
+	 * Check that we are running on an SMP-capable arch.  It should
+	 * be a rump capability, but after the CPU_INFO_FOREACH is
+	 * fixed, it will be every arch (for rump), so don't bother.
+	 */
+	if (uname(un) == -1)
+		atf_tc_fail_errno(uname);
+	if (strcmp(un.machine, i386) != 0  strcmp(un.machine, amd64) != 0)
+		atf_tc_skip(i386 or amd64 required (have %s), un.machine);
+
+	/*
+	 * Force SMP regardless of how many host CPUs there are.
+	 * Deadlock is highly unlikely to trigger otherwise.
+	 */
+	setenv(RUMP_NCPU, 2, 1);
+
+	rump_init();
+	memset(args, 0, sizeof(args));
+	args.ta_version = TMPFS_ARGS_VERSION;
+	args.ta_root_mode = 0777;
+	if (rump_sys_mount(MOUNT_TMPFS, /, 0, args, sizeof(args)) == -1)
+		atf_tc_fail_errno(could not mount tmpfs);
+
+	if (rump_sys_mkdir(/dir, 0777) == -1)
+		atf_tc_fail_errno(cannot create directory);
+
+	pthread_create(pt[0], NULL, r2w1, NULL);
+	pthread_create(pt[1], NULL, r2w2, NULL);
+
+	/* usually triggers in 1s for me */
+	sleep(4);
+	quittingtime = 1;
+
+	atf_tc_expect_timeout(PR kern/36681);
+
+	pthread_join(pt[0], NULL);
+	pthread_join(pt[1], NULL);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, renamerace);
-	return 0; /*XXX?*/
+	ATF_TP_ADD_TC(tp, renamerace2);
+
+	return atf_no_error();
 }



CVS commit: src/tests/fs/tmpfs

2010-06-06 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Mon Jun  7 03:39:41 UTC 2010

Modified Files:
src/tests/fs/tmpfs: t_create.sh t_mkdir.sh

Log Message:
Use atf_check to su in a couple cases, to make the test failure
easier to understand when the unprivileged user has /sbin/nologin
for a shell.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/fs/tmpfs/t_create.sh \
src/tests/fs/tmpfs/t_mkdir.sh

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

Modified files:

Index: src/tests/fs/tmpfs/t_create.sh
diff -u src/tests/fs/tmpfs/t_create.sh:1.4 src/tests/fs/tmpfs/t_create.sh:1.5
--- src/tests/fs/tmpfs/t_create.sh:1.4	Fri Jun  4 08:39:40 2010
+++ src/tests/fs/tmpfs/t_create.sh	Mon Jun  7 03:39:41 2010
@@ -1,4 +1,4 @@
-# $NetBSD: t_create.sh,v 1.4 2010/06/04 08:39:40 jmmv Exp $
+# $NetBSD: t_create.sh,v 1.5 2010/06/07 03:39:41 riz Exp $
 #
 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -86,12 +86,12 @@
 	[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail Incorrect owner
 	[ ${st_gid} -eq 100 ] || atf_fail Incorrect group
 
-	su ${user} -c 'touch b/a'
+	atf_check -s eq:0 -o empty -e empty su ${user} -c 'touch b/a'
 	eval $(stat -s b/a)
 	[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail Incorrect owner
 	[ ${st_gid} -eq 0 ] || atf_fail Incorrect group
 
-	su ${user} -c 'touch c/a'
+	atf_check -s eq:0 -o empty -e empty su ${user} -c 'touch c/a'
 	eval $(stat -s c/a)
 	[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail Incorrect owner
 	[ ${st_gid} -eq 100 ] || atf_fail Incorrect group
Index: src/tests/fs/tmpfs/t_mkdir.sh
diff -u src/tests/fs/tmpfs/t_mkdir.sh:1.4 src/tests/fs/tmpfs/t_mkdir.sh:1.5
--- src/tests/fs/tmpfs/t_mkdir.sh:1.4	Fri Jun  4 08:39:40 2010
+++ src/tests/fs/tmpfs/t_mkdir.sh	Mon Jun  7 03:39:41 2010
@@ -1,4 +1,4 @@
-# $NetBSD: t_mkdir.sh,v 1.4 2010/06/04 08:39:40 jmmv Exp $
+# $NetBSD: t_mkdir.sh,v 1.5 2010/06/07 03:39:41 riz Exp $
 #
 # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -115,12 +115,12 @@
 	[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail Incorrect owner
 	[ ${st_gid} -eq 100 ] || atf_fail Incorrect group
 
-	su ${user} -c 'mkdir b/a'
+	atf_check -s eq:0 -o empty -e empty su ${user} -c 'mkdir b/a'
 	eval $(stat -s b/a)
 	[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail Incorrect owner
 	[ ${st_gid} -eq 0 ] || atf_fail Incorrect group
 
-	su ${user} -c 'mkdir c/a'
+	atf_check -s eq:0 -o empty -e empty su ${user} -c 'mkdir c/a'
 	eval $(stat -s c/a)
 	[ ${st_uid} -eq $(id -u ${user}) ] || atf_fail Incorrect owner
 	[ ${st_gid} -eq 100 ] || atf_fail Incorrect group



CVS commit: src/tests/fs/tmpfs

2009-04-08 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Apr  8 09:05:16 UTC 2009

Modified Files:
src/tests/fs/tmpfs: t_renamerace.c

Log Message:
atf_tc_fail() instead of err()


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/fs/tmpfs/t_renamerace.c

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

Modified files:

Index: src/tests/fs/tmpfs/t_renamerace.c
diff -u src/tests/fs/tmpfs/t_renamerace.c:1.2 src/tests/fs/tmpfs/t_renamerace.c:1.3
--- src/tests/fs/tmpfs/t_renamerace.c:1.2	Wed Apr  8 08:57:24 2009
+++ src/tests/fs/tmpfs/t_renamerace.c	Wed Apr  8 09:05:16 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_renamerace.c,v 1.2 2009/04/08 08:57:24 pooka Exp $	*/
+/*	$NetBSD: t_renamerace.c,v 1.3 2009/04/08 09:05:16 pooka Exp $	*/
 
 /*
  * Modified for rump and atf from a program supplied
@@ -9,7 +9,6 @@
 #include sys/mount.h
 
 #include atf-c.h
-#include err.h
 #include errno.h
 #include fcntl.h
 #include pthread.h
@@ -67,7 +66,7 @@
   ukfs_init();
   fs = ukfs_mount(MOUNT_TMPFS, tmpfs, UKFS_DEFAULTMP, 0, args, sizeof(args));
   if (fs == NULL)
-err(1, ukfs_mount);
+atf_tc_fail(could not mount tmpfs: %d (%s), errno, strerror(errno));
 
   pthread_create(pt1, NULL, w1, fs);
   pthread_create(pt2, NULL, w2, fs);



CVS commit: src/tests/fs/tmpfs

2009-04-07 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Apr  7 20:51:46 UTC 2009

Modified Files:
src/tests/fs/tmpfs: Atffile Makefile
Added Files:
src/tests/fs/tmpfs: t_renamerace.c

Log Message:
add regression test for kern/41128


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/fs/tmpfs/Atffile
cvs rdiff -u -r1.2 -r1.3 src/tests/fs/tmpfs/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/fs/tmpfs/t_renamerace.c

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

Modified files:

Index: src/tests/fs/tmpfs/Atffile
diff -u src/tests/fs/tmpfs/Atffile:1.4 src/tests/fs/tmpfs/Atffile:1.5
--- src/tests/fs/tmpfs/Atffile:1.4	Sun Dec 30 09:13:32 2007
+++ src/tests/fs/tmpfs/Atffile	Tue Apr  7 20:51:46 2009
@@ -1,5 +1,5 @@
 Content-Type: application/X-atf-atffile; version=1
-X-NetBSD-Id: $NetBSD: Atffile,v 1.4 2007/12/30 09:13:32 jmmv Exp $
+X-NetBSD-Id: $NetBSD: Atffile,v 1.5 2009/04/07 20:51:46 pooka Exp $
 
 prop: test-suite = NetBSD
 
@@ -28,3 +28,4 @@
 tp: t_sockets
 tp: t_readdir
 tp: t_vnd
+tp: t_renamerace

Index: src/tests/fs/tmpfs/Makefile
diff -u src/tests/fs/tmpfs/Makefile:1.2 src/tests/fs/tmpfs/Makefile:1.3
--- src/tests/fs/tmpfs/Makefile:1.2	Wed Nov 21 15:39:34 2007
+++ src/tests/fs/tmpfs/Makefile	Tue Apr  7 20:51:46 2009
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2007/11/21 15:39:34 jmmv Exp $
+# $NetBSD: Makefile,v 1.3 2009/04/07 20:51:46 pooka Exp $
 
 TESTSDIR=	${TESTSBASE}/fs/tmpfs
 
@@ -28,6 +28,10 @@
 TESTS_SH+=	t_vnd
 TESTS_SH+=	t_vnode_leak
 
+TESTS_C+=	t_renamerace
+
+LDADD.t_renamerace+= -lukfs -lrumpfs_tmpfs -lrumpvfs -lrump -lrumpuser -lpthread
+
 FILES=		h_funcs.subr
 FILESDIR=	${TESTSDIR}
 

Added files:

Index: src/tests/fs/tmpfs/t_renamerace.c
diff -u /dev/null src/tests/fs/tmpfs/t_renamerace.c:1.1
--- /dev/null	Tue Apr  7 20:51:46 2009
+++ src/tests/fs/tmpfs/t_renamerace.c	Tue Apr  7 20:51:46 2009
@@ -0,0 +1,87 @@
+/*	$NetBSD: t_renamerace.c,v 1.1 2009/04/07 20:51:46 pooka Exp $	*/
+
+/*
+ * Modified for rump and atf from a program supplied
+ * by Nicolas Joly in kern/40948
+ */
+
+#include sys/types.h
+#include sys/mount.h
+
+#include atf-c.h
+#include err.h
+#include errno.h
+#include fcntl.h
+#include pthread.h
+#include stdio.h
+#include unistd.h
+#include string.h
+
+#include rump/rump.h
+#include rump/rump_syscalls.h
+#include rump/ukfs.h
+
+#include fs/tmpfs/tmpfs_args.h
+
+#define NROUND (116) /* usually triggered with this amount of rounds */
+
+ATF_TC(renamerace);
+ATF_TC_HEAD(renamerace, tc)
+{
+	atf_tc_set_md_var(tc, descr, rename(2) race against files 
+	unlinked mid-operation, kern/41128);
+}
+
+void *
+w1(void *arg)
+{
+  int fd, i;
+
+  for (i = 0; i  NROUND; i++) {
+fd = rump_sys_open(/rename.test1, O_WRONLY|O_CREAT|O_TRUNC, 0666);
+rump_sys_unlink(/rename.test1);
+rump_sys_close(fd);
+  }
+  return NULL;
+}
+
+ATF_TC_BODY(renamerace, tc)
+{
+  struct tmpfs_args args;
+  struct ukfs *fs;
+  pthread_t pt;
+  int fail = 0, succ = 0, i;
+
+  memset(args, 0, sizeof(args));
+  args.ta_version = TMPFS_ARGS_VERSION;
+  args.ta_root_mode = 0777;
+
+  ukfs_init();
+  fs = ukfs_mount(MOUNT_TMPFS, tmpfs, UKFS_DEFAULTMP, 0, args, sizeof(args));
+  if (fs == NULL)
+err(1, ukfs_mount);
+
+  pthread_create(pt, NULL, w1, fs);
+
+  for (i = 0; i  NROUND; i++) {
+int rv;
+rv = rump_sys_rename(/rename.test1, /rename.test2);
+#if 0
+if (rv == 0) {
+  if (succ++ % 1 == 0)
+printf(success\n);
+} else {
+  if (fail++ % 1 == 0)
+printf(fail\n);
+}
+#endif
+  }
+
+  pthread_join(pt, NULL);
+  ukfs_release(fs, 0);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+	ATF_TP_ADD_TC(tp, renamerace);
+}