Index: stable/10/contrib/netbsd-tests/fs/h_funcs.subr =================================================================== --- stable/10/contrib/netbsd-tests/fs/h_funcs.subr (revision 313477) +++ stable/10/contrib/netbsd-tests/fs/h_funcs.subr (revision 313478) @@ -1,63 +1,75 @@ #!/bin/sh # # $NetBSD: h_funcs.subr,v 1.3 2010/06/23 11:19:17 pooka Exp $ # # Copyright (c) 2007 The NetBSD Foundation, Inc. # All rights reserved. # # 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. # # # require_fs name # # Checks that the given file system is built into the kernel and # that its corresponding mount(8) utility is available. Otherwise # skips the test. # require_fs() { local name local autoload name="${1}" atf_require_prog mount atf_require_prog mount_${name} atf_require_prog umount # if we have autoloadable modules, just assume the file system atf_require_prog sysctl + # Begin FreeBSD + if true; then + if kldstat -m ${name}; then + found=yes + else + found=no + fi + else + # End FreeBSD autoload=$(sysctl -n kern.module.autoload) [ "${autoload}" = "1" ] && return 0 set -- $(sysctl -n vfs.generic.fstypes) found=no while [ ${#} -gt 1 ]; do if [ ${1} = ${name} ]; then found=yes break fi shift done + # Begin FreeBSD + fi + # End FreeBSD [ ${found} = yes ] || \ atf_skip "The kernel does not include support the " \ "\`${name}' file system" } Index: stable/10/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh =================================================================== --- stable/10/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh (revision 313477) +++ stable/10/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh (revision 313478) @@ -1,143 +1,159 @@ # $NetBSD: t_mknod.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $ # # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc. # All rights reserved. # # 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. # # # Verifies that the mknod operation works. # atf_test_case block block_head() { atf_set "descr" "Tests that block devices can be created" atf_set "require.user" "root" } block_body() { test_mount umask 022 atf_check -s eq:0 -o empty -e empty mknod fd0a b 2 0 eval $(stat -s fd0a) [ ${st_mode} = 060644 ] || atf_fail "Invalid mode" [ ${st_rdev} -eq 512 ] || atf_fail "Invalid device" test_unmount } atf_test_case block_kqueue block_kqueue_head() { atf_set "descr" "Tests that creating a block device raises the" \ "appropriate kqueue events" atf_set "require.user" "root" } block_kqueue_body() { test_mount umask 022 atf_check -s eq:0 -o empty -e empty mkdir dir echo 'mknod dir/fd0a b 2 0' | kqueue_monitor 1 dir kqueue_check dir NOTE_WRITE test_unmount } atf_test_case char char_head() { atf_set "descr" "Tests that character devices can be created" atf_set "require.user" "root" } char_body() { test_mount umask 022 atf_check -s eq:0 -o empty -e empty mknod null c 2 2 eval $(stat -s null) [ ${st_mode} = 020644 ] || atf_fail "Invalid mode" [ ${st_rdev} -eq 514 ] || atf_fail "Invalid device" test_unmount } atf_test_case char_kqueue char_kqueue_head() { atf_set "descr" "Tests that creating a character device raises the" \ "appropriate kqueue events" atf_set "require.user" "root" } char_kqueue_body() { test_mount umask 022 atf_check -s eq:0 -o empty -e empty mkdir dir echo 'mknod dir/null c 2 2' | kqueue_monitor 1 dir kqueue_check dir NOTE_WRITE test_unmount } atf_test_case pipe pipe_head() { atf_set "descr" "Tests that named pipes can be created" atf_set "require.user" "root" } pipe_body() { test_mount umask 022 + # Begin FreeBSD + if true; then + atf_check -s eq:0 -o empty -e empty mkfifo pipe + else + # End FreeBSD atf_check -s eq:0 -o empty -e empty mknod pipe p + # Begin FreeBSD + fi + # End FreeBSD eval $(stat -s pipe) [ ${st_mode} = 010644 ] || atf_fail "Invalid mode" test_unmount } atf_test_case pipe_kqueue pipe_kqueue_head() { atf_set "descr" "Tests that creating a named pipe raises the" \ "appropriate kqueue events" atf_set "require.user" "root" } pipe_kqueue_body() { test_mount umask 022 atf_check -s eq:0 -o empty -e empty mkdir dir + # Begin FreeBSD + if true; then + echo 'mkfifo dir/pipe' | kqueue_monitor 1 dir + else + # End FreeBSD echo 'mknod dir/pipe p' | kqueue_monitor 1 dir + # Begin FreeBSD + fi + # End FreeBSD kqueue_check dir NOTE_WRITE test_unmount } atf_init_test_cases() { . $(atf_get_srcdir)/../h_funcs.subr . $(atf_get_srcdir)/h_funcs.subr atf_add_test_case block atf_add_test_case block_kqueue atf_add_test_case char atf_add_test_case char_kqueue atf_add_test_case pipe atf_add_test_case pipe_kqueue } Index: stable/10/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh =================================================================== --- stable/10/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh (revision 313477) +++ stable/10/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh (revision 313478) @@ -1,116 +1,124 @@ # $NetBSD: t_readdir.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $ # # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc. # All rights reserved. # # 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. # # # Verifies that the readdir operation works. # atf_test_case dots dots_head() { atf_set "descr" "Verifies that readdir returns the '.' and '..'" \ "entries" atf_set "require.user" "root" } dots_body() { test_mount atf_check -s eq:0 -o save:stdout -e empty /bin/ls -a atf_check -s eq:0 -o ignore -e empty grep '^\.$' stdout atf_check -s eq:0 -o ignore -e empty grep '^\..$' stdout test_unmount } atf_test_case types types_head() { atf_set "descr" "Verifies that readdir works for all different" \ "file types" atf_set "require.user" "root" } types_body() { test_mount atf_check -s eq:0 -o empty -e empty mkdir dir atf_check -s eq:0 -o empty -e empty touch reg atf_check -s eq:0 -o empty -e empty ln -s reg lnk atf_check -s eq:0 -o empty -e empty mknod blk b 0 0 atf_check -s eq:0 -o empty -e empty mknod chr c 0 0 + # Begin FreeBSD + if true; then + atf_check -s eq:0 -o empty -e empty mkfifo fifo + else + # End FreeBSD atf_check -s eq:0 -o empty -e empty mknod fifo p + # Begin FreeBSD + fi + # End FreeBSD atf_check -s eq:0 -o empty -e empty \ $(atf_get_srcdir)/h_tools sockets sock atf_check -s eq:0 -o ignore -e empty ls atf_check -s eq:0 -o empty -e empty rm -rf * test_unmount } atf_test_case caching caching_head() { atf_set "descr" "Catch a bug caused by incorrect invalidation of" \ "readdir caching variables" atf_set "require.user" "root" } caching_body() { test_mount atf_check -s eq:0 -o empty -e empty touch $(jot 10) atf_check -s eq:0 -o empty -e empty rm * atf_check -s eq:0 -o empty -e empty touch $(jot 20) atf_check -s eq:0 -o empty -e empty -x "ls >/dev/null" test_unmount } atf_test_case many many_head() { atf_set "descr" "Verifies that readdir works with many files" atf_set "require.user" "root" } many_body() { test_mount atf_check -s eq:0 -o empty -e empty mkdir a echo "Creating 500 files" for f in $(jot 500); do touch a/$f done atf_check -s eq:0 -o empty -e empty rm a/* atf_check -s eq:0 -o empty -e empty rmdir a test_unmount } atf_init_test_cases() { . $(atf_get_srcdir)/../h_funcs.subr . $(atf_get_srcdir)/h_funcs.subr atf_add_test_case dots atf_add_test_case types atf_add_test_case caching atf_add_test_case many } Index: stable/10/contrib/netbsd-tests/fs/tmpfs/t_sizes.sh =================================================================== --- stable/10/contrib/netbsd-tests/fs/tmpfs/t_sizes.sh (revision 313477) +++ stable/10/contrib/netbsd-tests/fs/tmpfs/t_sizes.sh (revision 313478) @@ -1,131 +1,139 @@ # $NetBSD: t_sizes.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $ # # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc. # All rights reserved. # # 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. # # # Verifies that the file system controls memory usage correctly. # atf_test_case small small_head() { atf_set "descr" "Checks the status after creating a small file" atf_set "require.user" "root" } small_body() { test_mount -o -s10M echo a >a || atf_fail "Could not create file" eval $($(atf_get_srcdir)/h_tools statvfs .) f_bused=$((${f_blocks} - ${f_bfree})) [ ${f_bused} -gt 1 ] || atf_fail "Incorrect bused count" atf_check -s eq:0 -o empty -e empty rm a test_unmount } atf_test_case big big_head() { atf_set "descr" "Checks the status after creating a big file" atf_set "require.user" "root" } big_body() { test_mount -o -s10M + # Begin FreeBSD + if true; then + pagesize=$(sysctl -n hw.pagesize) + else + # End FreeBSD pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 3) + # Begin FreeBSD + fi + # End FreeBSD eval $($(atf_get_srcdir)/h_tools statvfs . | sed -e 's|^f_|cf_|') cf_bused=$((${cf_blocks} - ${cf_bfree})) atf_check -s eq:0 -o ignore -e ignore \ dd if=/dev/zero of=a bs=1m count=5 eval $($(atf_get_srcdir)/h_tools statvfs .) f_bused=$((${f_blocks} - ${f_bfree})) [ ${f_bused} -ne ${cf_bused} ] || atf_fail "bused did not change" [ ${f_bused} -gt $((5 * 1024 * 1024 / ${pagesize})) ] || \ atf_fail "bused too big" of_bused=${f_bused} atf_check -s eq:0 -o empty -e empty rm a eval $($(atf_get_srcdir)/h_tools statvfs .) f_bused=$((${f_blocks} - ${f_bfree})) [ ${f_bused} -lt ${of_bused} ] || \ atf_fail "bused was not correctly restored" test_unmount } atf_test_case overflow overflow_head() { atf_set "descr" "Checks the status after creating a big file that" \ "overflows the file system limits" atf_set "require.user" "root" } overflow_body() { test_mount -o -s10M atf_check -s eq:0 -o empty -e empty touch a atf_check -s eq:0 -o empty -e empty rm a eval $($(atf_get_srcdir)/h_tools statvfs .) of_bused=$((${f_blocks} - ${f_bfree})) atf_check -s eq:1 -o ignore -e ignore \ dd if=/dev/zero of=a bs=1m count=15 atf_check -s eq:0 -o empty -e empty rm a eval $($(atf_get_srcdir)/h_tools statvfs .) f_bused=$((${f_blocks} - ${f_bfree})) [ ${f_bused} -ge ${of_bused} -a ${f_bused} -le $((${of_bused} + 1)) ] \ || atf_fail "Incorrect bused" test_unmount } atf_test_case overwrite overwrite_head() { atf_set "descr" "Checks that writing to the middle of a file" \ "does not change its size" atf_set "require.user" "root" } overwrite_body() { test_mount -o -s10M atf_check -s eq:0 -o ignore -e ignore \ dd if=/dev/zero of=a bs=1024 count=10 sync atf_check -s eq:0 -o ignore -e ignore \ dd if=/dev/zero of=a bs=1024 conv=notrunc seek=1 count=1 sync eval $(stat -s a) [ ${st_size} -eq 10240 ] || atf_fail "Incorrect file size" test_unmount } atf_init_test_cases() { . $(atf_get_srcdir)/../h_funcs.subr . $(atf_get_srcdir)/h_funcs.subr atf_add_test_case small atf_add_test_case big atf_add_test_case overflow atf_add_test_case overwrite } Index: stable/10/contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh =================================================================== --- stable/10/contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh (revision 313477) +++ stable/10/contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh (revision 313478) @@ -1,59 +1,67 @@ # $NetBSD: t_statvfs.sh,v 1.4 2010/11/07 17:51:18 jmmv Exp $ # # Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. # All rights reserved. # # 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. # # # Verifies that the statvfs system call works properly (returning the # correct values) over a tmpfs mount point. # atf_test_case values values_head() { atf_set "descr" "Tests that statvfs(2) returns correct values" atf_set "require.user" "root" } values_body() { test_mount -o -s10M + # Begin FreeBSD + if true; then + pagesize=$(sysctl -n hw.pagesize) + else + # End FreeBSD pagesize=$(sysctl hw.pagesize | cut -d ' ' -f 3) + # Begin FreeBSD + fi + # End FreeBSD eval $($(atf_get_srcdir)/h_tools statvfs .) [ ${pagesize} -eq ${f_bsize} ] || \ atf_fail "Invalid bsize" [ $((${f_bsize} * ${f_blocks})) -ge $((10 * 1024 * 1024)) ] || \ atf_file "bsize * blocks too small" [ $((${f_bsize} * ${f_blocks})) -le \ $((10 * 1024 * 1024 + ${pagesize})) ] || \ atf_fail "bsize * blocks too big" test_unmount } atf_init_test_cases() { . $(atf_get_srcdir)/../h_funcs.subr . $(atf_get_srcdir)/h_funcs.subr atf_add_test_case values } Index: stable/10/contrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh =================================================================== --- stable/10/contrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh (revision 313477) +++ stable/10/contrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh (revision 313478) @@ -1,60 +1,68 @@ # $NetBSD: t_vnode_leak.sh,v 1.6 2010/11/07 17:51:18 jmmv Exp $ # # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc. # All rights reserved. # # 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. # atf_test_case main cleanup main_head() { atf_set "descr" "Verifies that vnodes are not leaked and that" \ "their reclaim operation works as expected: i.e.," \ "when all free vnodes are exhausted, unused ones" \ "have to be recycled, which is what the reclaim" \ "operation does." atf_set "require.user" "root" } main_body() { echo "Lowering kern.maxvnodes to 2000" + # Begin FreeBSD + if true; then + sysctl -n kern.maxvnodes > oldvnodes + else + # End FreeBSD sysctl kern.maxvnodes | awk '{ print $3; }' >oldvnodes + # Begin FreeBSD + fi + # End FreeBSD atf_check -s eq:0 -o ignore -e empty sysctl -w kern.maxvnodes=2000 test_mount -o -s$(((4000 + 2) * 4096)) echo "Creating 4000 directories" for f in $(jot 4000); do mkdir ${f} done test_unmount } main_cleanup() { oldvnodes=$(cat oldvnodes) echo "Restoring kern.maxvnodes to ${oldvnodes}" sysctl -w kern.maxvnodes=${oldvnodes} } atf_init_test_cases() { . $(atf_get_srcdir)/../h_funcs.subr . $(atf_get_srcdir)/h_funcs.subr atf_add_test_case main } Index: stable/10/contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c =================================================================== --- stable/10/contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c (revision 313477) +++ stable/10/contrib/netbsd-tests/kernel/kqueue/read/t_fifo.c (revision 313478) @@ -1,98 +1,102 @@ /* $NetBSD: t_fifo.c,v 1.3 2010/11/07 17:51:20 jmmv Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn and Jaromir Dolecek. * * 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 __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); __RCSID("$NetBSD: t_fifo.c,v 1.3 2010/11/07 17:51:20 jmmv Exp $"); #include #include #include #include #include #include #include #include #include #include "../../../h_macros.h" #define FIFONAME "fifo" ATF_TC(fifo); ATF_TC_HEAD(fifo, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_READ on fifo"); } ATF_TC_BODY(fifo, tc) { int kq, n, fd; struct kevent event[1]; char buffer[128]; RL(mkfifo(FIFONAME, 0644)); RL(fd = open(FIFONAME, O_RDWR, 0644)); RL(kq = kqueue()); EV_SET(&event[0], fd, EVFILT_READ, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); /* make sure there is something in the fifo */ RL(write(fd, "foo", 3)); (void)printf("fifo: wrote 'foo'\n"); (void)memset(event, 0, sizeof(event)); RL(n = kevent(kq, NULL, 0, event, 1, NULL)); (void)printf("kevent num %d filt %d flags: %#x, fflags: %#x, " +#ifdef __FreeBSD__ + "data: %" PRIdPTR "\n", n, event[0].filter, event[0].flags, +#else "data: %" PRId64 "\n", n, event[0].filter, event[0].flags, +#endif event[0].fflags, event[0].data); ATF_REQUIRE_EQ(event[0].filter, EVFILT_READ); RL(n = read(fd, buffer, event[0].data)); buffer[n] = '\0'; (void)printf("fifo: read '%s'\n", buffer); RL(close(fd)); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, fifo); return atf_no_error(); } Index: stable/10/contrib/netbsd-tests/kernel/kqueue/read/t_file.c =================================================================== --- stable/10/contrib/netbsd-tests/kernel/kqueue/read/t_file.c (revision 313477) +++ stable/10/contrib/netbsd-tests/kernel/kqueue/read/t_file.c (revision 313478) @@ -1,139 +1,143 @@ /* $NetBSD: t_file.c,v 1.3 2010/11/07 17:51:20 jmmv Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn. * * 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 __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); __RCSID("$NetBSD: t_file.c,v 1.3 2010/11/07 17:51:20 jmmv Exp $"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../../../h_macros.h" #define FILENAME "file" #define NLINES 5 static void child(void) { int i, n, fd; (void)sleep(1); for (i = 0; i < NLINES; ++i) { fd = open(FILENAME, O_WRONLY|O_APPEND, 0644); if (fd < 0) err(EXIT_FAILURE, "open()"); n = write(fd, "foo\n", 4); if (n < 0) err(EXIT_FAILURE, "write()"); (void)close(fd); (void)sleep(1); } _exit(0); } ATF_TC(file); ATF_TC_HEAD(file, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_READ on regular file"); } ATF_TC_BODY(file, tc) { char buffer[128]; struct kevent event[1]; pid_t pid; int fd, kq, n, num, status; RL(pid = fork()); if (pid == 0) { child(); /* NOTREACHED */ } RL(fd = open(FILENAME, O_RDONLY|O_CREAT, 0644)); #if 1 /* XXX: why was this disabled? */ RL(lseek(fd, 0, SEEK_END)); #endif RL(kq = kqueue()); EV_SET(&event[0], fd, EVFILT_READ, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); for (num = 0; num < NLINES;) { RL(n = kevent(kq, NULL, 0, event, 1, NULL)); num += n; (void)printf("kevent num %d flags: %#x, fflags: %#x, data: " +#ifdef __FreeBSD__ + "%" PRIdPTR "\n", n, event[0].flags, event[0].fflags, +#else "%" PRId64 "\n", n, event[0].flags, event[0].fflags, +#endif event[0].data); if (event[0].data < 0) #if 1 /* XXXLUKEM */ RL(lseek(fd, 0, SEEK_END)); #else RL(lseek(fd, event[0].data, SEEK_END)); #endif RL(n = read(fd, buffer, 128)); buffer[n] = '\0'; (void)printf("file(%d): %s", num, buffer); } (void)waitpid(pid, &status, 0); (void)printf("read: successful end\n"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, file); return atf_no_error(); } Index: stable/10/contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c =================================================================== --- stable/10/contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c (revision 313477) +++ stable/10/contrib/netbsd-tests/kernel/kqueue/read/t_pipe.c (revision 313478) @@ -1,84 +1,88 @@ /* $NetBSD: t_pipe.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn and Jaromir Dolecek. * * 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 __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); __RCSID("$NetBSD: t_pipe.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $"); #include #include #include #include #include "../../../h_macros.h" ATF_TC(pipe); ATF_TC_HEAD(pipe, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_READ for pipes"); } ATF_TC_BODY(pipe, tc) { struct kevent event[1]; char buffer[128]; int fds[2]; int kq, n; RL(pipe(fds)); RL(kq = kqueue()); EV_SET(&event[0], fds[0], EVFILT_READ, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); /* make sure there is something in the pipe */ RL(write(fds[1], "foo", 3)); (void)printf("pipe: wrote 'foo' to pipe\n"); RL(n = kevent(kq, NULL, 0, event, 1, NULL)); (void)printf("kevent num %d flags: %#x, fflags: %#x, data: " +#ifdef __FreeBSD__ + "%" PRIdPTR "\n", n, event[0].flags, event[0].fflags, event[0].data); +#else "%" PRId64 "\n", n, event[0].flags, event[0].fflags, event[0].data); +#endif RL(n = read(fds[0], buffer, event[0].data)); buffer[n] = '\0'; (void)printf("pipe: read '%s'\n", buffer); (void)printf("pipe: successful end\n"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, pipe); return atf_no_error(); } Index: stable/10/contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c =================================================================== --- stable/10/contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c (revision 313477) +++ stable/10/contrib/netbsd-tests/kernel/kqueue/read/t_ttypty.c (revision 313478) @@ -1,144 +1,148 @@ /* $NetBSD: t_ttypty.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn and Jaromir Dolecek. * * 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 __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); __RCSID("$NetBSD: t_ttypty.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $"); #include #include #include #include #include #include #include #include #include "../../../h_macros.h" static void h_check(bool check_master) { char slavetty[1024]; char buffer[128]; struct kevent event[1]; pid_t child; int amaster, aslave, acurrent; int kq, n, status; #if 0 int fl; #endif struct pollfd pfd; struct termios tio; RL(openpty(&amaster, &aslave, slavetty, NULL, NULL)); (void)printf("tty: openpty master %d slave %d tty '%s'\n", amaster, aslave, slavetty); acurrent = check_master ? amaster : aslave; RL(child = fork()); if (child == 0) { sleep(1); (void)printf("tty: child writing 'f00\\n'\n"); (void)write(check_master ? aslave : amaster, "f00\n", 4); _exit(0); } /* switch ONLCR off, to not get confused by newline translation */ RL(tcgetattr(acurrent, &tio)); tio.c_oflag &= ~ONLCR; RL(tcsetattr(acurrent, TCSADRAIN, &tio)); pfd.fd = acurrent; pfd.events = POLLIN; (void)printf("tty: polling ...\n"); RL(poll(&pfd, 1, INFTIM)); (void)printf("tty: returned from poll - %d\n", pfd.revents); #if 0 fl = 1; if (ioctl(acurrent, TIOCPKT, &fl) < 0) err(1, "ioctl"); #endif RL(kq = kqueue()); EV_SET(&event[0], acurrent, EVFILT_READ, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); RL(n = kevent(kq, NULL, 0, event, 1, NULL)); (void)printf("kevent num %d filt %d flags: %#x, fflags: %#x, " +#ifdef __FreeBSD__ + "data: %" PRIdPTR "\n", n, event[0].filter, event[0].flags, +#else "data: %" PRId64 "\n", n, event[0].filter, event[0].flags, +#endif event[0].fflags, event[0].data); ATF_REQUIRE_EQ(event[0].filter, EVFILT_READ); RL(n = read(acurrent, buffer, 128)); (void)printf("tty: read '%.*s' (n=%d)\n", n, buffer, n); (void)waitpid(child, &status, 0); (void)printf("tty: successful end\n"); } ATF_TC(master); ATF_TC_HEAD(master, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_READ for master tty"); } ATF_TC_BODY(master, tc) { h_check(true); } ATF_TC(slave); ATF_TC_HEAD(slave, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_READ for slave tty"); } ATF_TC_BODY(slave, tc) { h_check(false); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, master); ATF_TP_ADD_TC(tp, slave); return atf_no_error(); } Index: stable/10/contrib/netbsd-tests/kernel/kqueue/t_proc1.c =================================================================== --- stable/10/contrib/netbsd-tests/kernel/kqueue/t_proc1.c (revision 313477) +++ stable/10/contrib/netbsd-tests/kernel/kqueue/t_proc1.c (revision 313478) @@ -1,154 +1,158 @@ /* $NetBSD: t_proc1.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn and Jaromir Dolecek. * * 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 __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); __RCSID("$NetBSD: t_proc1.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $"); /* * this also used to trigger problem fixed in * rev. 1.1.1.1.2.13 of sys/kern/kern_event.c */ #include #include #include #include #include #include #include #include #include #include "../../h_macros.h" static int child(void) { pid_t ch; int status; char *argv[] = { NULL, NULL }; char *envp[] = { NULL, NULL }; if ((argv[0] = strdup("true")) == NULL) err(EXIT_FAILURE, "strdup(\"true\")"); if ((envp[0] = strdup("FOO=BAZ")) == NULL) err(EXIT_FAILURE, "strdup(\"FOO=BAZ\")"); /* Ensure parent is ready */ (void)sleep(2); /* Do fork */ switch (ch = fork()) { case -1: return EXIT_FAILURE; /* NOTREACHED */ case 0: return EXIT_SUCCESS; /* NOTREACHED */ default: wait(&status); break; } /* Exec */ execve("/usr/bin/true", argv, envp); /* NOTREACHED */ return EXIT_FAILURE; } ATF_TC(proc1); ATF_TC_HEAD(proc1, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_PROC"); } ATF_TC_BODY(proc1, tc) { struct kevent event[1]; pid_t pid; int kq, want, status; RL(kq = kqueue()); /* fork a child for doing the events */ RL(pid = fork()); if (pid == 0) { _exit(child()); /* NOTREACHED */ } (void)sleep(1); /* give child some time to come up */ event[0].ident = pid; event[0].filter = EVFILT_PROC; event[0].flags = EV_ADD | EV_ENABLE; event[0].fflags = NOTE_EXIT | NOTE_FORK | NOTE_EXEC; /* | NOTE_TRACK;*/ want = NOTE_EXIT | NOTE_FORK | NOTE_EXEC; RL(kevent(kq, event, 1, NULL, 0, NULL)); /* wait until we get all events we want */ while (want) { RL(kevent(kq, NULL, 0, event, 1, NULL)); printf("%ld:", (long)event[0].ident); if (event[0].fflags & NOTE_EXIT) { want &= ~NOTE_EXIT; printf(" NOTE_EXIT"); } if (event[0].fflags & NOTE_EXEC) { want &= ~NOTE_EXEC; printf(" NOTE_EXEC"); } if (event[0].fflags & NOTE_FORK) { want &= ~NOTE_FORK; printf(" NOTE_FORK"); } if (event[0].fflags & NOTE_CHILD) +#ifdef __FreeBSD__ + printf(" NOTE_CHILD, parent = %" PRIdPTR, event[0].data); +#else printf(" NOTE_CHILD, parent = %" PRId64, event[0].data); +#endif printf("\n"); } (void)waitpid(pid, &status, 0); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, proc1); return atf_no_error(); } Index: stable/10/contrib/netbsd-tests/kernel/kqueue/t_sig.c =================================================================== --- stable/10/contrib/netbsd-tests/kernel/kqueue/t_sig.c (revision 313477) +++ stable/10/contrib/netbsd-tests/kernel/kqueue/t_sig.c (revision 313478) @@ -1,133 +1,137 @@ /* $NetBSD: t_sig.c,v 1.2 2010/11/03 16:10:20 christos Exp $ */ /*- * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Luke Mewburn and Jaromir Dolecek. * * 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 __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); __RCSID("$NetBSD: t_sig.c,v 1.2 2010/11/03 16:10:20 christos Exp $"); #include #include #include #include #include #include #include #include #include #include #include #include "../../h_macros.h" #define NSIGNALS 5 ATF_TC(sig); ATF_TC_HEAD(sig, tc) { atf_tc_set_md_var(tc, "descr", "Checks EVFILT_SIGNAL"); } ATF_TC_BODY(sig, tc) { struct timespec timeout; struct kfilter_mapping km; struct kevent event[1]; char namebuf[32]; pid_t pid, child; int kq, n, num, status; pid = getpid(); (void)printf("my pid: %d\n", pid); /* fork a child to send signals */ RL(child = fork()); if (child == 0) { int i; (void)sleep(2); for(i = 0; i < NSIGNALS; ++i) { (void)kill(pid, SIGUSR1); (void)sleep(2); } _exit(0); /* NOTREACHED */ } RL(kq = kqueue()); (void)strlcpy(namebuf, "EVFILT_SIGNAL", sizeof(namebuf)); km.name = namebuf; RL(ioctl(kq, KFILTER_BYNAME, &km)); (void)printf("got %d as filter number for `%s'.\n", km.filter, km.name); /* ignore the signal to avoid taking it for real */ REQUIRE_LIBC(signal(SIGUSR1, SIG_IGN), SIG_ERR); event[0].ident = SIGUSR1; event[0].filter = km.filter; event[0].flags = EV_ADD | EV_ENABLE; RL(kevent(kq, event, 1, NULL, 0, NULL)); (void)sleep(1); timeout.tv_sec = 1; timeout.tv_nsec = 0; for (num = 0; num < NSIGNALS; num += n) { struct timeval then, now, diff; RL(gettimeofday(&then, NULL)); RL(n = kevent(kq, NULL, 0, event, 1, &timeout)); RL(gettimeofday(&now, NULL)); timersub(&now, &then, &diff); (void)printf("sig: kevent returned %d in %lld.%06ld\n", n, (long long)diff.tv_sec, (long)diff.tv_usec); if (n == 0) continue; +#ifdef __FreeBSD__ + (void)printf("sig: kevent flags: 0x%x, data: %" PRIdPTR " (# " +#else (void)printf("sig: kevent flags: 0x%x, data: %" PRId64 " (# " +#endif "times signal posted)\n", event[0].flags, event[0].data); } (void)waitpid(child, &status, 0); (void)printf("sig: finished successfully\n"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, sig); return atf_no_error(); } Index: stable/10 =================================================================== --- stable/10 (revision 313477) +++ stable/10 (revision 313478) Property changes on: stable/10 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r305483,306030-306031,306033,306036