diff --git a/contrib/netbsd-tests/FREEBSD-upgrade b/contrib/netbsd-tests/FREEBSD-upgrade new file mode 100644 index 000000000000..edeba708cb18 --- /dev/null +++ b/contrib/netbsd-tests/FREEBSD-upgrade @@ -0,0 +1,38 @@ +$FreeBSD$ + +This document contains a collection of notes specific to the import +of the NetBSD test suite into head. These notes are built on the instructions +in the FreeBSD Subversion Primer that detail how to deal with vendor +branches and you are supposed to follow those: + + http://www.freebsd.org/doc/en/articles/committers-guide/subversion-primer.html + +The NetBSD test source code was originally obtained via NetBSD anoncvs as +described in the NetBSD handbook: + + http://www.netbsd.org/docs/guide/en/chap-fetch.html#chap-fetch-cvs + +and is imported into the NetBSD/tests vendor branch (see +base/vendor/NetBSD/tests/). + +The process used to bootstrap the vendor tree was similar to the following: + + /bin/sh + export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot" + cvs -z9 co -D "09/30/2014 20:45" -P src/tests + mv src/tests/* tests/dist/. + +Please adjust the checkout date spec (the argument passed via -D) to match +the desired checkout time. + +To merge the vendor branch into head do something like this: + + cd .../base/head/contrib/netbsd-tests + svn merge --accept=postpone \ + svn+ssh://svn.freebsd.org/base/vendor/NetBSD/tests/dist . + find . -name Makefile\* | xargs svn rm --force + +and resolve any conflicts that may arise at this point. + +Lastly, with the list of old and new files in this import, make sure +to update the reachover Makefiles accordingly. diff --git a/contrib/netbsd-tests/bin/cat/d_align.in b/contrib/netbsd-tests/bin/cat/d_align.in new file mode 100644 index 000000000000..31bf4a7a143f --- /dev/null +++ b/contrib/netbsd-tests/bin/cat/d_align.in @@ -0,0 +1,3 @@ +a b c +1 2 3 +x y z diff --git a/contrib/netbsd-tests/bin/cat/d_align.out b/contrib/netbsd-tests/bin/cat/d_align.out new file mode 100644 index 000000000000..fd324697185b --- /dev/null +++ b/contrib/netbsd-tests/bin/cat/d_align.out @@ -0,0 +1,3 @@ + 1 a b c$ + 2 1 2 3$ + 3 x y z$ diff --git a/contrib/netbsd-tests/bin/cat/t_cat.sh b/contrib/netbsd-tests/bin/cat/t_cat.sh new file mode 100755 index 000000000000..1b7a9307eeeb --- /dev/null +++ b/contrib/netbsd-tests/bin/cat/t_cat.sh @@ -0,0 +1,59 @@ +# $NetBSD: t_cat.sh,v 1.2 2012/03/27 17:57:02 jruoho Exp $ +# +# Copyright (c) 2012 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Jukka Ruohonen. +# +# 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 align +align_head() { + atf_set "descr" "Test that cat(1) aligns the output " \ + "right with options '-be' (PR bin/4841)" +} + +align_body() { + + atf_check -s ignore -o file:$(atf_get_srcdir)/d_align.out \ + -x "cat -be $(atf_get_srcdir)/d_align.in" +} + +atf_test_case nonexistent +nonexistent_head() { + atf_set "descr" "Test that cat(1) doesn't return zero exit " \ + "status for a nonexistent file (PR bin/3538)" +} + +nonexistent_body() { + + atf_check -s not-exit:0 -o empty -e not-empty \ + -x "cat /some/name/that/does/not/exist" +} + +atf_init_test_cases() +{ + atf_add_test_case align + atf_add_test_case nonexistent +} diff --git a/contrib/netbsd-tests/bin/cp/t_cp.sh b/contrib/netbsd-tests/bin/cp/t_cp.sh new file mode 100755 index 000000000000..be55c7cb0ef3 --- /dev/null +++ b/contrib/netbsd-tests/bin/cp/t_cp.sh @@ -0,0 +1,294 @@ +# $NetBSD: t_cp.sh,v 1.1 2012/03/17 16:33:10 jruoho Exp $ +# +# Copyright (c) 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. +# + +FILES="file file2 file3 link dir dir2 dirlink target" + +cleanup() { + rm -fr ${FILES} +} + +cp_compare() { + echo "Ensuring that $2 and $3 are identical" + cmp -s $2 $3 || atf_fail "$2 and $3 are different" +} + +reset() { + cleanup + echo "I'm a file" > file + echo "I'm a file, 2" > file2 + echo "I'm a file, 3" > file3 + ln -s file link + mkdir dir + ln -s dir dirlink +} + +atf_test_case file_to_file +file_to_file_head() { + atf_set "descr" "Checks the copy of a file to a file" +} +file_to_file_body() { + reset + + file_to_file_simple + file_to_file_preserve + file_to_file_noflags +} + +file_to_file_simple() { + rm -f file2 + umask 022 + chmod 777 file + atf_check -s eq:0 -o empty -e empty cp file file2 + cp_compare file_to_file_simple file file2 + if [ `stat -f "%Lp" file2` != "755" ]; then + atf_fail "new file not created with umask" + fi + + chmod 644 file + chmod 777 file2 + cp_compare file_to_file_simple file file2 + if [ `stat -f "%Lp" file2` != "777" ]; then + atf_fail "existing files permissions not retained" + fi +} + +file_to_file_preserve() { + rm file3 + chmod 644 file + chflags nodump file + atf_check -s eq:0 -o empty -e empty cp -p file file3 + finfo=`stat -f "%p%u%g%m%z%f" file` + f3info=`stat -f "%p%u%g%m%z%f" file3` + if [ $finfo != $f3info ]; then + atf_fail "attributes not preserved" + fi +} + +file_to_file_noflags() { + rm file3 + chmod 644 file + chflags nodump file + atf_check -s eq:0 -o empty -e empty cp -p -N file file3 + finfo=`stat -f "%f" file` + f3info=`stat -f "%f" file3` + if [ $finfo = $f3info ]; then + atf_fail "-p -N preserved file flags" + fi +} + +atf_test_case file_to_link +file_to_link_head() { + atf_set "descr" "Checks the copy of a file to a symbolic link" +} +file_to_link_body() { + reset + atf_check -s eq:0 -o empty -e empty cp file2 link + cp_compare file_to_link file file2 +} + +atf_test_case link_to_file +link_to_file_head() { + atf_set "descr" "Checks the copy of a symbolic link to a file" +} +link_to_file_body() { + reset + # file and link are identical (not copied). + atf_check -s eq:1 -o empty -e ignore cp link file + atf_check -s eq:0 -o empty -e empty cp link file2 + cp_compare link_to_file file file2 +} + +atf_test_case file_over_link +file_over_link_head() { + atf_set "descr" "Checks the copy of a file to a symbolic link" \ + "without following it" +} +file_over_link_body() { + reset + atf_check -s eq:0 -o empty -e empty cp -P file link + cp_compare file_over_link file link +} + +atf_test_case link_over_file +link_over_file_head() { + atf_set "descr" "Checks the copy of a symbolic link to a file" \ + "without following the former" +} +link_over_file_body() { + reset + atf_check -s eq:0 -o empty -e empty cp -P link file + if [ `readlink link` != `readlink file` ]; then + atf_fail "readlink link != readlink file" + fi +} + +atf_test_case files_to_dir +files_to_dir_head() { + atf_set "descr" "Checks the copy of multiple files into a directory" +} +files_to_dir_body() { + reset + # can't copy multiple files to a file + atf_check -s eq:1 -o empty -e ignore cp file file2 file3 + atf_check -s eq:0 -o empty -e empty cp file file2 link dir + cp_compare files_to_dir file "dir/file" +} + +atf_test_case dir_to_file +dir_to_file_head() { + atf_set "descr" "Checks the copy of a directory onto a file, which" \ + "should not work" +} +dir_to_file_body() { + reset + # can't copy a dir onto a file + atf_check -s eq:1 -o empty -e ignore cp dir file + atf_check -s eq:1 -o empty -e ignore cp -R dir file +} + +atf_test_case file_to_linkdir +file_to_linkdir_head() { + atf_set "descr" "Checks the copy of a file to a symbolic link that" \ + "points to a directory" +} +file_to_linkdir_body() { + reset + atf_check -s eq:0 -o empty -e empty cp file dirlink + cp_compare file_to_linkdir file "dir/file" + + # overwrite the link + atf_check -s eq:0 -o empty -e empty cp -P file dirlink + atf_check -s eq:1 -o empty -e empty readlink dirlink + cp_compare file_to_linkdir file dirlink +} + +atf_test_case linkdir_to_file +linkdir_to_file_head() { + atf_set "descr" "Checks the copy of a symbolic link that points to" \ + "a directory onto a file" +} +linkdir_to_file_body() { + reset + # cannot copy a dir onto a file + atf_check -s eq:1 -o empty -e ignore cp dirlink file + + # overwrite the link + atf_check -s eq:0 -o empty -e empty cp -P dirlink file + if [ `readlink file` != `readlink dirlink` ]; then + atf_fail "readlink link != readlink file" + fi +} + +dir_to_dne_no_R() { + atf_check -s eq:1 -o empty -e ignore cp dir dir2 +} + +dir_to_dne() { + atf_check -s eq:0 -o empty -e empty cp -R dir dir2 + cp_compare dir_to_dne "dir/file" "dir2/file" + readlink dir2/link >/dev/null + if [ $? -gt 0 ]; then + atf_fail "-R didn't copy a link as a link" + fi +} + +dir_to_dir_H() { + dir_to_dir_setup + atf_check -s eq:0 -o empty -e empty cp -R dir dir2 + + chmod 777 dir + + # copy a dir into a dir, only command-line links are followed + atf_check -s eq:0 -o empty -e empty cp -R -H dirlink dir2 + cp_compare dir_to_dir_H "dir/file" "dir2/dirlink/file" + readlink dir2/dirlink/link >/dev/null + if [ $? -gt 0 ]; then + atf_fail "didn't copy a link as a link" + fi + + # Created directories have the same mode as the corresponding + # source directory, unmodified by the process's umask. + if [ `stat -f "%Lp" dir2/dirlink` != "777" ]; then + atf_fail "-R modified dir perms with umask" + fi +} + +dir_to_dir_L() { + dir_to_dir_setup + atf_check -s eq:0 -o empty -e empty cp -R dir dir2 + atf_check -s eq:0 -o empty -e empty cp -R -H dirlink dir2 + + # copy a dir into a dir, following all links + atf_check -s eq:0 -o empty -e empty cp -R -H -L dirlink dir2/dirlink + cp_compare dir_to_dir_L "dir/file" "dir2/dirlink/dirlink/file" + # fail if -R -L copied a link as a link + atf_check -s eq:1 -o ignore -e empty readlink dir2/dirlink/dirlink/link +} + +dir_to_dir_subdir_exists() { + # recursively copy a dir into another dir, with some subdirs already + # existing + cleanup + + mkdir -p dir/1 dir/2 dir/3 target/2 + echo "file" > dir/2/file + atf_check -s eq:0 -o empty -e empty cp -R dir/* target + cp_compare dir_to_dir_subdir_exists "dir/2/file" "target/2/file" +} + +dir_to_dir_setup() { + reset + umask 077 + cp -P file file2 file3 link dir +} + +atf_test_case dir_to_dir +dir_to_dir_head() { + atf_set "descr" "Checks the copy of a directory onto another directory" +} +dir_to_dir_body() { + dir_to_dir_setup + dir_to_dne_no_R + dir_to_dne + dir_to_dir_H + dir_to_dir_L + dir_to_dir_subdir_exists +} + +atf_init_test_cases() +{ + atf_add_test_case file_to_file + atf_add_test_case file_to_link + atf_add_test_case link_to_file + atf_add_test_case file_over_link + atf_add_test_case link_over_file + atf_add_test_case files_to_dir + atf_add_test_case file_to_linkdir + atf_add_test_case linkdir_to_file + atf_add_test_case dir_to_file + atf_add_test_case dir_to_dir +} diff --git a/contrib/netbsd-tests/bin/dd/t_dd.sh b/contrib/netbsd-tests/bin/dd/t_dd.sh new file mode 100755 index 000000000000..d713ad9cb246 --- /dev/null +++ b/contrib/netbsd-tests/bin/dd/t_dd.sh @@ -0,0 +1,130 @@ +# $NetBSD: t_dd.sh,v 1.1 2012/03/17 16:33:11 jruoho 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. +# + +test_dd_length() { + result=$1 + cmd=$2 + set -- x `eval $cmd | wc -c` + res=$2 + if [ x"$res" != x"$result" ]; then + atf_fail "Expected $result bytes of output, got $res: $cmd" + fi +} + +atf_test_case length +length_head() { + # XXX The PR should be stored in a tag. + atf_set "descr" "Test for result messages accidentally pumped into" \ + "the output file if the standard IO descriptors are" \ + "closed. The last of the three following tests is" \ + "the one expected to fail. (NetBSD PR bin/8521)" +} +length_body() { + test_dd_length 512 \ + "dd if=/dev/zero of=/dev/fd/5 count=1 5>&1 >/dev/null 2>/dev/null" + test_dd_length 512 \ + "dd if=/dev/zero of=/dev/fd/5 count=1 5>&1 >&- 2>/dev/null" + test_dd_length 512 \ + "dd if=/dev/zero of=/dev/fd/5 count=1 5>&1 >&- 2>&-" +} + +test_dd_io() { + res="`echo -n "$2" | eval $1`" + if [ x"$res" != x"$3" ]; then + atf_fail "Expected \"$3\", got \"$res\": $1" + fi +} + +allbits1="\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377" + +ebcdicbits1="\000\001\002\003\067\055\056\057\026\005\045\013\014\015\016\017\020\021\022\023\074\075\062\046\030\031\077\047\034\035\036\037\100\132\177\173\133\154\120\175\115\135\134\116\153\140\113\141\360\361\362\363\364\365\366\367\370\371\172\136\114\176\156\157\174\301\302\303\304\305\306\307\310\311\321\322\323\324\325\326\327\330\331\342\343\344\345\346\347\350\351\255\340\275\232\155\171\201\202\203\204\205\206\207\210\211\221\222\223\224\225\226\227\230\231\242\243\244\245\246\247\250\251\300\117\320\137\007\040\041\042\043\044\025\006\027\050\051\052\053\054\011\012\033\060\061\032\063\064\065\066\010\070\071\072\073\004\024\076\341\101\102\103\104\105\106\107\110\111\121\122\123\124\125\126\127\130\131\142\143\144\145\146\147\150\151\160\161\162\163\164\165\166\167\170\200\212\213\214\215\216\217\220\152\233\234\235\236\237\240\252\253\254\112\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\241\276\277\312\313\314\315\316\317\332\333\334\335\336\337\352\353\354\355\356\357\372\373\374\375\376\377" + +allvisbits=`echo -n "$allbits1" | unvis | vis` +ebcdicvisbits=`echo -n "$ebcdicbits1" | unvis | vis` + +atf_test_case io +io_head() { + atf_set "descr" "This checks the combination of bs= with" \ + "conv=ebcdic. Prior to revision 1.24 of dd's" \ + "args.c, the conv option would be ignored." +} +io_body() { + test_dd_io "unvis | dd 2>/dev/null | vis" \ + "$allvisbits" "$allvisbits" + test_dd_io "unvis | dd ibs=1 2>/dev/null | vis" \ + "$allvisbits" "$allvisbits" + test_dd_io "unvis | dd obs=1 2>/dev/null | vis" \ + "$allvisbits" "$allvisbits" + test_dd_io "unvis | dd bs=1 2>/dev/null | vis" \ + "$allvisbits" "$allvisbits" + + test_dd_io "unvis | dd conv=ebcdic 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + test_dd_io "unvis | dd conv=ebcdic ibs=512 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + test_dd_io "unvis | dd conv=ebcdic obs=512 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + test_dd_io "unvis | dd conv=ebcdic bs=512 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + + test_dd_io "unvis | dd conv=ebcdic 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + test_dd_io "unvis | dd conv=ebcdic ibs=1 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + test_dd_io "unvis | dd conv=ebcdic obs=1 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" + test_dd_io "unvis | dd conv=ebcdic bs=1 2>/dev/null | vis" \ + "$allvisbits" "$ebcdicvisbits" +} + +atf_test_case seek +seek_head() { + atf_set "descr" "Tests output file seeking" +} + +seek_body() { + echo TEST1234 > testfile + atf_check -s exit:0 -e ignore \ + dd if=/dev/zero of=testfile seek=1 bs=8k count=1 + atf_check -s exit:0 -e ignore -o match:'^TEST1234$' dd if=testfile + eval $(stat -s testfile) + atf_check_equal $st_size $((2*8192)) + + echo -n TEST1234 > tf2 + atf_check -s exit:0 -e ignore -x \ + 'dd bs=4 if=/dev/zero count=1 | tr \\0 \\n | dd of=tf2 bs=4 seek=1' + atf_check -s exit:0 -e ignore -o match:'^TEST$' dd if=tf2 + eval $(stat -s tf2) + atf_check_equal $st_size 8 +} + +atf_init_test_cases() +{ + atf_add_test_case length + atf_add_test_case io + atf_add_test_case seek +} diff --git a/contrib/netbsd-tests/bin/df/getmntinfo.c b/contrib/netbsd-tests/bin/df/getmntinfo.c new file mode 100644 index 000000000000..4ad1f40ce6be --- /dev/null +++ b/contrib/netbsd-tests/bin/df/getmntinfo.c @@ -0,0 +1,218 @@ +/* $NetBSD: getmntinfo.c,v 1.1 2012/03/17 16:33:11 jruoho 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. + */ + +#include +#include +#include + +#include +#include +#include + +#define KB * 1024 +#define MB * 1024 KB +#define GB * 1024 MB + +static struct statvfs *getnewstatvfs(void); +static void other_variants(const struct statvfs *, const int *, int, + const int *, int); +static void setup_filer(void); +static void setup_ld0g(void); +static void setup_strpct(void); + +static struct statvfs *allstatvfs; +static int sftotal, sfused; + +struct statvfs * +getnewstatvfs(void) +{ + + if (sftotal == sfused) { + sftotal = sftotal ? sftotal * 2 : 1; + allstatvfs = realloc(allstatvfs, + sftotal * sizeof(struct statvfs)); + if (allstatvfs == NULL) + err(EXIT_FAILURE, "realloc"); + } + + return (&allstatvfs[sfused++]); +} + +void +other_variants(const struct statvfs *tmpl, const int *minfree, int minfreecnt, + const int *consumed, int consumedcnt) +{ + int64_t total, used; + struct statvfs *sf; + int i, j; + + for (i = 0; i < minfreecnt; i++) + for (j = 0; j < consumedcnt; j++) { + sf = getnewstatvfs(); + *sf = *tmpl; + total = (int64_t)(u_long)sf->f_blocks * sf->f_bsize; + used = total * consumed[j] / 100; + sf->f_bfree = (total - used) / sf->f_bsize; + sf->f_bavail = (total * (100 - minfree[i]) / 100 - + used) / (int)sf->f_bsize; + sf->f_bresvd = sf->f_bfree - sf->f_bavail; + } +} + +/* + * Parameter taken from: + * http://mail-index.NetBSD.org/tech-userlevel/2004/03/24/0001.html + */ +void +setup_filer(void) +{ + static const struct statvfs tmpl = { +#define BSIZE 512 +#define TOTAL 1147ULL GB +#define USED 132ULL MB + .f_bsize = BSIZE, + .f_frsize = BSIZE, + .f_blocks = TOTAL / BSIZE, + .f_bfree = (TOTAL - USED) / BSIZE, + .f_bavail = (TOTAL - USED) / BSIZE, + .f_bresvd = 0, + .f_mntfromname = "filer:/", + .f_mntonname = "/filer", +#undef USED +#undef TOTAL +#undef BSIZE + }; + static const int minfree[] = { 0, 5, 10, 15, }; + static const int consumed[] = { 0, 20, 60, 95, 100 }; + + *getnewstatvfs() = tmpl; + other_variants(&tmpl, minfree, sizeof(minfree) / sizeof(minfree[0]), + consumed, sizeof(consumed) / sizeof(consumed[0])); +} + +/* + * Parameter taken from: + * http://mail-index.NetBSD.org/current-users/2004/03/01/0038.html + */ +void +setup_ld0g(void) +{ + static const struct statvfs tmpl = { +#define BSIZE 4096 /* Guess */ +#define TOTAL 1308726116ULL KB +#define USED 17901268ULL KB +#define AVAIL 1225388540ULL KB + .f_bsize = BSIZE, + .f_frsize = BSIZE, + .f_blocks = TOTAL / BSIZE, + .f_bfree = (TOTAL - USED) / BSIZE, + .f_bavail = AVAIL / BSIZE, + .f_bresvd = (TOTAL - USED) / BSIZE - AVAIL / BSIZE, + .f_mntfromname = "/dev/ld0g", + .f_mntonname = "/anon-root", +#undef AVAIL +#undef USED +#undef TOTAL +#undef BSIZE + }; + static const int minfree[] = { 0, 5, 10, 15, }; + static const int consumed[] = { 0, 20, 60, 95, 100 }; + + *getnewstatvfs() = tmpl; + other_variants(&tmpl, minfree, sizeof(minfree) / sizeof(minfree[0]), + consumed, sizeof(consumed) / sizeof(consumed[0])); +} + +/* + * Test of strpct() with huge number. + */ +void +setup_strpct(void) +{ + static const struct statvfs tmpl = { +#define BSIZE 4096 /* Guess */ +#define TOTAL 0x4ffffffffULL KB +#define USED (TOTAL / 2) +#define AVAIL (TOTAL / 2) + .f_bsize = BSIZE, + .f_frsize = BSIZE, + .f_blocks = TOTAL / BSIZE, + .f_bfree = (TOTAL - USED) / BSIZE, + .f_bavail = AVAIL / BSIZE, + .f_bresvd = (TOTAL - USED) / BSIZE - AVAIL / BSIZE, + .f_mntfromname = "/dev/strpct", + .f_mntonname = "/strpct", +#undef AVAIL +#undef USED +#undef TOTAL +#undef BSIZE + }; + + *getnewstatvfs() = tmpl; +} + +/* + * Parameter taken from: + * http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=23600 + */ +static void +setup_pr23600(void) +{ + static const struct statvfs tmpl = { +#define BSIZE 512 +#define TOTAL 20971376ULL +#define USED 5719864ULL +#define AVAIL 15251512ULL + .f_bsize = BSIZE, + .f_frsize = BSIZE, + .f_blocks = TOTAL, + .f_bfree = TOTAL - USED, + .f_bavail = AVAIL, + .f_bresvd = TOTAL - USED - AVAIL, + .f_mntfromname = "/dev/wd0e", + .f_mntonname = "/mount/windows/C", +#undef AVAIL +#undef USED +#undef TOTAL +#undef BSIZE + }; + + *getnewstatvfs() = tmpl; +} + +int +getmntinfo(struct statvfs **mntbuf, int flags) +{ + + setup_filer(); + setup_ld0g(); + setup_strpct(); + setup_pr23600(); + + *mntbuf = allstatvfs; + return (sfused); +} diff --git a/contrib/netbsd-tests/bin/df/t_df.sh b/contrib/netbsd-tests/bin/df/t_df.sh new file mode 100755 index 000000000000..ffb5aad3e0d0 --- /dev/null +++ b/contrib/netbsd-tests/bin/df/t_df.sh @@ -0,0 +1,148 @@ +# $NetBSD: t_df.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# +# Copyright (c) 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 normal +normal_head() { + atf_set "descr" "Checks that the output of df without flags is" \ + "correct according to some already-known, sane" \ + "output" +} +normal_body() { + cat >expout <expout <&1` + if [ "$res" != "$2" ]; then + atf_fail "Expected $2, got $res from expression: " \ + "`eval echo $1`" + fi +} + +atf_test_case lang +lang_ops_head() { + atf_set "descr" "Test that expr(1) works with non-C LANG (PR bin/2486)" +} +lang_body() { + + export LANG=nonexistent + atf_check -s exit:0 -o inline:"21\n" -e empty -x "expr 10 + 11" + + export LANG=ru_RU.KOI8-R + atf_check -s exit:0 -o inline:"21\n" -e empty -x "expr 10 + 11" +} + +atf_test_case overflow +overflow_head() { + atf_set "descr" "Test overflow cases" +} +overflow_body() { + test_expr '4611686018427387904 + 4611686018427387903' \ + '9223372036854775807' + test_expr '4611686018427387904 + 4611686018427387904' \ + "expr: integer overflow or underflow occurred for operation '4611686018427387904 + 4611686018427387904'" + test_expr '4611686018427387904 - -4611686018427387904' \ + "expr: integer overflow or underflow occurred for operation '4611686018427387904 - -4611686018427387904'" + test_expr '-4611686018427387904 - 4611686018427387903' \ + '-9223372036854775807' + test_expr '-4611686018427387904 - 4611686018427387905' \ + "expr: integer overflow or underflow occurred for operation '-4611686018427387904 - 4611686018427387905'" + test_expr '-4611686018427387904 \* 1' '-4611686018427387904' + test_expr '-4611686018427387904 \* -1' '4611686018427387904' + test_expr '-4611686018427387904 \* 2' '-9223372036854775808' + test_expr '-4611686018427387904 \* 3' \ + "expr: integer overflow or underflow occurred for operation '-4611686018427387904 * 3'" + test_expr '-4611686018427387904 \* -2' \ + "expr: integer overflow or underflow occurred for operation '-4611686018427387904 * -2'" + test_expr '4611686018427387904 \* 1' '4611686018427387904' + test_expr '4611686018427387904 \* 2' \ + "expr: integer overflow or underflow occurred for operation '4611686018427387904 * 2'" + test_expr '4611686018427387904 \* 3' \ + "expr: integer overflow or underflow occurred for operation '4611686018427387904 * 3'" +} + +atf_test_case gtkmm +gtkmm_head() { + atf_set "descr" "Test from gtk-- configure that cause problems on old expr" +} +gtkmm_body() { + test_expr '3 \> 3 \| 3 = 3 \& 4 \> 4 \| 3 = 3 \& 4 = 4 \& 5 \>= 5' '1' + test_expr '3 \> 3 \| 3 = 3 \& 4 \> 4 \| 3 = 3 \& 4 = 4 \& 5 \>= 6' '0' + test_expr '3 \> 3 \| 3 = 3 \& 4 \> 4 \| 3 = 3 \& 4 = 3 \& 5 \>= 5' '0' + test_expr '3 \> 3 \| 3 = 3 \& 4 \> 4 \| 3 = 2 \& 4 = 4 \& 5 \>= 5' '0' + test_expr '3 \> 2 \| 3 = 3 \& 4 \> 4 \| 3 = 3 \& 4 = 4 \& 5 \>= 6' '1' + test_expr '3 \> 3 \| 3 = 3 \& 4 \> 3 \| 3 = 3 \& 4 = 4 \& 5 \>= 5' '1' +} + +atf_test_case colon_vs_math +colon_vs_math_head() { + atf_set "descr" "Basic precendence test with the : operator vs. math" +} +colon_vs_math_body() { + test_expr '2 : 4 / 2' '0' + test_expr '4 : 4 % 3' '1' +} + +atf_test_case arithmetic_ops +arithmetic_ops_head() { + atf_set "descr" "Dangling arithemtic operator" +} +arithmetic_ops_body() { + test_expr '.java_wrapper : /' '0' + test_expr '4 : \*' '0' + test_expr '4 : +' '0' + test_expr '4 : -' '0' + test_expr '4 : /' '0' + test_expr '4 : %' '0' +} + +atf_test_case basic_math +basic_math_head() { + atf_set "descr" "Basic math test" +} +basic_math_body() { + test_expr '2 + 4 \* 5' '22' +} + +atf_test_case basic_functional +basic_functional_head() { + atf_set "descr" "Basic functional tests" +} +basic_functional_body() { + test_expr '2' '2' + test_expr '-4' '-4' + test_expr 'hello' 'hello' +} + +atf_test_case compare_ops_precedence +compare_ops_precedence_head() { + atf_set "descr" "Compare operator precendence test" +} +compare_ops_precedence_body() { + test_expr '2 \> 1 \* 17' '0' +} + +atf_test_case compare_ops +compare_ops_head() { + atf_set "descr" "Compare operator tests" +} +compare_ops_body() { + test_expr '2 \!= 5' '1' + test_expr '2 \!= 2' '0' + test_expr '2 \<= 3' '1' + test_expr '2 \<= 2' '1' + test_expr '2 \<= 1' '0' + test_expr '2 \< 3' '1' + test_expr '2 \< 2' '0' + test_expr '2 = 2' '1' + test_expr '2 = 4' '0' + test_expr '2 \>= 1' '1' + test_expr '2 \>= 2' '1' + test_expr '2 \>= 3' '0' + test_expr '2 \> 1' '1' + test_expr '2 \> 2' '0' +} + +atf_test_case multiply +multiply_head() { + atf_set "descr" "Test the multiply operator (PR bin/12838)" +} +multiply_body() { + test_expr '1 \* -1' '-1' + test_expr '2 \> 1 \* 17' '0' +} + +atf_test_case negative +negative_head() { + atf_set "descr" "Test the additive inverse" +} +negative_body() { + test_expr '-1 + 5' '4' + test_expr '- 1 + 5' 'expr: syntax error' + + test_expr '5 + -1' '4' + test_expr '5 + - 1' 'expr: syntax error' + + test_expr '1 - -5' '6' +} + +atf_test_case math_precedence +math_precedence_head() { + atf_set "descr" "More complex math test for precedence" +} +math_precedence_body() { + test_expr '-3 + -1 \* 4 + 3 / -6' '-7' +} + +atf_test_case precedence +precedence_head() { + atf_set "descr" "Test precedence" +} +precedence_body() { + # This is messy but the shell escapes cause that + test_expr 'X1/2/3 : X\\\(.\*[^/]\\\)//\*[^/][^/]\*/\*$ \| . : \\\(.\\\)' '1/2' +} + +atf_test_case regex +regex_head() { + atf_set "descr" "Test proper () returning \1 from a regex" +} +regex_body() { + # This is messy but the shell escapes cause that + test_expr '1/2 : .\*/\\\(.\*\\\)' '2' +} + +atf_init_test_cases() +{ + atf_add_test_case lang + atf_add_test_case overflow + atf_add_test_case gtkmm + atf_add_test_case colon_vs_math + atf_add_test_case arithmetic_ops + atf_add_test_case basic_math + atf_add_test_case basic_functional + atf_add_test_case compare_ops_precedence + atf_add_test_case compare_ops + atf_add_test_case multiply + atf_add_test_case negative + atf_add_test_case math_precedence + atf_add_test_case precedence + atf_add_test_case regex +} diff --git a/contrib/netbsd-tests/bin/pax/t_pax.sh b/contrib/netbsd-tests/bin/pax/t_pax.sh new file mode 100755 index 000000000000..63ae7f8965ce --- /dev/null +++ b/contrib/netbsd-tests/bin/pax/t_pax.sh @@ -0,0 +1,54 @@ +# $NetBSD: t_pax.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# +# Copyright (c) 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 append +append_head() { + atf_set "descr" "Ensure that appending a file to an archive" \ + "produces the same results as if the file" \ + "had been there during the archive's creation" +} +append_body() { + touch foo bar + + # store both foo and bar into file1.tar + atf_check -s eq:0 -o empty -e empty \ + pax -w -b 512 -x ustar -f file1.tar foo bar + + # store foo into file2.tar, then append bar to file2.tar + atf_check -s eq:0 -o empty -e empty \ + pax -w -b 512 -x ustar -f file2.tar foo + atf_check -s eq:0 -o empty -e empty \ + pax -w -b 512 -x ustar -f file2.tar -a bar + + # ensure that file1.tar and file2.tar are equal + atf_check -s eq:0 -o empty -e empty cmp file1.tar file2.tar +} + +atf_init_test_cases() +{ + atf_add_test_case append +} diff --git a/contrib/netbsd-tests/bin/ps/keywords b/contrib/netbsd-tests/bin/ps/keywords new file mode 100644 index 000000000000..3f05f5464b84 --- /dev/null +++ b/contrib/netbsd-tests/bin/ps/keywords @@ -0,0 +1,123 @@ +# $NetBSD: keywords,v 1.2 2014/01/16 04:16:32 mlelstv Exp $ +# +# Table of keywords for use with ps "-o" option. +# +# The first column (keyword) is the name of a keyword. +# +# The second column (header) is the default column header associated +# with the keyword, except if the keyword is an alias, in which case the +# second column is the name of another keyword. +# +# The third column (flag) may be blank, "LJUST", or "ALIAS". "ALIAS" +# means that the keyword is an alias. "LJUST" means that the keyword +# should be displayed in a left-justified column. The default is that +# the keyword should be displayed in a right-justified column. +# +# keyword header flag +# +ktracep KTRACEP +nwchan WCHAN +p_ru P_RU +paddr PADDR +rlink RLINK +%cpu %CPU +%mem %MEM +acflag ACFLG +acflg acflag ALIAS +args command ALIAS +blocked sigmask ALIAS +caught sigcatch ALIAS +comm COMMAND LJUST +command COMMAND LJUST +cpu CPU +cputime time ALIAS +ctime CTIME +egid EGID +egroup EGROUP LJUST +etime ELAPSED +euid EUID +euser EUSER LJUST +f F +flags f ALIAS +gid GID +group GROUP LJUST +groupnames GROUPNAMES LJUST +groups GROUPS LJUST +holdcnt HOLDCNT +ignored sigignore ALIAS +inblk INBLK +inblock inblk ALIAS +jobc JOBC +ktrace KTRACE +laddr LADDR +lid LID +lim LIM +login LOGIN LJUST +logname login ALIAS +lstart STARTED LJUST +lstate STAT LJUST +ltime LTIME +majflt MAJFLT +minflt MINFLT +msgrcv MSGRCV +msgsnd MSGSND +ni nice ALIAS +nice NI +nivcsw NIVCSW +nlwp NLWP +nsignals nsigs ALIAS +nsigs NSIGS +nswap NSWAP +nvcsw NVCSW +oublk OUBLK +oublock oublk ALIAS +pagein PAGEIN +pcpu %cpu ALIAS +pending sig ALIAS +pgid PGID +pid PID +pmem %mem ALIAS +ppid PPID +pri PRI +re RE +rgid RGID +rgroup RGROUP LJUST +rlwp RLWP +rss RSS +rssize rsz ALIAS +rsz RSZ +ruid RUID +ruser RUSER LJUST +sess SESS +sid SID +sig PENDING +sigcatch CAUGHT +sigignore IGNORED +sigmask BLOCKED +sl SL +start STARTED +stat state ALIAS +state STAT LJUST +stime STIME +svgid SVGID +svgroup SVGROUP LJUST +svuid SVUID +svuser SVUSER LJUST +tdev TDEV +time TIME +tpgid TPGID +tsess TSESS +tsiz TSIZ +tt TTY LJUST +tty TTY LJUST +uaddr UADDR +ucomm UCOMM LJUST +uid UID +upr UPR +user USER LJUST +usrpri upr ALIAS +utime UTIME +vsize vsz ALIAS +vsz VSZ +wchan WCHAN LJUST +xstat XSTAT diff --git a/contrib/netbsd-tests/bin/ps/t_ps.sh b/contrib/netbsd-tests/bin/ps/t_ps.sh new file mode 100755 index 000000000000..8f8829bc3543 --- /dev/null +++ b/contrib/netbsd-tests/bin/ps/t_ps.sh @@ -0,0 +1,404 @@ +# $NetBSD: t_ps.sh,v 1.2 2014/01/16 04:16:32 mlelstv 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. +# + +# the implementation of "ps" to test +: ${TEST_PS:="ps"} +# tab and newline characters +tab="$(printf '\t')" +# nl="$(printf '\n')" doesn't work +nl=' +' + +# +# Parse the "keywords" file into a load of shell variables +# +setup_keywords() +{ + # Set variables representing the header text + # for all normal keywords (except aliases), and + # for regular expressions to match the text in left- or + # right-justified columns. + # For example, head_text_p_cpu="%CPU" head_regexp_p_cpu=" *%CPU". + while read keyword heading flag + do + case "$keyword" in + ''|\#*) continue + ;; + esac + [ x"$flag" = x"ALIAS" ] && continue + kvar="${keyword}" + case "${keyword}" in + %*) kvar="p_${keyword#%}" + ;; + esac + eval head_text_${kvar}=\'"${heading}"\' + case "${flag}" in + '') # right justified + eval head_regexp_${kvar}=\'" *${heading}"\' + ;; + LJUST) # left justified + eval head_regexp_${kvar}=\'"${heading} *"\' + ;; + *) atf_fail "unknown flag in keywords" + ;; + esac + done <"$(atf_get_srcdir)/keywords" + + # Now do the aliases. + while read keyword heading flag + do + case "$keyword" in + ''|\#*) continue + ;; + esac + [ x"$flag" != x"ALIAS" ] && continue + kvar="${keyword}" + avar="${heading}" + case "${keyword}" in + %*) kvar="p_${keyword#%}" + ;; + esac + case "${heading}" in + %*) avar="p_${heading#%}" + ;; + esac + eval head_text_${kvar}=\"\$head_text_${avar}\" + eval head_regexp_${kvar}=\"\$head_regexp_${avar}\" + done <"$(atf_get_srcdir)/keywords" + + # default sets of keywords + default_keywords='pid tty stat time command' + j_keywords='user pid ppid pgid sess jobc state tt time command' + l_keywords='uid pid ppid cpu pri nice vsz rss wchan state tt time command' + s_keywords='uid pid ppid cpu lid nlwp pri nice vsz rss wchan lstate tt ltime command' + u_keywords='user pid %cpu %mem vsz rss tt state start time command' + v_keywords='pid state time sl re pagein vsz rss lim tsiz %cpu %mem command' +} + +# Convert a list of keywords like "pid comm" to a regexp +# like " *PID COMMAND *" +heading_keywords_to_regexp() +{ + local keywords="$1" + local regexp + regexp="$(echo "$keywords" | \ + sed -E -e 's/\%/p_/g' -e 's/(^| )/\1\$head_regexp_/g')" + eval regexp=\""${regexp}"\" + regexp="^${regexp}\$" + echo "$regexp" +} + +# +# Check that a string matches a regexp; use the specified id +# in error or success messages. +# +check_regexp() { + local id="$1" string="$2" regexp="$3" + if ! expr "$string" : "$regexp" >/dev/null + then + atf_fail "${id}: expected [${regexp}], got [${string}]" + false + fi +} + +# +# Run "ps $args -p $$"; check that only one line is printed, +# without a preceding header line. +# +check_no_heading_line() +{ + local args="$1" + local output="$(eval "${TEST_PS} $args -p $$")" + case "$output" in + *"$nl"*) + local firstline="${output%%${nl}*}" + atf_fail "check_no_heading_line [$args] got [$firstline]" + ;; + *) + ;; + esac +} + +# +# Run "ps $args"; check that the heading matches the expected regexp. +# +check_heading_regexp() +{ + args="$1" + regexp="$2" + actual="$( eval "${TEST_PS} $args" | sed -e 1q )" + check_regexp "heading [$args]" "${actual}" "${regexp}" +} + +# +# Run "ps $args"; check that the heading matches a regexp constructed +# from the specified keywords. +# +check_heading_keywords() +{ + args="$1" + keywords="$2" + check_heading_regexp "$args" "$(heading_keywords_to_regexp "$keywords")" +} + +# +# Try several variations on "ps $flag", "ps -$flag", etc., +# and check that the heading always has the correct keywords. +# +check_heading_variations() +{ + flag="$1" + keywords="$2" + for args in "$flag" "-$flag" "-$flag$flag -$flag"; do + check_heading_keywords "$args" "$keywords" + done +} + +atf_test_case default_columns +default_columns_head() +{ + atf_set "descr" "Checks that the default set of columns is correct" \ + "and also check that the columns printed by the -j," \ + "-l, -s, -u and -v flags alone are correct" +} +default_columns_body() +{ + setup_keywords + check_heading_keywords '' "$default_keywords" + check_heading_variations 'j' "$j_keywords" + check_heading_variations 'l' "$l_keywords" + check_heading_variations 's' "$s_keywords" + check_heading_variations 'u' "$u_keywords" + check_heading_variations 'v' "$v_keywords" +} + +atf_test_case minus_O +minus_O_head() +{ + atf_set "descr" "Checks that 'ps -O foo' inserts columns just after" \ + "the pid column" +} +minus_O_body() +{ + setup_keywords + check_heading_keywords '-O %cpu,%mem' \ + "$(echo "${default_keywords}" | sed -e 's/pid/pid %cpu %mem/')" + check_heading_keywords '-O %cpu -O %mem' \ + "$(echo "${default_keywords}" | sed -e 's/pid/pid %cpu %mem/')" + check_heading_keywords '-O%cpu -O%mem' \ + "$(echo "${default_keywords}" | sed -e 's/pid/pid %cpu %mem/')" +} + +atf_test_case minus_o +minus_o_head() +{ + atf_set "descr" "Checks simple cases of 'ps -o foo' to control which" \ + "columns are printed; this does not test header" \ + "overriding via 'ps -o foo=BAR'" +} +minus_o_body() +{ + setup_keywords + # Keywords for "-o name" override the default display + check_heading_keywords '-o pid,%cpu,%mem' \ + "pid %cpu %mem" + check_heading_keywords '-o pid -o %cpu,%mem' \ + "pid %cpu %mem" + check_heading_keywords '-opid -o %cpu,%mem' \ + "pid %cpu %mem" + # Space works like comma + check_heading_keywords '-opid -o "%cpu %mem"' \ + "pid %cpu %mem" + # Check missing pid + check_heading_keywords '-o comm' \ + "comm" + # Check pid present but not first + check_heading_keywords '-o comm,pid' \ + "comm pid" +} + +atf_test_case override_heading_simple +override_heading_simple_head() +{ + atf_set "descr" "Tests simple uses of header overriding via" \ + "'ps -o foo=BAR'. This does not test columns " \ + "with null headings, or headings with embedded" \ + "space, ',' or '='." +} +override_heading_simple_body() +{ + setup_keywords + check_heading_regexp '-o pid=PPP -o comm' \ + '^ *PPP '"${head_text_comm}"'$' # no trailing space + check_heading_regexp '-o pid=PPP -o comm=CCC' \ + '^ *PPP CCC$' + check_heading_regexp '-o pid,comm=CCC' \ + '^'"${head_regexp_pid}"' CCC$' + check_heading_regexp '-o pid -o comm=CCC' \ + '^'"${head_regexp_pid}"' CCC$' + # Check missing pid + check_heading_regexp '-o comm=CCC' \ + '^CCC$' + # Check pid present but not first + check_heading_regexp '-o comm=CCC -o pid=PPP' \ + '^CCC *PPP$' + check_heading_regexp '-o comm,pid=PPP' \ + '^'"${head_regexp_comm}"' *PPP$' +} + +atf_test_case override_heading_embedded_specials +override_heading_embedded_specials_head() +{ + atf_set "descr" "Tests header overriding with embedded space," \ + "',' or '='. Everything after the first '='" \ + "is part of the heading." +} +override_heading_embedded_specials_body() +{ + setup_keywords + # Check embedded "," or "=" in override header. + check_heading_regexp '-o comm,pid==' \ + '^'"${head_regexp_comm}"' *=$' + check_heading_regexp '-o comm,pid=,' \ + '^'"${head_regexp_comm}"' *,$' + check_heading_regexp '-o pid=PPP,comm' \ + '^ *PPP,comm$' # not like '-o pid=PPP -o comm' + check_heading_regexp '-o pid=PPP,comm=CCC' \ + '^ *PPP,comm=CCC$' # not like '-o pid=PPP -o comm=CCC' + check_heading_regexp '-o comm,pid=PPP,QQQ' \ + '^'"${head_regexp_comm}"' *PPP,QQQ$' + check_heading_regexp '-o comm,pid=ppid,tty=state' \ + '^'"${head_regexp_comm}"' *ppid,tty=state$' + # Check embedded space or tab in override header. + check_heading_regexp '-o comm,pid="PPP QQQ"' \ + '^'"${head_regexp_comm}"' *PPP QQQ$' + check_heading_regexp '-o comm,pid="PPP${tab}QQQ"' \ + '^'"${head_regexp_comm}"' *PPP'"${tab}"'QQQ$' +} + +atf_test_case override_heading_some_null +override_heading_some_null_head() +{ + atf_set "descr" "Tests simple uses of null column headings" \ + "overriding via 'ps -o foo=BAR -o baz='. This" \ + "does not test the case where all columns have" \ + "null headings." +} +override_heading_some_null_body() +{ + setup_keywords + check_heading_regexp '-o pid=PPP -o comm=' \ + '^ *PPP *$' + check_heading_regexp '-o pid= -o comm=CCC' \ + '^ * CCC$' + check_heading_regexp '-o pid -o comm=' \ + '^'"${head_regexp_pid}"' *$' + # Check missing pid + check_heading_regexp '-o ppid= -o comm=CCC' \ + '^ * CCC$' + check_heading_regexp '-o ppid=PPP -o comm=' \ + '^ *PPP *$' + # Check pid present but not first + check_heading_regexp '-o comm= -o pid=PPP' \ + '^ * PPP$' + check_heading_regexp '-o comm,pid=' \ + '^'"${head_regexp_comm}"' *$' + # A field with a null custom heading retains a minimum width + # derived from the default heading. This does not apply + # to a field with a very short (non-null) custom heading. + # + # We choose "holdcnt" as a column whose width is likely to be + # determined entirely by the header width, because the values + # are likely to be very small. + check_heading_regexp '-o holdcnt -o holdcnt -o holdcnt' \ + '^HOLDCNT HOLDCNT HOLDCNT$' + check_heading_regexp '-o holdcnt -o holdcnt= -o holdcnt' \ + '^HOLDCNT HOLDCNT$' + check_heading_regexp '-o holdcnt -o holdcnt=HH -o holdcnt' \ + '^HOLDCNT HH HOLDCNT$' +} + +atf_test_case override_heading_all_null +override_heading_all_null_head() +{ + atf_set "descr" "Tests the use of 'ps -o foo= -o bar=' (with a" \ + "null heading for every column). The heading" \ + "should not be printed at all in this case." +} +override_heading_all_null_body() +{ + setup_keywords + # A heading with a space is not a null heading, + # so should not be suppressed + check_heading_regexp '-o comm=" "' \ + '^ *$' + # Null headings should be suppressed + check_no_heading_line '-o pid= -o comm=' + check_no_heading_line '-o pid= -o comm=' + # Check missing pid + check_no_heading_line '-o ppid=' + check_no_heading_line '-o comm=' + check_no_heading_line '-o command=' + check_no_heading_line '-o ppid= -o comm=' + check_no_heading_line '-o comm= -o ppid=' + # Check pid present but not first + check_no_heading_line '-o comm= -o pid=' + check_no_heading_line '-o ppid= -o pid= -o command=' +} + +atf_test_case duplicate_column +duplicate_column_head() +{ + atf_set "descr" "Tests the use of -o options to display the" \ + "same column more than once" +} +duplicate_column_body() +{ + setup_keywords + # two custom headers + check_heading_regexp '-o pid=PPP -o pid=QQQ' \ + '^ *PPP *QQQ$' + # one custom header, before and after default header + check_heading_regexp '-o pid=PPP -o pid' \ + '^ *PPP '"${head_regexp_pid}"'$' + check_heading_regexp '-o pid -o pid=QQQ' \ + '^'"${head_regexp_pid}"' *QQQ$' + # custom headers both before and after default header + check_heading_regexp '-o pid=PPP -o pid -o pid=QQQ' \ + '^ *PPP '"${head_regexp_pid}"' *QQQ$' +} + +atf_init_test_cases() { + atf_add_test_case default_columns + atf_add_test_case minus_O + atf_add_test_case minus_o + atf_add_test_case override_heading_simple + atf_add_test_case override_heading_embedded_specials + atf_add_test_case override_heading_some_null + atf_add_test_case override_heading_all_null + atf_add_test_case duplicate_column +} diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_case.out new file mode 100644 index 000000000000..4c4205563e80 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_case.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before case +before break +after break, return value: 0 +after case +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_compound.out new file mode 100644 index 000000000000..01113ca97a69 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_compound.out @@ -0,0 +1,8 @@ +before case +before dotcmd +compound start +before break +after break, return value: 0 +compound end +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_file.out new file mode 100644 index 000000000000..52640203d8da --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_file.out @@ -0,0 +1,6 @@ +before case +before dotcmd +before break +after break, return value: 0 +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_for.out new file mode 100644 index 000000000000..e116ee2b6a66 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_for.out @@ -0,0 +1,7 @@ +before case +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_func.out new file mode 100644 index 000000000000..906a804d2185 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_func.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before function +before break +after break +after function +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_subshell.out new file mode 100644 index 000000000000..073caff318ba --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_subshell.out @@ -0,0 +1,8 @@ +before case +before dotcmd +subshell start +before break +after break, return value: 0 +subshell end +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_until.out new file mode 100644 index 000000000000..f47bd43cccba --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_until.out @@ -0,0 +1,7 @@ +before case +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_while.out new file mode 100644 index 000000000000..e9a73f8112b1 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_break_while.out @@ -0,0 +1,7 @@ +before case +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_case.out new file mode 100644 index 000000000000..7919427ae304 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_case.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before case +before continue +after continue, return value: 0 +after case +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_compound.out new file mode 100644 index 000000000000..9195e0889eb9 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_compound.out @@ -0,0 +1,8 @@ +before case +before dotcmd +compound start +before continue +after continue, return value: 0 +compound end +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_file.out new file mode 100644 index 000000000000..100a5906f0a4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_file.out @@ -0,0 +1,6 @@ +before case +before dotcmd +before continue +after continue, return value: 0 +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_for.out new file mode 100644 index 000000000000..9a078d0abc1e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_for.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_func.out new file mode 100644 index 000000000000..6282c89d7437 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_func.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before function +before continue +after continue +after function +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_subshell.out new file mode 100644 index 000000000000..b066ab64b7d7 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_subshell.out @@ -0,0 +1,8 @@ +before case +before dotcmd +subshell start +before continue +after continue, return value: 0 +subshell end +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_until.out new file mode 100644 index 000000000000..afc85b6561a1 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_until.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_while.out new file mode 100644 index 000000000000..cb4137d23391 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_continue_while.out @@ -0,0 +1,8 @@ +before case +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_case.out new file mode 100644 index 000000000000..734369d564e3 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_case.out @@ -0,0 +1,6 @@ +before case +before dotcmd +before case +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_compound.out new file mode 100644 index 000000000000..2fae84e35df0 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_compound.out @@ -0,0 +1,6 @@ +before case +before dotcmd +compound start +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_file.out new file mode 100644 index 000000000000..f97ecc6dab50 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_file.out @@ -0,0 +1,5 @@ +before case +before dotcmd +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_for.out new file mode 100644 index 000000000000..d863537007be --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_for.out @@ -0,0 +1,6 @@ +before case +before dotcmd +before for +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_func.out new file mode 100644 index 000000000000..aed8fa4db71a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_func.out @@ -0,0 +1,7 @@ +before case +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_subshell.out new file mode 100644 index 000000000000..364d2458e604 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_subshell.out @@ -0,0 +1,6 @@ +before case +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_until.out new file mode 100644 index 000000000000..daf3811e2e9a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_until.out @@ -0,0 +1,6 @@ +before case +before dotcmd +before until +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_while.out new file mode 100644 index 000000000000..ef6a6764d515 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/case_return_while.out @@ -0,0 +1,6 @@ +before case +before dotcmd +before while +before return +after dotcmd, return value: 0 +after case diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_case.out new file mode 100644 index 000000000000..144bcd6d00f4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_case.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before case +before break +after break, return value: 0 +after case +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_compound.out new file mode 100644 index 000000000000..3fd7b2f92e2a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_compound.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +compound start +before break +after break, return value: 0 +compound end +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_file.out new file mode 100644 index 000000000000..5ad5ed396a74 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_file.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +before break +after break, return value: 0 +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_for.out new file mode 100644 index 000000000000..7f03e495bcde --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_for.out @@ -0,0 +1,7 @@ +compound start +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_func.out new file mode 100644 index 000000000000..82e86b3c778e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_func.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before function +before break +after break +after function +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_subshell.out new file mode 100644 index 000000000000..e26e980f7ebf --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_subshell.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +subshell start +before break +after break, return value: 0 +subshell end +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_until.out new file mode 100644 index 000000000000..34dd25adeaa0 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_until.out @@ -0,0 +1,7 @@ +compound start +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_while.out new file mode 100644 index 000000000000..7019045bc39f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_break_while.out @@ -0,0 +1,7 @@ +compound start +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_case.out new file mode 100644 index 000000000000..206548ccff38 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_case.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before case +before continue +after continue, return value: 0 +after case +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_compound.out new file mode 100644 index 000000000000..a8c7efc159ec --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_compound.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +compound start +before continue +after continue, return value: 0 +compound end +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_file.out new file mode 100644 index 000000000000..c619ad560f9d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_file.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +before continue +after continue, return value: 0 +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_for.out new file mode 100644 index 000000000000..35b092a42fb3 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_for.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_func.out new file mode 100644 index 000000000000..198dbd6af513 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_func.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before function +before continue +after continue +after function +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_subshell.out new file mode 100644 index 000000000000..1ecaa96e422f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_subshell.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +subshell start +before continue +after continue, return value: 0 +subshell end +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_until.out new file mode 100644 index 000000000000..4a74a8e8e431 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_until.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_while.out new file mode 100644 index 000000000000..b2d939ed538c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_continue_while.out @@ -0,0 +1,8 @@ +compound start +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_case.out new file mode 100644 index 000000000000..995d5b556f42 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_case.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +before case +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_compound.out new file mode 100644 index 000000000000..f6e4858e6f5d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_compound.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +compound start +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_file.out new file mode 100644 index 000000000000..84347b28f74d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_file.out @@ -0,0 +1,5 @@ +compound start +before dotcmd +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_for.out new file mode 100644 index 000000000000..ec234472aa6d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_for.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +before for +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_func.out new file mode 100644 index 000000000000..12798d0e0322 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_func.out @@ -0,0 +1,7 @@ +compound start +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_subshell.out new file mode 100644 index 000000000000..af0ab785fbb4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_subshell.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_until.out new file mode 100644 index 000000000000..a108f502d2c6 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_until.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +before until +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_while.out new file mode 100644 index 000000000000..ef34c037a9f8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/compound_return_while.out @@ -0,0 +1,6 @@ +compound start +before dotcmd +before while +before return +after dotcmd, return value: 0 +compound end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_case.out new file mode 100644 index 000000000000..2f34f10c726b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_case.out @@ -0,0 +1,6 @@ +before dotcmd +before case +before break +after break, return value: 0 +after case +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_compound.out new file mode 100644 index 000000000000..0c7300d6a3ee --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_compound.out @@ -0,0 +1,6 @@ +before dotcmd +compound start +before break +after break, return value: 0 +compound end +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_file.out new file mode 100644 index 000000000000..fb4db197ddac --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_file.out @@ -0,0 +1,4 @@ +before dotcmd +before break +after break, return value: 0 +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_for.out new file mode 100644 index 000000000000..66f445287d5b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_for.out @@ -0,0 +1,5 @@ +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_func.out new file mode 100644 index 000000000000..c5488abadbc5 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_func.out @@ -0,0 +1,6 @@ +before dotcmd +before function +before break +after break +after function +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_subshell.out new file mode 100644 index 000000000000..47e2394084af --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_subshell.out @@ -0,0 +1,6 @@ +before dotcmd +subshell start +before break +after break, return value: 0 +subshell end +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_until.out new file mode 100644 index 000000000000..b51ff195bd84 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_until.out @@ -0,0 +1,5 @@ +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_while.out new file mode 100644 index 000000000000..0fd3a83ce03d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_break_while.out @@ -0,0 +1,5 @@ +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_case.out new file mode 100644 index 000000000000..2cf3be6d3b4e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_case.out @@ -0,0 +1,6 @@ +before dotcmd +before case +before continue +after continue, return value: 0 +after case +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_compound.out new file mode 100644 index 000000000000..7bec42019aee --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_compound.out @@ -0,0 +1,6 @@ +before dotcmd +compound start +before continue +after continue, return value: 0 +compound end +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_file.out new file mode 100644 index 000000000000..2f8806c60b6d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_file.out @@ -0,0 +1,4 @@ +before dotcmd +before continue +after continue, return value: 0 +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_for.out new file mode 100644 index 000000000000..e8da2390bbbf --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_for.out @@ -0,0 +1,6 @@ +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_func.out new file mode 100644 index 000000000000..da683c02a158 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_func.out @@ -0,0 +1,6 @@ +before dotcmd +before function +before continue +after continue +after function +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_subshell.out new file mode 100644 index 000000000000..388558b060e6 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_subshell.out @@ -0,0 +1,6 @@ +before dotcmd +subshell start +before continue +after continue, return value: 0 +subshell end +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_until.out new file mode 100644 index 000000000000..bb0f28134eee --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_until.out @@ -0,0 +1,6 @@ +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_while.out new file mode 100644 index 000000000000..63338234aa4c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_continue_while.out @@ -0,0 +1,6 @@ +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_case.out new file mode 100644 index 000000000000..486685242bda --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_case.out @@ -0,0 +1,4 @@ +before dotcmd +before case +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_compound.out new file mode 100644 index 000000000000..6b831451d867 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_compound.out @@ -0,0 +1,4 @@ +before dotcmd +compound start +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_file.out new file mode 100644 index 000000000000..2d6742310a0f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_file.out @@ -0,0 +1,3 @@ +before dotcmd +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_for.out new file mode 100644 index 000000000000..83f8e002950f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_for.out @@ -0,0 +1,4 @@ +before dotcmd +before for +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_func.out new file mode 100644 index 000000000000..a0db2c99cfa8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_func.out @@ -0,0 +1,5 @@ +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_subshell.out new file mode 100644 index 000000000000..83cd0e4ed0b0 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_subshell.out @@ -0,0 +1,4 @@ +before dotcmd +subshell start +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_until.out new file mode 100644 index 000000000000..fdf2449045a1 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_until.out @@ -0,0 +1,4 @@ +before dotcmd +before until +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_while.out new file mode 100644 index 000000000000..a733aa38912b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/file_return_while.out @@ -0,0 +1,4 @@ +before dotcmd +before while +before return +after dotcmd, return value: 0 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_case.out new file mode 100644 index 000000000000..262db24358d4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_case.out @@ -0,0 +1,5 @@ +before for +before dotcmd +before case +before break +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_compound.out new file mode 100644 index 000000000000..418a4de73c0c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_compound.out @@ -0,0 +1,5 @@ +before for +before dotcmd +compound start +before break +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_file.out new file mode 100644 index 000000000000..752c95c9815c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_file.out @@ -0,0 +1,4 @@ +before for +before dotcmd +before break +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_for.out new file mode 100644 index 000000000000..20af6224fc55 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_for.out @@ -0,0 +1,12 @@ +before for +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_func.out new file mode 100644 index 000000000000..fe0cab4fa49b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_func.out @@ -0,0 +1,5 @@ +before for +before dotcmd +before function +before break +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_subshell.out new file mode 100644 index 000000000000..985aab6270c4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_subshell.out @@ -0,0 +1,10 @@ +before for +before dotcmd +subshell start +before break +after dotcmd, return value: 0 +before dotcmd +subshell start +before break +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_until.out new file mode 100644 index 000000000000..b47c90198f18 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_until.out @@ -0,0 +1,12 @@ +before for +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_while.out new file mode 100644 index 000000000000..deb4cebaece8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_break_while.out @@ -0,0 +1,12 @@ +before for +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_case.out new file mode 100644 index 000000000000..e989063290ea --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_case.out @@ -0,0 +1,8 @@ +before for +before dotcmd +before case +before continue +before dotcmd +before case +before continue +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_compound.out new file mode 100644 index 000000000000..0fd23b628719 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_compound.out @@ -0,0 +1,8 @@ +before for +before dotcmd +compound start +before continue +before dotcmd +compound start +before continue +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_file.out new file mode 100644 index 000000000000..286bb88c1ea1 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_file.out @@ -0,0 +1,6 @@ +before for +before dotcmd +before continue +before dotcmd +before continue +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_for.out new file mode 100644 index 000000000000..044d5a35c55e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_for.out @@ -0,0 +1,14 @@ +before for +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_func.out new file mode 100644 index 000000000000..a0cc6cc18fd8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_func.out @@ -0,0 +1,8 @@ +before for +before dotcmd +before function +before continue +before dotcmd +before function +before continue +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_subshell.out new file mode 100644 index 000000000000..f1ae7aab16d0 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_subshell.out @@ -0,0 +1,10 @@ +before for +before dotcmd +subshell start +before continue +after dotcmd, return value: 0 +before dotcmd +subshell start +before continue +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_until.out new file mode 100644 index 000000000000..b1c4147a9730 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_until.out @@ -0,0 +1,14 @@ +before for +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_while.out new file mode 100644 index 000000000000..f8e5c5d11830 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_continue_while.out @@ -0,0 +1,14 @@ +before for +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_case.out new file mode 100644 index 000000000000..24b7145a05c4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_case.out @@ -0,0 +1,10 @@ +before for +before dotcmd +before case +before return +after dotcmd, return value: 0 +before dotcmd +before case +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_compound.out new file mode 100644 index 000000000000..30b4dac3988e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_compound.out @@ -0,0 +1,10 @@ +before for +before dotcmd +compound start +before return +after dotcmd, return value: 0 +before dotcmd +compound start +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_file.out new file mode 100644 index 000000000000..88555621c77f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_file.out @@ -0,0 +1,8 @@ +before for +before dotcmd +before return +after dotcmd, return value: 0 +before dotcmd +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_for.out new file mode 100644 index 000000000000..52a72a9fb0c8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_for.out @@ -0,0 +1,10 @@ +before for +before dotcmd +before for +before return +after dotcmd, return value: 0 +before dotcmd +before for +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_func.out new file mode 100644 index 000000000000..4f0fee21740b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_func.out @@ -0,0 +1,12 @@ +before for +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_subshell.out new file mode 100644 index 000000000000..4b8f36c1a331 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_subshell.out @@ -0,0 +1,10 @@ +before for +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_until.out new file mode 100644 index 000000000000..3eaf9df84b8b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_until.out @@ -0,0 +1,10 @@ +before for +before dotcmd +before until +before return +after dotcmd, return value: 0 +before dotcmd +before until +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_while.out new file mode 100644 index 000000000000..8cbad954cdad --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/for_return_while.out @@ -0,0 +1,10 @@ +before for +before dotcmd +before while +before return +after dotcmd, return value: 0 +before dotcmd +before while +before return +after dotcmd, return value: 0 +after for diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_case.out new file mode 100644 index 000000000000..7373371e511b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_case.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before case +before break +after break, return value: 0 +after case +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_compound.out new file mode 100644 index 000000000000..e87b4a2e8e14 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_compound.out @@ -0,0 +1,8 @@ +before function +before dotcmd +compound start +before break +after break, return value: 0 +compound end +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_file.out new file mode 100644 index 000000000000..cf144227aefe --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_file.out @@ -0,0 +1,6 @@ +before function +before dotcmd +before break +after break, return value: 0 +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_for.out new file mode 100644 index 000000000000..c3853488a517 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_for.out @@ -0,0 +1,7 @@ +before function +before dotcmd +before for +before break +after for +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_func.out new file mode 100644 index 000000000000..5c1c4c830164 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_func.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before function +before break +after break +after function +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_subshell.out new file mode 100644 index 000000000000..affe3e4bdefb --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_subshell.out @@ -0,0 +1,8 @@ +before function +before dotcmd +subshell start +before break +after break, return value: 0 +subshell end +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_until.out new file mode 100644 index 000000000000..b0f942a04fbf --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_until.out @@ -0,0 +1,7 @@ +before function +before dotcmd +before until +before break +after until +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_while.out new file mode 100644 index 000000000000..d687aa766498 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_break_while.out @@ -0,0 +1,7 @@ +before function +before dotcmd +before while +before break +after while +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_case.out new file mode 100644 index 000000000000..b1ad4be38bfd --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_case.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before case +before continue +after continue, return value: 0 +after case +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_compound.out new file mode 100644 index 000000000000..d6a5edd9940f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_compound.out @@ -0,0 +1,8 @@ +before function +before dotcmd +compound start +before continue +after continue, return value: 0 +compound end +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_file.out new file mode 100644 index 000000000000..f300d6afee79 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_file.out @@ -0,0 +1,6 @@ +before function +before dotcmd +before continue +after continue, return value: 0 +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_for.out new file mode 100644 index 000000000000..d46095d58d36 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_for.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before for +before continue +before continue +after for +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_func.out new file mode 100644 index 000000000000..3ff73a2bdaa9 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_func.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before function +before continue +after continue +after function +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_subshell.out new file mode 100644 index 000000000000..fd295aad8542 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_subshell.out @@ -0,0 +1,8 @@ +before function +before dotcmd +subshell start +before continue +after continue, return value: 0 +subshell end +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_until.out new file mode 100644 index 000000000000..7a6508328e00 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_until.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before until +before continue +before continue +after until +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_while.out new file mode 100644 index 000000000000..6ecbe8261164 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_continue_while.out @@ -0,0 +1,8 @@ +before function +before dotcmd +before while +before continue +before continue +after while +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_case.out new file mode 100644 index 000000000000..8f0c0948357a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_case.out @@ -0,0 +1,6 @@ +before function +before dotcmd +before case +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_compound.out new file mode 100644 index 000000000000..e3d86704f79d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_compound.out @@ -0,0 +1,6 @@ +before function +before dotcmd +compound start +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_file.out new file mode 100644 index 000000000000..95e341525799 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_file.out @@ -0,0 +1,5 @@ +before function +before dotcmd +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_for.out new file mode 100644 index 000000000000..511cc39ca34f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_for.out @@ -0,0 +1,6 @@ +before function +before dotcmd +before for +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_func.out new file mode 100644 index 000000000000..a87d3a780043 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_func.out @@ -0,0 +1,7 @@ +before function +before dotcmd +before function +before return +after function +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_subshell.out new file mode 100644 index 000000000000..fdb37b20979e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_subshell.out @@ -0,0 +1,6 @@ +before function +before dotcmd +subshell start +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_until.out new file mode 100644 index 000000000000..08b45be42f4f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_until.out @@ -0,0 +1,6 @@ +before function +before dotcmd +before until +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_while.out new file mode 100644 index 000000000000..27fbcaf88b22 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/func_return_while.out @@ -0,0 +1,6 @@ +before function +before dotcmd +before while +before return +after dotcmd +after function diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_case.out new file mode 100644 index 000000000000..155daea6606d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_case.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before case +before break +after break, return value: 0 +after case +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_compound.out new file mode 100644 index 000000000000..a643ac080d91 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_compound.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +compound start +before break +after break, return value: 0 +compound end +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_file.out new file mode 100644 index 000000000000..2556d89acbbe --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_file.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +before break +after break, return value: 0 +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_for.out new file mode 100644 index 000000000000..27040a992adf --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_for.out @@ -0,0 +1,7 @@ +subshell start +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_func.out new file mode 100644 index 000000000000..83ec062eed6a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_func.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before function +before break +after break +after function +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_subshell.out new file mode 100644 index 000000000000..8a53ac59e578 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_subshell.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +subshell start +before break +after break, return value: 0 +subshell end +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_until.out new file mode 100644 index 000000000000..a31fa5bfa332 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_until.out @@ -0,0 +1,7 @@ +subshell start +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_while.out new file mode 100644 index 000000000000..42eb970ef81d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_break_while.out @@ -0,0 +1,7 @@ +subshell start +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_case.out new file mode 100644 index 000000000000..4d74b7b151e2 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_case.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before case +before continue +after continue, return value: 0 +after case +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_compound.out new file mode 100644 index 000000000000..4328df396efb --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_compound.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +compound start +before continue +after continue, return value: 0 +compound end +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_file.out new file mode 100644 index 000000000000..a4a6e4ae0411 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_file.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +before continue +after continue, return value: 0 +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_for.out new file mode 100644 index 000000000000..e82988936104 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_for.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_func.out new file mode 100644 index 000000000000..e0ead4c87cb9 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_func.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before function +before continue +after continue +after function +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_subshell.out new file mode 100644 index 000000000000..dfcdfb46a662 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_subshell.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +subshell start +before continue +after continue, return value: 0 +subshell end +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_until.out new file mode 100644 index 000000000000..66e8f9f269ae --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_until.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_while.out new file mode 100644 index 000000000000..f1c83f43d394 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_continue_while.out @@ -0,0 +1,8 @@ +subshell start +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_case.out new file mode 100644 index 000000000000..008d9396a260 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_case.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +before case +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_compound.out new file mode 100644 index 000000000000..bdab2314d44b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_compound.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +compound start +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_file.out new file mode 100644 index 000000000000..43d011dfb970 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_file.out @@ -0,0 +1,5 @@ +subshell start +before dotcmd +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_for.out new file mode 100644 index 000000000000..7cfed898d338 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_for.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +before for +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_func.out new file mode 100644 index 000000000000..b695c53484c8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_func.out @@ -0,0 +1,7 @@ +subshell start +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_subshell.out new file mode 100644 index 000000000000..c5ccf597e61c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_subshell.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_until.out new file mode 100644 index 000000000000..64737ad7341f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_until.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +before until +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_while.out new file mode 100644 index 000000000000..de520c4493ef --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/subshell_return_while.out @@ -0,0 +1,6 @@ +subshell start +before dotcmd +before while +before return +after dotcmd, return value: 0 +subshell end diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_case.out new file mode 100644 index 000000000000..f0483b459129 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_case.out @@ -0,0 +1,5 @@ +before until +before dotcmd +before case +before break +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_compound.out new file mode 100644 index 000000000000..a5e37ba7ab5d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_compound.out @@ -0,0 +1,5 @@ +before until +before dotcmd +compound start +before break +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_file.out new file mode 100644 index 000000000000..a2fde4dafe28 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_file.out @@ -0,0 +1,4 @@ +before until +before dotcmd +before break +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_for.out new file mode 100644 index 000000000000..8b3faf520a8f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_for.out @@ -0,0 +1,12 @@ +before until +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_func.out new file mode 100644 index 000000000000..a83ce2b82c0c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_func.out @@ -0,0 +1,5 @@ +before until +before dotcmd +before function +before break +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_subshell.out new file mode 100644 index 000000000000..008d30dfc7d6 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_subshell.out @@ -0,0 +1,10 @@ +before until +before dotcmd +subshell start +before break +after dotcmd, return value: 0 +before dotcmd +subshell start +before break +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_until.out new file mode 100644 index 000000000000..05fb94a46af3 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_until.out @@ -0,0 +1,12 @@ +before until +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_while.out new file mode 100644 index 000000000000..6ae1f9c4225d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_break_while.out @@ -0,0 +1,12 @@ +before until +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_case.out new file mode 100644 index 000000000000..40028fb08139 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_case.out @@ -0,0 +1,8 @@ +before until +before dotcmd +before case +before continue +before dotcmd +before case +before continue +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_compound.out new file mode 100644 index 000000000000..3641e1e3f5c2 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_compound.out @@ -0,0 +1,8 @@ +before until +before dotcmd +compound start +before continue +before dotcmd +compound start +before continue +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_file.out new file mode 100644 index 000000000000..c9f5193b740f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_file.out @@ -0,0 +1,6 @@ +before until +before dotcmd +before continue +before dotcmd +before continue +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_for.out new file mode 100644 index 000000000000..fd582401d026 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_for.out @@ -0,0 +1,14 @@ +before until +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_func.out new file mode 100644 index 000000000000..6beb16323068 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_func.out @@ -0,0 +1,8 @@ +before until +before dotcmd +before function +before continue +before dotcmd +before function +before continue +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_subshell.out new file mode 100644 index 000000000000..534509e7e69d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_subshell.out @@ -0,0 +1,10 @@ +before until +before dotcmd +subshell start +before continue +after dotcmd, return value: 0 +before dotcmd +subshell start +before continue +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_until.out new file mode 100644 index 000000000000..ddfeb2797a7e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_until.out @@ -0,0 +1,14 @@ +before until +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_while.out new file mode 100644 index 000000000000..5707821eca00 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_continue_while.out @@ -0,0 +1,14 @@ +before until +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_case.out new file mode 100644 index 000000000000..70dd420505cd --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_case.out @@ -0,0 +1,10 @@ +before until +before dotcmd +before case +before return +after dotcmd, return value: 0 +before dotcmd +before case +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_compound.out new file mode 100644 index 000000000000..145d2c580f07 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_compound.out @@ -0,0 +1,10 @@ +before until +before dotcmd +compound start +before return +after dotcmd, return value: 0 +before dotcmd +compound start +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_file.out new file mode 100644 index 000000000000..5b0adb198c6d --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_file.out @@ -0,0 +1,8 @@ +before until +before dotcmd +before return +after dotcmd, return value: 0 +before dotcmd +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_for.out new file mode 100644 index 000000000000..b113e8c0552a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_for.out @@ -0,0 +1,10 @@ +before until +before dotcmd +before for +before return +after dotcmd, return value: 0 +before dotcmd +before for +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_func.out new file mode 100644 index 000000000000..1ab16ab70360 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_func.out @@ -0,0 +1,12 @@ +before until +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_subshell.out new file mode 100644 index 000000000000..d44463108242 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_subshell.out @@ -0,0 +1,10 @@ +before until +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_until.out new file mode 100644 index 000000000000..39980179a781 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_until.out @@ -0,0 +1,10 @@ +before until +before dotcmd +before until +before return +after dotcmd, return value: 0 +before dotcmd +before until +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_while.out new file mode 100644 index 000000000000..9b140cf7a0a3 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/until_return_while.out @@ -0,0 +1,10 @@ +before until +before dotcmd +before while +before return +after dotcmd, return value: 0 +before dotcmd +before while +before return +after dotcmd, return value: 0 +after until diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_case.out new file mode 100644 index 000000000000..1b0731fcaf38 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_case.out @@ -0,0 +1,5 @@ +before while +before dotcmd +before case +before break +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_compound.out new file mode 100644 index 000000000000..05c23eb4284c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_compound.out @@ -0,0 +1,5 @@ +before while +before dotcmd +compound start +before break +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_file.out new file mode 100644 index 000000000000..cb70ae19221e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_file.out @@ -0,0 +1,4 @@ +before while +before dotcmd +before break +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_for.out new file mode 100644 index 000000000000..b94eac165604 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_for.out @@ -0,0 +1,12 @@ +before while +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +before dotcmd +before for +before break +after for +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_func.out new file mode 100644 index 000000000000..7d54c1514a67 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_func.out @@ -0,0 +1,5 @@ +before while +before dotcmd +before function +before break +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_subshell.out new file mode 100644 index 000000000000..234cd663c2e0 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_subshell.out @@ -0,0 +1,10 @@ +before while +before dotcmd +subshell start +before break +after dotcmd, return value: 0 +before dotcmd +subshell start +before break +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_until.out new file mode 100644 index 000000000000..f3602302673f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_until.out @@ -0,0 +1,12 @@ +before while +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +before dotcmd +before until +before break +after until +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_while.out new file mode 100644 index 000000000000..451b0a23671b --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_break_while.out @@ -0,0 +1,12 @@ +before while +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +before dotcmd +before while +before break +after while +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_case.out new file mode 100644 index 000000000000..d7f412c0d554 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_case.out @@ -0,0 +1,8 @@ +before while +before dotcmd +before case +before continue +before dotcmd +before case +before continue +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_compound.out new file mode 100644 index 000000000000..001904764a68 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_compound.out @@ -0,0 +1,8 @@ +before while +before dotcmd +compound start +before continue +before dotcmd +compound start +before continue +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_file.out new file mode 100644 index 000000000000..9070dea4528e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_file.out @@ -0,0 +1,6 @@ +before while +before dotcmd +before continue +before dotcmd +before continue +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_for.out new file mode 100644 index 000000000000..98696ee40190 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_for.out @@ -0,0 +1,14 @@ +before while +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +before dotcmd +before for +before continue +before continue +after for +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_func.out new file mode 100644 index 000000000000..77efc2c9c87a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_func.out @@ -0,0 +1,8 @@ +before while +before dotcmd +before function +before continue +before dotcmd +before function +before continue +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_subshell.out new file mode 100644 index 000000000000..b4106a1e2d83 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_subshell.out @@ -0,0 +1,10 @@ +before while +before dotcmd +subshell start +before continue +after dotcmd, return value: 0 +before dotcmd +subshell start +before continue +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_until.out new file mode 100644 index 000000000000..7f893a015a6a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_until.out @@ -0,0 +1,14 @@ +before while +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +before dotcmd +before until +before continue +before continue +after until +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_while.out new file mode 100644 index 000000000000..317be17fadc4 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_continue_while.out @@ -0,0 +1,14 @@ +before while +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +before dotcmd +before while +before continue +before continue +after while +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_case.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_case.out new file mode 100644 index 000000000000..abb6a4afcfab --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_case.out @@ -0,0 +1,10 @@ +before while +before dotcmd +before case +before return +after dotcmd, return value: 0 +before dotcmd +before case +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_compound.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_compound.out new file mode 100644 index 000000000000..b37418b3d34e --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_compound.out @@ -0,0 +1,10 @@ +before while +before dotcmd +compound start +before return +after dotcmd, return value: 0 +before dotcmd +compound start +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_file.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_file.out new file mode 100644 index 000000000000..1c4791ef7639 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_file.out @@ -0,0 +1,8 @@ +before while +before dotcmd +before return +after dotcmd, return value: 0 +before dotcmd +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_for.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_for.out new file mode 100644 index 000000000000..0569d6fe6707 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_for.out @@ -0,0 +1,10 @@ +before while +before dotcmd +before for +before return +after dotcmd, return value: 0 +before dotcmd +before for +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_func.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_func.out new file mode 100644 index 000000000000..cb5a30853a10 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_func.out @@ -0,0 +1,12 @@ +before while +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +before dotcmd +before function +before return +after function +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_subshell.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_subshell.out new file mode 100644 index 000000000000..161a227239bc --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_subshell.out @@ -0,0 +1,10 @@ +before while +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +before dotcmd +subshell start +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_until.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_until.out new file mode 100644 index 000000000000..d84a5f71dca8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_until.out @@ -0,0 +1,10 @@ +before while +before dotcmd +before until +before return +after dotcmd, return value: 0 +before dotcmd +before until +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_while.out b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_while.out new file mode 100644 index 000000000000..4eeaaa9b5244 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/out/while_return_while.out @@ -0,0 +1,10 @@ +before while +before dotcmd +before while +before return +after dotcmd, return value: 0 +before dotcmd +before while +before return +after dotcmd, return value: 0 +after while diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/scoped_command b/contrib/netbsd-tests/bin/sh/dotcmd/scoped_command new file mode 100755 index 000000000000..fda4e53a302a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/dotcmd/scoped_command @@ -0,0 +1,129 @@ +#!/bin/sh +# +# $NetBSD: scoped_command,v 1.1 2014/05/31 14:29:06 christos Exp $ +# +# Copyright (c) 2014 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Jarmo Jaakkola. +# +# 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. +# + +set -e + +# USAGE: +# scoped_command scope cmd msg var_suffix +# +# Write to stdout a piece of Bourne Shell script with _cmd_ in specific +# _scope_. The execution of _cmd_ is bracketed by prints of "before _msg_" +# and "after _msg_, return value ${?}". If the generated script uses +# variables, __var_suffix_ is appended to their names to allow nesting of +# scripts generated this way. +# +# _scope_ should be one of: case, compound, file, for, func, subshell, +# until, while. +# _cmd_ is the command line to execute. Remember proper quoting! +# _msg_ is text that will be used inside single quotes. +# _var_suffix_ is a syntactically valid identifier name. + +# don't rely on command lists (';') +cmd="echo 'before ${3}' +${2} +echo 'after ${3}, return value:' ${?}" + +echo "#!/bin/sh" + +[ 'func' = "${1}" ] && cat <0, and is not part of the compound list following a +# while, until, or if keyword, and is not a part of an AND or OR list, +# and is not a pipeline preceded by the ! reserved word, then the shell +# shall immediately exit. + +crud() { + set -e + for x in a + do + BAR="foo" + false && echo true + echo mumble + done +} + +atf_test_case set_e +set_e_head() { + atf_set "descr" "Tests that 'set -e' turns on error detection" \ + "and that it behaves as defined by the standard" +} +set_e_body() { + foo=`crud` + atf_check_equal 'x$foo' 'xmumble' +} + +atf_init_test_cases() { + atf_add_test_case set_e +} diff --git a/contrib/netbsd-tests/bin/sh/t_evaltested.sh b/contrib/netbsd-tests/bin/sh/t_evaltested.sh new file mode 100755 index 000000000000..e40f8bd4b3be --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_evaltested.sh @@ -0,0 +1,60 @@ +# $NetBSD: t_evaltested.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# +# Copyright (c) 2011 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 evaltested + +evaltested_head() { + atf_set "descr" "Tests that eval in a tested context does not exit" +} + +evaltested_body() { + set -e +cat > helper.sh << EOF +set -e +if eval false +then + echo "'eval false' returned true" + exit 1 +fi +echo "passed" +exit 0 +EOF + output="$(/bin/sh helper.sh)" + [ $? = 0 ] && return + + if [ -n "$output" ] + then + atf_fail "$output" + else + atf_fail "'eval false' exited from a tested context" + fi + +} + +atf_init_test_cases() { + atf_add_test_case evaltested +} diff --git a/contrib/netbsd-tests/bin/sh/t_exit.sh b/contrib/netbsd-tests/bin/sh/t_exit.sh new file mode 100755 index 000000000000..62c5869c009c --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_exit.sh @@ -0,0 +1,105 @@ +# $NetBSD: t_exit.sh,v 1.3 2012/04/13 06:12:32 jruoho 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. +# + +crud() { + test yes = no + + cat <helper.sh + atf_check -s eq:0 -o match:exiting -e empty /bin/sh helper.sh + atf_check -s eq:0 -o match:exiting -e empty /bin/ksh helper.sh +} + +atf_test_case trap_zero__explicit_exit +trap_zero__explicit_exit_body() { + echo '( trap "echo exiting" 0; exit )' >helper.sh + atf_check -s eq:0 -o match:exiting -e empty /bin/sh helper.sh + atf_check -s eq:0 -o match:exiting -e empty /bin/ksh helper.sh +} + +atf_test_case trap_zero__explicit_return +trap_zero__explicit_return_body() { + echo '( trap "echo exiting" 0; return )' >helper.sh + atf_check -s eq:0 -o match:exiting -e empty /bin/sh helper.sh + atf_check -s eq:0 -o match:exiting -e empty /bin/ksh helper.sh +} + +atf_init_test_cases() { + atf_add_test_case background + atf_add_test_case function + atf_add_test_case readout + atf_add_test_case trap_subshell + atf_add_test_case trap_zero__implicit_exit + atf_add_test_case trap_zero__explicit_exit + atf_add_test_case trap_zero__explicit_return +} diff --git a/contrib/netbsd-tests/bin/sh/t_expand.sh b/contrib/netbsd-tests/bin/sh/t_expand.sh new file mode 100755 index 000000000000..eeaad5f7db71 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_expand.sh @@ -0,0 +1,142 @@ +# $NetBSD: t_expand.sh,v 1.2 2013/10/06 21:05:50 ast Exp $ +# +# Copyright (c) 2007, 2009 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. +# + +# +# This file tests the functions in expand.c. +# + +delim_argv() { + str= + while [ $# -gt 0 ]; do + if [ -z "${str}" ]; then + str=">$1<" + else + str="${str} >$1<" + fi + shift + done + echo ${str} +} + +atf_test_case dollar_at +dollar_at_head() { + atf_set "descr" "Somewhere between 2.0.2 and 3.0 the expansion" \ + "of the \$@ variable had been broken. Check for" \ + "this behavior." +} +dollar_at_body() { + # This one should work everywhere. + got=`echo "" "" | sed 's,$,EOL,'` + atf_check_equal ' EOL' '$got' + + # This code triggered the bug. + set -- "" "" + got=`echo "$@" | sed 's,$,EOL,'` + atf_check_equal ' EOL' '$got' + + set -- - + shift + n_arg() { echo $#; } + n_args=`n_arg "$@"` + atf_check_equal '0' '$n_args' +} + +atf_test_case dollar_at_with_text +dollar_at_with_text_head() { + atf_set "descr" "Test \$@ expansion when it is surrounded by text" \ + "within the quotes. PR bin/33956." +} +dollar_at_with_text_body() { + set -- + atf_check_equal '' "$(delim_argv "$@")" + atf_check_equal '>foobar<' "$(delim_argv "foo$@bar")" + atf_check_equal '>foo bar<' "$(delim_argv "foo $@ bar")" + + set -- a b c + atf_check_equal '>a< >b< >c<' "$(delim_argv "$@")" + atf_check_equal '>fooa< >b< >cbar<' "$(delim_argv "foo$@bar")" + atf_check_equal '>foo a< >b< >c bar<' "$(delim_argv "foo $@ bar")" +} + +atf_test_case strip +strip_head() { + atf_set "descr" "Checks that the %% operator works and strips" \ + "the contents of a variable from the given point" \ + "to the end" +} +strip_body() { + line='#define bindir "/usr/bin" /* comment */' + stripped='#define bindir "/usr/bin" ' + atf_expect_fail "PR bin/43469" + atf_check_equal '$stripped' '${line%%/\**}' +} + +atf_test_case varpattern_backslashes +varpattern_backslashes_head() { + atf_set "descr" "Tests that protecting wildcards with backslashes" \ + "works in variable patterns." +} +varpattern_backslashes_body() { + line='/foo/bar/*/baz' + stripped='/foo/bar/' + atf_check_equal $stripped ${line%%\**} +} + +atf_test_case arithmetic +arithmetic_head() { + atf_set "descr" "POSIX requires shell arithmetic to use signed" \ + "long or a wider type. We use intmax_t, so at" \ + "least 64 bits should be available. Make sure" \ + "this is true." +} +arithmetic_body() { + atf_check_equal '3' '$((1 + 2))' + atf_check_equal '2147483647' '$((0x7fffffff))' + atf_check_equal '9223372036854775807' '$(((1 << 63) - 1))' +} + +atf_test_case iteration_on_null_parameter +iteration_on_null_parameter_head() { + atf_set "descr" "Check iteration of \$@ in for loop when set to null;" \ + "the error \"sh: @: parameter not set\" is incorrect." \ + "PR bin/48202." +} +iteration_on_null_parameter_body() { + s1=`/bin/sh -uc 'N=; set -- ${N}; for X; do echo "[$X]"; done' 2>&1` + s2=`/bin/sh -uc 'N=; set -- ${N:-}; for X; do echo "[$X]"; done' 2>&1` + atf_check_equal '' '$s1' + atf_check_equal '[]' '$s2' +} + +atf_init_test_cases() { + atf_add_test_case dollar_at + atf_add_test_case dollar_at_with_text + atf_add_test_case strip + atf_add_test_case varpattern_backslashes + atf_add_test_case arithmetic + atf_add_test_case iteration_on_null_parameter +} diff --git a/contrib/netbsd-tests/bin/sh/t_fsplit.sh b/contrib/netbsd-tests/bin/sh/t_fsplit.sh new file mode 100755 index 000000000000..2c3dbae23dc8 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_fsplit.sh @@ -0,0 +1,186 @@ +# $NetBSD: t_fsplit.sh,v 1.1 2012/03/17 16:33:11 jruoho 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. +# + +# The standard +# http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html +# explains (section 2.6) that Field splitting should be performed on the +# result of variable expansions. +# In particular this means that in ${x-word}, 'word' must be expanded as if +# the "${x-" and "}" were absent from the input line. +# +# So: sh -c 'set ${x-a b c}; echo $#' should give 3. +# + +nl=' +' + +check() +{ + result="$(eval $1)" + # Remove newlines + oifs="$IFS" + IFS="$nl" + result="$(echo $result)" + IFS="$oifs" + if [ "$2" != "$result" ] + then + atf_fail "expected [$2], found [$result]" + fi +} + +atf_test_case for +for_head() { + atf_set "descr" "Checks field splitting in for loops" +} +for_body() { + unset x + + # Since I managed to break this, leave the test in + check 'for f in $x; do echo x${f}y; done' '' +} + +atf_test_case default_val +default_val_head() { + atf_set "descr" "Checks field splitting in variable default values" +} +default_val_body() { + unset x + + # Check that IFS is applied to text from ${x-...} unless it is inside + # any set of "..." + check 'set ${x-a b c}; echo $#' 3 + check 'for i in ${x-a b c}; do echo "z${i}z"; done' 'zaz zbz zcz' + check 'for i in ${x-"a b" c}; do echo "z${i}z"; done' 'za bz zcz' + check 'for i in ${x-"a ${x-b c}" d}; do echo "z${i}z"; done' 'za b cz zdz' + check 'for i in ${x-"a ${x-"b c"}" d}; do echo "z${i}z"; done' 'za b cz zdz' + check 'for i in ${x-a ${x-"b c"} d}; do echo "z${i}z"; done' 'zaz zb cz zdz' + check 'for i in ${x-a ${x-b c} d}; do echo "z${i}z"; done' 'zaz zbz zcz zdz' +} + +atf_test_case ifs_alpha +ifs_alpha_head() { + atf_set "descr" "Checks that field splitting works with alphabetic" \ + "characters" +} +ifs_alpha_body() { + unset x + + # repeat with an alphabetic in IFS + check 'IFS=q; set ${x-aqbqc}; echo $#' 3 + check 'IFS=q; for i in ${x-aqbqc}; do echo "z${i}z"; done' 'zaz zbz zcz' + check 'IFS=q; for i in ${x-"aqb"qc}; do echo "z${i}z"; done' 'zaqbz zcz' + check 'IFS=q; for i in ${x-"aq${x-bqc}"qd}; do echo "z${i}z"; done' 'zaqbqcz zdz' + check 'IFS=q; for i in ${x-"aq${x-"bqc"}"qd}; do echo "z${i}z"; done' 'zaqbqcz zdz' + check 'IFS=q; for i in ${x-aq${x-"bqc"}qd}; do echo "z${i}z"; done' 'zaz zbqcz zdz' +} + +atf_test_case quote +quote_head() { + atf_set "descr" "Checks that field splitting works with multi-word" \ + "fields" +} +quote_body() { + unset x + + # Some quote propagation checks + check 'set "${x-a b c}"; echo $#' 1 + check 'set "${x-"a b" c}"; echo $1' 'a b c' + check 'for i in "${x-a b c}"; do echo "z${i}z"; done' 'za b cz' +} + +atf_test_case dollar_at +dollar_at_head() { + atf_set "descr" "Checks that field splitting works when expanding" \ + "\$@" +} +dollar_at_body() { + unset x + + # Check we get "$@" right + check 'set ""; for i; do echo "z${i}z"; done' 'zz' + check 'set ""; for i in "$@"; do echo "z${i}z"; done' 'zz' + check 'set "" ""; for i; do echo "z${i}z"; done' 'zz zz' + check 'set "" ""; for i in "$@"; do echo "z${i}z"; done' 'zz zz' + check 'set "" ""; for i in $@; do echo "z${i}z"; done' '' + check 'set "a b" c; for i; do echo "z${i}z"; done' 'za bz zcz' + check 'set "a b" c; for i in "$@"; do echo "z${i}z"; done' 'za bz zcz' + check 'set "a b" c; for i in $@; do echo "z${i}z"; done' 'zaz zbz zcz' + check 'set " a b " c; for i in "$@"; do echo "z${i}z"; done' 'z a b z zcz' + check 'set --; for i in x"$@"x; do echo "z${i}z"; done' 'zxxz' + check 'set a; for i in x"$@"x; do echo "z${i}z"; done' 'zxaxz' + check 'set a b; for i in x"$@"x; do echo "z${i}z"; done' 'zxaz zbxz' +} + +atf_test_case ifs +ifs_head() { + atf_set "descr" "Checks that IFS correctly configures field" \ + "splitting behavior" +} +ifs_body() { + unset x + + # Some IFS tests + check 't="-- "; IFS=" "; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '0' + check 't=" x"; IFS=" x"; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '1' + check 't=" x "; IFS=" x"; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '1' + check 't=axb; IFS="x"; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '2 a:b' + check 't="a x b"; IFS="x"; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '2 a : b' + check 't="a xx b"; IFS="x"; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '3 a :: b' + check 't="a xx b"; IFS="x "; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '3 a::b' + # A recent 'clarification' means that a single trailing IFS non-whitespace + # doesn't generate an empty parameter + check 't="xax"; IFS="x"; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '2 :a' + check 't="xax "; IFS="x "; set $t; IFS=":"; r="$*"; IFS=; echo $# $r' '2 :a' + # Verify that IFS isn't being applied where it shouldn't be. + check 'IFS="x"; set axb; IFS=":"; r="$*"; IFS=; echo $# $r' '1 axb' +} + +atf_test_case var_length +var_length_head() { + atf_set "descr" "Checks that field splitting works when expanding" \ + "a variable's length" +} +var_length_body() { + unset x + + # Check that we apply IFS to ${#var} + long=12345678123456781234567812345678 + long=$long$long$long$long + check 'echo ${#long}; IFS=2; echo ${#long}; set 1 ${#long};echo $#' '128 1 8 3' + check 'IFS=2; set ${x-${#long}}; IFS=" "; echo $* $#' '1 8 2' + check 'IFS=2; set ${x-"${#long}"}; IFS=" "; echo $* $#' '128 1' +} + +atf_init_test_cases() { + atf_add_test_case for + atf_add_test_case default_val + atf_add_test_case ifs_alpha + atf_add_test_case quote + atf_add_test_case dollar_at + atf_add_test_case ifs + atf_add_test_case var_length +} diff --git a/contrib/netbsd-tests/bin/sh/t_here.sh b/contrib/netbsd-tests/bin/sh/t_here.sh new file mode 100755 index 000000000000..250c686aa39a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_here.sh @@ -0,0 +1,73 @@ +# $NetBSD: t_here.sh,v 1.1 2012/03/17 16:33:11 jruoho 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. +# + +nl=' +' + +check() +{ + SVIFS="$IFS" + result="$(eval $1)" + # Remove newlines + oifs="$IFS" + IFS="$nl" + result="$(echo $result)" + IFS="$oifs" + if [ "$2" != "$result" ] + then + atf_fail "expected [$2], found [$result]" + fi + IFS="$SVIFS" +} + +atf_test_case all +all_head() { + atf_set "descr" "Basic tests for here documents" +} +all_body() { + y=x + + IFS= + check 'x=`cat </dev/null | tr '\n' ' ' | sed 's/ *$//'` + if [ "$result" != "$2" ]; then + MSG=`printf "%-56s %-8s %s" "$3" "$result" "$2"` + failwith "$MSG" + failcount=`expr $failcount + 1` + fi + count=`expr $count + 1` +} + +# direct check: try the given expression. +dcheck() +{ + check1 "$1" "$2" "$1" +} + +# eval check: indirect through eval. +# as of this writing, this changes the behavior pretty drastically and +# is thus important to test. (PR bin/29861) +echeck() +{ + check1 'eval '"'($1)'" "$2" "eval '($1)'" +} + +atf_test_case all +all_head() { + atf_set "descr" "Tests that 'set -e' works correctly" +} +all_body() { + count=0 + failcount=0 + + # make sure exiting from a subshell behaves as expected + dcheck '(set -e; exit 1; echo ERR$?); echo OK$?' 'OK1' + echeck '(set -e; exit 1; echo ERR$?); echo OK$?' 'OK1' + + # first, check basic functioning. + # The ERR shouldn't print; the result of the () should be 1. + # Henceforth we'll assume that we don't need to check $?. + dcheck '(set -e; false; echo ERR$?); echo -n OK$?' 'OK1' + echeck '(set -e; false; echo ERR$?); echo -n OK$?' 'OK1' + + # these cases should be equivalent to the preceding. + dcheck '(set -e; /nonexistent; echo ERR); echo OK' 'OK' + echeck '(set -e; /nonexistent; echo ERR); echo OK' 'OK' + dcheck '(set -e; nonexistent-program-on-path; echo ERR); echo OK' 'OK' + echeck '(set -e; nonexistent-program-on-path; echo ERR); echo OK' 'OK' + dcheck 'f() { false; }; (set -e; f; echo ERR); echo OK' 'OK' + echeck 'f() { false; }; (set -e; f; echo ERR); echo OK' 'OK' + dcheck 'f() { return 1; }; (set -e; f; echo ERR); echo OK' 'OK' + echeck 'f() { return 1; }; (set -e; f; echo ERR); echo OK' 'OK' + + # but! with set -e, the false should cause an *immediate* exit. + # The return form should not, as such, but there's no way to + # distinguish it. + dcheck 'f() { false; echo ERR; }; (set -e; f); echo OK' 'OK' + echeck 'f() { false; echo ERR; }; (set -e; f); echo OK' 'OK' + + # set is not scoped, so these should not exit at all. + dcheck 'f() { set +e; false; echo OK; }; (set -e; f); echo OK' 'OK OK' + echeck 'f() { set +e; false; echo OK; }; (set -e; f); echo OK' 'OK OK' + + # according to the standard, only failing *simple* commands + # cause an exit under -e. () is not a simple command. + # Correct (per POSIX): + #dcheck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK OK' + #echeck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK OK' + # Wrong current behavior: + dcheck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK' + echeck '(set -e; (set +e; false; echo OK; false); echo OK)' 'OK' + + # make sure an inner nested shell does exit though. + dcheck '(set -e; (false; echo ERR)); echo OK' 'OK' + + # The left hand side of an || or && is explicitly tested and + # thus should not cause an exit. Furthermore, because a || or + # && expression is not a simple command, there should be no + # exit even if the overall result is false. + dcheck '(set -e; false || true; echo OK); echo OK' 'OK OK' + echeck '(set -e; false || true; echo OK); echo OK' 'OK OK' + dcheck '(set -e; false && true; echo OK); echo OK' 'OK OK' + echeck '(set -e; false && true; echo OK); echo OK' 'OK OK' + + # However, the right hand side is not tested, so a failure + # there *should* cause an exit, regardless of whether it + # appears inside a non-simple command. + # + # Note that in at least one place the standard does not + # distinguish between the left and right hand sides of + # logical operators. It is possible that for strict + # compliance these need to not exit; however, if so that + # should probably be limited to when some strict-posix setting + # is in effect and tested accordingly. + # + dcheck '(set -e; false || false; echo ERR); echo OK' 'OK' + dcheck '(set -e; true && false; echo ERR); echo OK' 'OK' + echeck '(set -e; false || false; echo ERR); echo OK' 'OK' + echeck '(set -e; true && false; echo ERR); echo OK' 'OK' + + # correct: + #dcheck '(set -e; false && false; echo ERR); echo OK' 'OK' + #echeck '(set -e; false && false; echo ERR); echo OK' 'OK' + + # wrong current behavior: + dcheck '(set -e; false && false; echo ERR); echo OK' 'ERR OK' + echeck '(set -e; false && false; echo ERR); echo OK' 'ERR OK' + + # A failure that is not reached because of short-circuit + # evaluation should not cause an exit, however. + dcheck '(set -e; true || false; echo OK); echo OK' 'OK OK' + echeck '(set -e; true || false; echo OK); echo OK' 'OK OK' + + # For completeness, test the other two combinations. + dcheck '(set -e; true || true; echo OK); echo OK' 'OK OK' + dcheck '(set -e; true && true; echo OK); echo OK' 'OK OK' + echeck '(set -e; true || true; echo OK); echo OK' 'OK OK' + echeck '(set -e; true && true; echo OK); echo OK' 'OK OK' + + # likewise, none of these should exit. + dcheck '(set -e; while false; do :; done; echo OK); echo OK' 'OK OK' + dcheck '(set -e; if false; then :; fi; echo OK); echo OK' 'OK OK' + # problematic :-) + #dcheck '(set -e; until false; do :; done; echo OK); echo OK' 'OK OK' + dcheck '(set -e; until [ "$t" = 1 ]; do t=1; done; echo OK); echo OK' \ + 'OK OK' + echeck '(set -e; while false; do :; done; echo OK); echo OK' 'OK OK' + echeck '(set -e; if false; then :; fi; echo OK); echo OK' 'OK OK' + echeck '(set -e; until [ "$t" = 1 ]; do t=1; done; echo OK); echo OK' \ + 'OK OK' + + # the bang operator tests its argument and thus the argument + # should not cause an exit. it is also not a simple command (I + # believe) so it also shouldn't exit even if it yields a false + # result. + dcheck '(set -e; ! false; echo OK); echo OK' 'OK OK' + dcheck '(set -e; ! true; echo OK); echo OK' 'OK OK' + echeck '(set -e; ! false; echo OK); echo OK' 'OK OK' + echeck '(set -e; ! true; echo OK); echo OK' 'OK OK' + + # combined case with () and &&; the inner expression is false + # but does not itself exit, and the () should not cause an + # exit even when failing. + # correct: + #dcheck '(set -e; (false && true); echo OK); echo OK' 'OK OK' + #echeck '(set -e; (false && true); echo OK); echo OK' 'OK OK' + # wrong current behavior: + dcheck '(set -e; (false && true); echo OK); echo OK' 'OK' + echeck '(set -e; (false && true); echo OK); echo OK' 'OK' + + # pipelines. only the right-hand end is significant. + dcheck '(set -e; false | true; echo OK); echo OK' 'OK OK' + echeck '(set -e; false | true; echo OK); echo OK' 'OK OK' + dcheck '(set -e; true | false; echo ERR); echo OK' 'OK' + echeck '(set -e; true | false; echo ERR); echo OK' 'OK' + + dcheck '(set -e; while true | false; do :; done; echo OK); echo OK' \ + 'OK OK' + dcheck '(set -e; if true | false; then :; fi; echo OK); echo OK' \ + 'OK OK' + + + # According to dsl@ in PR bin/32282, () is not defined as a + # subshell, only as a grouping operator [and a scope, I guess] + # so the nested false ought to cause the whole shell to exit, + # not just the subshell. dholland@ would like to see C&V, + # because that seems like a bad idea. (Among other things, it + # would break all the above test logic, which relies on being + # able to isolate set -e behavior inside ().) However, I'm + # going to put these tests here to make sure the issue gets + # dealt with sometime. + # + # XXX: the second set has been disabled in the name of making + # all tests "pass". + + # 1. error if the whole shell exits (current behavior) + dcheck 'echo OK; (set -e; false); echo OK' 'OK OK' + echeck 'echo OK; (set -e; false); echo OK' 'OK OK' + # 2. error if the whole shell does not exit (dsl's suggested behavior) + #dcheck 'echo OK; (set -e; false); echo ERR' 'OK' + #echeck 'echo OK; (set -e; false); echo ERR' 'OK' + + # The current behavior of the shell is that it exits out as + # far as -e is set and then stops. This is probably a + # consequence of it handling () wrong, but it's a somewhat + # curious compromise position between 1. and 2. above. + dcheck '(set -e; (false; echo ERR); echo ERR); echo OK' 'OK' + echeck '(set -e; (false; echo ERR); echo ERR); echo OK' 'OK' + + # backquote expansion (PR bin/17514) + + # correct + #dcheck '(set -e; echo ERR `false`; echo ERR); echo OK' 'OK' + #dcheck '(set -e; echo ERR $(false); echo ERR); echo OK' 'OK' + #dcheck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'OK' + #dcheck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'OK' + # wrong current behavior + dcheck '(set -e; echo ERR `false`; echo ERR); echo OK' 'ERR ERR OK' + dcheck '(set -e; echo ERR $(false); echo ERR); echo OK' 'ERR ERR OK' + dcheck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'ERR ERR OK' + dcheck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'ERR ERR OK' + + dcheck '(set -e; x=`false`; echo ERR); echo OK' 'OK' + dcheck '(set -e; x=$(false); echo ERR); echo OK' 'OK' + dcheck '(set -e; x=`exit 3`; echo ERR); echo OK' 'OK' + dcheck '(set -e; x=$(exit 3); echo ERR); echo OK' 'OK' + + # correct + #echeck '(set -e; echo ERR `false`; echo ERR); echo OK' 'OK' + #echeck '(set -e; echo ERR $(false); echo ERR); echo OK' 'OK' + #echeck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'OK' + #echeck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'OK' + + # wrong current behavior + echeck '(set -e; echo ERR `false`; echo ERR); echo OK' 'ERR ERR OK' + echeck '(set -e; echo ERR $(false); echo ERR); echo OK' 'ERR ERR OK' + echeck '(set -e; echo ERR `exit 3`; echo ERR); echo OK' 'ERR ERR OK' + echeck '(set -e; echo ERR $(exit 3); echo ERR); echo OK' 'ERR ERR OK' + + echeck '(set -e; x=`false`; echo ERR); echo OK' 'OK' + echeck '(set -e; x=$(false); echo ERR); echo OK' 'OK' + echeck '(set -e; x=`exit 3`; echo ERR); echo OK' 'OK' + echeck '(set -e; x=$(exit 3); echo ERR); echo OK' 'OK' + + # shift (PR bin/37493) + # correct + #dcheck '(set -e; shift || true; echo OK); echo OK' 'OK OK' + #echeck '(set -e; shift || true; echo OK); echo OK' 'OK OK' + # wrong current behavior + dcheck '(set -e; shift || true; echo OK); echo OK' 'OK' + echeck '(set -e; shift || true; echo OK); echo OK' 'OK' + + # Done. + + if [ "x$SH_FAILS" != x ]; then + printf '%-56s %-8s %s\n' "Expression" "Result" "Should be" + echo "$SH_FAILS" + atf_fail "$failcount of $count failed cases" + else + atf_pass + fi +} + +atf_init_test_cases() { + atf_add_test_case all +} diff --git a/contrib/netbsd-tests/bin/sh/t_ulimit.sh b/contrib/netbsd-tests/bin/sh/t_ulimit.sh new file mode 100755 index 000000000000..3e7c0a68e70f --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_ulimit.sh @@ -0,0 +1,46 @@ +# $NetBSD: t_ulimit.sh,v 1.1 2012/06/11 18:32:59 njoly Exp $ +# +# Copyright (c) 2012 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. +# + +# ulimit builtin test. + +atf_test_case limits +limits_head() { + atf_set "descr" "Checks for limits flags" +} +limits_body() { + atf_check -s eq:0 -o ignore -e empty \ + /bin/sh -c "ulimit -a" + for l in $(ulimit -a | sed 's,^.*(,,;s, .*$,,'); + do + atf_check -s eq:0 -o ignore -e empty \ + /bin/sh -c "ulimit $l" + done +} + +atf_init_test_cases() { + atf_add_test_case limits +} diff --git a/contrib/netbsd-tests/bin/sh/t_varquote.sh b/contrib/netbsd-tests/bin/sh/t_varquote.sh new file mode 100755 index 000000000000..17687779637a --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_varquote.sh @@ -0,0 +1,81 @@ +# $NetBSD: t_varquote.sh,v 1.2 2012/03/25 18:50:19 christos 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. +# + +# Variable quoting test. + +check() { + if [ "$1" != "$2" ] + then + atf_fail "expected [$2], found [$1]" 1>&2 + fi +} + +atf_test_case all +all_head() { + atf_set "descr" "Basic checks for variable quoting" +} +all_body() { + foo='${a:-foo}' + check "$foo" '${a:-foo}' + + foo="${a:-foo}" + check "$foo" "foo" + + foo=${a:-"'{}'"} + check "$foo" "'{}'" + + foo=${a:-${b:-"'{}'"}} + check "$foo" "'{}'" + + foo="${a:-"'{}'"}" + check "$foo" "'{}'" + + foo="${a:-${b:-"${c:-${d:-"x}"}}y}"}}z}" + # " z*" + # ${a:- } + # ${b:- } + # " y*" + # ${c:- } + # ${d:- } + # "x*" + check "$foo" "x}y}z}" +} + +atf_test_case nested_quotes_multiword +nested_quotes_multiword_head() { + atf_set "descr" "Tests that having nested quoting in a multi-word" \ + "string works (PR bin/43597)" +} +nested_quotes_multiword_body() { + atf_check -s eq:0 -o match:"first-word second-word" -e empty \ + /bin/sh -c 'echo "${foo:="first-word"} second-word"' +} + +atf_init_test_cases() { + atf_add_test_case all + atf_add_test_case nested_quotes_multiword +} diff --git a/contrib/netbsd-tests/bin/sh/t_wait.sh b/contrib/netbsd-tests/bin/sh/t_wait.sh new file mode 100755 index 000000000000..99b47df7ad27 --- /dev/null +++ b/contrib/netbsd-tests/bin/sh/t_wait.sh @@ -0,0 +1,59 @@ +# $NetBSD: t_wait.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $ +# +# Copyright (c) 2008, 2009, 2010 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 individual +individual_head() { + atf_set "descr" "Tests that waiting for individual jobs works" +} +individual_body() { + # atf-sh confuses wait for some reason; work it around by creating + # a helper script that executes /bin/sh directly. + cat >helper.sh < 4 +node 1 -> 1 +node 2 -> 1 +node 3 -> 4 +node 4 -> 0 +node 5 -> 2 +node 6 -> 1 +node 7 -> 1 +node 8 -> 6 +node 9 -> 2 +node 10 -> 1 +node 11 -> 1 +node 12 -> 3 +node 13 -> 1 +node 14 -> 4 +node 15 -> 3 +node 16 -> 5 +node 17 -> 0 +node 18 -> 2 +node 19 -> 0 +node 20 -> 2 +node 21 -> 2 +node 22 -> 0 +node 23 -> 1 +20 nodes used out of 24 +47 items +load 1.95 actual load 2.35 +init2=10 +cipher1=NULL +s_client:cipher1=DES_CBC_MD5:DES_CBC_SHA:DES_EDE_SHA:RC4_MD5cipher2 = DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5 +---------------------------- DUMP ------------------------ +[req] Attribute_text_7=Email Address +[req] Attribute_text_2=State or Province Name (full name) +[default] tmp_cert_dir=/tmp/eay/.ca_certs +[req] Attribute_text_1=Country Name (2 letter code) +[[genrsa]] +[req] Attribute_default_5=TR +[req] Attribute_text_6=Common Name (eg, YOUR name) +[req] Attribute_default_1=AU +[[req]] +[[special]] +[[gendh]] +[req] Attribute_text_3=Locality Name (eg, city) +[req] Attribute_type_1=countryName +[default] init5==10' again +[req] Attribute_type_3=localityName +[s_client] cipher3=DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5 +[default] in\#it1=10 +[req] Attribute_text_4=Organization Name (eg, company) +[req] Attribute_type_7=emailAddress +[gendh] def_generator=2 +[default] HOME=/tmp/eay +[s_client] cipher4=DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5 +[default] init=5 +[SSLeay] version=0.5.0 +[req] Attribute_type_4=organizationName +[default] tmp2_cert_dir=thisis/tmp/eaystuff +[req] Attribute_type_5=organizationalUnitName +[[SSLEAY]] +[default] init4=10' +[[default]] +[default] LOGNAME=Eric Young (home=/tmp/eay) +[special] RANDFILE=/tmp/eay/.rand +[req] default_keyfile=privkey.pem +[req] Attribute_default_4=Mincom Pty Ltd +[req] Attribute_default_2=Queensland +[gendh] default_bits=512 +[req] default_bits=512 +[default] init2=10 +[SSLEAY] version=0.5.0 +[s_client] cipher1=DES_CBC_MD5:DES_CBC_SHA:DES_EDE_SHA:RC4_MD5cipher2 = DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5 +[req] Attribute_text_5=Organizational Unit Name (eg, section) +[req] Attribute_type_2=stateOrProvinceName +[genrsa] default_bits=512 +[default] init3=10' +[[SSLeay]] +[[s_client]] +[req] Attribute_type_6=commonName diff --git a/contrib/netbsd-tests/crypto/libcrypto/conf/d_conf_ssleay.cnf b/contrib/netbsd-tests/crypto/libcrypto/conf/d_conf_ssleay.cnf new file mode 100644 index 000000000000..3fdde34dd264 --- /dev/null +++ b/contrib/netbsd-tests/crypto/libcrypto/conf/d_conf_ssleay.cnf @@ -0,0 +1,78 @@ +# +# This is a test configuration file for use in SSLeay etc... +# + +init = 5 +in\#it1 =10 +init2='10' +init3='10\'' +init4="10'" +init5='='10\'' again' + +SSLeay::version = 0.5.0 + +[genrsa] +default_bits = 512 +SSLEAY::version = 0.5.0 + +[gendh] +default_bits = 512 +def_generator = 2 + +[s_client] +cipher1 = DES_CBC_MD5:DES_CBC_SHA:DES_EDE_SHA:RC4_MD5\ +cipher2 = 'DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5' +cipher3 = "DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5" +cipher4 = DES_CBC_MD5 DES_CBC_SHA DES_EDE_SHA RC4_MD5 + +[ default ] +#cert_dir = $ENV::HOME/.ca_certs + +HOME = /tmp/eay + +tmp_cert_dir = $HOME/.ca_certs +tmp2_cert_dir = thisis$(HOME)stuff + +LOGNAME = Eric Young (home=$HOME) + +[ special ] + +#H=$HOME +#H=$default::HOME +#H=$ENV::HOME +# +# SSLeay example configuration file. +# This is mostly being used for generation of certificate requests. +# + +RANDFILE = $HOME/.rand + +[ req ] +default_bits = 512 +default_keyfile = privkey.pem + +Attribute_type_1 = countryName +Attribute_text_1 = Country Name (2 letter code) +Attribute_default_1 = AU + +Attribute_type_2 = stateOrProvinceName +Attribute_text_2 = State or Province Name (full name) +Attribute_default_2 = Queensland + +Attribute_type_3 = localityName +Attribute_text_3 = Locality Name (eg, city) + +Attribute_type_4 = organizationName +Attribute_text_4 = Organization Name (eg, company) +Attribute_default_4 = Mincom Pty Ltd + +Attribute_type_5 = organizationalUnitName +Attribute_text_5 = Organizational Unit Name (eg, section) +Attribute_default_5 = TR + +Attribute_type_6 = commonName +Attribute_text_6 = Common Name (eg, YOUR name) + +Attribute_type_7 = emailAddress +Attribute_text_7 = Email Address + diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_certs.sh b/contrib/netbsd-tests/crypto/libcrypto/t_certs.sh new file mode 100755 index 000000000000..6965a5727022 --- /dev/null +++ b/contrib/netbsd-tests/crypto/libcrypto/t_certs.sh @@ -0,0 +1,41 @@ +# $NetBSD: t_certs.sh,v 1.1 2010/07/10 16:43:25 jmmv Exp $ +# +# Copyright (c) 2008, 2009, 2010 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 x509v3 +x509v3_head() +{ + atf_set "descr" "Checks x509v3 certificates" +} +x509v3_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_x509v3test" +} + +atf_init_test_cases() +{ + atf_add_test_case x509v3 +} diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_ciphers.sh b/contrib/netbsd-tests/crypto/libcrypto/t_ciphers.sh new file mode 100755 index 000000000000..127040773aa7 --- /dev/null +++ b/contrib/netbsd-tests/crypto/libcrypto/t_ciphers.sh @@ -0,0 +1,122 @@ +# $NetBSD: t_ciphers.sh,v 1.4 2012/07/14 16:04:06 spz Exp $ +# +# Copyright (c) 2008, 2009, 2010 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 bf +bf_head() +{ + atf_set "descr" "Checks blowfish cipher" +} +bf_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_bftest" +} + +atf_test_case cast +cast_head() +{ + atf_set "descr" "Checks CAST cipher" + atf_set "timeout" "300" +} +cast_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_casttest" +} + +atf_test_case des +des_head() +{ + atf_set "descr" "Checks DES cipher (libdes)" +} +des_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_destest" +} + +atf_test_case evp +evp_head() +{ + atf_set "descr" "Checks EVP cipher" +} +evp_body() +{ + atf_check -o ignore -e ignore $(atf_get_srcdir)/h_evp_test $(atf_get_srcdir)/evptests.txt +} + +atf_test_case rc2 +rc2_head() +{ + atf_set "descr" "Checks RC2 cipher" +} +rc2_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_rc2test" +} + +atf_test_case rc4 +rc4_head() +{ + atf_set "descr" "Checks RC4 cipher" +} +rc4_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_rc4test" +} + +atf_test_case idea +idea_head() +{ + atf_set "descr" "Checks IDEA cipher" +} +idea_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_ideatest" +} + +atf_test_case rc5 +rc5_head() +{ + atf_set "descr" "Checks RC5 cipher" +} +rc5_body() +{ + [ -x "$(atf_get_srcdir)/h_rc5test" ] \ + || atf_skip "RC5 support not available; system built" \ + "with MKCRYPTO_RC5=no" + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_rc5test" +} + +atf_init_test_cases() +{ + atf_add_test_case bf + atf_add_test_case cast + atf_add_test_case des + atf_add_test_case evp + atf_add_test_case rc2 + atf_add_test_case rc4 + atf_add_test_case idea + atf_add_test_case rc5 +} diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_hashes.sh b/contrib/netbsd-tests/crypto/libcrypto/t_hashes.sh new file mode 100755 index 000000000000..700dbdbf9fc9 --- /dev/null +++ b/contrib/netbsd-tests/crypto/libcrypto/t_hashes.sh @@ -0,0 +1,108 @@ +# $NetBSD: t_hashes.sh,v 1.2 2012/07/14 16:04:06 spz Exp $ +# +# Copyright (c) 2008, 2009, 2010 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 hmac +hmac_head() +{ + atf_set "descr" "Checks HMAC message authentication code" +} +hmac_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_hmactest" +} + +atf_test_case md2 +md2_head() +{ + atf_set "descr" "Checks MD2 digest" +} +md2_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_md2test" +} + +atf_test_case md4 +md4_head() +{ + atf_set "descr" "Checks MD4 digest" +} +md4_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_md4test" +} + +atf_test_case md5 +md5_head() +{ + atf_set "descr" "Checks MD5 digest" +} +md5_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_md5test" +} + +atf_test_case ripemd +ripemd_head() +{ + atf_set "descr" "Checks RMD-160 digest" +} +ripemd_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_ripemdtest" +} + +atf_test_case sha +sha_head() +{ + atf_set "descr" "Checks SHA-1 digest" +} +sha_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_shatest" +} + + +atf_test_case mdc2 +mdc2_head() +{ + atf_set "descr" "Checks MDC2 digest" +} +mdc2_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_mdc2test" +} + +atf_init_test_cases() +{ + atf_add_test_case hmac + atf_add_test_case md2 + atf_add_test_case md4 + atf_add_test_case md5 + atf_add_test_case ripemd + atf_add_test_case sha + atf_add_test_case mdc2 +} diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_libcrypto.sh b/contrib/netbsd-tests/crypto/libcrypto/t_libcrypto.sh new file mode 100755 index 000000000000..aa7af27ceee4 --- /dev/null +++ b/contrib/netbsd-tests/crypto/libcrypto/t_libcrypto.sh @@ -0,0 +1,107 @@ +# $NetBSD: t_libcrypto.sh,v 1.3 2010/11/08 19:06:12 pooka Exp $ +# +# Copyright (c) 2008, 2009, 2010 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 engine +engine_head() +{ + atf_set "descr" "Checks ENGINE framework" +} +engine_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_enginetest" +} + +atf_test_case rand +rand_head() +{ + atf_set "descr" "Checks peudo-random number generator" +} +rand_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_randtest" +} + +atf_test_case bn +bn_head() +{ + atf_set "descr" "Checks BIGNUM library" + atf_set "timeout" "300" +} +bn_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_bntest" + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_divtest" + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_exptest" +} + +atf_test_case conf +conf_head() +{ + atf_set "descr" "Checks configuration modules" +} +conf_body() +{ + cp $(atf_get_srcdir)/d_conf_ssleay.cnf ssleay.cnf + + atf_check -o file:$(atf_get_srcdir)/d_conf.out \ + $(atf_get_srcdir)/h_conftest +} + +atf_test_case lhash +lhash_head() +{ + atf_set "descr" "Checks lhash - dynamic hash tables" +} +lhash_body() +{ + atf_check -o ignore -e ignore -x \ + "echo hoge | $(atf_get_srcdir)/h_lhashtest" +} + +atf_test_case threads +threads_head() +{ + atf_set "descr" "Checks threading" +} +threads_body() +{ + $(atf_get_srcdir)/h_threadstest \ + -cert $(atf_get_srcdir)/d_server.pem \ + -ccert $(atf_get_srcdir)/d_client.pem \ + 2>&1 | tee out + atf_check -s eq:1 -o empty -e empty grep :error: out +} + +atf_init_test_cases() +{ + atf_add_test_case engine + atf_add_test_case rand + atf_add_test_case bn + atf_add_test_case conf + atf_add_test_case lhash + atf_add_test_case threads +} diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_pubkey.sh b/contrib/netbsd-tests/crypto/libcrypto/t_pubkey.sh new file mode 100755 index 000000000000..1453e757a4cc --- /dev/null +++ b/contrib/netbsd-tests/crypto/libcrypto/t_pubkey.sh @@ -0,0 +1,110 @@ +# $NetBSD: t_pubkey.sh,v 1.3 2011/06/09 05:25:21 spz Exp $ +# +# Copyright (c) 2008, 2009, 2010 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 dsa +dsa_head() +{ + atf_set "descr" "Checks DSA cipher" +} +dsa_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_dsatest" +} + +atf_test_case dh +dh_head() +{ + atf_set "descr" "Checks Diffie-Hellman key agreement protocol" +} +dh_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_dhtest" +} + +atf_test_case rsa +rsa_head() +{ + atf_set "descr" "Checks RSA" + atf_set "timeout" "300" +} +rsa_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_rsatest" +} + +atf_test_case ec +ec_head() +{ + atf_set "descr" "Checks EC cipher" + atf_set "timeout" "300" +} +ec_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_ectest" +} + +atf_test_case ecdh +ecdh_head() +{ + atf_set "descr" "Checks ECDH key agreement protocol" +} +ecdh_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_ecdhtest" +} + +atf_test_case ecdsa +ecdsa_head() +{ + atf_set "descr" "Checks ECDSA algorithm" + atf_set "timeout" "300" +} +ecdsa_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_ecdsatest" +} + +atf_test_case srp +srp_head() +{ + atf_set "descr" "Checks SRP key agreement protocol" +} +srp_body() +{ + atf_check -o ignore -e ignore "$(atf_get_srcdir)/h_srptest" +} + +atf_init_test_cases() +{ + atf_add_test_case dsa + atf_add_test_case dh + atf_add_test_case rsa + atf_add_test_case ec + atf_add_test_case ecdh + atf_add_test_case ecdsa + atf_add_test_case srp +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_aesctr1.c b/contrib/netbsd-tests/crypto/opencrypto/h_aesctr1.c new file mode 100644 index 000000000000..41d866cf17cb --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_aesctr1.c @@ -0,0 +1,250 @@ +/* $NetBSD: h_aesctr1.c,v 1.4 2014/01/19 13:40:59 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include + +/* + * Test vectors from RFC 3686 + * + * Test vectors 3, 6, and 9 are disabled because we don't support + * 36-byte (ie, unpadded) operations. + */ + +const struct { + size_t len; + size_t key_len; + unsigned char key[36]; /* Includes 32-bit nonce */ + unsigned char iv[8]; + unsigned char plaintx[36]; + unsigned char ciphertx[36]; +} tests[] = { + /* Test Vector #1: Encrypting 16 octets using AES-CTR w/ 128-bit key*/ + { 16, 20, + { 0xAE, 0x68, 0x52, 0xF8, 0x12, 0x10, 0x67, 0xCC, + 0x4B, 0xF7, 0xA5, 0x76, 0x55, 0x77, 0xF3, 0x9E, + 0x00, 0x00, 0x00, 0x30 }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, + 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67 }, + { 0xE4, 0x09, 0x5D, 0x4F, 0xB7, 0xA7, 0xB3, 0x79, + 0x2D, 0x61, 0x75, 0xA3, 0x26, 0x13, 0x11, 0xB8 } + }, + + /* Test Vector #2: Encrypting 32 octets using AES-CTR w/ 128-bit key */ + { 32, 20, + { 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7, + 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63, + 0x00, 0x6C, 0xB6, 0xDB }, + { 0xC0, 0x54, 0x3B, 0x59, 0xDA, 0x48, 0xD9, 0x0B }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, + { 0x51, 0x04, 0xA1, 0x06, 0x16, 0x8A, 0x72, 0xD9, + 0x79, 0x0D, 0x41, 0xEE, 0x8E, 0xDA, 0xD3, 0x88, + 0xEB, 0x2E, 0x1E, 0xFC, 0x46, 0xDA, 0x57, 0xC8, + 0xFC, 0xE6, 0x30, 0xDF, 0x91, 0x41, 0xBE, 0x28 } + }, + + /* Test Vector #3: Encrypting 36 octets using AES-CTR w/ 128-bit key */ +/* { 36, 20, + { 0x76, 0x91, 0xBE, 0x03, 0x5E, 0x50, 0x20, 0xA8, + 0xAC, 0x6E, 0x61, 0x85, 0x29, 0xF9, 0xA0, 0xDC, + 0x00, 0xE0, 0x01, 0x7B }, + { 0x27, 0x77, 0x7F, 0x3F, 0x4A, 0x17, 0x86, 0xF0 }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23 }, + { 0xC1, 0xCF, 0x48, 0xA8, 0x9F, 0x2F, 0xFD, 0xD9, + 0xCF, 0x46, 0x52, 0xE9, 0xEF, 0xDB, 0x72, 0xD7, + 0x45, 0x40, 0xA4, 0x2B, 0xDE, 0x6D, 0x78, 0x36, + 0xD5, 0x9A, 0x5C, 0xEA, 0xAE, 0xF3, 0x10, 0x53, + 0x25, 0xB2, 0x07, 0x2F } + }, +*/ + /* Test Vector #4: Encrypting 16 octets using AES-CTR w/ 192-bit key */ + { 16, 28, + { 0x16, 0xAF, 0x5B, 0x14, 0x5F, 0xC9, 0xF5, 0x79, + 0xC1, 0x75, 0xF9, 0x3E, 0x3B, 0xFB, 0x0E, 0xED, + 0x86, 0x3D, 0x06, 0xCC, 0xFD, 0xB7, 0x85, 0x15, + 0x00, 0x00, 0x00, 0x48 }, + { 0x36, 0x73, 0x3C, 0x14, 0x7D, 0x6D, 0x93, 0xCB }, + { 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, + 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67 }, + { 0x4B, 0x55, 0x38, 0x4F, 0xE2, 0x59, 0xC9, 0xC8, + 0x4E, 0x79, 0x35, 0xA0, 0x03, 0xCB, 0xE9, 0x28 } + }, + + /* Test Vector #5: Encrypting 32 octets using AES-CTR w/ 192-bit key */ + { 32, 28, + { 0x7C, 0x5C, 0xB2, 0x40, 0x1B, 0x3D, 0xC3, 0x3C, + 0x19, 0xE7, 0x34, 0x08, 0x19, 0xE0, 0xF6, 0x9C, + 0x67, 0x8C, 0x3D, 0xB8, 0xE6, 0xF6, 0xA9, 0x1A, + 0x00, 0x96, 0xB0, 0x3B }, + { 0x02, 0x0C, 0x6E, 0xAD, 0xC2, 0xCB, 0x50, 0x0D }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, + { 0x45, 0x32, 0x43, 0xFC, 0x60, 0x9B, 0x23, 0x32, + 0x7E, 0xDF, 0xAA, 0xFA, 0x71, 0x31, 0xCD, 0x9F, + 0x84, 0x90, 0x70, 0x1C, 0x5A, 0xD4, 0xA7, 0x9C, + 0xFC, 0x1F, 0xE0, 0xFF, 0x42, 0xF4, 0xFB, 0x00 } + }, + + /* Test Vector #6: Encrypting 36 octets using AES-CTR w/ 192-bit key */ +/* + { 36, 28, + { 0x02, 0xBF, 0x39, 0x1E, 0xE8, 0xEC, 0xB1, 0x59, + 0xB9, 0x59, 0x61, 0x7B, 0x09, 0x65, 0x27, 0x9B, + 0xF5, 0x9B, 0x60, 0xA7, 0x86, 0xD3, 0xE0, 0xFE, + 0x00, 0x07, 0xBD, 0xFD }, + { 0x5C, 0xBD, 0x60, 0x27, 0x8D, 0xCC, 0x09, 0x12 }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23 }, + { 0x96, 0x89, 0x3F, 0xC5, 0x5E, 0x5C, 0x72, 0x2F, + 0x54, 0x0B, 0x7D, 0xD1, 0xDD, 0xF7, 0xE7, 0x58, + 0xD2, 0x88, 0xBC, 0x95, 0xC6, 0x91, 0x65, 0x88, + 0x45, 0x36, 0xC8, 0x11, 0x66, 0x2F, 0x21, 0x88, + 0xAB, 0xEE, 0x09, 0x35 }, + }, +*/ + /* Test Vector #7: Encrypting 16 octets using AES-CTR w/ 256-bit key */ + { 16, 36, + { 0x77, 0x6B, 0xEF, 0xF2, 0x85, 0x1D, 0xB0, 0x6F, + 0x4C, 0x8A, 0x05, 0x42, 0xC8, 0x69, 0x6F, 0x6C, + 0x6A, 0x81, 0xAF, 0x1E, 0xEC, 0x96, 0xB4, 0xD3, + 0x7F, 0xC1, 0xD6, 0x89, 0xE6, 0xC1, 0xC1, 0x04, + 0x00, 0x00, 0x00, 0x60 }, + { 0xDB, 0x56, 0x72, 0xC9, 0x7A, 0xA8, 0xF0, 0xB2 }, + { 0x53, 0x69, 0x6E, 0x67, 0x6C, 0x65, 0x20, 0x62, + 0x6C, 0x6F, 0x63, 0x6B, 0x20, 0x6D, 0x73, 0x67 }, + { 0x14, 0x5A, 0xD0, 0x1D, 0xBF, 0x82, 0x4E, 0xC7, + 0x56, 0x08, 0x63, 0xDC, 0x71, 0xE3, 0xE0, 0xC0 }, + }, + + /* Test Vector #8: Encrypting 32 octets using AES-CTR w/ 256-bit key */ + { 32, 36, + { 0xF6, 0xD6, 0x6D, 0x6B, 0xD5, 0x2D, 0x59, 0xBB, + 0x07, 0x96, 0x36, 0x58, 0x79, 0xEF, 0xF8, 0x86, + 0xC6, 0x6D, 0xD5, 0x1A, 0x5B, 0x6A, 0x99, 0x74, + 0x4B, 0x50, 0x59, 0x0C, 0x87, 0xA2, 0x38, 0x84, + 0x00, 0xFA, 0xAC, 0x24 }, + { 0xC1, 0x58, 0x5E, 0xF1, 0x5A, 0x43, 0xD8, 0x75 }, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, + { 0xF0, 0x5E, 0x23, 0x1B, 0x38, 0x94, 0x61, 0x2C, + 0x49, 0xEE, 0x00, 0x0B, 0x80, 0x4E, 0xB2, 0xA9, + 0xB8, 0x30, 0x6B, 0x50, 0x8F, 0x83, 0x9D, 0x6A, + 0x55, 0x30, 0x83, 0x1D, 0x93, 0x44, 0xAF, 0x1C }, + }, + + /* Test Vector #9: Encrypting 36 octets using AES-CTR w/ 256-bit key */ +/* + { 36, 36, + { 0xFF 0x7A 0x61 0x7C 0xE6 0x91 0x48 0xE4, + 0xF1 0x72 0x6E 0x2F 0x43 0x58 0x1D 0xE2, + 0xAA 0x62 0xD9 0xF8 0x05 0x53 0x2E 0xDF, + 0xF1 0xEE 0xD6 0x87 0xFB 0x54 0x15 0x3D, + 0x00 0x1C 0xC5 0xB7 }, + { 0x51 0xA5 0x1D 0x70 0xA1 0xC1 0x11 0x48 }, + { 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07, + 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F, + 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17, + 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F, + 0x20 0x21 0x22 0x23 }, + { 0xEB 0x6C 0x52 0x82 0x1D 0x0B 0xBB 0xF7, + 0xCE 0x75 0x94 0x46 0x2A 0xCA 0x4F 0xAA, + 0xB4 0x07 0xDF 0x86 0x65 0x69 0xFD 0x07, + 0xF4 0x8C 0xC0 0xB5 0x83 0xD6 0x07 0x1F, + 0x1E 0xC0 0xE6 0xB8 }, + }, +*/ +}; + +int +main(void) +{ + int fd, res; + size_t i; + struct session_op cs; + struct crypt_op co; + unsigned char buf[36]; + + for (i = 0; i < __arraycount(tests); i++) { + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open %zu", i); + memset(&cs, 0, sizeof(cs)); + cs.cipher = CRYPTO_AES_CTR; + cs.keylen = tests[i].key_len; + cs.key = __UNCONST(&tests[i].key); + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION %zu", i); + + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = tests[i].len; + co.src = __UNCONST(&tests[i].plaintx); + co.dst = buf; + co.dst_len = sizeof(buf); + co.iv = __UNCONST(&tests[i].iv); + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT %zu", i); + + if (memcmp(co.dst, tests[i].ciphertx, tests[i].len)) { + size_t j; + printf(" Loc Actual Golden\n"); + for (j = 0; j < tests[i].len; j++) + printf("0x%2zu: 0x%2x 0x%2x\n", j, + buf[j], tests[i].ciphertx[j]); + warnx("verification failed %zu", i); + } + close(fd); + } + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_aesctr2.c b/contrib/netbsd-tests/crypto/opencrypto/h_aesctr2.c new file mode 100644 index 000000000000..4bbd30ea1ecd --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_aesctr2.c @@ -0,0 +1,97 @@ +/* $NetBSD: h_aesctr2.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +unsigned char key[20] = {0xae, 0x68, 0x52, 0xf8, 0x12, 0x10, 0x67, 0xcc, + 0x4b, 0xf7, 0xa5, 0x76, 0x55, 0x77, 0xf3, 0x9e, + 0x00, 0x00, 0x00, 0x30}; +unsigned char iv[8] = {0}; +char plaintx[16] = "Single block msg"; +const unsigned char ciphertx[16] = { + 0xe4, 0x09, 0x5d, 0x4f, 0xb7, 0xa7, 0xb3, 0x79, + 0x2d, 0x61, 0x75, 0xa3, 0x26, 0x13, 0x11, 0xb8 +}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char ibuf[24]; + unsigned char obuf[24]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.cipher = CRYPTO_AES_CTR; + cs.keylen = 20; + cs.key = key; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memcpy(ibuf, iv, 8); + memcpy(ibuf + 8, plaintx, 16); + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = sizeof(ibuf); + co.src = ibuf; + co.dst = obuf; + co.dst_len = sizeof(obuf); + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + memset(ibuf, 0, sizeof(ibuf)); + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_DECRYPT; + co.len = sizeof(obuf); + co.src = obuf; + co.dst = ibuf; + co.dst_len = sizeof(ibuf); + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + + if (memcmp((char *)co.dst + 8, plaintx, sizeof(plaintx))) + warnx("verification failed"); + + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_arc4.c b/contrib/netbsd-tests/crypto/opencrypto/h_arc4.c new file mode 100644 index 000000000000..4bf8428549bf --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_arc4.c @@ -0,0 +1,80 @@ +/* $NetBSD: h_arc4.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +unsigned char key[] = "abcdefgh"; +char plaintx[16] = "1234567890123456"; +const unsigned char ciphertx[16] = { + 0x21, 0xc6, 0x0d, 0xa5, 0x34, 0x24, 0x8b, 0xce, + 0x95, 0x86, 0x64, 0xb3, 0x66, 0x77, 0x9b, 0x4c +}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.cipher = CRYPTO_ARC4; + cs.keylen = 8; + cs.key = key; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = sizeof(plaintx); + co.src = plaintx; + co.dst = buf; + co.dst_len = sizeof(buf); + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + + if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) + errx(1, "verification failed"); + + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_camellia.c b/contrib/netbsd-tests/crypto/opencrypto/h_camellia.c new file mode 100644 index 000000000000..bb489e77824d --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_camellia.c @@ -0,0 +1,87 @@ +/* $NetBSD: h_camellia.c,v 1.3 2014/01/17 19:39:51 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +/* Test vector from RFC3713 */ +unsigned char key[32] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, + 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; +unsigned char iv[16] = {0}; +char plaintx[16] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, + 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}; +const unsigned char ciphertx[16] = { + 0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c, + 0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09 +}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.cipher = CRYPTO_CAMELLIA_CBC; + cs.keylen = 32; + cs.key = key; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = sizeof(plaintx); + co.src = plaintx; + co.dst = buf; + co.dst_len = sizeof(buf); + co.iv = iv; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + + if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) + warnx("verification failed"); + + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_cbcdes.c b/contrib/netbsd-tests/crypto/opencrypto/h_cbcdes.c new file mode 100644 index 000000000000..4861d783fe7d --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_cbcdes.c @@ -0,0 +1,82 @@ +/* $NetBSD: h_cbcdes.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +unsigned char key[] = "abcdefgh"; +unsigned char iv[8] = {0}; +char plaintx[16] = "1234567890123456"; +const unsigned char ciphertx[16] = { + 0x21, 0xc6, 0x0d, 0xa5, 0x34, 0x24, 0x8b, 0xce, + 0x95, 0x86, 0x64, 0xb3, 0x66, 0x77, 0x9b, 0x4c +}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.cipher = CRYPTO_DES_CBC; + cs.keylen = 8; + cs.key = key; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = sizeof(plaintx); + co.src = plaintx; + co.dst = buf; + co.dst_len = sizeof(buf); + co.iv = iv; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + + if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) + errx(1, "verification failed"); + + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_comp.c b/contrib/netbsd-tests/crypto/opencrypto/h_comp.c new file mode 100644 index 000000000000..dd5f6470c5d6 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_comp.c @@ -0,0 +1,90 @@ +/* $NetBSD: h_comp.c,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include + +char text[100000] = {0}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co1, co2; + unsigned char buf1[10000], buf2[100000]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.comp_alg = CRYPTO_GZIP_COMP; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co1, 0, sizeof(co1)); + co1.ses = cs.ses; + co1.op = COP_COMP; + co1.len = sizeof(text); + co1.src = text; + co1.dst = buf1; + co1.dst_len = sizeof(buf1); + res = ioctl(fd, CIOCCRYPT, &co1); + if (res < 0) + err(1, "CIOCCRYPT1"); + fprintf(stderr, "len %d/%d\n", co1.len, co1.dst_len); +#if 0 + buf1[co1.dst_len - 8]++; /* modify CRC */ +#endif + write(1, buf1, co1.dst_len); + memset(&co2, 0, sizeof(co2)); + co2.ses = cs.ses; + co2.op = COP_DECOMP; + co2.len = co1.dst_len; + co2.src = buf1; + co2.dst = buf2; + co2.dst_len = sizeof(buf2); + buf2[10] = 0x33; + res = ioctl(fd, CIOCCRYPT, &co2); + fprintf(stderr, "canary: %x\n", buf2[10]); + if (res < 0) + err(1, "CIOCCRYPT2"); + fprintf(stderr, "len %d/%d\n", co2.len, co2.dst_len); + if (memcmp(text, buf2, co2.dst_len)) + errx(1, "memcmp"); + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_comp_zlib.c b/contrib/netbsd-tests/crypto/opencrypto/h_comp_zlib.c new file mode 100644 index 000000000000..7a57ceb31839 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_comp_zlib.c @@ -0,0 +1,92 @@ +/* $NetBSD: h_comp_zlib.c,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +char text[10000] = {0}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co1; + unsigned char buf1[10000], buf2[10000]; + z_stream z; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.comp_alg = CRYPTO_DEFLATE_COMP; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co1, 0, sizeof(co1)); + co1.ses = cs.ses; + co1.op = COP_COMP; + co1.len = sizeof(text); + co1.src = text; + co1.dst = buf1; + co1.dst_len = sizeof(buf1); + co1.flags = COP_F_BATCH; + res = ioctl(fd, CIOCCRYPT, &co1); + if (res < 0) + err(1, "CIOCCRYPT"); + + memset(&z, 0, sizeof(z)); + z.next_in = buf1; + z.avail_in = co1.dst_len; + z.zalloc = Z_NULL; + z.zfree = Z_NULL; + z.opaque = 0; + z.next_out = buf2; + z.avail_out = sizeof(buf2); + res = inflateInit2(&z, -15); + if (res != Z_OK) + errx(1, "inflateInit: %d", res); + do { + res = inflate(&z, Z_SYNC_FLUSH); + } while (res == Z_OK); + if (res != Z_STREAM_END) + errx(1, "inflate: %d", res); + if (z.total_out != sizeof(text)) + errx(1, "decomp len %lu", z.total_out); + if (memcmp(buf2, text, sizeof(text))) + errx(1, "decomp data mismatch"); + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_comp_zlib_rnd.c b/contrib/netbsd-tests/crypto/opencrypto/h_comp_zlib_rnd.c new file mode 100644 index 000000000000..86ed55afaaf3 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_comp_zlib_rnd.c @@ -0,0 +1,96 @@ +/* $NetBSD: h_comp_zlib_rnd.c,v 1.1 2014/01/14 17:51:39 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include + +char text[1000]; + +int +main(void) +{ + unsigned int i; + int fd, res; + struct session_op cs; + struct crypt_op co1; + unsigned char buf1[10000], buf2[10000]; + z_stream z; + + for (i = 0; i < sizeof(text)/sizeof(long); i++) + *(long *)(text + i * sizeof(long)) = random(); + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.comp_alg = CRYPTO_DEFLATE_COMP; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co1, 0, sizeof(co1)); + co1.ses = cs.ses; + co1.op = COP_COMP; + co1.len = sizeof(text); + co1.src = text; + co1.dst = buf1; + co1.dst_len = sizeof(buf1); + res = ioctl(fd, CIOCCRYPT, &co1); + if (res < 0) + err(1, "CIOCCRYPT"); + + memset(&z, 0, sizeof(z)); + z.next_in = buf1; + z.avail_in = co1.dst_len; + z.zalloc = Z_NULL; + z.zfree = Z_NULL; + z.opaque = 0; + z.next_out = buf2; + z.avail_out = sizeof(buf2); + res = inflateInit2(&z, -15); + if (res != Z_OK) + errx(1, "inflateInit: %d", res); + do { + res = inflate(&z, Z_SYNC_FLUSH); + } while (res == Z_OK); + if (res != Z_STREAM_END) + errx(1, "inflate: %d", res); + if (z.total_out != sizeof(text)) + errx(1, "decomp len %lu", z.total_out); + if (memcmp(buf2, text, sizeof(text))) + errx(1, "decomp data mismatch"); + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_gcm.c b/contrib/netbsd-tests/crypto/opencrypto/h_gcm.c new file mode 100644 index 000000000000..33f41f0eb271 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_gcm.c @@ -0,0 +1,126 @@ +/* $NetBSD: h_gcm.c,v 1.2 2014/01/17 14:16:08 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +unsigned char key[20] = { 0 }; +char plaintx[16] = { 0 }; +unsigned char iv[16] = { 0 }; +const unsigned char ciphertx[16] = { + 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92, + 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78 +}; +const unsigned char hash[16] = { + 0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd, + 0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf +}; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char databuf[16]; + unsigned char macbuf[16]; + unsigned char databuf2[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.mac = CRYPTO_AES_128_GMAC; + cs.mackeylen = sizeof(key); + cs.mackey = key; + cs.cipher = CRYPTO_AES_GCM_16; + cs.key = key; + cs.keylen = sizeof(key); + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co, 0, sizeof(co)); + memset(databuf, 0, sizeof(databuf)); + memset(macbuf, 0, sizeof(macbuf)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = sizeof(plaintx); + co.src = plaintx; + co.dst = databuf; + co.mac = macbuf; + co.iv = iv; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); +#if 1 + if (memcmp(co.dst, ciphertx, sizeof(ciphertx))) + errx(1, "verification failed"); + if (memcmp(macbuf, hash, sizeof(hash))) + errx(1, "hash failed"); +#else + { + int i; + for (i = 0; i < sizeof(databuf); i++) + printf("%02x ", databuf[i]); + printf("\n"); + } + { + int i; + for (i = 0; i < sizeof(macbuf); i++) + printf("%02x ", macbuf[i]); + printf("\n"); + } +#endif + memset(databuf2, 0, sizeof(databuf2)); + memset(macbuf, 0, sizeof(macbuf)); + co.ses = cs.ses; + co.op = COP_DECRYPT; + co.len = sizeof(databuf); + co.src = databuf; + co.dst = databuf2; + co.mac = macbuf; + co.iv = iv; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + + if (memcmp(co.dst, plaintx, sizeof(plaintx))) + errx(1, "verification failed"); + if (memcmp(macbuf, hash, sizeof(hash))) + errx(1, "hash failed"); + + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_md5.c b/contrib/netbsd-tests/crypto/opencrypto/h_md5.c new file mode 100644 index 000000000000..98379c79d2ed --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_md5.c @@ -0,0 +1,109 @@ +/* $NetBSD: h_md5.c,v 1.5 2014/01/18 20:10:34 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +/* Test vectors from RFC1321 */ + +const struct { + size_t len; + unsigned char plaintx[80]; + unsigned char digest[16]; +} tests[] = { + { 0, "", + { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, + 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e } }, + { 1, "a", + { 0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, + 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 } }, + { 3, "abc", + { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, + 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 } }, + { 14, "message digest", + { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d, + 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 } }, + { 26, "abcdefghijklmnopqrstuvwxyz", + { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, + 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b } }, + { 62, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, + 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f } }, + { 80, "123456789012345678901234567890123456789012345678901234567890" + "12345678901234567890", + { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, + 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a } }, +}; + +int +main(void) +{ + int fd, res; + size_t i; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.mac = CRYPTO_MD5; + + for (i = 0; i < __arraycount(tests); i++) { + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION test %zu", i); + + memset(&co, 0, sizeof(co)); + memset(&buf, 0, sizeof(buf)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = tests[i].len; + co.src = __UNCONST(&tests[i].plaintx); + co.mac = buf; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT test %zu", i); + + if (memcmp(co.mac, tests[i].digest, sizeof(tests[i].digest))) + errx(1, "verification failed test %zu", i); + + res = ioctl(fd, CIOCFSESSION, &cs.ses); + if (res < 0) + err(1, "CIOCFSESSION test %zu", i); + } + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_md5hmac.c b/contrib/netbsd-tests/crypto/opencrypto/h_md5hmac.c new file mode 100644 index 000000000000..6753094c51e1 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_md5hmac.c @@ -0,0 +1,181 @@ +/* $NetBSD: h_md5hmac.c,v 1.4 2014/01/18 02:31:14 joerg Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +#define MD5_HMAC_KEYLEN 16 /* Fixed key length supported */ + +/* Test data from RFC2202 */ +const struct { + int num; + size_t key_len; + size_t len; + unsigned char key[80]; + unsigned char data[80]; + unsigned char mac[16]; +} tests[] = { + /* Test #1 */ + { 1, 16, 8, + { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b }, + "Hi There", + { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c, + 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d } + }, + /* Test #2 */ + { 2, 4, 28, + "Jefe", + "what do ya want for nothing?", + { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03, + 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 } + }, + /* Test #3 */ + { 3, 16, 50, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, + { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88, + 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 } + }, + /* Test #4 */ + { 4, 25, 50, + { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19 }, + { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd }, + { 0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea, + 0x3a, 0x75, 0x16, 0x47, 0x46, 0xff, 0xaa, 0x79 } + }, + /* Test #5 */ + { 5, 16, 20, + { 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c }, + "Test With Truncation", + { 0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00, + 0xf9, 0xba, 0xb9, 0x95, 0x69, 0x0e, 0xfd, 0x4c } + }, + /* Test #6 */ + { 6, 80, 54, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, + "Test Using Larger Than Block-Size Key - Hash Key First", + { 0x6b, 0x1a, 0xb7, 0xfe, 0x4b, 0xd7, 0xbf, 0x8f, + 0x0b, 0x62, 0xe6, 0xce, 0x61, 0xb9, 0xd0, 0xcd } + }, + /* Test #7 */ + { 7, 80, 73, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, + "Test Using Larger Than Block-Size Key and Larger " + "Than One Block-Size Data", + { 0x6f, 0x63, 0x0f, 0xad, 0x67, 0xcd, 0xa0, 0xee, + 0x1f, 0xb1, 0xf5, 0x62, 0xdb, 0x3a, 0xa5, 0x3e } + }, +}; + +int +main(void) +{ + size_t i; + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + for (i = 0; i < __arraycount(tests); i++) { + if (tests[i].key_len != MD5_HMAC_KEYLEN) + continue; + + memset(&cs, 0, sizeof(cs)); + cs.mac = CRYPTO_MD5_HMAC; + cs.mackeylen = tests[i].key_len; + cs.mackey = __UNCONST(&tests[i].key); + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION test %d", tests[i].num); + + memset(&co, 0, sizeof(co)); + memset(buf, 0, sizeof(buf)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = tests[i].len; + co.src = __UNCONST(&tests[i].data); + co.mac = buf; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT test %d", tests[i].num); + + if (memcmp(co.mac, tests[i].mac, sizeof(tests[i].mac))) + errx(1, "verification failed test %d", tests[i].num); + + res = ioctl(fd, CIOCFSESSION, &cs.ses); + if (res < 0) + err(1, "CIOCFSESSION test %d", tests[i].num); + } + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_null.c b/contrib/netbsd-tests/crypto/opencrypto/h_null.c new file mode 100644 index 000000000000..85e480592583 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_null.c @@ -0,0 +1,76 @@ +/* $NetBSD: h_null.c,v 1.3 2014/01/17 19:35:33 pgoyette Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +unsigned char key[] = "abcdefgh"; +char plaintx[16] = "1234567890123456"; + +int +main(void) +{ + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.cipher = CRYPTO_NULL_CBC; + cs.keylen = 8; + cs.key = key; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + memset(&co, 0, sizeof(co)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = sizeof(plaintx); + co.src = plaintx; + co.dst = buf; + co.dst_len = sizeof(buf); + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT"); + + if (memcmp(co.dst, plaintx, sizeof(plaintx))) + errx(1, "verification failed"); + + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_sha1hmac.c b/contrib/netbsd-tests/crypto/opencrypto/h_sha1hmac.c new file mode 100644 index 000000000000..c153f761f2b8 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_sha1hmac.c @@ -0,0 +1,191 @@ +/* $NetBSD: h_sha1hmac.c,v 1.2 2014/01/18 02:31:14 joerg Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +#define SHA1_HMAC_KEYLEN 20 /* Only key-length we support */ + +/* Test data from RFC2202 */ +const struct { + int num; + size_t key_len; + size_t len; + unsigned char key[80]; + unsigned char data[80]; + unsigned char mac[20]; +} tests[] = { + /* Test #1 */ + { 1, 20, 8, + { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b }, + "Hi There", + { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64, + 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, + 0xf1, 0x46, 0xbe, 0x00 } + }, + /* Test #2 */ + { 2, 4, 28, + "Jefe", + "what do ya want for nothing?", + { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, + 0xd2, 0x74, 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, + 0x25, 0x9a, 0x7c, 0x79 } + }, + /* Test #3 */ + { 3, 20, 50, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa }, + { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, + 0x91, 0xa3, 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, + 0x63, 0xf1, 0x75, 0xd3 } + }, + /* Test #4 */ + { 4, 25, 50, + { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19 }, + { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, + 0xcd, 0xcd }, + { 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6, + 0xbc, 0x84, 0x14, 0xf9, 0xbf, 0x50, 0xc8, 0x6c, + 0x2d, 0x72, 0x35, 0xda } + }, + /* Test #5 */ + { 5, 20, 20, + { 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c }, + "Test With Truncation", + { 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f, + 0xe7, 0xf2, 0x7b, 0xe1, 0xd5, 0x8b, 0xb9, 0x32, + 0x4a, 0x9a, 0x5a, 0x04 } + }, + /* Test #6 */ + { 6, 80, 54, + { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0x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, 0xaa, 0xaa }, + "Test Using Larger Than Block-Size Key and Larger Than " + "One Block-Size Data", + { 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78, + 0x6d, 0x6b, 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, + 0xbb, 0xff, 0x1a, 0x91 } + }, +}; + +int +main(void) +{ + size_t i; + int fd, res; + struct session_op cs; + struct crypt_op co; + unsigned char buf[20]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + for (i = 0; i < __arraycount(tests); i++) { + if (tests[i].key_len != SHA1_HMAC_KEYLEN) + continue; + + memset(&cs, 0, sizeof(cs)); + cs.mac = CRYPTO_SHA1_HMAC; + cs.mackeylen = tests[i].key_len; + cs.mackey = __UNCONST(&tests[i].key); + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION test %d", tests[i].num); + + memset(&co, 0, sizeof(co)); + memset(buf, 0, sizeof(buf)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = tests[i].len; + co.src = __UNCONST(&tests[i].data); + co.mac = buf; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT test %d", tests[i].num); + + if (memcmp(co.mac, &tests[i].mac, sizeof(tests[i].mac))) + errx(1, "verification failed test %d", tests[i].num); + + res = ioctl(fd, CIOCFSESSION, &cs.ses); + if (res < 0) + err(1, "CIOCFSESSION test %d", tests[i].num); + } + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/h_xcbcmac.c b/contrib/netbsd-tests/crypto/opencrypto/h_xcbcmac.c new file mode 100644 index 000000000000..3f89c6e3e5e1 --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/h_xcbcmac.c @@ -0,0 +1,109 @@ +/* $NetBSD: h_xcbcmac.c,v 1.4 2014/01/16 23:56:04 joerg Exp $ */ + +/*- + * Copyright (c) 2014 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. + */ + +#include +#include +#include +#include + +#include +#include + +#include + + +/* test vectors from RFC3566 */ +unsigned char key[16] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f +}; +char plaintx[1000] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21 +}; +const struct { + size_t len; + unsigned char mac[12]; +} tests[] = { + { 0, { 0x75, 0xf0, 0x25, 0x1d, 0x52, 0x8a, + 0xc0, 0x1c, 0x45, 0x73, 0xdf, 0xd5 } }, + { 3, { 0x5b, 0x37, 0x65, 0x80, 0xae, 0x2f, + 0x19, 0xaf, 0xe7, 0x21, 0x9c, 0xee } }, + { 16, { 0xd2, 0xa2, 0x46, 0xfa, 0x34, 0x9b, + 0x68, 0xa7, 0x99, 0x98, 0xa4, 0x39 } }, + { 20, { 0x47, 0xf5, 0x1b, 0x45, 0x64, 0x96, + 0x62, 0x15, 0xb8, 0x98, 0x5c, 0x63 } }, + { 32, { 0xf5, 0x4f, 0x0e, 0xc8, 0xd2, 0xb9, + 0xf3, 0xd3, 0x68, 0x07, 0x73, 0x4b } }, + { 34, { 0xbe, 0xcb, 0xb3, 0xbc, 0xcd, 0xb5, + 0x18, 0xa3, 0x06, 0x77, 0xd5, 0x48 } }, + { 1000, { 0xf0, 0xda, 0xfe, 0xe8, 0x95, 0xdb, + 0x30, 0x25, 0x37, 0x61, 0x10, 0x3b } }, +}; + +int +main(void) +{ + int fd, res; + size_t i; + struct session_op cs; + struct crypt_op co; + unsigned char buf[16]; + + fd = open("/dev/crypto", O_RDWR, 0); + if (fd < 0) + err(1, "open"); + memset(&cs, 0, sizeof(cs)); + cs.mac = CRYPTO_AES_XCBC_MAC_96; + cs.mackeylen = sizeof(key); + cs.mackey = key; + res = ioctl(fd, CIOCGSESSION, &cs); + if (res < 0) + err(1, "CIOCGSESSION"); + + for (i = 0; i < __arraycount(tests); i++) { + memset(&co, 0, sizeof(co)); + memset(buf, 0, sizeof(buf)); + if (tests[i].len == sizeof(plaintx)) + memset(&plaintx, 0, sizeof(plaintx)); + co.ses = cs.ses; + co.op = COP_ENCRYPT; + co.len = tests[i].len; + co.src = plaintx; + co.mac = buf; + res = ioctl(fd, CIOCCRYPT, &co); + if (res < 0) + err(1, "CIOCCRYPT test %zu", i); + if (memcmp(buf, &tests[i].mac, sizeof(tests[i].mac))) + errx(1, "verification failed test %zu", i); + } + return 0; +} diff --git a/contrib/netbsd-tests/crypto/opencrypto/t_opencrypto.sh b/contrib/netbsd-tests/crypto/opencrypto/t_opencrypto.sh new file mode 100755 index 000000000000..f7faa3af9aca --- /dev/null +++ b/contrib/netbsd-tests/crypto/opencrypto/t_opencrypto.sh @@ -0,0 +1,272 @@ +# $NetBSD: t_opencrypto.sh,v 1.4 2014/01/18 15:15:16 pgoyette Exp $ +# +# Copyright (c) 2014 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. +# + +# Start a rumpserver, load required modules, and set requires sysctl vars + +start_rump() { + rump_libs="-l rumpvfs -l rumpdev -l rumpdev_opencrypto" + rump_libs="${rump_libs} -l rumpkern_z -l rumpkern_crypto" + + rump_server ${rump_libs} ${RUMP_SERVER} || \ + return 1 + + rump.sysctl -w kern.cryptodevallowsoft=-1 && \ + return 0 + + rump.halt + + return 1 +} + +common_head() { + atf_set descr "$1" + atf_set timeout 10 + atf_set require.progs rump_server rump.sysctl rump.halt +} + +common_body() { + local status + + start_rump || atf_skip "Cannot set-up rump environment" + LD_PRELOAD="/usr/lib/librumphijack.so" ; export LD_PRELOAD + RUMPHIJACK="blanket=/dev/crypto" ; export RUMPHIJACK + $(atf_get_srcdir)/$1 + status=$? + unset RUMPHIJACK + unset LD_PRELOAD + if [ $status -ne 0 ] ; then + atf_fail "$1 returned non-zero status, check output/error" + fi +} + +common_cleanup() { + unset RUMPHIJACK + unset LD_PRELOAD + rump.halt +} + +atf_test_case arc4 cleanup +arc4_head() { + common_head "Test ARC4 crypto" +} + +arc4_body() { + atf_skip "ARC4 not implemented by swcrypto" + common_body h_arc4 +} + +arc4_cleanup() { + common_cleanup +} + +atf_test_case camellia cleanup +camellia_head() { + common_head "Test CAMELLIA_CBC crypto" +} + +camellia_body() { + common_body h_camellia +} + +camellia_cleanup() { + common_cleanup +} + +atf_test_case cbcdes cleanup +cbcdes_head() { + common_head "Test ARC4 crypto" +} + +cbcdes_body() { + common_body h_cbcdes +} + +cbcdes_cleanup() { + common_cleanup +} + +atf_test_case comp cleanup +comp_head() { + common_head "Test GZIP_COMP Compression" +} + +comp_body() { + common_body h_comp +} + +comp_cleanup() { + common_cleanup +} + +atf_test_case comp_deflate cleanup +comp_deflate_head() { + common_head "Test DEFLATE_COMP Compression" +} + +comp_deflate_body() { + common_body h_comp_zlib +} + +comp_deflate_cleanup() { + common_cleanup +} + +atf_test_case comp_zlib_rnd cleanup +comp_zlib_rnd_head() { + common_head "Test DEFLATE_COMP Compression with random data" +} + +comp_zlib_rnd_body() { + common_body h_comp_zlib_rnd +} + +comp_zlib_rnd_cleanup() { + common_cleanup +} + +atf_test_case aesctr1 cleanup +aesctr1_head() { + common_head "Test AES_CTR crypto" +} + +aesctr1_body() { + common_body h_aesctr1 +} + +aesctr1_cleanup() { + common_cleanup +} + +atf_test_case aesctr2 cleanup +aesctr2_head() { + common_head "Test AES_CTR crypto" +} + +aesctr2_body() { + common_body h_aesctr2 +} + +aesctr2_cleanup() { + common_cleanup +} + +atf_test_case gcm cleanup +gcm_head() { + common_head "Test AES_GCM_16 crypto" +} + +gcm_body() { + common_body h_gcm +} + +gcm_cleanup() { + common_cleanup +} + +atf_test_case md5 cleanup +md5_head() { + common_head "Test MD5 crypto" +} + +md5_body() { + common_body h_md5 +} + +md5_cleanup() { + common_cleanup +} + +atf_test_case md5_hmac cleanup +md5_hmac_head() { + common_head "Test MD5_HMAC crypto" +} + +md5_hmac_body() { + common_body h_md5hmac +} + +md5_hmac_cleanup() { + common_cleanup +} + +atf_test_case null cleanup +null_head() { + common_head "Test NULL_CBC crypto" +} + +null_body() { + common_body h_null +} + +null_cleanup() { + common_cleanup +} + +atf_test_case sha1_hmac cleanup +sha1_hmac_head() { + common_head "Test SHA1_HMAC crypto" +} + +sha1_hmac_body() { + common_body h_sha1hmac +} + +sha1_hmac_cleanup() { + common_cleanup +} + +atf_test_case xcbcmac cleanup +xcbcmac_head() { + common_head "Test XCBC_MAC_96 crypto" +} + +xcbcmac_body() { + common_body h_xcbcmac +} + +xcbcmac_cleanup() { + common_cleanup +} + +atf_init_test_cases() { + RUMP_SERVER="unix://t_opencrypto_socket" ; export RUMP_SERVER + + atf_add_test_case arc4 + atf_add_test_case camellia + atf_add_test_case cbcdes + atf_add_test_case comp + atf_add_test_case comp_deflate + atf_add_test_case comp_zlib_rnd + atf_add_test_case aesctr1 + atf_add_test_case aesctr2 + atf_add_test_case gcm + atf_add_test_case md5 + atf_add_test_case md5_hmac + atf_add_test_case null + atf_add_test_case sha1_hmac + atf_add_test_case xcbcmac +} diff --git a/contrib/netbsd-tests/dev/audio/h_pad.c b/contrib/netbsd-tests/dev/audio/h_pad.c new file mode 100644 index 000000000000..dd481ac1a85c --- /dev/null +++ b/contrib/netbsd-tests/dev/audio/h_pad.c @@ -0,0 +1,76 @@ +/* $NetBSD: h_pad.c,v 1.1 2010/08/04 13:15:15 pooka Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. 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 AUTHOR ``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 AUTHOR 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 + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "h_pad_musa.c" + +/* + * Stuff some audio into /dev/audio, read it from /dev/pad. Use in + * conjunction with t_pad, which tests that we got sensible output + * by comparing against a previous audibly good result. + */ + +#define BUFSIZE 1024 + +int +main(int argc, char *argv[]) +{ + char buf[BUFSIZE]; + char zeros[BUFSIZE]; + int padfd, audiofd; + ssize_t n; + + rump_init(); + audiofd = rump_sys_open("/dev/audio0", O_RDWR); + if (audiofd == -1) + err(1, "open audio"); + + padfd = rump_sys_open("/dev/pad0", O_RDONLY); + if (padfd == -1) + err(1, "open pad"); + + if ((n = rump_sys_write(audiofd, musa, sizeof(musa))) != sizeof(musa)) + err(1, "write"); + + memset(zeros, 0, sizeof(zeros)); + while ((n = rump_sys_read(padfd, buf, sizeof(buf))) > 0) { + if (memcmp(buf, zeros, sizeof(buf)) == 0) + break; + write(STDOUT_FILENO, buf, n); + } +} diff --git a/contrib/netbsd-tests/dev/audio/h_pad_musa.c b/contrib/netbsd-tests/dev/audio/h_pad_musa.c new file mode 100644 index 000000000000..322305ea4921 --- /dev/null +++ b/contrib/netbsd-tests/dev/audio/h_pad_musa.c @@ -0,0 +1,344 @@ +unsigned char musa[] = { +0x46, 0xdb, 0x76, 0x67, 0x61, 0xff, 0xfc, 0x67, 0xff, 0xe9, 0xdb, 0x79, +0x5d, 0x53, 0x5b, 0x79, 0xef, 0x65, 0x67, 0x5b, 0x67, 0x67, 0x72, 0x66, +0x4f, 0x5b, 0xe7, 0xf5, 0x5e, 0x53, 0x61, 0xe7, 0x5c, 0x53, 0x67, 0x67, +0x67, 0x5b, 0x54, 0x60, 0x4e, 0xec, 0xef, 0x5b, 0x5b, 0x6f, 0x69, 0xff, +0x71, 0x53, 0x77, 0x67, 0x67, 0x5b, 0x5b, 0x5b, 0x75, 0x6c, 0x67, 0x6d, +0x67, 0x7e, 0xff, 0x63, 0x66, 0x61, 0x67, 0x5b, 0x5b, 0x67, 0x67, 0x5f, +0x5b, 0x64, 0x5b, 0x5b, 0x55, 0x53, 0x5c, 0x5d, 0x67, 0x53, 0x63, 0x5e, +0xe7, 0xf5, 0x51, 0x5b, 0x5e, 0x5e, 0x67, 0x5b, 0x67, 0xff, 0x67, 0x67, +0xe9, 0x6e, 0x67, 0x5c, 0x60, 0x67, 0x7a, 0xff, 0xe7, 0xff, 0x58, 0x5b, +0x64, 0x6e, 0x67, 0x55, 0x5f, 0xff, 0xff, 0xff, 0xff, 0x56, 0x5b, 0x53, +0x5b, 0x67, 0x54, 0x58, 0x67, 0x67, 0x6e, 0x67, 0x5c, 0x58, 0x67, 0x67, +0x5b, 0x65, 0x64, 0x70, 0x5b, 0x5b, 0x67, 0xfc, 0xf7, 0xf2, 0xff, 0xec, +0x73, 0x67, 0x67, 0xff, 0x67, 0x74, 0xff, 0x67, 0x5e, 0x5e, 0x67, 0x72, +0x77, 0x7c, 0x67, 0x5d, 0x5b, 0x67, 0x5b, 0x55, 0x67, 0x5c, 0x67, 0x60, +0x5b, 0x5b, 0x61, 0x54, 0x67, 0x5b, 0xe8, 0x75, 0xe2, 0x67, 0xff, 0x62, +0x5b, 0x5b, 0xff, 0xe8, 0xff, 0xe7, 0x6a, 0xee, 0x78, 0x67, 0xff, 0x67, +0x7a, 0xff, 0x6a, 0xff, 0xff, 0x67, 0xff, 0x71, 0xfd, 0x6c, 0x5e, 0xfe, +0xff, 0x6d, 0xe7, 0xff, 0xec, 0x68, 0x5b, 0xff, 0x5c, 0x6a, 0xeb, 0x69, +0x60, 0xff, 0x67, 0x67, 0x67, 0x7a, 0xdf, 0xec, 0x55, 0x5b, 0x5b, 0x5b, +0x71, 0x5c, 0x77, 0x72, 0x68, 0xe7, 0x6d, 0xff, 0xff, 0xff, 0xdb, 0xe7, +0xde, 0xdb, 0xff, 0xff, 0x69, 0xee, 0x78, 0x67, 0xef, 0xea, 0x5b, 0x5b, +0x67, 0x5d, 0x6f, 0xff, 0xff, 0x67, 0x67, 0x67, 0x61, 0x54, 0x5b, 0xff, +0x67, 0x67, 0x5b, 0x67, 0xf4, 0x67, 0x67, 0x67, 0x5b, 0x65, 0xf2, 0x67, +0xff, 0xe7, 0xe7, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xfc, +0xf7, 0xf2, 0x7d, 0x5b, 0x56, 0x67, 0x5e, 0xe2, 0x7f, 0x67, 0x75, 0x67, +0x6d, 0x63, 0x66, 0x67, 0x5b, 0x5b, 0x5b, 0x5b, 0x65, 0xf0, 0x6a, 0xe7, +0x5f, 0x67, 0xff, 0x6f, 0x7b, 0x67, 0x5b, 0xff, 0xff, 0x72, 0x67, 0xff, +0xff, 0xff, 0xff, 0x67, 0x7e, 0x6d, 0xff, 0xff, 0xff, 0x67, 0xff, 0xee, +0xe7, 0xff, 0xff, 0x6a, 0xe7, 0xe7, 0x7a, 0x67, 0xff, 0xff, 0xff, 0x67, +0x67, 0xff, 0xff, 0x67, 0x67, 0x67, 0x5c, 0x5b, 0x67, 0x7f, 0x67, 0xdb, +0xfe, 0xde, 0xec, 0x5c, 0x61, 0x5b, 0x67, 0x6e, 0x67, 0x67, 0xfe, 0xff, +0xe7, 0xff, 0xe7, 0xff, 0xff, 0xe6, 0xd9, 0xe7, 0xff, 0xff, 0x73, 0x68, +0x6c, 0x55, 0xe7, 0xe7, 0xec, 0x67, 0x5b, 0x71, 0xfd, 0xff, 0xff, 0xff, +0x71, 0x67, 0x5b, 0x53, 0x5e, 0x5e, 0x5b, 0x5d, 0x79, 0x70, 0x67, 0x67, +0x60, 0x5c, 0x67, 0xff, 0x7d, 0x75, 0xff, 0xff, 0xe7, 0xec, 0xff, 0xff, +0xe7, 0xfd, 0x67, 0xf7, 0xdc, 0xf1, 0x6b, 0xe9, 0xff, 0x79, 0x7a, 0x6f, +0xfa, 0xf9, 0xff, 0x5b, 0x53, 0x5b, 0x67, 0x77, 0x67, 0x66, 0x67, 0x5b, +0x67, 0x5b, 0x67, 0x67, 0x74, 0x75, 0x7e, 0xf3, 0x67, 0x5c, 0x67, 0x67, +0x5c, 0x67, 0x6a, 0xea, 0xff, 0xff, 0x67, 0xff, 0x7b, 0x78, 0xdf, 0xff, +0xdd, 0xee, 0xfd, 0xf6, 0x67, 0xe7, 0xff, 0x74, 0x67, 0x67, 0xe7, 0xfe, +0xff, 0xec, 0x5c, 0x61, 0xe7, 0x6a, 0x5b, 0xf8, 0xfb, 0xef, 0x79, 0x65, +0x5f, 0x5b, 0x67, 0x60, 0x67, 0x55, 0xf2, 0xff, 0xe7, 0x61, 0x5b, 0x67, +0x67, 0x5b, 0x5e, 0x5e, 0xe8, 0xf3, 0x67, 0xe8, 0xe7, 0xdd, 0xff, 0xe7, +0xdb, 0xf7, 0x70, 0xff, 0xff, 0x6f, 0xff, 0xff, 0xe7, 0x67, 0xff, 0x60, +0x5c, 0x5d, 0x6e, 0xff, 0xec, 0xff, 0x67, 0x67, 0x67, 0x5b, 0x5b, 0x67, +0x5c, 0xff, 0xff, 0x67, 0x6e, 0x67, 0x67, 0x60, 0x67, 0x67, 0x67, 0x67, +0x67, 0x70, 0xff, 0xff, 0x67, 0xff, 0xff, 0xff, 0xfd, 0xf6, 0xff, 0xff, +0xf5, 0xff, 0xff, 0xe2, 0x6c, 0x67, 0x67, 0xff, 0x67, 0xff, 0x63, 0x5b, +0x67, 0x5b, 0x7b, 0x67, 0x67, 0x5d, 0x49, 0x5b, 0x67, 0xe7, 0xff, 0xdf, +0xe5, 0x4d, 0x3b, 0x55, 0xbe, 0xbf, 0x66, 0x41, 0x5b, 0xc3, 0xd3, 0x47, +0x43, 0x79, 0xcf, 0x67, 0x3e, 0x51, 0xc4, 0xbc, 0x6d, 0x3e, 0x50, 0xdf, +0xe7, 0xf9, 0xd4, 0xca, 0x46, 0x37, 0xee, 0xaf, 0xba, 0x40, 0x34, 0x4b, +0xc9, 0xc7, 0x56, 0x39, 0x46, 0xc5, 0xbc, 0x4f, 0x33, 0x4f, 0xbc, 0xc8, +0x4b, 0x39, 0x7e, 0xb6, 0xbc, 0x4b, 0x39, 0x45, 0xcc, 0xc1, 0xec, 0x41, +0x4a, 0xc5, 0xce, 0x48, 0x4c, 0xc9, 0xc4, 0x59, 0x41, 0x53, 0xd9, 0xdb, +0x56, 0x56, 0xdd, 0xcd, 0xdf, 0x4e, 0x5c, 0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6f, 0x55, 0x60, 0xf9, 0xe5, 0xdf, +0xff, 0xdd, 0xfd, 0x69, 0xff, 0x5b, 0x67, 0x67, 0x78, 0xdc, 0x76, 0x73, +0x68, 0xf5, 0x62, 0x5b, 0x73, 0xff, 0xe8, 0xe7, 0xe3, 0xfc, 0x71, 0xe7, +0x6b, 0x58, 0x53, 0x65, 0x6f, 0x7a, 0x67, 0xff, 0x7b, 0x67, 0x5b, 0x5b, +0x53, 0x6e, 0x66, 0x76, 0xed, 0xfe, 0xd6, 0x67, 0x7f, 0xf4, 0xe7, 0xfe, +0xff, 0xff, 0xff, 0x72, 0xeb, 0x67, 0x71, 0xff, 0x67, 0x6f, 0x6a, 0xdb, +0x70, 0xe7, 0x6b, 0x6e, 0x7c, 0x67, 0x5b, 0x53, 0x4d, 0x4d, 0x5c, 0x67, +0xf4, 0xe7, 0xe2, 0xe7, 0xfe, 0x5e, 0x67, 0x67, 0xe7, 0xeb, 0xff, 0x5f, +0x67, 0x67, 0xef, 0x67, 0x5b, 0xff, 0xff, 0xe7, 0xdb, 0xe7, 0xe7, 0x71, +0x67, 0xeb, 0xff, 0x7d, 0x62, 0xed, 0xe7, 0xed, 0x75, 0xff, 0xe7, 0x63, +0x66, 0x5f, 0x5b, 0x66, 0xe7, 0xff, 0xff, 0x67, 0x6a, 0xe7, 0x5f, 0x5d, +0x67, 0x5b, 0xff, 0x6b, 0x5f, 0xe7, 0xff, 0xe7, 0xe8, 0x56, 0x6d, 0x67, +0x59, 0xff, 0x53, 0x66, 0xd0, 0x67, 0x67, 0xf6, 0x68, 0xff, 0xff, 0x67, +0xdf, 0xea, 0xdd, 0xdc, 0x5d, 0xde, 0x5c, 0x50, 0xdb, 0x71, 0xe7, 0xff, +0x72, 0xff, 0x6c, 0x67, 0x67, 0x5b, 0x5b, 0xff, 0xff, 0x5b, 0xe8, 0xff, +0x5b, 0x53, 0x5b, 0x67, 0x67, 0x74, 0xdb, 0xfb, 0x70, 0xed, 0x7a, 0xe7, +0xec, 0x5b, 0x67, 0x64, 0x52, 0xe1, 0xe8, 0xe7, 0x73, 0x68, 0xde, 0x74, +0x68, 0xdb, 0xdb, 0x68, 0x5b, 0xff, 0xff, 0x6e, 0x67, 0x5c, 0x60, 0x53, +0x5a, 0x70, 0x61, 0x52, 0x5b, 0xff, 0x5b, 0xe7, 0xfb, 0xf8, 0x6e, 0x7c, +0x5d, 0x78, 0x7d, 0x5b, 0xff, 0x7e, 0x5b, 0x5b, 0x67, 0x6d, 0xff, 0x5c, +0x72, 0xf7, 0xe7, 0xe7, 0x67, 0xff, 0x5f, 0x6a, 0xff, 0x67, 0xe7, 0xf9, +0x67, 0xff, 0x67, 0x60, 0x5c, 0xff, 0x67, 0x66, 0x63, 0xff, 0xe7, 0xe7, +0x6d, 0xe7, 0x5e, 0xf5, 0xfe, 0x67, 0x56, 0x67, 0xe7, 0xff, 0x67, 0x67, +0x78, 0x4b, 0x5c, 0xd6, 0x5d, 0xdf, 0xe7, 0xff, 0xff, 0x5b, 0x77, 0xff, +0xff, 0xff, 0x53, 0x7e, 0x5b, 0x6d, 0xe7, 0x56, 0x73, 0xfd, 0xe7, 0xf6, +0xfd, 0xff, 0x6f, 0x5b, 0xfb, 0xee, 0x7b, 0xff, 0x79, 0x5b, 0x53, 0x55, +0x53, 0x58, 0x49, 0x5a, 0x6e, 0xdc, 0xff, 0xff, 0xe8, 0x67, 0x67, 0xdb, +0x67, 0x56, 0x54, 0x5b, 0x51, 0x4d, 0x58, 0x5b, 0xea, 0xf1, 0x5d, 0xff, +0xe7, 0xda, 0xe5, 0xd7, 0xde, 0xea, 0xef, 0x67, 0xff, 0x60, 0x5b, 0x67, +0x53, 0x67, 0x50, 0xeb, 0x5b, 0x67, 0x5b, 0x67, 0xed, 0x4a, 0x65, 0xff, +0x5b, 0xd5, 0x57, 0xdd, 0xff, 0x5c, 0xbe, 0x3c, 0xd3, 0x47, 0x5c, 0x68, +0x63, 0x4d, 0xd3, 0x4d, 0xf6, 0x5b, 0x5f, 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0x5b, 0x5f, 0x4d, 0xdb, 0x5b, 0xff, 0xe6, 0xea, +0xea, 0xef, 0xe5, 0xe7, 0xe7, 0xda, 0xe0, 0xff, 0x67, 0xe7, 0x4e, 0x68, +0x50, 0x59, 0x5c, 0xec, 0xff, 0xe7, 0x5b, 0xf5, 0xfe, 0x73, 0xf6, 0xe7, +0xff, 0x63, 0xeb, 0x6e, 0x67, 0x5d, 0x68, 0x65, 0x5b, 0x57, 0xff, 0xff, +0xe0, 0xff, 0x5d, 0x5f, 0x68, 0xff, 0xff, 0x68, 0xde, 0x5e, 0x67, 0x74, +0xff, 0x68, 0x73, 0xf6, 0xfd, 0xe7, 0xff, 0xfc, 0xdf, 0xff, 0xe7, 0x67, +0x67, 0xea, 0xdf, 0x7a, 0x5b, 0x67, 0xff, 0x5b, 0x60, 0x5b, 0x53, 0x56, +0xfe, 0xf5, 0x74, 0x67, 0x62, 0xff, 0x67, 0x6d, 0x5b, 0x7d, 0x72, 0xe7, +0x5c, 0xe7, 0x5b, 0x65, 0xf0, 0xff, 0x6a, 0xef, 0xfa, 0xe4, 0x67, 0x69, +0xff, 0x5b, 0xdb, 0xe3, 0xdf, 0x67, 0x76, 0xe7, 0x7e, 0x5b, 0xff, 0x67, +0x67, 0xe7, 0x5c, 0x61, 0x53, 0xea, 0x5b, 0x64, 0x65, 0x7c, 0x5d, 0x67, +0x6f, 0x67, 0x5d, 0x5b, 0xfb, 0xff, 0xd7, 0xff, 0xdd, 0x6a, 0x67, 0x6c, +0x56, 0xe8, 0xec, 0xe2, 0x5b, 0x67, 0x6c, 0xfe, 0x5e, 0x60, 0xe6, 0x53, +0x67, 0x7c, 0x5f, 0xf8, 0xfb, 0x67, 0xe7, 0xff, 0xe7, 0xe7, 0xdb, 0xdf, +0x67, 0x55, 0x61, 0x5c, 0x6c, 0x53, 0x69, 0xe7, 0x5b, 0x67, 0x62, 0x56, +0x67, 0x61, 0x67, 0xe8, 0xdb, 0x77, 0xdd, 0xdb, 0xeb, 0x67, 0x5b, 0xff, +0x5d, 0x6f, 0x67, 0x67, 0xe7, 0xff, 0x67, 0xe0, 0xe9, 0xeb, 0xe4, 0x67, +0xff, 0x67, 0x67, 0x75, 0x5b, 0x7f, 0xf4, 0xff, 0xff, 0x72, 0x77, 0x5b, +0x67, 0x5b, 0x67, 0xe7, 0x5b, 0x7a, 0x6f, 0x5d, 0xea, 0x61, 0x4d, 0x60, +0xe7, 0x79, 0x59, 0xff, 0x7d, 0x56, 0x5e, 0x67, 0x59, 0x5b, 0xe7, 0xde, +0x75, 0x7e, 0xf7, 0x6f, 0x66, 0x67, 0xf0, 0xfc, 0xe7, 0x67, 0xff, 0x7e, +0x6a, 0x6a, 0x67, 0x67, 0xff, 0xee, 0x67, 0x77, 0xee, 0x67, 0x67, 0x61, +0x67, 0x67, 0x67, 0x67, 0x51, 0xe7, 0x5c, 0x5b, 0xff, 0x5c, 0x72, 0x67, +0x67, 0xff, 0x5d, 0xff, 0x53, 0x6a, 0x5e, 0x57, 0x5d, 0xea, 0xe7, 0xfb, +0xe7, 0xe7, 0xfc, 0xe7, 0xdb, 0xff, 0xff, 0xf3, 0xe7, 0x67, 0xff, 0xff, +0xe7, 0x76, 0x66, 0x5b, 0xff, 0x69, 0xff, 0x64, 0x4e, 0x60, 0xea, 0x5b, +0x67, 0x67, 0x67, 0x5b, 0x67, 0x5b, 0x57, 0x67, 0x77, 0xee, 0xe7, 0xe7, +0xed, 0xff, 0xff, 0x62, 0x5b, 0x67, 0x6c, 0xff, 0x5b, 0x6c, 0xdc, 0x5a, +0x5d, 0x67, 0x71, 0x79, 0x67, 0xd3, 0xe7, 0xff, 0xe7, 0xfb, 0xff, 0xe0, +0x66, 0x67, 0xe7, 0x67, 0x76, 0xe7, 0x67, 0x67, 0x5e, 0xff, 0x6d, 0x5e, +0x68, 0x61, 0x6c, 0xff, 0x53, 0x5d, 0xe9, 0x5f, 0x55, 0xe9, 0x5b, 0x67, +0x67, 0x5f, 0xfa, 0x57, 0x66, 0xe7, 0x6b, 0x67, 0xff, 0xff, 0xe7, 0xff, +0xd8, 0xed, 0xff, 0x74, 0xec, 0x68, 0x67, 0xe7, 0x68, 0xee, 0xff, 0x7c, +0xf1, 0x64, 0x5a, 0x67, 0x53, 0x65, 0x67, 0x5b, 0x79, 0x70, 0x67, 0x5d, +0x4f, 0x54, 0xff, 0xf2, 0x7d, 0x76, 0xe7, 0xe8, 0x75, 0xde, 0xff, 0x5b, +0x75, 0x5b, 0xed, 0x76, 0x66, 0x6e, 0x67, 0x7b, 0x5f, 0x67, 0x67, 0x5b, +0x5d, 0xdd, 0xef, 0xf7, 0xda, 0x60, 0xe6, 0xe3, 0x61, 0xfd, 0xf6, 0xff, +0x67, 0x62, 0x59, 0x53, 0x74, 0x6d, 0x5b, 0xff, 0x5b, 0x67, 0x72, 0x6f, +0x5b, 0xff, 0x6b, 0xe7, 0xe7, 0x67, 0x67, 0xef, 0xdd, 0x6a, 0x60, 0x67, +0xe7, 0xe7, 0x65, 0x63, 0xf3, 0xe9, 0x62, 0x74, 0x67, 0xff, 0xf5, 0xe7, +0xff, 0xff, 0x68, 0x53, 0x6b, 0x69, 0xff, 0xe7, 0xe7, 0xf0, 0x79, 0x55, +0x53, 0x5d, 0xff, 0x67, 0xdb, 0xf8, 0x6e, 0x7a, 0x53, 0xff, 0x5b, 0x51, +0x5e, 0x67, 0x5e, 0x5e, 0x67, 0x67, 0x5b, 0x5b, 0x5b, 0x5b, 0x67, 0xe7, +0x78, 0x7b, 0xf0, 0xea, 0x67, 0xff, 0x67, 0x79, 0xff, 0xe7, 0xf8, 0x6e, +0xe9, 0xff, 0x61, 0xff, 0x58, 0x67, 0x5b, 0x75, 0x67, 0xff, 0x5b, 0x67, +0x67, 0x6d, 0x5b, 0x5b, 0x5f, 0x5d, 0x67, 0x5b, 0x53, 0x5b, 0x67, 0x79, +0xff, 0xf0, 0xe9, 0x67, 0x60, 0x5b, 0x67, 0x6e, 0x67, 0xff, 0xe7, 0xe8, +0x6c, 0xf4, 0x67, 0x67, 0xf5, 0xdc, 0x6d, 0xff, 0xff, 0x6e, 0x67, 0xff, +0x65, 0xf8, 0xf7, 0x5c, 0xea, 0xff, 0xd7, 0xff, 0xff, 0x70, 0x5b, 0x5d, +0xff, 0x66, 0x53, 0x6e, 0x66, 0x76, 0xff, 0x67, 0x67, 0x53, 0x5b, 0x73, +0x76, 0x67, 0xe7, 0xdd, 0x67, 0xff, 0x5b, 0x65, 0x67, 0x67, 0xff, 0x6f, +0x7a, 0x79, 0x67, 0x69, 0xe7, 0xee, 0xe7, 0xe7, 0xe7, 0xff, 0x4d, 0xe7, +0xe8, 0xff, 0x67, 0x7f, 0xff, 0x67, 0x67, 0x6d, 0x58, 0xe7, 0x67, 0x6b, +0xff, 0x5b, 0x67, 0x5d, 0x5b, 0x52, 0x59, 0xfe, 0x53, 0x78, 0xff, 0x53, +0x63, 0x72, 0x5b, 0x51, 0x5b, 0x5c, 0xec, 0xf4, 0xe7, 0xd9, 0xd6, 0xfe, +0xed, 0x63, 0x5b, 0xff, 0x67, 0x7c, 0xff, 0x67, 0xe9, 0x6f, 0x67, 0x67, +0xff, 0xdb, 0xe4, 0x67, 0x5c, 0x67, 0x5f, 0x5b, 0x5b, 0x5b, 0x5b, 0x75, +0x67, 0x67, 0x67, 0xe7, 0x67, 0x5b, 0x67, 0x67, 0x5f, 0x67, 0xe9, 0xff, +0x5b, 0x65, 0xe7, 0xea, 0x7a, 0xff, 0x7a, 0x67, 0x5f, 0x67, 0x6b, 0x5b, +0x67, 0x67, 0x61, 0x67, 0x67, 0xff, 0xe8, 0x5b, 0xff, 0xe7, 0xe7, 0xe7, +0xe7, 0xe7, 0x67, 0x5c, 0x5b, 0x5b, 0x67, 0xff, 0x67, 0xea, 0x6f, 0x67, +0x67, 0x67, 0x4e, 0x53, 0xe9, 0x79, 0x59, 0xdd, 0xd4, 0xe3, 0xdd, 0xe8, +0x5b, 0x62, 0x7f, 0xd1, 0x6d, 0x53, 0xed, 0x6e, 0x66, 0x67, 0x67, 0x67, +0x67, 0xff, 0x69, 0x67, 0xea, 0x5d, 0x6f, 0xdb, 0x5f, 0x5b, 0xe7, 0xf7, +0xd0, 0xe8, 0xec, 0x73, 0x5b, 0x67, 0xf4, 0x67, 0x74, 0x67, 0x5b, 0x5b, +0x5b, 0x66, 0x53, 0x55, 0x5b, 0x71, 0x5b, 0x5c, 0x70, 0xed, 0x4e, 0x4d, +0x6a, 0xe7, 0x6f, 0xfb, 0xd5, 0xdf, 0x67, 0x77, 0x72, 0xfd, 0xe7, 0xed, +0x68, 0xff, 0x74, 0x67, 0x61, 0xff, 0x68, 0x6e, 0x53, 0x5b, 0x67, 0x5a, +0x5a, 0xff, 0xdd, 0x5e, 0x57, 0xea, 0xff, 0x4d, 0x6b, 0xf8, 0x53, 0x67, +0x67, 0xf2, 0x7b, 0x53, 0x58, 0x5b, 0x56, 0x67, 0xe7, 0xf4, 0x6c, 0xff, +0xe7, 0xff, 0x68, 0xee, 0x77, 0x7c, 0xf1, 0x67, 0xe7, 0x5f, 0x6a, 0xff, +0xff, 0xff, 0xff, 0x60, 0xfc, 0xe7, 0x72, 0x54, 0x76, 0x67, 0x67, 0x67, +0xd9, 0xdb, 0x4f, 0x67, 0x5b, 0x5b, 0x56, 0x67, 0xe7, 0x4e, 0xea, 0x7b, +}; diff --git a/contrib/netbsd-tests/dev/audio/t_pad.sh b/contrib/netbsd-tests/dev/audio/t_pad.sh new file mode 100755 index 000000000000..8caf23a7de90 --- /dev/null +++ b/contrib/netbsd-tests/dev/audio/t_pad.sh @@ -0,0 +1,47 @@ +# $NetBSD: t_pad.sh,v 1.3 2010/11/07 17:51:17 jmmv Exp $ +# +# Copyright (c) 2010 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 pad_output +pad_output_head() +{ + + atf_set "descr" "Check pad driver output against known-good output" +} + +pad_output_body() +{ + + atf_check -s exit:0 uudecode $(atf_get_srcdir)/t_pad_output.bz2.uue + atf_check -s exit:0 bunzip2 t_pad_output.bz2 + atf_check -s exit:0 -o file:t_pad_output $(atf_get_srcdir)/h_pad +} + +atf_init_test_cases() +{ + + atf_add_test_case pad_output +} diff --git a/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue b/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue new file mode 100644 index 000000000000..0aadfa7dae51 --- /dev/null +++ b/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue @@ -0,0 +1,998 @@ +begin 644 t_pad_output.bz2 +M0EIH.3%!629368,\S/H`A(]_____________________________________ +M________X)/JWW=]LJ1DQ(V-I-I+:VTPD*VTAK31))5F;9)60#$TK+5K#:U* +M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6;RR>\')].P3D$$](H$P`+Q$#R9EM],/LF@J(<\D$. +M/5Z&N(%&=::F4A=/.[EPZ3,D0?,TDHW$5#VJ_.+9+T:K@@-AS%F]'`C^0RN6 +M.T3PP8P/*Y'L<'%D6,M?KEX1GTQ[F(9"7L'']09$3[G=+LLC3'M&O\_2D"J. +M-23_-0=UH]+PB_]$2:EHB(LCL+EZ9_L$K.P?_!%C4V@TJGK^RF'5?3&HH#W4<^([=]`GB(* +MD5I(S67Z/>1&OB,!+&4]W!]L15^9&!#?R>\^KRQ1*/45V%@$06[2:O-W1)4; +M5P@K=*ED%_UM9$F,;'O,ZY(K.AE-9\B+4;OV3YR(NU(3Z&/-6M70(BN9+N\' +ML6C@L['=3AH(!OA(W687;HO@OIEU!I<8"+%8DSU=CH3+KG7])+2RW&G9)9!$ +MQ3;ITH2B6!BN`1`O#JF@(/QQ`10C/`7':QDX8,LL'T0#(.-2M,NJR,(=0>`1/&Y[*7J[B?1AG% +M9-1B$-Z+7N*DI('6:N>R8MBAV_Z_7(O.3=5P8[)($D+5KG$;E14J\-D@R_UF +MLF&AA&/2@6)ZJ;TZ"\7E;.)/TN*8W)V^ICH>)^QR\OC]+_7M)4#V.("KGD7? +M9_&Y+>H95?]3-GMO9,YO+``2779/YN6']*5(!!*+T\?CMLH@"7+1>[/ +MD0(#@&)QD)H9/ODAR$DD)/>;%E;NN8`?8H>.\=GM&$A]>FMMU]R]\GP4Z;Z? +M&K\1"`'8'_&H29W967@\S[B@0/F@@@$"@$$$" +M[H'M:I>M='#:"WN/&D).V0(?^EY+-1M?,[Z5E14BV`0Q$FYY5JF1__B[DBG" +&A(09YF?0 +` +end diff --git a/contrib/netbsd-tests/dev/cgd/paramsfile b/contrib/netbsd-tests/dev/cgd/paramsfile new file mode 100644 index 000000000000..066eab6fc434 --- /dev/null +++ b/contrib/netbsd-tests/dev/cgd/paramsfile @@ -0,0 +1,8 @@ +algorithm aes-cbc; +iv-method encblkno1; +keylength 128; +verify_method none; +keygen pkcs5_pbkdf2/sha1 { + iterations 42; + salt AAAAgKajcCnHR7sR1k1RKQ9Q0uY=; +}; diff --git a/contrib/netbsd-tests/dev/cgd/t_cgd.sh b/contrib/netbsd-tests/dev/cgd/t_cgd.sh new file mode 100755 index 000000000000..9cd50a5fd86d --- /dev/null +++ b/contrib/netbsd-tests/dev/cgd/t_cgd.sh @@ -0,0 +1,159 @@ +# $NetBSD: t_cgd.sh,v 1.11 2013/02/19 21:08:24 joerg Exp $ +# +# Copyright (c) 2010 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. +# + +rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'` +rawcgd=/dev/rcgd0${rawpart} +cgdserver=\ +"rump_server -lrumpvfs -lrumpkern_crypto -lrumpdev -lrumpdev_disk -lrumpdev_cgd" + +atf_test_case basic cleanup +basic_head() +{ + + atf_set "descr" "Tests that encrypt/decrypt works" + atf_set "require.progs" "rump_server" +} + +basic_body() +{ + + d=$(atf_get_srcdir) + atf_check -s exit:0 \ + ${cgdserver} -d key=/dev/dk,hostpath=dk.img,size=1m unix://csock + + export RUMP_SERVER=unix://csock + atf_check -s exit:0 -x "echo 12345 | \ + rump.cgdconfig -p cgd0 /dev/dk ${d}/paramsfile" + atf_check -s exit:0 -e ignore -x \ + "dd if=${d}/t_cgd count=2 | rump.dd of=${rawcgd}" + atf_check -s exit:0 -e ignore dd if=${d}/t_cgd of=testfile count=2 + atf_check -s exit:0 -e ignore -o file:testfile \ + rump.dd if=${rawcgd} count=2 +} + +basic_cleanup() +{ + + env RUMP_SERVER=unix://csock rump.halt || true +} + +atf_test_case wrongpass cleanup +wrongpass_head() +{ + + atf_set "descr" "Tests that wrong password does not give original " \ + "plaintext" + atf_set "require.progs" "rump_server" +} + +wrongpass_body() +{ + + d=$(atf_get_srcdir) + atf_check -s exit:0 \ + ${cgdserver} -d key=/dev/dk,hostpath=dk.img,size=1m unix://csock + + export RUMP_SERVER=unix://csock + atf_check -s exit:0 -x "echo 12345 | \ + rump.cgdconfig -p cgd0 /dev/dk ${d}/paramsfile" + atf_check -s exit:0 -e ignore -x \ + "dd if=${d}/t_cgd | rump.dd of=${rawcgd} count=2" + + # unconfig and reconfig cgd + atf_check -s exit:0 rump.cgdconfig -u cgd0 + atf_check -s exit:0 -x "echo 54321 | \ + rump.cgdconfig -p cgd0 /dev/dk ${d}/paramsfile" + + atf_check -s exit:0 -e ignore dd if=${d}/t_cgd of=testfile count=2 + atf_check -s exit:0 -e ignore -o not-file:testfile \ + rump.dd if=${rawcgd} count=2 +} + +wrongpass_cleanup() +{ + + env RUMP_SERVER=unix://csock rump.halt || true +} + + +atf_test_case unaligned_write cleanup +unaligned_write_head() +{ + + atf_set "descr" "Attempt unaligned writes to a raw cgd device" + atf_set "require.progs" "rump_server" +} + +unaligned_write_body() +{ + d=$(atf_get_srcdir) + atf_check -s exit:0 \ + ${cgdserver} -d key=/dev/dk,hostpath=dk.img,size=1m unix://csock + + export RUMP_SERVER=unix://csock + atf_check -s exit:0 -x "echo 12345 | \ + rump.cgdconfig -p cgd0 /dev/dk ${d}/paramsfile" + + # Check that cgd rejects writes of totally bogus lengths. + atf_check -s not-exit:0 -e ignore -x \ + "echo die hard | rump.dd of=${rawcgd} bs=123 conv=sync" + + # Check that cgd rejects non-sector-length writes even if they + # are integral multiples of the block size. + atf_check -s not-exit:0 -e ignore -x \ + "echo die hard | rump.dd of=${rawcgd} bs=64 conv=sync" + atf_check -s not-exit:0 -e ignore -x \ + "echo die hard | rump.dd of=${rawcgd} bs=256 conv=sync" + + # Check that cgd rejects misaligned buffers, produced by + # packetizing the input on bogus boundaries and using the + # bizarre behaviour of `bs=N' in dd. + atf_check -s not-exit:0 -e ignore -x \ + "(echo -n x && sleep 1 && head -c 511 + + + + cmd_data + + command + targets + event_nr + 0x0 + flags + 0x4 + version + + 0x4 + 0x1 + 0x0 + + + \ No newline at end of file diff --git a/contrib/netbsd-tests/dev/dm/dm_version_cmd.plist b/contrib/netbsd-tests/dev/dm/dm_version_cmd.plist new file mode 100644 index 000000000000..e40e53ebdd51 --- /dev/null +++ b/contrib/netbsd-tests/dev/dm/dm_version_cmd.plist @@ -0,0 +1,20 @@ + + + + + cmd_data + + command + version + event_nr + 0x0 + flags + 0x4 + version + + 0x4 + 0x0 + 0x0 + + + \ No newline at end of file diff --git a/contrib/netbsd-tests/dev/dm/h_dm.c b/contrib/netbsd-tests/dev/dm/h_dm.c new file mode 100644 index 000000000000..3380ad3fb5b2 --- /dev/null +++ b/contrib/netbsd-tests/dev/dm/h_dm.c @@ -0,0 +1,146 @@ +/* $NetBSD: h_dm.c,v 1.1 2010/10/06 11:24:55 haad Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. 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 AUTHOR ``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 AUTHOR 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 + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +int dm_test_targets(void); +int dm_test_versions(void); + +/* + * Test simple dm versions command on device-mapper device. + */ +int +dm_test_versions(void) { + int fd; + int error; + prop_dictionary_t dict_in, dict_out; + struct plistref prefp; + char *xml; + + error = 0; + + error = rump_init(); + if (error != 0) + err(1, "Rump init failed"); + + fd = rump_sys_open("/dev/mapper/control", O_RDWR, 0); + if (fd == -1) + err(1, "Open dm device failed"); + + dict_in = prop_dictionary_internalize_from_file("dm_version_cmd.plist"); + dict_out = prop_dictionary_create(); + + prop_dictionary_externalize_to_pref(dict_in, &prefp); + + error = rump_sys_ioctl(fd, NETBSD_DM_IOCTL, &prefp); + if (error < 0) + err(1, "Dm control ioctl failed"); + + dict_out = prop_dictionary_internalize(prefp.pref_plist); + + xml = prop_dictionary_externalize(dict_out); + + rump_sys_close(fd); + + return error; +} + +/* + * Test simple dm targets command on device-mapper device. + */ +int +dm_test_targets(void) { + int fd; + int error; + prop_dictionary_t dict_in, dict_out; + struct plistref prefp; + char *xml; + + error = 0; + + error = rump_init(); + if (error != 0) + err(1, "Rump init failed"); + + fd = rump_sys_open("/dev/mapper/control", O_RDWR, 0); + if (fd == -1) + err(1, "Open dm device failed"); + + dict_in = prop_dictionary_internalize_from_file("dm_targets_cmd.plist"); + dict_out = prop_dictionary_create(); + + prop_dictionary_externalize_to_pref(dict_in, &prefp); + + error = rump_sys_ioctl(fd, NETBSD_DM_IOCTL, &prefp); + if (error < 0) + err(1, "Dm control ioctl failed"); + + dict_out = prop_dictionary_internalize(prefp.pref_plist); + + xml = prop_dictionary_externalize(dict_out); + + rump_sys_close(fd); + + return error; +} + +int +main(int argc, char **argv) { + int error; + + error = 0; + + error = dm_test_versions(); + if (error != 0) + err(1, "dm_test_versions failed"); + + error = dm_test_targets(); + if (error != 0) + err(1, "dm_test_targets failed"); + + return error; +} diff --git a/contrib/netbsd-tests/dev/dm/t_dm.sh b/contrib/netbsd-tests/dev/dm/t_dm.sh new file mode 100755 index 000000000000..02d1ee34cd15 --- /dev/null +++ b/contrib/netbsd-tests/dev/dm/t_dm.sh @@ -0,0 +1,47 @@ +# $NetBSD: t_dm.sh,v 1.2 2010/11/07 17:51:17 jmmv Exp $ +# +# Copyright (c) 2010 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 dm_test +dm_test_head() +{ + atf_set "descr" "Check dm driver routines and create lineary, stripe mapped disks" +} + +dm_test_body() +{ + # XXX Actually we need disks than 1 for stripe check let it leave for later now. + #atf_check -s exit:0 uudecode $(atf_get_srcdir)/t_dm_disk_1.bz2.uue + #atf_check -s exit:0 bunzip2 t_dm_disk_1.bz2 + #atf_check -s exit:0 -o file:t_dm_disk_1 $(atf_get_srcdir)/h_dm + atf_check -s exit:0 $(atf_get_srcdir)/h_dm +} + +atf_init_test_cases() +{ + + atf_add_test_case dm_test +} diff --git a/contrib/netbsd-tests/dev/md/h_mdserv.c b/contrib/netbsd-tests/dev/md/h_mdserv.c new file mode 100644 index 000000000000..f5ac6a9e66ee --- /dev/null +++ b/contrib/netbsd-tests/dev/md/h_mdserv.c @@ -0,0 +1,109 @@ +/* $NetBSD: h_mdserv.c,v 1.4 2011/02/10 13:29:02 pooka Exp $ */ + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define MDSIZE (1024*1024) + +#define REQUIRE(a, msg) if ((a) != 0) err(1, msg); + +static void * +prober(void *arg) +{ + int fd, error; + char buf[4]; + ssize_t n; + + fd = rump_sys_open(arg, O_RDONLY); + for (;;) { + n = rump_sys_read(fd, buf, sizeof(buf)); + + switch (n) { + case 4: + error = 0; + goto out; + + case -1: + if (errno == ENXIO) { + usleep(1000); + continue; + } + + /* FALLTHROUGH */ + default: + error = EPIPE; + goto out; + } + } + out: + + error = rump_daemonize_done(error); + REQUIRE(error, "rump_daemonize_done"); + + if (error) + exit(1); + + return NULL; +} + +int +main(int argc, char *argv[]) +{ + pthread_t pt; + struct md_conf md; + int fd, error; + + if (argc != 2) + exit(1); + + md.md_addr = calloc(1, MDSIZE); + md.md_size = MDSIZE; + md.md_type = MD_UMEM_SERVER; + + error = rump_daemonize_begin(); + REQUIRE(error, "rump_daemonize_begin"); + + error = rump_init(); + REQUIRE(error, "rump_init"); + + error = rump_init_server("unix://commsock"); + REQUIRE(error, "init server"); + + if ((fd = rump_sys_open(argv[1], O_RDWR)) == -1) + err(1, "open"); + + /* + * Now, configuring the md driver also causes our process + * to start acting as the worker for the md. Splitting it + * into two steps in the driver is not easy, since md is + * supposed to be unconfigured when the process dies + * (process may exit between calling ioctl1 and ioctl2). + * So, start a probe thread which attempts to read the md + * and declares the md as configured when the read is + * succesful. + */ + error = pthread_create(&pt, NULL, prober, argv[1]); + REQUIRE(error, "pthread_create"); + pthread_detach(pt); + + if (rump_sys_ioctl(fd, MD_SETCONF, &md) == -1) { + rump_daemonize_done(errno); + exit(1); + } + + return 0; +} diff --git a/contrib/netbsd-tests/dev/md/t_md.sh b/contrib/netbsd-tests/dev/md/t_md.sh new file mode 100755 index 000000000000..85de73e80b23 --- /dev/null +++ b/contrib/netbsd-tests/dev/md/t_md.sh @@ -0,0 +1,65 @@ +# $NetBSD: t_md.sh,v 1.7 2011/05/14 17:42:28 jmmv Exp $ +# +# Copyright (c) 2010 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. +# + +rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'` +rawmd=/dev/rmd0${rawpart} + +atf_test_case basic cleanup +basic_head() +{ + + atf_set "descr" "Check that md can be created, read and written" +} + +basic_body() +{ + + # Scope out raw part. This is actually the *host* raw partition, + # but just let it slide for now, since they *should* be the same. + rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'` + + atf_check -s exit:0 $(atf_get_srcdir)/h_mdserv ${rawmd} + + export RUMP_SERVER=unix://commsock + atf_check -s exit:0 -e ignore -x \ + "dd if=/bin/ls count=10 | rump.dd of=${rawmd} seek=100" + atf_check -s exit:0 -e ignore -x \ + "rump.dd if=${rawmd} skip=100 count=10 | dd of=testfile" + atf_check -s exit:0 -e ignore -o file:testfile dd if=/bin/ls count=10 +} + +basic_cleanup() +{ + + env RUMP_SERVER=unix://commsock rump.halt +} + +atf_init_test_cases() +{ + + atf_add_test_case basic +} diff --git a/contrib/netbsd-tests/dev/raidframe/t_raid.sh b/contrib/netbsd-tests/dev/raidframe/t_raid.sh new file mode 100755 index 000000000000..ae21eedf5e34 --- /dev/null +++ b/contrib/netbsd-tests/dev/raidframe/t_raid.sh @@ -0,0 +1,323 @@ +#! /usr/bin/atf-sh +# $NetBSD: t_raid.sh,v 1.12 2013/02/19 21:08:24 joerg Exp $ +# +# Copyright (c) 2010 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. +# + +rawpart=`sysctl -n kern.rawpartition | tr '01234' 'abcde'` +rawraid=/dev/rraid0${rawpart} +raidserver="rump_server -lrumpvfs -lrumpdev -lrumpdev_disk -lrumpdev_raidframe" + +makecfg() +{ + level=${1} + ncol=${2} + + printf "START array\n1 ${ncol} 0\nSTART disks\n" > raid.conf + diskn=0 + while [ ${ncol} -gt ${diskn} ] ; do + echo "/disk${diskn}" >> raid.conf + diskn=$((diskn+1)) + done + + printf "START layout\n32 1 1 ${level}\nSTART queue\nfifo 100\n" \ + >> raid.conf +} + +atf_test_case smalldisk cleanup +smalldisk_head() +{ + atf_set "descr" "Checks the raidframe works on small disks " \ + "(PR kern/44239)" + atf_set "require.progs" "rump_server" +} + +smalldisk_body() +{ + makecfg 1 2 + export RUMP_SERVER=unix://sock + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=1m \ + -d key=/disk1,hostpath=disk1.img,size=1m \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -C raid.conf raid0 +} + +smalldisk_cleanup() +{ + export RUMP_SERVER=unix://sock + rump.halt +} + + +# make this smaller once 44239 is fixed +export RAID_MEDIASIZE=32m + +atf_test_case raid1_compfail cleanup +raid1_compfail_head() +{ + atf_set "descr" "Checks that RAID1 works after component failure" + atf_set "require.progs" "rump_server" +} + +raid1_compfail_body() +{ + makecfg 1 2 + export RUMP_SERVER=unix://sock + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -C raid.conf raid0 + atf_check -s exit:0 rump.raidctl -I 12345 raid0 + atf_check -s exit:0 -o ignore rump.raidctl -iv raid0 + + # put some data there + atf_check -s exit:0 -e ignore \ + dd if=$(atf_get_srcdir)/t_raid of=testfile count=4 + atf_check -s exit:0 -e ignore -x \ + "dd if=testfile | rump.dd of=${rawraid} conv=sync" + + # restart server with failed component + rump.halt + rm disk1.img # FAIL + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -c raid.conf raid0 + + # check if we we get what we wrote + atf_check -s exit:0 -o file:testfile -e ignore \ + rump.dd if=${rawraid} count=4 +} + +raid1_compfail_cleanup() +{ + export RUMP_SERVER=unix://sock + rump.halt +} + + + +atf_test_case raid1_comp0fail cleanup +raid1_comp0fail_head() +{ + atf_set "descr" "Checks configuring RAID1 after component 0 fails" \ + "(PR kern/44251)" + atf_set "require.progs" "rump_server" +} + +raid1_comp0fail_body() +{ + makecfg 1 2 + export RUMP_SERVER=unix://sock + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -C raid.conf raid0 + atf_check -s exit:0 rump.raidctl -I 12345 raid0 + atf_check -s exit:0 -o ignore rump.raidctl -iv raid0 + + # restart server with failed component + rump.halt + rm disk0.img # FAIL + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -c raid.conf raid0 +} + +raid1_comp0fail_cleanup() +{ + export RUMP_SERVER=unix://sock + rump.halt +} + +atf_test_case raid1_normal cleanup +raid1_normal_head() +{ + atf_set "descr" "Checks that RAID1 -c configurations work " \ + "in the normal case" + atf_set "require.progs" "rump_server" +} + +raid1_normal_body() +{ + makecfg 1 2 + export RUMP_SERVER=unix://sock + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -C raid.conf raid0 + atf_check -s exit:0 rump.raidctl -I 12345 raid0 + atf_check -s exit:0 -o ignore rump.raidctl -iv raid0 + + # put some data there + atf_check -s exit:0 -e ignore \ + dd if=$(atf_get_srcdir)/t_raid of=testfile count=4 + atf_check -s exit:0 -e ignore -x \ + "dd if=testfile | rump.dd of=${rawraid} conv=sync" + + # restart server, disks remain normal + rump.halt + + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -c raid.conf raid0 + + # check if we we get what we wrote + atf_check -s exit:0 -o file:testfile -e ignore \ + rump.dd if=${rawraid} count=4 + +} + +raid1_normal_cleanup() +{ + export RUMP_SERVER=unix://sock + rump.halt +} + + +atf_test_case raid5_compfail cleanup +raid5_compfail_head() +{ + atf_set "descr" "Checks that RAID5 works after component failure" + atf_set "require.progs" "rump_server" +} + +raid5_compfail_body() +{ + makecfg 5 3 + export RUMP_SERVER=unix://sock + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -C raid.conf raid0 + atf_check -s exit:0 rump.raidctl -I 12345 raid0 + atf_check -s exit:0 -o ignore rump.raidctl -iv raid0 + + # put some data there + atf_check -s exit:0 -e ignore \ + dd if=$(atf_get_srcdir)/t_raid of=testfile count=4 + atf_check -s exit:0 -e ignore -x \ + "dd if=testfile | rump.dd of=${rawraid} conv=sync" + + # restart server with failed component + rump.halt + rm disk2.img # FAIL + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -c raid.conf raid0 + + # check if we we get what we wrote + atf_check -s exit:0 -o file:testfile -e ignore \ + rump.dd if=${rawraid} count=4 +} + +raid5_compfail_cleanup() +{ + export RUMP_SERVER=unix://sock + rump.halt +} + +atf_test_case raid5_normal cleanup +raid5_normal_head() +{ + atf_set "descr" "Checks that RAID5 works after normal shutdown " \ + "and 'raidctl -c' startup" + atf_set "require.progs" "rump_server" +} + +raid5_normal_body() +{ + makecfg 5 3 + export RUMP_SERVER=unix://sock + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -C raid.conf raid0 + atf_check -s exit:0 rump.raidctl -I 12345 raid0 + atf_check -s exit:0 -o ignore rump.raidctl -iv raid0 + + # put some data there + atf_check -s exit:0 -e ignore \ + dd if=$(atf_get_srcdir)/t_raid of=testfile count=4 + atf_check -s exit:0 -e ignore -x \ + "dd if=testfile | rump.dd of=${rawraid} conv=sync" + + # restart server after normal shutdown + rump.halt + + atf_check -s exit:0 ${raidserver} \ + -d key=/disk0,hostpath=disk0.img,size=${RAID_MEDIASIZE} \ + -d key=/disk1,hostpath=disk1.img,size=${RAID_MEDIASIZE} \ + -d key=/disk2,hostpath=disk2.img,size=${RAID_MEDIASIZE} \ + ${RUMP_SERVER} + + atf_check -s exit:0 rump.raidctl -c raid.conf raid0 + + # check if we we get what we wrote + atf_check -s exit:0 -o file:testfile -e ignore \ + rump.dd if=${rawraid} count=4 +} + +raid5_normal_cleanup() +{ + export RUMP_SERVER=unix://sock + rump.halt +} + +atf_init_test_cases() +{ + atf_add_test_case smalldisk + atf_add_test_case raid1_normal + atf_add_test_case raid1_comp0fail + atf_add_test_case raid1_compfail + atf_add_test_case raid5_normal + atf_add_test_case raid5_compfail +} diff --git a/contrib/netbsd-tests/dev/scsipi/libscsitest/SCSITEST.ioconf b/contrib/netbsd-tests/dev/scsipi/libscsitest/SCSITEST.ioconf new file mode 100644 index 000000000000..afee6c80bd58 --- /dev/null +++ b/contrib/netbsd-tests/dev/scsipi/libscsitest/SCSITEST.ioconf @@ -0,0 +1,12 @@ +# $NetBSD: SCSITEST.ioconf,v 1.1 2014/04/24 21:46:44 pooka Exp $ +# + +ioconf scsitest + +include "conf/files" +include "dev/scsipi/files.scsipi" +include "rump/dev/files.rump" + +pseudo-root mainbus* + +scsitest0 at mainbus? diff --git a/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest.c b/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest.c new file mode 100644 index 000000000000..8f214f783d8c --- /dev/null +++ b/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest.c @@ -0,0 +1,259 @@ +/* $NetBSD: scsitest.c,v 1.2 2014/04/25 00:24:39 pooka Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. 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 AUTHOR ``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 AUTHOR 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. + */ + +/* + * A SCSI target which is useful for debugging our scsipi driver stack. + * Currently it pretends to be a single CD. + * + * Freely add the necessary features for your tests. Just remember to + * run the atf test suite to make sure you didn't cause regressions to + * other tests. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: scsitest.c,v 1.2 2014/04/25 00:24:39 pooka Exp $"); + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "scsitest.h" + +int scsitest_match(device_t, cfdata_t, void *); +void scsitest_attach(device_t, device_t, void *); + +struct scsitest { + struct scsipi_channel sc_channel; + struct scsipi_adapter sc_adapter; +}; + +CFATTACH_DECL_NEW(scsitest, sizeof(struct scsitest), scsitest_match, + scsitest_attach, NULL, NULL); + +/* + * tosi.iso can be used to deliver CD requests to a host file with the + * name in USE_TOSI_ISO (yes, it's extrasimplistic). + */ +//#define USE_TOSI_ISO + +#define CDBLOCKSIZE 2048 +static uint32_t mycdsize = 2048; +static int isofd; + +#define MYCDISO "tosi.iso" + +unsigned rump_scsitest_err[RUMP_SCSITEST_MAXERROR]; + +static void +sense_notready(struct scsipi_xfer *xs) +{ + struct scsi_sense_data *sense = &xs->sense.scsi_sense; + + xs->error = XS_SENSE; + + sense->response_code = 0x70; + sense->flags = SKEY_NOT_READY; + sense->asc = 0x3A; + sense->ascq = 0x00; + sense->extra_len = 6; +} + +/* + * This is pretty much a CD target for now + */ +static void +scsitest_request(struct scsipi_channel *chan, + scsipi_adapter_req_t req, void *arg) +{ + struct scsipi_xfer *xs = arg; + struct scsipi_generic *cmd = xs->cmd; +#ifdef USE_TOSI_ISO + int error; +#endif + + if (req != ADAPTER_REQ_RUN_XFER) + return; + + //show_scsipi_xs(xs); + + switch (cmd->opcode) { + case SCSI_TEST_UNIT_READY: + if (isofd == -1) + sense_notready(xs); + + break; + case INQUIRY: { + struct scsipi_inquiry_data *inqbuf = (void *)xs->data; + + memset(inqbuf, 0, sizeof(*inqbuf)); + inqbuf->device = T_CDROM; + inqbuf->dev_qual2 = SID_REMOVABLE; + strcpy(inqbuf->vendor, "RUMPHOBO"); + strcpy(inqbuf->product, "It's a LIE"); + strcpy(inqbuf->revision, "0.00"); + break; + } + case READ_CD_CAPACITY: { + struct scsipi_read_cd_cap_data *ret = (void *)xs->data; + + _lto4b(CDBLOCKSIZE, ret->length); + _lto4b(mycdsize, ret->addr); + + break; + } + case READ_DISCINFO: { + struct scsipi_read_discinfo_data *ret = (void *)xs->data; + + memset(ret, 0, sizeof(*ret)); + break; + } + case READ_TRACKINFO: { + struct scsipi_read_trackinfo_data *ret = (void *)xs->data; + + _lto4b(mycdsize, ret->track_size); + break; + } + case READ_TOC: { + struct scsipi_toc_header *ret = (void *)xs->data; + + memset(ret, 0, sizeof(*ret)); + break; + } + case START_STOP: { + struct scsipi_start_stop *param = (void *)cmd; + + if (param->how & SSS_LOEJ) { +#ifdef USE_TOSI_ISO + rumpuser_close(isofd, &error); +#endif + isofd = -1; + } + break; + } + case SCSI_SYNCHRONIZE_CACHE_10: { + if (isofd == -1) { + if ((xs->xs_control & XS_CTL_SILENT) == 0) + atomic_inc_uint(&rump_scsitest_err + [RUMP_SCSITEST_NOISYSYNC]); + + sense_notready(xs); + } + + break; + } + case GET_CONFIGURATION: { + memset(xs->data, 0, sizeof(struct scsipi_get_conf_data)); + break; + } + case SCSI_READ_6_COMMAND: { +#ifdef USE_TOSI_ISO + struct scsi_rw_6 *param = (void *)cmd; + + printf("reading %d bytes from %d\n", + param->length * CDBLOCKSIZE, + _3btol(param->addr) * CDBLOCKSIZE); + rumpuser_pread(isofd, xs->data, + param->length * CDBLOCKSIZE, + _3btol(param->addr) * CDBLOCKSIZE, + &error); +#endif + + break; + } + case SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL: + /* hardcoded for now */ + break; + default: + printf("unhandled opcode 0x%x\n", cmd->opcode); + break; + } + + scsipi_done(xs); +} + +int +scsitest_match(device_t parent, cfdata_t match, void *aux) +{ +#ifdef USE_TOSI_ISO + uint64_t fsize; + int error, ft; + + if (rumpuser_getfileinfo(MYCDISO, &fsize, &ft, &error)) + return 0; + if (ft != RUMPUSER_FT_REG) + return 0; + mycdsize = fsize / CDBLOCKSIZE; + + if ((isofd = rumpuser_open(MYCDISO, RUMPUSER_OPEN_RDWR, &error)) == -1) + return 0; +#else + /* + * We pretend to have a medium present initially, so != -1. + */ + isofd = -2; +#endif + + return 1; +} + +void +scsitest_attach(device_t parent, device_t self, void *aux) +{ + struct scsitest *sc = device_private(self); + + aprint_naive("\n"); + aprint_normal("\n"); + + memset(&sc->sc_adapter, 0, sizeof(sc->sc_adapter)); + sc->sc_adapter.adapt_nchannels = 1; + sc->sc_adapter.adapt_request = scsitest_request; + sc->sc_adapter.adapt_minphys = minphys; + sc->sc_adapter.adapt_dev = self; + sc->sc_adapter.adapt_max_periph = 1; + sc->sc_adapter.adapt_openings = 1; + + memset(&sc->sc_channel, 0, sizeof(sc->sc_channel)); + sc->sc_channel.chan_bustype = &scsi_bustype; + sc->sc_channel.chan_ntargets = 2; + sc->sc_channel.chan_nluns = 1; + sc->sc_channel.chan_id = 0; + sc->sc_channel.chan_flags = SCSIPI_CHAN_NOSETTLE; + sc->sc_channel.chan_adapter = &sc->sc_adapter; + + config_found_ia(self, "scsi", &sc->sc_channel, scsiprint); +} diff --git a/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest.h b/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest.h new file mode 100644 index 000000000000..ba9b84a3f598 --- /dev/null +++ b/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest.h @@ -0,0 +1,38 @@ +/* $NetBSD: scsitest.h,v 1.1 2014/04/25 00:24:39 pooka Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. 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 AUTHOR ``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 AUTHOR 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. + */ + +#ifndef _RUMP_SCSITEST_H_ +#define _RUMP_SCSITEST_H_ + +enum { + RUMP_SCSITEST_NOISYSYNC, + RUMP_SCSITEST_MAXERROR +}; + +extern unsigned rump_scsitest_err[RUMP_SCSITEST_MAXERROR]; + +#endif /* _RUMP_SCSITEST_H_ */ diff --git a/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest_component.c b/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest_component.c new file mode 100644 index 000000000000..db0e209ad322 --- /dev/null +++ b/contrib/netbsd-tests/dev/scsipi/libscsitest/scsitest_component.c @@ -0,0 +1,46 @@ +/* $NetBSD: scsitest_component.c,v 1.1 2014/04/24 21:46:44 pooka Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. 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 AUTHOR ``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 AUTHOR 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 +__KERNEL_RCSID(0, "$NetBSD: scsitest_component.c,v 1.1 2014/04/24 21:46:44 pooka Exp $"); + +#include +#include +#include +#include +#include + +#include "ioconf.c" + +#include "rump_private.h" + +RUMP_COMPONENT(RUMP_COMPONENT_DEV) +{ + + config_init_component(cfdriver_ioconf_scsitest, + cfattach_ioconf_scsitest, cfdata_ioconf_scsitest); +} diff --git a/contrib/netbsd-tests/dev/scsipi/t_cd.c b/contrib/netbsd-tests/dev/scsipi/t_cd.c new file mode 100644 index 000000000000..58e61a564ea0 --- /dev/null +++ b/contrib/netbsd-tests/dev/scsipi/t_cd.c @@ -0,0 +1,81 @@ +/* $NetBSD: t_cd.c,v 1.7 2014/04/25 00:24:39 pooka Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. 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 AUTHOR ``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 AUTHOR 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 +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "scsitest.h" + +#include "../../h_macros.h" + +ATF_TC(noisyeject); +ATF_TC_HEAD(noisyeject, tc) +{ + + atf_tc_set_md_var(tc, "descr", "test for CD eject noisyness " + "(PR kern/43785)"); +} + +ATF_TC_BODY(noisyeject, tc) +{ + static char fname[] = "/dev/rcd0_"; + int part, fd, arg = 0; + + RL(part = getrawpartition()); + fname[strlen(fname)-1] = 'a' + part; + rump_init(); + /* + * Rump CD emulation has been fixed, so no longer a problem. + * + atf_tc_expect_signal(SIGSEGV, "PR kern/47646: Broken test or " + "a real problem in rump or the driver"); + */ + RL(fd = rump_sys_open(fname, O_RDWR)); + RL(rump_sys_ioctl(fd, DIOCEJECT, &arg)); + + ATF_REQUIRE_EQ(rump_scsitest_err[RUMP_SCSITEST_NOISYSYNC], 0); + RL(rump_sys_close(fd)); + // atf_tc_expect_fail("PR kern/43785"); + ATF_REQUIRE_EQ(rump_scsitest_err[RUMP_SCSITEST_NOISYSYNC], 0); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, noisyeject); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/dev/sysmon/t_swsensor.sh b/contrib/netbsd-tests/dev/sysmon/t_swsensor.sh new file mode 100755 index 000000000000..5b54431fad85 --- /dev/null +++ b/contrib/netbsd-tests/dev/sysmon/t_swsensor.sh @@ -0,0 +1,398 @@ +# $NetBSD: t_swsensor.sh,v 1.7 2013/04/14 16:07:46 martin Exp $ + +get_sensor_info() { + rump.envstat -x | \ + sed -e "\;swsensor;,\;/array;p" -e "d" +} + +get_sensor_key() { + get_sensor_info | grep -A1 $1 | grep integer | sed -e 's;<[/a-z]*>;;g' +} + +get_powerd_event_count() { + grep "not running" powerd.log | wc -l +} + +get_rnd_bits_count() { + env RUMPHIJACK=blanket=/dev/random:/dev/urandom \ + RUMP_SERVER=unix://t_swsensor_socket \ + LD_PRELOAD=/usr/lib/librumphijack.so rndctl -l | \ + grep "swsensor-sensor" | \ + awk '{print $2}' +} + +check_powerd_event() { + event=$(grep "not running" powerd.log | \ + sed -e "$1p" -e "d" ) + event=${event##*//} + script=${event%% *} + event=${event#* } + device=${event%% *} + event=${event#* } + state=${event%% *} + sensor=${event#* } + sensor=${sensor% *} + + if [ "${script}" != "sensor_indicator" ] ; then + echo "Event uses wrong script: ${script}" + elif [ "${device}" != "swsensor" ] ; then + echo "Event uses wrong device: ${device}" + elif [ "${sensor}" != "sensor" ] ; then + echo "Event uses wrong sensor: ${sensor}" + elif [ "${state}" != "$2" ] ; then + echo "Event uses wrong state: ${state}" + fi +} + +# Start the rump server, then load the swsensor module with the +# requested properties + +start_rump() { + rump_allserver -l rumpvfs -l rumpdev -l rumpdev_sysmon ${RUMP_SERVER} + if [ $( get_sensor_info | wc -l ) -ne 0 ] ; then + rump.modunload swsensor + rump.modload -f $1 swsensor + else + rump.modload $1 swsensor + fi + return $? +} + +common_head() { + atf_set descr "$1" + atf_set timeout 60 + atf_set require.progs rump.powerd rump.envstat rump.modload \ + rump.halt rump.sysctl rump_server \ + sed grep awk \ + rndctl expr +} + +common_cleanup() { + rump.modunload swsensor + rump.halt +} + +create_envsys_conf_files() { + cat << ENV0 > env0.conf + swsensor { + refresh-timeout = 2s; + } +ENV0 + cat << ENV1 > env1.conf + swsensor { + sensor0 { critical-min = $(( $1 - $2 )); } + } +ENV1 + cat << ENV2 > env2.conf + swsensor { + sensor0 { critical-min = $1; } + } +ENV2 +} + +# Test body common to all sensors +# $1 sensor mode +# $2 initial sensor value +# $3 initial limit +# $4 amount to lower limit +# $5 difference from limit to trigger event +# $6 sensor flags, for FHAS_ENTROPY and FMONNOTSUPP + +common_body() { + # Start the rump-server process and load the module + modload_args="-i mode=$1 -i value=$2 -i limit=$3 ${6:+-i flags=$6}" + start_rump "$modload_args" + + # create configuration files for updates + create_envsys_conf_files $3 $4 + + if [ $? -ne 0 ] ; then + atf_skip "Cannot set-up rump environment" + fi + + # start powerd so we can detect sensor events + rump.powerd -n -d > powerd.log 2>&1 & + if [ -z "$(jobs)" ] ; then + skip_events=1 + echo "Skipping event sub-tests - powerd did not start" + else + skip_events=0 + expected_event=1 + fi + + # Step 0 - verify that sensor is registered + get_sensor_info | grep -q swsensor || + atf_fail "0: Device swsensor not registered" + + # Step 1 - update the refresh-timeout and verify + # (use $(( ... )) since the timeout is displayed in hex!) + rump.envstat -c env0.conf + if [ $(( $( get_sensor_key refresh-timeout ) )) -ne 2 ] ; then + atf_fail "1: Could not set refresh-timout to 2s" + fi + + # Step 2 - verify that we can read sensor's value + if [ $1 -ne 0 -a $( get_sensor_key cur-value ) -ne $2 ] ; then + atf_fail "2: Value not available" + fi + + # Step 3 - verify that changes in sensor value are seen + rump.sysctl -w hw.swsensor.cur_value=$(( $2 + 1 )) + if [ $( get_sensor_key cur-value ) -ne $(( $2 + 1 )) ] ; then + atf_fail "3: Value not updated" + fi + + # Step 4 - if sensor provides hw limit, make sure we can read it + if [ $1 -ne 0 ] ; then + if [ $( get_sensor_key critical-min ) -ne $3 ] ; then + atf_fail "4: Limit not set by device" + fi + fi + + # Step 5 - if sensor provides hw limit, make sure it works + if [ $1 -ne 0 -a ${skip_events} -eq 0 ] ; then + rump.sysctl -w hw.swsensor.cur_value=$(( $3 - $5 )) + sleep 5 + cnt=$(get_powerd_event_count) + if [ ${cnt} -lt ${expected_event} ] ; then + atf_fail "5: No event triggered" + elif [ ${cnt} -gt ${expected_event} ] ; then + atf_fail "5: Multiple events triggered" + fi + evt=$( check_powerd_event ${cnt} "critical-under") + if [ -n "${evt}" ] ; then + atf_fail "5: ${evt}" + fi + expected_event=$(( 1 + ${expected_event} )) + fi + + # Step 6 - verify that we return to normal state + if [ $1 -ne 0 -a ${skip_events} -eq 0 ] ; then + rump.sysctl -w hw.swsensor.cur_value=$(( $3 + $5 )) + sleep 5 + cnt=$(get_powerd_event_count) + if [ ${cnt} -lt ${expected_event} ] ; then + atf_fail "6: No event triggered" + elif [ ${cnt} -gt ${expected_event} ] ; then + atf_fail "6: Multiple events triggered" + fi + evt=$( check_powerd_event ${cnt} "normal") + if [ -n "${evt}" ] ; then + atf_fail "6: ${evt}" + fi + expected_event=$(( 1 + ${expected_event} )) + fi + + # Step 7 - verify that we can set our own limit + + # Steps 7 thru 12 are skipped if the sensor cannot be monitored + if [ $( expr \( 0$6 / 2048 \) % 2 ) -ne 1 ] ; then + rump.envstat -c env1.conf + if [ $( get_sensor_key critical-min ) -ne $(( $3 - $4 )) ] ; then + atf_fail "7: Limit not set by envstat -c" + fi + + # Step 8 - make sure user-set limit works + if [ ${skip_events} -eq 0 ] ; then + rump.sysctl -w hw.swsensor.cur_value=$(( $3 - $4 - $5 )) + sleep 5 + cnt=$(get_powerd_event_count) + if [ ${cnt} -lt ${expected_event} ] ; then + atf_fail "8: No event triggered" + elif [ ${cnt} -gt ${expected_event} ] ; then + atf_fail "8: Multiple events triggered" + fi + evt=$( check_powerd_event ${cnt} "critical-under") + if [ -n "${evt}" ] ; then + atf_fail "8: ${evt}" + fi + expected_event=$(( 1 + ${expected_event} )) + fi + + # Step 9 - verify that we return to normal state + if [ ${skip_events} -eq 0 ] ; then + rump.sysctl -w hw.swsensor.cur_value=$(( $3 - $4 + $5 )) + sleep 5 + cnt=$(get_powerd_event_count) + if [ ${cnt} -lt ${expected_event} ] ; then + atf_fail "9: No event triggered" + elif [ ${cnt} -gt ${expected_event} ] ; then + atf_fail "9: Multiple events triggered" + fi + evt=$( check_powerd_event ${cnt} "normal") + if [ -n "${evt}" ] ; then + atf_fail "9: ${evt}" + fi + expected_event=$(( 1 + ${expected_event} )) + fi + + # Step 10 - reset to defaults + rump.envstat -S + if [ $1 -eq 0 ] ; then + get_sensor_info | grep -q critical-min && + atf_fail "10: Failed to clear a limit with envstat -S" + else + if [ $( get_sensor_key critical-min ) -ne $3 ] ; then + atf_fail "10: Limit not reset to initial value" + fi + fi + + # Step 11 - see if more events occur + if [ ${skip_events} -eq 0 ] ; then + rump.envstat -c env0.conf + rump.sysctl -w hw.swsensor.cur_value=$(( $3 - $4 - $5 )) + sleep 5 + cnt=$(get_powerd_event_count) + if [ ${cnt} -ge ${expected_event} ] ; then + if [ $1 -ne 2 ] ; then + atf_fail "11b Event triggered after reset" + fi + evt=$( check_powerd_event ${cnt} "critical-under") + if [ -n "${evt}" ] ; then + atf_fail "11a: ${evt}" + fi + fi + fi + + # Step 12 - make sure we can set new limits once more + rump.envstat -c env2.conf + if [ $( get_sensor_key critical-min ) -ne $3 ] ; then + atf_fail "12a: Limit not reset to same value" + fi + rump.envstat -c env1.conf + if [ $( get_sensor_key critical-min ) -ne $(( $3 - $4 )) ] ; then + atf_fail "12b: Limit not reset to new value" + fi + fi + + # Step 13 - confirm registration (or lack thereof) with rndctl + rnd_bits=$( get_rnd_bits_count ) + if [ $( expr \( 0$6 / 8192 \) % 2 ) -eq 1 ] ; then + if [ -z "$rnd_bits" ] ; then + atf_fail "13a: Not registered with rndctl" + fi + else + if [ -n "$rnd_bits" ] ; then + atf_fail "13b: Wrongly registered with rndctl" + fi + fi + + # Steps 14 and 15 are only if sensor is providing entropy + if [ $( expr \( 0$6 / 8192 \) % 2 ) -ne 1 ] ; then + return + fi + + # Step 14 - make sure entropy collected when device is being polled + rump.envstat -c env0.conf + rump.sysctl -w hw.swsensor.cur_value=$3 + sleep 5 + rump.sysctl -w hw.swsensor.cur_value=$(( $3 + $4 )) + sleep 5 + new_rnd_bits=$( get_rnd_bits_count ) + if [ $new_rnd_bits -le $rnd_bits ] ; then + atf_expect_fail "PR kern/47661" + atf_fail "14a: entropy bits did not increase after polling" + fi + rnd_bits=$new_rnd_bits + sleep 5 + new_rnd_bits=$( get_rnd_bits_count ) + if [ $new_rnd_bits -gt $rnd_bits ] ; then + atf_expect_fail "PR kern/47661" + atf_fail "14b: entropy bits increased after poll with no value change" + fi + + # Step 15 - make sure entropy collected when device is interrogated + # + rump.envstat -c env0.conf + rump.sysctl -w hw.swsensor.cur_value=$3 + get_sensor_key cur-value + rnd_bits=$( get_rnd_bits_count ) + rump.sysctl -w hw.swsensor.cur_value=$(( $3 + $4 )) + get_sensor_key cur-value + new_rnd_bits=$( get_rnd_bits_count ) + if [ $new_rnd_bits -le $rnd_bits ] ; then + atf_expect_fail "PR kern/47661" + atf_fail "15a: entropy bits did not increase after interrogation" + fi + rnd_bits=$new_rnd_bits + get_sensor_key cur-value + new_rnd_bits=$( get_rnd_bits_count ) + if [ $new_rnd_bits -gt $rnd_bits ] ; then + atf_expect_fail "PR kern/47661" + atf_fail "15b: entropy bits increased after interrogation with no value change" + fi +} + +atf_test_case simple_sensor cleanup +simple_sensor_head() { + common_head "Test a simple sensor" +} + +simple_sensor_body() { + common_body 0 50 30 10 1 +} + +simple_sensor_cleanup() { + common_cleanup +} + +atf_test_case limit_sensor cleanup +limit_sensor_head() { + common_head "Test a sensor with internal limit" +} + +limit_sensor_body() { + common_body 1 45 25 8 2 +} + +limit_sensor_cleanup() { + common_cleanup +} + +atf_test_case alarm_sensor cleanup +alarm_sensor_head() { + common_head "Test a sensor with internal checking" +} + +alarm_sensor_body() { + common_body 2 40 20 6 3 +} + +alarm_sensor_cleanup() { + common_cleanup +} + +atf_test_case entropy_polled_sensor cleanup +entropy_polled_sensor_head() { + common_head "Test a simple sensor that provides entropy" +} + +entropy_polled_sensor_body() { + common_body 0 50 30 10 1 8192 +} + +entropy_polled_sensor_cleanup() { + common_cleanup +} + +atf_test_case entropy_interrupt_sensor cleanup +entropy_interrupt_sensor_head() { + common_head "Test a sensor that provides entropy without polling" +} + +entropy_interrupt_sensor_body() { + common_body 0 50 30 10 1 10240 +} + +entropy_interrupt_sensor_cleanup() { + common_cleanup +} + +atf_init_test_cases() { + RUMP_SERVER="unix://t_swsensor_socket" ; export RUMP_SERVER + atf_add_test_case simple_sensor + atf_add_test_case limit_sensor + atf_add_test_case alarm_sensor + atf_add_test_case entropy_polled_sensor + atf_add_test_case entropy_interrupt_sensor +} diff --git a/contrib/netbsd-tests/dev/sysmon/t_swwdog.c b/contrib/netbsd-tests/dev/sysmon/t_swwdog.c new file mode 100644 index 000000000000..19e3795f0b59 --- /dev/null +++ b/contrib/netbsd-tests/dev/sysmon/t_swwdog.c @@ -0,0 +1,192 @@ +/* $NetBSD: t_swwdog.c,v 1.5 2011/06/26 12:14:59 christos Exp $ */ + +/* + * Copyright (c) 2010 Antti Kantee. 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 AUTHOR ``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 AUTHOR 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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "../../h_macros.h" + +static volatile sig_atomic_t tcount; + +static void +sigcount(int sig) +{ + + assert(sig == SIGUSR1); + tcount++; +} + +/* + * Since we are testing for swwdog's ability to reboot/panic, we need + * to fork and monitor the exit status from the parent and report + * something sensible back to atf. + */ +static int +testbody(int max) +{ + char wname[WDOG_NAMESIZE]; + struct wdog_conf wc; + struct wdog_mode wm; + pid_t p1, p2; + int status; + int fd; + + signal(SIGUSR1, sigcount); + + switch ((p1 = fork())) { + case 0: + break; + case -1: + atf_tc_fail_errno("fork"); + break; + default: + p2 = wait(&status); + ATF_REQUIRE_EQ(p1, p2); + ATF_REQUIRE_EQ(tcount, max); + return status; + } + + rump_init(); + + fd = rump_sys_open("/dev/watchdog", O_RDWR); + if (fd == -1) + err(1, "open watchdog"); + + wc.wc_count = 1; + wc.wc_names = wname; + + if (rump_sys_ioctl(fd, WDOGIOC_GWDOGS, &wc) == -1) + err(1, "can't fetch watchdog names"); + + if (wc.wc_count) { + assert(wc.wc_count == 1); + + strlcpy(wm.wm_name, wc.wc_names, sizeof(wm.wm_name)); + wm.wm_mode = WDOG_MODE_ETICKLE; + wm.wm_period = 1; + if (rump_sys_ioctl(fd, WDOGIOC_SMODE, &wm) == -1) + atf_tc_fail_errno("failed to set tickle"); + + usleep(400000); + if (max == 1) + rump_sys_ioctl(fd, WDOGIOC_TICKLE); + else { + wm.wm_mode = WDOG_MODE_DISARMED; + rump_sys_ioctl(fd, WDOGIOC_SMODE, &wm); + } + kill(getppid(), SIGUSR1); + + sleep(2); + printf("staying alive\n"); + kill(getppid(), SIGUSR1); + _exit(2); + } + /* fail */ + _exit(1); +} + +ATF_TC(reboot); +ATF_TC_HEAD(reboot, tc) +{ + + atf_tc_set_md_var(tc, "descr", "check swwdog reboot capability"); +} + +ATF_TC_BODY(reboot, tc) +{ + extern bool rumpns_swwdog_reboot; + int status; + + /* XXX: should use sysctl */ + rumpns_swwdog_reboot = true; + status = testbody(1); + + ATF_REQUIRE(WIFEXITED(status)); + ATF_REQUIRE_EQ(WEXITSTATUS(status), 0); +} + +ATF_TC(panic); +ATF_TC_HEAD(panic, tc) +{ + + atf_tc_set_md_var(tc, "descr", "check swwdog panic capability"); +} + +ATF_TC_BODY(panic, tc) +{ + extern bool rumpns_swwdog_reboot; + int status; + + /* XXX: should use sysctl */ + rumpns_swwdog_reboot = false; + status = testbody(1); + + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE_EQ(WTERMSIG(status), SIGABRT); +} + +ATF_TC(disarm); +ATF_TC_HEAD(disarm, tc) +{ + + atf_tc_set_md_var(tc, "descr", "check swwdog disarm capability"); +} + +ATF_TC_BODY(disarm, tc) +{ + int status; + + status = testbody(2); + + ATF_REQUIRE(WIFEXITED(status)); + ATF_REQUIRE_EQ(WEXITSTATUS(status), 2); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, panic); + ATF_TP_ADD_TC(tp, reboot); + ATF_TP_ADD_TC(tp, disarm); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/fs/cd9660/pr_48787.image.bz2.uue b/contrib/netbsd-tests/fs/cd9660/pr_48787.image.bz2.uue new file mode 100644 index 000000000000..d8f7488f36d2 --- /dev/null +++ b/contrib/netbsd-tests/fs/cd9660/pr_48787.image.bz2.uue @@ -0,0 +1,103 @@ +begin 644 pr_48787.image.bz2 +M0EIH.3%!62936>D^3`0``+M_V?_7U17T!W_H/^_?8..V$"1DB`0``B$`0I-H +MP`+N-!HLI8)131H4](]3TC(VH`S4;4````T&@R&C0R:!*$1D(8B:C!,(Q-&3 +M-`!,``"&:`FC'&AH&C3(TT:9`8F"``&@-`:9`8$R`J1(A&A$R&391FA#TC0V +MHQ'J8@&T@VHT`QII&Z!"B5;S7YT+1"ZB8Y+5"M,5_J`!]Y:[$2%,%W`ZAA2@ +MVE)'DK^*?'3QU`DFQ4@22)(B[N3GZN?E<)`DDB.C)7\X71*B1K*2))(DD1HI +MU5$TUVF[4JP89^FHY$B*FEBC(RN$5"8O'XO]1++(._=;ZKXR%:QK3^W7/>RT +M8EODZ#MX53U8C0F]6O.G4J/9YNQA$B2))$<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0R$A"P8>:89+I+'"&$B")A'5G8B+ZJ14JXH:'.:@IH0&T(0($A+" +/#6J,VO\7="Thomas Schmitt (scdbackup@gmx.net)", +# ="Thomas Schmitt" and ="1999" +# an Open Source license approved by opensource.org +# + +mntpnt="" + +atf_test_case pr_kern_48787 cleanup +pr_kern_48787_head() { + atf_set "descr" "Verifies 32bit overflow isssues from PR kern/48787 are fixed" + atf_set "require.user" "root" + atf_set "require.progs" "rump_cd9660 bunzip2 stat" + atf_set "timeout" 6000 +} + +pr_kern_48787_body() { + avail=$( df -Pk . | awk '{if (NR==2) print $4}' ) + if [ $avail -lt 4500000 ]; then + atf_skip "not enough free disk space, have ${avail} Kbytes, need ~ 4500000 Kbytes" + fi + bunzip2 < $(atf_get_srcdir)/pr_48787.image.bz2 > pr_48787.image + mntpnt=$(pwd)/mnt + mkdir ${mntpnt} + rump_cd9660 -o norrip ./pr_48787.image ${mntpnt} + if [ ! -r ${mntpnt}/small_file ]; then + atf_fail "${mntpnt}/small_file does not exist" + fi + if [ ! -r ${mntpnt}/my/large_file ]; then + atf_fail "${mntpnt}/my/large_file does not exist" + fi + umount ${mntpnt} + rump_cd9660 ./pr_48787.image ${mntpnt} + if [ ! -r ${mntpnt}/small_file ]; then + atf_fail "${mntpnt}/small_file does not exist" + fi + if [ ! -r ${mntpnt}/my/large_file ]; then + atf_fail "${mntpnt}/my/large_file does not exist" + fi + echo "this assumes current cd9660 inode encoding - adapt on changes" + atf_check -o match:"^4329541966$" stat -f "%i" ${mntpnt}/small_file + atf_check -o match:"^4329545920$" stat -f "%i" ${mntpnt}/my/large_file + umount ${mntpnt} + touch "done" +} + +pr_kern_48787_cleanup() { + if [ ! -f done ]; then + if [ "x${mntpnt}" != "x" ]; then + umount -f ${mntpnt} || true + fi + fi +} + +atf_init_test_cases() { + atf_add_test_case pr_kern_48787 +} diff --git a/contrib/netbsd-tests/fs/common/fstest_ext2fs.c b/contrib/netbsd-tests/fs/common/fstest_ext2fs.c new file mode 100644 index 000000000000..85bb79f7ebd0 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_ext2fs.c @@ -0,0 +1,139 @@ +/* $NetBSD: fstest_ext2fs.c,v 1.2 2010/07/30 16:15:05 pooka Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * 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 +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct ext2fstestargs { + struct ufs_args ta_uargs; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; +}; + +int +ext2fs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct ext2fstestargs *args; + + size /= 512; + snprintf(cmd, 1024, "newfs_ext2fs -F -s %"PRId64" %s >/dev/null", + size, image); + res = system(cmd); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.ext2fs", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return res; +} + +int +ext2fs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct ext2fstestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) + return res; + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + free(args); + + return 0; +} + +int +ext2fs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct ext2fstestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_EXT2FS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +ext2fs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} diff --git a/contrib/netbsd-tests/fs/common/fstest_ffs.c b/contrib/netbsd-tests/fs/common/fstest_ffs.c new file mode 100644 index 000000000000..7ae4e8f5970c --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_ffs.c @@ -0,0 +1,156 @@ +/* $NetBSD: fstest_ffs.c,v 1.6 2012/08/05 02:03:05 riastradh Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * 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 +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct ffstestargs { + struct ufs_args ta_uargs; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; +}; + +int +ffs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, off_t size, + void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct ffstestargs *args; + struct sigaction act, oact; + + size /= 512; + snprintf(cmd, 1024, "newfs -F -s %"PRId64" %s >/dev/null", size, image); + memset(&act, 0, sizeof(act)); + act.sa_handler = SIG_DFL; + sigaction(SIGCHLD, &act, &oact); + res = system(cmd); + sigaction(SIGCHLD, &oact, NULL); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.ffs", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return 0; +} +__strong_alias(ffslog_fstest_newfs,ffs_fstest_newfs); + +int +ffs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct ffstestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) { + errno = res; + return -1; + } + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + free(args); + + return 0; +} +__strong_alias(ffslog_fstest_delfs,ffs_fstest_delfs); + +int +ffs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct ffstestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_FFS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +ffslog_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + + return ffs_fstest_mount(tc, buf, path, flags | MNT_LOG); +} + +int +ffs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} +__strong_alias(ffslog_fstest_unmount,ffs_fstest_unmount); diff --git a/contrib/netbsd-tests/fs/common/fstest_lfs.c b/contrib/netbsd-tests/fs/common/fstest_lfs.c new file mode 100644 index 000000000000..fd131cffe6b8 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_lfs.c @@ -0,0 +1,192 @@ +/* $NetBSD: fstest_lfs.c,v 1.4 2010/07/30 16:15:05 pooka Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * 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 +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" +#include "mount_lfs.h" + +sem_t lfs_clearnerloop; + +struct lfstestargs { + struct ufs_args ta_uargs; + pthread_t ta_cleanerthread; + sem_t ta_cleanerloop; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; + char ta_mntpath[MAXPATHLEN]; + char ta_hostpath[MAXPATHLEN]; +}; + +int +lfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, off_t size, + void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct lfstestargs *args; + + size /= 512; + snprintf(cmd, 1024, "newfs_lfs -D -F -s %"PRId64" ./%s >/dev/null", + size, image); + res = system(cmd); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + strcpy(args->ta_hostpath, image); + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.lfs", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + sem_init(&args->ta_cleanerloop, 0, 0); + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return 0; +} + +int +lfs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct lfstestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) + return res; + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + pthread_join(args->ta_cleanerthread, NULL); + free(args); + + return 0; +} + +static void * +cleaner(void *arg) +{ + char thepath[MAXPATHLEN]; + struct lfstestargs *args = arg; + const char *the_argv[7]; + char buf[64]; + + /* this inspired by the cleaner code. fixme */ + sprintf(thepath, "/dev/r%s", args->ta_devpath+5); + rump_pub_etfs_register(thepath, args->ta_hostpath, RUMP_ETFS_CHR); + sprintf(buf, "%p", &args->ta_cleanerloop); + + the_argv[0] = "megamaid"; + the_argv[1] = "-D"; /* don't fork() & detach */ + the_argv[2] = "-S"; + the_argv[3] = buf; + the_argv[4] = args->ta_mntpath; + the_argv[5] = NULL; + + /* xxxatf */ + optind = 1; + opterr = 1; + + lfs_cleaner_main(5, __UNCONST(the_argv)); + + return NULL; +} + +int +lfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + struct lfstestargs *args = buf; + int res; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_LFS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + if (res == -1) + return res; + + strcpy(args->ta_mntpath, path); + res = pthread_create(&args->ta_cleanerthread, NULL, cleaner, args); + if (res) + return res; + + /* wait for cleaner to initialize */ + sem_wait(&args->ta_cleanerloop); + + return 0; +} + +int +lfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) { + return res; + } + + res = rump_sys_rmdir(path); + return res; +} diff --git a/contrib/netbsd-tests/fs/common/fstest_msdosfs.c b/contrib/netbsd-tests/fs/common/fstest_msdosfs.c new file mode 100644 index 000000000000..2c94e3f92fa8 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_msdosfs.c @@ -0,0 +1,140 @@ +/* $NetBSD: fstest_msdosfs.c,v 1.3 2012/03/26 15:10:26 njoly Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * 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 +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct msdosfstestargs { + struct msdosfs_args ta_uargs; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; +}; + +int +msdosfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct msdosfstestargs *args; + + size /= 512; size -= (size % 63); + snprintf(cmd, 1024, "newfs_msdos -C %"PRId64"s %s >/dev/null", + size, image); + res = system(cmd); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.msdosfs", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + args->ta_uargs.mask = 0755; + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return 0; +} + +int +msdosfs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct msdosfstestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) + return res; + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + free(args); + + return 0; +} + +int +msdosfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct msdosfstestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_MSDOS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +msdosfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} diff --git a/contrib/netbsd-tests/fs/common/fstest_nfs.c b/contrib/netbsd-tests/fs/common/fstest_nfs.c new file mode 100644 index 000000000000..5ef256f1be41 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_nfs.c @@ -0,0 +1,326 @@ +/* $NetBSD: fstest_nfs.c,v 1.9 2011/02/28 21:08:46 pooka Exp $ */ + +/* + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * + * 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 AUTHOR ``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 AUTHOR 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 +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "h_fsmacros.h" +#include "mount_nfs.h" +#include "../../net/config/netconfig.c" + +#define SERVERADDR "10.3.2.1" +#define SERVERROADDR "10.4.2.1" +#define CLIENTADDR "10.3.2.2" +#define CLIENTROADDR "10.4.2.2" +#define NETNETMASK "255.255.255.0" +#define EXPORTPATH "/myexport" + +static void +childfail(int status) +{ + + atf_tc_fail("child died"); +} + +/* fork rump nfsd, configure interface */ +static int +donewfs(const atf_tc_t *tc, void **argp, + const char *image, off_t size, void *fspriv) +{ + const char *srcdir; + char *nfsdargv[16]; + char nfsdpath[MAXPATHLEN]; + char imagepath[MAXPATHLEN]; + char ethername[MAXPATHLEN], ethername_ro[MAXPATHLEN]; + char ifname[IFNAMSIZ], ifname_ro[IFNAMSIZ]; + char cwd[MAXPATHLEN]; + struct nfstestargs *args; + pid_t childpid; + int pipes[2]; + int devnull; + + /* + * First, we start the nfs service. + */ + srcdir = atf_tc_get_config_var(tc, "srcdir"); + sprintf(nfsdpath, "%s/../nfs/nfsservice/rumpnfsd", srcdir); + sprintf(ethername, "/%s/%s.etherbus", getcwd(cwd, sizeof(cwd)), image); + sprintf(ethername_ro, "%s_ro", ethername); + sprintf(imagepath, "/%s/%s", cwd, image); + + nfsdargv[0] = nfsdpath; + nfsdargv[1] = ethername; + nfsdargv[2] = ethername_ro; + nfsdargv[3] = __UNCONST(SERVERADDR); + nfsdargv[4] = __UNCONST(SERVERROADDR); + nfsdargv[5] = __UNCONST(NETNETMASK); + nfsdargv[6] = __UNCONST(EXPORTPATH); + nfsdargv[7] = imagepath; + nfsdargv[8] = NULL; + + signal(SIGCHLD, childfail); + if (pipe(pipes) == -1) + return errno; + + switch ((childpid = fork())) { + case 0: + if (chdir(dirname(nfsdpath)) == -1) + err(1, "chdir"); + close(pipes[0]); + if (dup2(pipes[1], 3) == -1) + err(1, "dup2"); + if (execvp(nfsdargv[0], nfsdargv) == -1) + err(1, "execvp"); + case -1: + return errno; + default: + close(pipes[1]); + break; + } + + /* + * Ok, nfsd has been run. The following sleep helps with the + * theoretical problem that nfsd can't start fast enough to + * process our mount request and we end up doing a timeout + * before the mount. This would take several seconds. So + * try to make sure nfsd is up&running already at this stage. + */ + if (read(pipes[0], &devnull, 4) == -1) + return errno; + + /* + * Configure our networking interface. + */ + rump_init(); + netcfg_rump_makeshmif(ethername, ifname); + netcfg_rump_if(ifname, CLIENTADDR, NETNETMASK); + netcfg_rump_makeshmif(ethername_ro, ifname_ro); + netcfg_rump_if(ifname_ro, CLIENTROADDR, NETNETMASK); + + /* + * That's it. The rest is done in mount, since we don't have + * the mountpath available here. + */ + args = malloc(sizeof(*args)); + if (args == NULL) + return errno; + memset(args, 0, sizeof(*args)); + args->ta_childpid = childpid; + strcpy(args->ta_ethername, ethername); + + *argp = args; + + return 0; +} + +int +nfs_fstest_newfs(const atf_tc_t *tc, void **argp, + const char *image, off_t size, void *fspriv) +{ + + return donewfs(tc, argp, image, size, fspriv); +} + +int +nfsro_fstest_newfs(const atf_tc_t *tc, void **argp, + const char *image, off_t size, void *fspriv) +{ + + return donewfs(tc, argp, image, size, fspriv); +} + +/* mount the file system */ +static int +domount(const atf_tc_t *tc, void *arg, const char *serverpath, + const char *path, int flags) +{ + char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN]; + const char *nfscliargs[] = { + "nfsclient", + serverpath, + path, + NULL, + }; + struct nfs_args args; + int mntflags; + + if (rump_sys_mkdir(path, 0777) == -1) + return errno; + + /* XXX: atf does not reset values */ + optind = 1; + opterr = 1; + + /* + * We use nfs parseargs here, since as a side effect it + * takes care of the RPC hulabaloo. + */ + mount_nfs_parseargs(__arraycount(nfscliargs)-1, __UNCONST(nfscliargs), + &args, &mntflags, canon_dev, canon_dir); + + if (rump_sys_mount(MOUNT_NFS, path, flags, &args, sizeof(args)) == -1) { + return errno; + } + + return 0; +} + +int +nfs_fstest_mount(const atf_tc_t *tc, void *arg, const char *path, int flags) +{ + + return domount(tc, arg, SERVERADDR ":" EXPORTPATH, path, flags); +} + +/* + * This is where the magic happens! + * + * If we are mounting r/w, do the normal thing. However, if we are + * doing a r/o mount, switch use the r/o server export address + * and do a r/w mount. This way we end up testing the r/o export policy + * of the server! (yes, slightly questionable semantics, but at least + * we notice very quickly if our assumption is broken in the future ;) + */ +int +nfsro_fstest_mount(const atf_tc_t *tc, void *arg, const char *path, int flags) +{ + + if (flags & MNT_RDONLY) { + flags &= ~MNT_RDONLY; + return domount(tc, arg, SERVERROADDR":"EXPORTPATH, path, flags); + } else { + return domount(tc, arg, SERVERADDR":"EXPORTPATH, path, flags); + } +} + +static int +dodelfs(const atf_tc_t *tc, void *arg) +{ + + /* + * XXX: no access to "args" since we're called from "cleanup". + * Trust atf to kill nfsd process and remove etherfile. + */ +#if 0 + /* + * It's highly expected that the child will die next, so we + * don't need that information anymore thank you very many. + */ + signal(SIGCHLD, SIG_IGN); + + /* + * Just KILL it. Sending it SIGTERM first causes it to try + * to send some unmount RPCs, leading to sticky situations. + */ + kill(args->ta_childpid, SIGKILL); + wait(&status); + + /* remove ethernet bus */ + if (unlink(args->ta_ethername) == -1) + atf_tc_fail_errno("unlink ethername"); +#endif + + return 0; +} + +int +nfs_fstest_delfs(const atf_tc_t *tc, void *arg) +{ + + return dodelfs(tc, arg); +} + +int +nfsro_fstest_delfs(const atf_tc_t *tc, void *arg) +{ + + return dodelfs(tc, arg); +} + +static int +dounmount(const atf_tc_t *tc, const char *path, int flags) +{ + int status, i, sverrno; + + /* + * NFS handles sillyrenames in an workqueue. Some of them might + * be still in the queue even if all user activity has ceased. + * We try to unmount for 2 seconds to give them a chance + * to flush out. + * + * PR kern/43799 + */ + for (i = 0; i < 20; i++) { + if ((status = rump_sys_unmount(path, flags)) == 0) + break; + sverrno = errno; + if (sverrno != EBUSY) + break; + usleep(100000); + } + if (status == -1) + return sverrno; + + if (rump_sys_rmdir(path) == -1) + return errno; + + return 0; +} + +int +nfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + + return dounmount(tc, path, flags); +} + +int +nfsro_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + + return dounmount(tc, path, flags); +} diff --git a/contrib/netbsd-tests/fs/common/fstest_puffs.c b/contrib/netbsd-tests/fs/common/fstest_puffs.c new file mode 100644 index 000000000000..14e4bfba43ba --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_puffs.c @@ -0,0 +1,452 @@ +/* $NetBSD: fstest_puffs.c,v 1.11 2013/09/09 19:47:38 pooka Exp $ */ + +/* + * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. + * + * 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 AUTHOR ``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 AUTHOR 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 +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "h_fsmacros.h" + +#define BUFSIZE (128*1024) +#define DTFS_DUMP "-o","dump" + +static bool mayquit = false; + +static ssize_t +xread(int fd, void *vp, size_t n) +{ + size_t left; + + left = n; + do { + ssize_t ssz; + + ssz = read(fd, vp, left); + if (ssz == -1) { + return ssz; + } + left -= ssz; + vp = (char *)vp + ssz; + } while (left > 0); + return n; +} + +static ssize_t +xwrite(int fd, const void *vp, size_t n) +{ + size_t left; + + left = n; + do { + ssize_t ssz; + + ssz = write(fd, vp, left); + if (ssz == -1) { + return ssz; + } + left -= ssz; + vp = (const char *)vp + ssz; + } while (left > 0); + return n; +} + +/* + * Threads which shovel data between comfd and /dev/puffs. + * (cannot use polling since fd's are in different namespaces) + */ +static void * +readshovel(void *arg) +{ + struct putter_hdr *phdr; + struct puffs_req *preq; + struct puffstestargs *args = arg; + char buf[BUFSIZE]; + ssize_t n; + int comfd, puffsfd; + + comfd = args->pta_servfd; + puffsfd = args->pta_rumpfd; + + phdr = (void *)buf; + preq = (void *)buf; + + rump_pub_lwproc_newlwp(1); + + for (;;) { + n = rump_sys_read(puffsfd, buf, sizeof(*phdr)); + if (n <= 0) { + fprintf(stderr, "readshovel r1 %zd / %d\n", n, errno); + break; + } + + assert(phdr->pth_framelen < BUFSIZE); + n = rump_sys_read(puffsfd, buf+sizeof(*phdr), + phdr->pth_framelen - sizeof(*phdr)); + if (n <= 0) { + fprintf(stderr, "readshovel r2 %zd / %d\n", n, errno); + break; + } + + /* Analyze request */ + if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS) { + assert(preq->preq_optype < PUFFS_VFS_MAX); + args->pta_vfs_toserv_ops[preq->preq_optype]++; + } else if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN) { + assert(preq->preq_optype < PUFFS_VN_MAX); + args->pta_vn_toserv_ops[preq->preq_optype]++; + } + + n = phdr->pth_framelen; + if (xwrite(comfd, buf, n) != n) { + fprintf(stderr, "readshovel write %zd / %d\n", n, errno); + break; + } + } + + if (n != 0 && mayquit == false) + abort(); + return NULL; +} + +static void * +writeshovel(void *arg) +{ + struct puffstestargs *args = arg; + struct putter_hdr *phdr; + struct puffs_req *preq; + char buf[BUFSIZE]; + size_t toread; + ssize_t n; + int comfd, puffsfd; + + rump_pub_lwproc_newlwp(1); + + comfd = args->pta_servfd; + puffsfd = args->pta_rumpfd; + + phdr = (struct putter_hdr *)buf; + preq = (void *)buf; + + for (;;) { + uint64_t off; + + /* + * Need to write everything to the "kernel" in one chunk, + * so make sure we have it here. + */ + off = 0; + toread = sizeof(struct putter_hdr); + assert(toread < BUFSIZE); + do { + n = xread(comfd, buf+off, toread); + if (n <= 0) { + fprintf(stderr, "writeshovel read %zd / %d\n", + n, errno); + goto out; + } + off += n; + if (off >= sizeof(struct putter_hdr)) + toread = phdr->pth_framelen - off; + else + toread = off - sizeof(struct putter_hdr); + } while (toread); + + if (__predict_false( + PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS + && preq->preq_optype == PUFFS_VFS_UNMOUNT)) { + if (preq->preq_rv == 0) + mayquit = true; + } + + n = rump_sys_write(puffsfd, buf, phdr->pth_framelen); + if ((size_t)n != phdr->pth_framelen) { + fprintf(stderr, "writeshovel wr %zd / %d\n", n, errno); + break; + } + } + + out: + if (n != 0) + abort(); + return NULL; +} + +static void +rumpshovels(struct puffstestargs *args) +{ + pthread_t pt; + int rv; + + if ((rv = rump_init()) == -1) + err(1, "rump_init"); + + if (pthread_create(&pt, NULL, readshovel, args) == -1) + err(1, "read shovel"); + pthread_detach(pt); + + if (pthread_create(&pt, NULL, writeshovel, args) == -1) + err(1, "write shovel"); + pthread_detach(pt); +} + +static void +childfail(int sign) +{ + + atf_tc_fail("child died"); /* almost signal-safe */ +} + +struct puffstestargs *theargs; /* XXX */ + +/* XXX: we don't support size */ +static int +donewfs(const atf_tc_t *tc, void **argp, + const char *image, off_t size, void *fspriv, char **theargv) +{ + struct puffstestargs *args; + pid_t childpid; + int *pflags; + char comfd[16]; + int sv[2]; + int mntflags; + size_t len; + ssize_t n; + + *argp = NULL; + + args = malloc(sizeof(*args)); + if (args == NULL) + return errno; + memset(args, 0, sizeof(*args)); + + pflags = &args->pta_pflags; + + /* Create sucketpair for communication with the real file server */ + if (socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) == -1) + return errno; + + signal(SIGCHLD, childfail); + + switch ((childpid = fork())) { + case 0: + close(sv[1]); + snprintf(comfd, sizeof(sv[0]), "%d", sv[0]); + if (setenv("PUFFS_COMFD", comfd, 1) == -1) + return errno; + + if (execvp(theargv[0], theargv) == -1) + return errno; + case -1: + return errno; + default: + close(sv[0]); + break; + } + + /* read args */ + if ((n = xread(sv[1], &len, sizeof(len))) != sizeof(len)) + err(1, "mp 1 %zd", n); + if (len > MAXPATHLEN) + err(1, "mntpath > MAXPATHLEN"); + if ((size_t)xread(sv[1], args->pta_dir, len) != len) + err(1, "mp 2"); + if (xread(sv[1], &len, sizeof(len)) != sizeof(len)) + err(1, "fn 1"); + if (len > MAXPATHLEN) + err(1, "devpath > MAXPATHLEN"); + if ((size_t)xread(sv[1], args->pta_dev, len) != len) + err(1, "fn 2"); + if (xread(sv[1], &mntflags, sizeof(mntflags)) != sizeof(mntflags)) + err(1, "mntflags"); + if (xread(sv[1], &args->pta_pargslen, sizeof(args->pta_pargslen)) + != sizeof(args->pta_pargslen)) + err(1, "puffstest_args len"); + args->pta_pargs = malloc(args->pta_pargslen); + if (args->pta_pargs == NULL) + err(1, "malloc"); + if (xread(sv[1], args->pta_pargs, args->pta_pargslen) + != (ssize_t)args->pta_pargslen) + err(1, "puffstest_args"); + if (xread(sv[1], pflags, sizeof(*pflags)) != sizeof(*pflags)) + err(1, "pflags"); + + args->pta_childpid = childpid; + args->pta_servfd = sv[1]; + strlcpy(args->pta_dev, image, sizeof(args->pta_dev)); + + *argp = theargs = args; + + return 0; +} + +int +puffs_fstest_newfs(const atf_tc_t *tc, void **argp, + const char *image, off_t size, void *fspriv) +{ + char dtfs_path[MAXPATHLEN]; + char *dtfsargv[6]; + char **theargv; + + /* build dtfs exec path from atf test dir */ + sprintf(dtfs_path, "%s/../puffs/h_dtfs/h_dtfs", + atf_tc_get_config_var(tc, "srcdir")); + + if (fspriv) { + theargv = fspriv; + theargv[0] = dtfs_path; + } else { + dtfsargv[0] = dtfs_path; + dtfsargv[1] = __UNCONST("-i"); + dtfsargv[2] = __UNCONST("-s"); + dtfsargv[3] = __UNCONST("dtfs"); + dtfsargv[4] = __UNCONST("fictional"); + dtfsargv[5] = NULL; + + theargv = dtfsargv; + } + + return donewfs(tc, argp, image, size, fspriv, theargv); +} + +int +p2k_ffs_fstest_newfs(const atf_tc_t *tc, void **argp, + const char *image, off_t size, void *fspriv) +{ + char *rumpffs_argv[5]; + int rv; + + rump_init(); + if ((rv = ffs_fstest_newfs(tc, argp, image, size, fspriv)) != 0) + return rv; + if (mkdir("p2kffsfake", 0777) == -1 && errno != EEXIST) + return errno; + + setenv("P2K_NODETACH", "1", 1); + rumpffs_argv[0] = __UNCONST("rump_ffs"); + rumpffs_argv[1] = __UNCONST(image); + rumpffs_argv[2] = __UNCONST("p2kffsfake"); /* NOTUSED */ + rumpffs_argv[3] = NULL; + + if ((rv = donewfs(tc, argp, image, size, fspriv, rumpffs_argv)) != 0) + ffs_fstest_delfs(tc, argp); + return rv; +} + +int +puffs_fstest_mount(const atf_tc_t *tc, void *arg, const char *path, int flags) +{ + struct puffstestargs *pargs = arg; + int fd; + + rump_init(); + fd = rump_sys_open("/dev/puffs", O_RDWR); + if (fd == -1) + return fd; + + if (rump_sys_mkdir(path, 0777) == -1) + return -1; + + if (rump_sys_mount(MOUNT_PUFFS, path, flags, + pargs->pta_pargs, pargs->pta_pargslen) == -1) { + /* apply "to kill a child" to avoid atf hang (kludge) */ + kill(pargs->pta_childpid, SIGKILL); + return -1; + } + + pargs->pta_rumpfd = fd; + rumpshovels(pargs); + + return 0; +} +__strong_alias(p2k_ffs_fstest_mount,puffs_fstest_mount); + +int +puffs_fstest_delfs(const atf_tc_t *tc, void *arg) +{ + + /* useless ... */ + return 0; +} + +int +p2k_ffs_fstest_delfs(const atf_tc_t *tc, void *arg) +{ + + return ffs_fstest_delfs(tc, arg); +} + +int +puffs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + struct puffstestargs *pargs = theargs; + int status; + int rv; + + /* ok, child might exit here */ + signal(SIGCHLD, SIG_IGN); + + rv = rump_sys_unmount(path, flags); + if (rv) + return rv; + + if ((rv = rump_sys_rmdir(path)) != 0) + return rv; + + if (waitpid(pargs->pta_childpid, &status, WNOHANG) > 0) + return 0; + kill(pargs->pta_childpid, SIGTERM); + usleep(10); + if (waitpid(pargs->pta_childpid, &status, WNOHANG) > 0) + return 0; + kill(pargs->pta_childpid, SIGKILL); + usleep(500); + wait(&status); + + rmdir("p2kffsfake"); + + return 0; +} +__strong_alias(p2k_ffs_fstest_unmount,puffs_fstest_unmount); diff --git a/contrib/netbsd-tests/fs/common/fstest_rumpfs.c b/contrib/netbsd-tests/fs/common/fstest_rumpfs.c new file mode 100644 index 000000000000..e4003db3d026 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_rumpfs.c @@ -0,0 +1,90 @@ +/* $NetBSD: fstest_rumpfs.c,v 1.2 2014/03/16 10:28:03 njoly Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * 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 +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "h_fsmacros.h" + +int +rumpfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + char tmp[64]; + int res; + + snprintf(tmp, sizeof(tmp), "%"PRId64, size); + res = setenv("RUMP_MEMLIMIT", tmp, 0); + if (res == -1) + return res; + + return rump_init(); +} + +int +rumpfs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + + return 0; +} + +int +rumpfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + return rump_sys_mount(MOUNT_RUMPFS, path, flags, NULL, 0); +} + +int +rumpfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + return rump_sys_rmdir(path); +} diff --git a/contrib/netbsd-tests/fs/common/fstest_sysvbfs.c b/contrib/netbsd-tests/fs/common/fstest_sysvbfs.c new file mode 100644 index 000000000000..a7cf7f4cd8e1 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_sysvbfs.c @@ -0,0 +1,139 @@ +/* $NetBSD: fstest_sysvbfs.c,v 1.2 2010/07/30 16:15:05 pooka Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * 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 +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct sysvbfstestargs { + struct ufs_args ta_uargs; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; +}; + +int +sysvbfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct sysvbfstestargs *args; + + size /= 512; + snprintf(cmd, 1024, "newfs_sysvbfs -F -s %"PRId64" %s >/dev/null", + size, image); + res = system(cmd); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.sysvbfs", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return 0; +} + +int +sysvbfs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct sysvbfstestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) + return res; + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + free(args); + + return 0; +} + +int +sysvbfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct sysvbfstestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_SYSVBFS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +sysvbfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} diff --git a/contrib/netbsd-tests/fs/common/fstest_tmpfs.c b/contrib/netbsd-tests/fs/common/fstest_tmpfs.c new file mode 100644 index 000000000000..83848432e21f --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_tmpfs.c @@ -0,0 +1,112 @@ +/* $NetBSD: fstest_tmpfs.c,v 1.2 2010/07/30 16:15:05 pooka Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * 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 +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct tmpfstestargs { + struct tmpfs_args ta_uargs; +}; + +int +tmpfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + int res; + struct tmpfstestargs *args; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + args->ta_uargs.ta_version = TMPFS_ARGS_VERSION; + args->ta_uargs.ta_root_mode = 0777; + args->ta_uargs.ta_size_max = size; + + *buf = args; + + return 0; +} + +int +tmpfs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + struct tmpfstestargs *args = buf; + + free(args); + + return 0; +} + +int +tmpfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct tmpfstestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_TMPFS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +tmpfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} diff --git a/contrib/netbsd-tests/fs/common/fstest_udf.c b/contrib/netbsd-tests/fs/common/fstest_udf.c new file mode 100644 index 000000000000..3c9e017f388f --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_udf.c @@ -0,0 +1,153 @@ +/* $NetBSD: fstest_udf.c,v 1.4 2013/07/02 15:00:55 reinoud Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * 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 +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct udftestargs { + struct udf_args ta_uargs; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; +}; + +int +udf_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, off_t size, + void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct udftestargs *args; + struct sigaction act, oact; + + /* + * Sectorsize can be specified with -S, as a multiple of 512. + * newfs_udf takes humanized number as size in bytes as -s parameter! + */ + snprintf(cmd, 1024, "newfs_udf -F -s %"PRId64" %s >/dev/null", size, image); + memset(&act, 0, sizeof(act)); + act.sa_handler = SIG_DFL; + sigaction(SIGCHLD, &act, &oact); + res = system(cmd); + sigaction(SIGCHLD, &oact, NULL); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.udf", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + args->ta_uargs.version = UDFMNT_VERSION; + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return 0; +} +__strong_alias(udflog_fstest_newfs,udf_fstest_newfs); + +int +udf_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct udftestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) { + errno = res; + return -1; + } + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + free(args); + + return 0; +} +__strong_alias(udflog_fstest_delfs,udf_fstest_delfs); + +int +udf_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct udftestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_UDF, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +udf_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} +__strong_alias(udflog_fstest_unmount,udf_fstest_unmount); diff --git a/contrib/netbsd-tests/fs/common/fstest_v7fs.c b/contrib/netbsd-tests/fs/common/fstest_v7fs.c new file mode 100644 index 000000000000..92110e430e83 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_v7fs.c @@ -0,0 +1,140 @@ +/* $NetBSD: fstest_v7fs.c,v 1.1 2011/08/11 10:52:12 uch Exp $ */ + +/*- + * Copyright (c) 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * 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 +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "h_fsmacros.h" + +struct v7fstestargs { + struct v7fs_args ta_uargs; + char ta_devpath[MAXPATHLEN]; + char ta_imgpath[MAXPATHLEN]; +}; + +int +v7fs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + char cmd[1024]; + int res; + static unsigned int num = 0; + struct v7fstestargs *args; + + size /= 512; + snprintf(cmd, 1024, "newfs_v7fs -F -s %"PRId64" %s >/dev/null", + size, image); + res = system(cmd); + if (res != 0) + return res; + + res = rump_init(); + if (res != 0) + return res; + + args = calloc(1, sizeof(*args)); + if (args == NULL) + return -1; + + snprintf(args->ta_devpath, MAXPATHLEN, "/dev/device%d.v7fs", num); + snprintf(args->ta_imgpath, MAXPATHLEN, "%s", image); + args->ta_uargs.fspec = args->ta_devpath; + args->ta_uargs.endian = _BYTE_ORDER; + + res = rump_pub_etfs_register(args->ta_devpath, image, RUMP_ETFS_BLK); + if (res != 0) { + free(args); + return res; + } + + *buf = args; + num++; + + return 0; +} + +int +v7fs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + int res; + struct v7fstestargs *args = buf; + + res = rump_pub_etfs_remove(args->ta_devpath); + if (res != 0) + return res; + + res = unlink(args->ta_imgpath); + if (res != 0) + return res; + + free(args); + + return 0; +} + +int +v7fs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + int res; + struct v7fstestargs *args = buf; + + res = rump_sys_mkdir(path, 0777); + if (res == -1) + return res; + + res = rump_sys_mount(MOUNT_V7FS, path, flags, &args->ta_uargs, + sizeof(args->ta_uargs)); + return res; +} + +int +v7fs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + int res; + + res = rump_sys_unmount(path, flags); + if (res == -1) + return res; + + res = rump_sys_rmdir(path); + return res; +} diff --git a/contrib/netbsd-tests/fs/common/fstest_zfs.c b/contrib/netbsd-tests/fs/common/fstest_zfs.c new file mode 100644 index 000000000000..88aa05f28ff7 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/fstest_zfs.c @@ -0,0 +1,134 @@ +/* $NetBSD: fstest_zfs.c,v 1.1 2012/08/20 16:37:35 pooka Exp $ */ + +/*- + * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * 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 +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "h_fsmacros.h" + +#define SRVPATH "zfssurvo" +#define SRVURL "unix://" SRVPATH +#define ZFSDEV "/zfsdev" + +int +zfs_fstest_newfs(const atf_tc_t *tc, void **buf, const char *image, + off_t size, void *fspriv) +{ + int res; + int fd; + + /* XXX: hardcoded zfs minimum size */ + size = MAX(64*1024*1024, size); + + res = rump_init(); + if (res != 0) { + errno = res; + return -1; + } + + /* create backing image, sparse file is enough */ + if ((fd = open(image, O_RDWR | O_CREAT, 0777)) == -1) + return -1; + if (ftruncate(fd, size) == -1) { + close(fd); + return -1; + } + close(fd); + + res = rump_pub_etfs_register(ZFSDEV, image, RUMP_ETFS_BLK); + if (res != 0) { + errno = res; + return -1; + } + + res = rump_init_server(SRVURL); + if (res != 0) { + errno = res; + return -1; + } + *buf = NULL; + + return 0; +} + +int +zfs_fstest_delfs(const atf_tc_t *tc, void *buf) +{ + + unlink(SRVPATH); + return 0; +} + +int +zfs_fstest_mount(const atf_tc_t *tc, void *buf, const char *path, int flags) +{ + char tmpbuf[128]; + int error; + + /* set up the hijack env for running zpool */ + setenv("RUMP_SERVER", SRVURL, 1); + snprintf(tmpbuf, sizeof(tmpbuf)-1, "blanket=/dev/zfs:%s:%s", + ZFSDEV, path); + setenv("RUMPHIJACK", tmpbuf, 1); + setenv("LD_PRELOAD", "/usr/lib/librumphijack.so", 1); + + while (*path == '/') + path++; + + /* run zpool create */ + snprintf(tmpbuf, sizeof(tmpbuf)-1, "zpool create %s %s", + path, ZFSDEV); + if ((error = system(tmpbuf)) != 0) { + errno = error; + return -1; + } + + return 0; +} + +int +zfs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags) +{ + + unmount(path, flags); + unlink(SRVPATH); + + return 0; +} diff --git a/contrib/netbsd-tests/fs/common/h_fsmacros.h b/contrib/netbsd-tests/fs/common/h_fsmacros.h new file mode 100644 index 000000000000..b47a70802bba --- /dev/null +++ b/contrib/netbsd-tests/fs/common/h_fsmacros.h @@ -0,0 +1,337 @@ +/* $NetBSD: h_fsmacros.h,v 1.38 2013/06/26 19:29:24 reinoud Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nicolas Joly. + * + * 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. + */ + +#ifndef __H_FSMACROS_H_ +#define __H_FSMACROS_H_ + +#include + +#include +#include +#include + +#include + +#include "../../h_macros.h" + +#define FSPROTOS(_fs_) \ +int _fs_##_fstest_newfs(const atf_tc_t *, void **, const char *, \ + off_t, void *); \ +int _fs_##_fstest_delfs(const atf_tc_t *, void *); \ +int _fs_##_fstest_mount(const atf_tc_t *, void *, const char *, int); \ +int _fs_##_fstest_unmount(const atf_tc_t *, const char *, int); + +FSPROTOS(ext2fs); +FSPROTOS(ffs); +FSPROTOS(ffslog); +FSPROTOS(lfs); +FSPROTOS(msdosfs); +FSPROTOS(nfs); +FSPROTOS(nfsro); +FSPROTOS(p2k_ffs); +FSPROTOS(puffs); +FSPROTOS(rumpfs); +FSPROTOS(sysvbfs); +FSPROTOS(tmpfs); +FSPROTOS(udf); +FSPROTOS(v7fs); +FSPROTOS(zfs); + +#ifndef FSTEST_IMGNAME +#define FSTEST_IMGNAME "image.fs" +#endif +#ifndef FSTEST_IMGSIZE +#define FSTEST_IMGSIZE (10000 * 512) +#endif +#ifndef FSTEST_MNTNAME +#define FSTEST_MNTNAME "/mnt" +#endif + +#define FSTEST_CONSTRUCTOR(_tc_, _fs_, _args_) \ +do { \ + if (_fs_##_fstest_newfs(_tc_, &_args_, \ + FSTEST_IMGNAME, FSTEST_IMGSIZE, NULL) != 0) \ + atf_tc_fail_errno("newfs failed"); \ + if (_fs_##_fstest_mount(_tc_, _args_, FSTEST_MNTNAME, 0) != 0) \ + atf_tc_fail_errno("mount failed"); \ +} while (/*CONSTCOND*/0); + +#define FSTEST_CONSTRUCTOR_FSPRIV(_tc_, _fs_, _args_, _privargs_) \ +do { \ + if (_fs_##_fstest_newfs(_tc_, &_args_, \ + FSTEST_IMGNAME, FSTEST_IMGSIZE, _privargs_) != 0) \ + atf_tc_fail_errno("newfs failed"); \ + if (_fs_##_fstest_mount(_tc_, _args_, FSTEST_MNTNAME, 0) != 0) \ + atf_tc_fail_errno("mount failed"); \ +} while (/*CONSTCOND*/0); + +#define FSTEST_DESTRUCTOR(_tc_, _fs_, _args_) \ +do { \ + if (_fs_##_fstest_unmount(_tc_, FSTEST_MNTNAME, 0) != 0) { \ + rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); \ + atf_tc_fail_errno("unmount failed"); \ + } \ + if (_fs_##_fstest_delfs(_tc_, _args_) != 0) \ + atf_tc_fail_errno("delfs failed"); \ +} while (/*CONSTCOND*/0); + +#define ATF_TC_FSADD(fs,type,func,desc) \ + ATF_TC(fs##_##func); \ + ATF_TC_HEAD(fs##_##func,tc) \ + { \ + atf_tc_set_md_var(tc, "descr", type " test for " desc); \ + atf_tc_set_md_var(tc, "X-fs.type", #fs); \ + atf_tc_set_md_var(tc, "X-fs.mntname", type); \ + if (strcmp(#fs, "zfs") == 0) { \ + /* This should not be necessary. */ \ + atf_tc_set_md_var(tc, "require.user", "root"); \ + } \ + } \ + void *fs##func##tmp; \ + \ + ATF_TC_BODY(fs##_##func,tc) \ + { \ + if (!atf_check_fstype(tc, #fs)) \ + atf_tc_skip("filesystem not selected"); \ + FSTEST_CONSTRUCTOR(tc,fs,fs##func##tmp); \ + func(tc,FSTEST_MNTNAME); \ + if (fs##_fstest_unmount(tc, FSTEST_MNTNAME, 0) != 0) { \ + rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); \ + atf_tc_fail_errno("unmount failed"); \ + } \ + } + +#define ATF_TC_FSADD_RO(_fs_,_type_,_func_,_desc_,_gen_) \ + ATF_TC(_fs_##_##_func_); \ + ATF_TC_HEAD(_fs_##_##_func_,tc) \ + { \ + atf_tc_set_md_var(tc, "descr",_type_" test for "_desc_);\ + atf_tc_set_md_var(tc, "X-fs.type", #_fs_); \ + atf_tc_set_md_var(tc, "X-fs.mntname", _type_); \ + if (strcmp(#_fs_, "zfs") == 0) { \ + /* This should not be necessary. */ \ + atf_tc_set_md_var(tc, "require.user", "root"); \ + } \ + } \ + void *_fs_##_func_##tmp; \ + \ + ATF_TC_BODY(_fs_##_##_func_,tc) \ + { \ + if (!atf_check_fstype(tc, #_fs_)) \ + atf_tc_skip("filesystem not selected"); \ + FSTEST_CONSTRUCTOR(tc,_fs_,_fs_##_func_##tmp); \ + _gen_(tc,FSTEST_MNTNAME); \ + if (_fs_##_fstest_unmount(tc, FSTEST_MNTNAME, 0) != 0) \ + atf_tc_fail_errno("unmount r/w failed"); \ + if (_fs_##_fstest_mount(tc, _fs_##_func_##tmp, \ + FSTEST_MNTNAME, MNT_RDONLY) != 0) \ + atf_tc_fail_errno("mount ro failed"); \ + _func_(tc,FSTEST_MNTNAME); \ + if (_fs_##_fstest_unmount(tc, FSTEST_MNTNAME, 0) != 0) {\ + rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); \ + atf_tc_fail_errno("unmount failed"); \ + } \ + } + +#define ATF_TP_FSADD(fs,func) \ + ATF_TP_ADD_TC(tp,fs##_##func) + +#define ATF_TC_FSAPPLY_NOZFS(func,desc) \ + ATF_TC_FSADD(ext2fs,MOUNT_EXT2FS,func,desc) \ + ATF_TC_FSADD(ffs,MOUNT_FFS,func,desc) \ + ATF_TC_FSADD(ffslog,MOUNT_FFS,func,desc) \ + ATF_TC_FSADD(lfs,MOUNT_LFS,func,desc) \ + ATF_TC_FSADD(msdosfs,MOUNT_MSDOS,func,desc) \ + ATF_TC_FSADD(nfs,MOUNT_NFS,func,desc) \ + ATF_TC_FSADD(puffs,MOUNT_PUFFS,func,desc) \ + ATF_TC_FSADD(p2k_ffs,MOUNT_PUFFS,func,desc) \ + ATF_TC_FSADD(rumpfs,MOUNT_RUMPFS,func,desc) \ + ATF_TC_FSADD(sysvbfs,MOUNT_SYSVBFS,func,desc) \ + ATF_TC_FSADD(tmpfs,MOUNT_TMPFS,func,desc) \ + ATF_TC_FSADD(udf,MOUNT_UDF,func,desc) \ + ATF_TC_FSADD(v7fs,MOUNT_V7FS,func,desc) + +#define ATF_TP_FSAPPLY_NOZFS(func) \ + ATF_TP_FSADD(ext2fs,func); \ + ATF_TP_FSADD(ffs,func); \ + ATF_TP_FSADD(ffslog,func); \ + ATF_TP_FSADD(lfs,func); \ + ATF_TP_FSADD(msdosfs,func); \ + ATF_TP_FSADD(nfs,func); \ + ATF_TP_FSADD(puffs,func); \ + ATF_TP_FSADD(p2k_ffs,func); \ + ATF_TP_FSADD(rumpfs,func); \ + ATF_TP_FSADD(sysvbfs,func); \ + ATF_TP_FSADD(tmpfs,func); \ + ATF_TP_FSADD(udf,func); \ + ATF_TP_FSADD(v7fs,func); + +/* XXX: this will not scale */ +#ifdef WANT_ZFS_TESTS +#define ATF_TC_FSAPPLY(func,desc) \ + ATF_TC_FSAPPLY_NOZFS(func,desc) \ + ATF_TC_FSADD(zfs,MOUNT_ZFS,func,desc) +#define ATF_TP_FSAPPLY(func) \ + ATF_TP_FSAPPLY_NOZFS(func) \ + ATF_TP_FSADD(zfs,func); + +#else /* !WANT_ZFS_TESTS */ + +#define ATF_TC_FSAPPLY(func,desc) \ + ATF_TC_FSAPPLY_NOZFS(func,desc) +#define ATF_TP_FSAPPLY(func) \ + ATF_TP_FSAPPLY_NOZFS(func) + +#endif /* WANT_ZFS_TESTS */ + +/* + * Same as above, but generate a file system image first and perform + * tests for a r/o mount. + * + * Missing the following file systems: + * + lfs (fstest_lfs routines cannot handle remount. FIXME!) + * + tmpfs (memory backend) + * + rumpfs (memory backend) + * + puffs (memory backend, but could be run in theory) + */ + +#define ATF_TC_FSAPPLY_RO(func,desc,gen) \ + ATF_TC_FSADD_RO(ext2fs,MOUNT_EXT2FS,func,desc,gen) \ + ATF_TC_FSADD_RO(ffs,MOUNT_FFS,func,desc,gen) \ + ATF_TC_FSADD_RO(ffslog,MOUNT_FFS,func,desc,gen) \ + ATF_TC_FSADD_RO(msdosfs,MOUNT_MSDOS,func,desc,gen) \ + ATF_TC_FSADD_RO(nfs,MOUNT_NFS,func,desc,gen) \ + ATF_TC_FSADD_RO(nfsro,MOUNT_NFS,func,desc,gen) \ + ATF_TC_FSADD_RO(sysvbfs,MOUNT_SYSVBFS,func,desc,gen) \ + ATF_TC_FSADD_RO(udf,MOUNT_UDF,func,desc,gen) \ + ATF_TC_FSADD_RO(v7fs,MOUNT_V7FS,func,desc,gen) + +#define ATF_TP_FSAPPLY_RO(func) \ + ATF_TP_FSADD(ext2fs,func); \ + ATF_TP_FSADD(ffs,func); \ + ATF_TP_FSADD(ffslog,func); \ + ATF_TP_FSADD(msdosfs,func); \ + ATF_TP_FSADD(nfs,func); \ + ATF_TP_FSADD(nfsro,func); \ + ATF_TP_FSADD(sysvbfs,func); \ + ATF_TP_FSADD(udf,func); \ + ATF_TP_FSADD(v7fs,func); + +#define ATF_FSAPPLY(func,desc) \ + ATF_TC_FSAPPLY(func,desc); \ + ATF_TP_ADD_TCS(tp) \ + { \ + ATF_TP_FSAPPLY(func); \ + return atf_no_error(); \ + } + +static __inline bool +atf_check_fstype(const atf_tc_t *tc, const char *fs) +{ + const char *fstype; + + if (!atf_tc_has_config_var(tc, "fstype")) + return true; + + fstype = atf_tc_get_config_var(tc, "fstype"); + if (strcmp(fstype, fs) == 0) + return true; + return false; +} + +#define FSTYPE_EXT2FS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "ext2fs") == 0) +#define FSTYPE_FFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "ffs") == 0) +#define FSTYPE_FFSLOG(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "ffslog") == 0) +#define FSTYPE_LFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "lfs") == 0) +#define FSTYPE_MSDOS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "msdosfs") == 0) +#define FSTYPE_NFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "nfs") == 0) +#define FSTYPE_NFSRO(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "nfsro") == 0) +#define FSTYPE_P2K_FFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "p2k_ffs") == 0) +#define FSTYPE_PUFFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "puffs") == 0) +#define FSTYPE_RUMPFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "rumpfs") == 0) +#define FSTYPE_SYSVBFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "sysvbfs") == 0) +#define FSTYPE_TMPFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "tmpfs") == 0) +#define FSTYPE_UDF(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "udf") == 0) +#define FSTYPE_V7FS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "v7fs") == 0) +#define FSTYPE_ZFS(tc)\ + (strcmp(atf_tc_get_md_var(tc, "X-fs.type"), "zfs") == 0) + +#define FSTEST_ENTER() \ + if (rump_sys_chdir(FSTEST_MNTNAME) == -1) \ + atf_tc_fail_errno("failed to cd into test mount") + +#define FSTEST_EXIT() \ + if (rump_sys_chdir("/") == -1) \ + atf_tc_fail_errno("failed to cd out of test mount") + +/* + * file system args structures + */ + +struct nfstestargs { + pid_t ta_childpid; + char ta_ethername[MAXPATHLEN]; +}; + +struct puffstestargs { + uint8_t *pta_pargs; + size_t pta_pargslen; + + int pta_pflags; + pid_t pta_childpid; + + int pta_rumpfd; + int pta_servfd; + + char pta_dev[MAXPATHLEN]; + char pta_dir[MAXPATHLEN]; + + int pta_mntflags; + + int pta_vfs_toserv_ops[PUFFS_VFS_MAX]; + int pta_vn_toserv_ops[PUFFS_VN_MAX]; +}; + +#endif /* __H_FSMACROS_H_ */ diff --git a/contrib/netbsd-tests/fs/common/snapshot.c b/contrib/netbsd-tests/fs/common/snapshot.c new file mode 100644 index 000000000000..7baf611b6ed6 --- /dev/null +++ b/contrib/netbsd-tests/fs/common/snapshot.c @@ -0,0 +1,228 @@ +/* $NetBSD: snapshot.c,v 1.7 2013/02/06 09:05:01 hannken Exp $ */ + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +ATF_TC_WITH_CLEANUP(snapshot); +ATF_TC_HEAD(snapshot, tc) +{ + + atf_tc_set_md_var(tc, "descr", "basic snapshot features"); +} + +static void +makefile(const char *path) +{ + int fd; + + fd = rump_sys_open(path, O_CREAT | O_RDWR, 0777); + if (fd == -1) + atf_tc_fail_errno("create %s", path); + rump_sys_close(fd); +} + +ATF_TC_BODY(snapshot, tc) +{ + char buf[1024]; + struct fss_set fss; + int fssfd; + int fd, fd2, i; + + if (system(NEWFS) == -1) + atf_tc_fail_errno("cannot create file system"); + + rump_init(); + begin(); + + if (rump_sys_mkdir("/mnt", 0777) == -1) + atf_tc_fail_errno("mount point create"); + if (rump_sys_mkdir("/snap", 0777) == -1) + atf_tc_fail_errno("mount point 2 create"); + + rump_pub_etfs_register("/diskdev", IMGNAME, RUMP_ETFS_BLK); + + mount_diskfs("/diskdev", "/mnt"); + +#define TESTSTR1 "huihai\n" +#define TESTSZ1 (sizeof(TESTSTR1)-1) +#define TESTSTR2 "baana liten\n" +#define TESTSZ2 (sizeof(TESTSTR2)-1) + + fd = rump_sys_open("/mnt/myfile", O_RDWR | O_CREAT, 0777); + if (fd == -1) + atf_tc_fail_errno("create file"); + if (rump_sys_write(fd, TESTSTR1, TESTSZ1) != TESTSZ1) + atf_tc_fail_errno("write fail"); + + fssfd = rump_sys_open("/dev/rfss0", O_RDWR); + if (fssfd == -1) + atf_tc_fail_errno("cannot open fss"); + makefile(BAKNAME); + memset(&fss, 0, sizeof(fss)); + fss.fss_mount = __UNCONST("/mnt"); + fss.fss_bstore = __UNCONST(BAKNAME); + fss.fss_csize = 0; + if (rump_sys_ioctl(fssfd, FSSIOCSET, &fss) == -1) + atf_tc_fail_errno("create snapshot"); + + for (i = 0; i < 10000; i++) { + if (rump_sys_write(fd, TESTSTR2, TESTSZ2) != TESTSZ2) + atf_tc_fail_errno("write fail"); + } + rump_sys_sync(); + + /* technically we should fsck it first? */ + mount_diskfs("/dev/fss0", "/snap"); + + /* check for old contents */ + fd2 = rump_sys_open("/snap/myfile", O_RDONLY); + if (fd2 == -1) + atf_tc_fail_errno("fail"); + memset(buf, 0, sizeof(buf)); + if (rump_sys_read(fd2, buf, sizeof(buf)) == -1) + atf_tc_fail_errno("read snap"); + ATF_CHECK(strcmp(buf, TESTSTR1) == 0); + + /* check that new files are invisible in the snapshot */ + makefile("/mnt/newfile"); + if (rump_sys_open("/snap/newfile", O_RDONLY) != -1) + atf_tc_fail("newfile exists in snapshot"); + if (errno != ENOENT) + atf_tc_fail_errno("newfile open should fail with ENOENT"); + + /* check that removed files are still visible in the snapshot */ + rump_sys_unlink("/mnt/myfile"); + if (rump_sys_open("/snap/myfile", O_RDONLY) == -1) + atf_tc_fail_errno("unlinked file no longer in snapshot"); + + /* done for now */ +} + +ATF_TC_CLEANUP(snapshot, tc) +{ + + unlink(IMGNAME); +} + +ATF_TC_WITH_CLEANUP(snapshotstress); +ATF_TC_HEAD(snapshotstress, tc) +{ + + atf_tc_set_md_var(tc, "descr", "snapshot on active file system"); +} + +#define NACTIVITY 4 + +static bool activity_stop = false; +static pid_t wrkpid; + +static void * +fs_activity(void *arg) +{ + int di, fi; + char *prefix = arg, path[128]; + + rump_pub_lwproc_newlwp(wrkpid); + + RL(rump_sys_mkdir(prefix, 0777)); + while (! activity_stop) { + for (di = 0; di < 5; di++) { + snprintf(path, sizeof(path), "%s/d%d", prefix, di); + RL(rump_sys_mkdir(path, 0777)); + for (fi = 0; fi < 5; fi++) { + snprintf(path, sizeof(path), "%s/d%d/f%d", + prefix, di, fi); + makefile(path); + } + } + for (di = 0; di < 5; di++) { + for (fi = 0; fi < 5; fi++) { + snprintf(path, sizeof(path), "%s/d%d/f%d", + prefix, di, fi); + RL(rump_sys_unlink(path)); + } + snprintf(path, sizeof(path), "%s/d%d", prefix, di); + RL(rump_sys_rmdir(path)); + } + } + RL(rump_sys_rmdir(prefix)); + + rump_pub_lwproc_releaselwp(); + + return NULL; +} + +ATF_TC_BODY(snapshotstress, tc) +{ + pthread_t at[NACTIVITY]; + struct fss_set fss; + char prefix[NACTIVITY][128]; + int i, fssfd; + + if (system(NEWFS) == -1) + atf_tc_fail_errno("cannot create file system"); + /* Force SMP so the stress makes sense. */ + RL(setenv("RUMP_NCPU", "4", 1)); + RZ(rump_init()); + /* Prepare for fsck to use the RUMP /dev/fss0. */ + RL(rump_init_server("unix://commsock")); + RL(setenv("LD_PRELOAD", "/usr/lib/librumphijack.so", 1)); + RL(setenv("RUMP_SERVER", "unix://commsock", 1)); + RL(setenv("RUMPHIJACK", "blanket=/dev/rfss0", 1)); + begin(); + + RL(rump_sys_mkdir("/mnt", 0777)); + + rump_pub_etfs_register("/diskdev", IMGNAME, RUMP_ETFS_BLK); + + mount_diskfs("/diskdev", "/mnt"); + + /* Start file system activity. */ + RL(wrkpid = rump_sys_getpid()); + for (i = 0; i < NACTIVITY; i++) { + snprintf(prefix[i], sizeof(prefix[i]), "/mnt/a%d", i); + RL(pthread_create(&at[i], NULL, fs_activity, prefix[i])); + sleep(1); + } + + fssfd = rump_sys_open("/dev/rfss0", O_RDWR); + if (fssfd == -1) + atf_tc_fail_errno("cannot open fss"); + makefile(BAKNAME); + memset(&fss, 0, sizeof(fss)); + fss.fss_mount = __UNCONST("/mnt"); + fss.fss_bstore = __UNCONST(BAKNAME); + fss.fss_csize = 0; + if (rump_sys_ioctl(fssfd, FSSIOCSET, &fss) == -1) + atf_tc_fail_errno("create snapshot"); + + activity_stop = true; + for (i = 0; i < NACTIVITY; i++) + RL(pthread_join(at[i], NULL)); + + RL(system(FSCK " /dev/rfss0")); +} + +ATF_TC_CLEANUP(snapshotstress, tc) +{ + + unlink(IMGNAME); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, snapshot); + ATF_TP_ADD_TC(tp, snapshotstress); + return 0; +} diff --git a/contrib/netbsd-tests/fs/ffs/ffs_common.sh b/contrib/netbsd-tests/fs/ffs/ffs_common.sh new file mode 100755 index 000000000000..eaf7142808a1 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/ffs_common.sh @@ -0,0 +1,99 @@ +# $NetBSD: ffs_common.sh,v 1.2 2013/07/29 13:15:24 skrll Exp $ + +create_ffs() +{ + local endian=$1; shift + local vers=$1; shift + local type=$1; shift + local op; + if [ ${type} = "both" ]; then + op="-q user -q group" + else + op="-q ${type}" + fi + atf_check -o ignore -e ignore newfs ${op} \ + -B ${endian} -O ${vers} -s 4000 -F ${IMG} +} + +create_ffs_server() +{ + local sarg=$1; shift + create_ffs $* + atf_check -o ignore -e ignore $(atf_get_srcdir)/h_ffs_server \ + ${sarg} ${IMG} ${RUMP_SERVER} +} + +rump_shutdown() +{ + for s in ${RUMP_SOCKETS_LIST}; do + atf_check -s exit:0 env RUMP_SERVER=unix://${s} rump.halt; + done +# check that the quota inode creation didn't corrupt the filesystem + atf_check -s exit:0 -o "match:already clean" \ + -o "match:Phase 6 - Check Quotas" \ + fsck_ffs -nf -F ${IMG} +} + +# from tests/ipf/h_common.sh via tests/sbin/resize_ffs +test_case() +{ + local name="${1}"; shift + local check_function="${1}"; shift + local descr="${1}"; shift + + atf_test_case "${name}" cleanup + + eval "${name}_head() { \ + atf_set "descr" "${descr}" + atf_set "timeout" "60" + }" + eval "${name}_body() { \ + RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \ + export RUMP_SERVER=unix://\${RUMP_SOCKET}; \ + ${check_function} " "${@}" "; \ + }" + eval "${name}_cleanup() { \ + for s in \${RUMP_SOCKETS_LIST}; do \ + export RUMP_SERVER=unix://\${s}; \ + atf_check -s exit:1 -o ignore -e ignore rump.halt; \ + done; \ + }" + tests="${tests} ${name}" +} + +test_case_root() +{ + local name="${1}"; shift + local check_function="${1}"; shift + local descr="${1}"; shift + + atf_test_case "${name}" cleanup + + eval "${name}_head() { \ + atf_set "descr" "${descr}" + atf_set "require.user" "root" + atf_set "timeout" "360" + }" + eval "${name}_body() { \ + RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \ + export RUMP_SERVER=unix://\${RUMP_SOCKET}; \ + ${check_function} " "${@}" "; \ + }" + eval "${name}_cleanup() { \ + for s in \${RUMP_SOCKETS_LIST}; do \ + export RUMP_SERVER=unix://\${s}; \ + atf_check -s exit:1 -o ignore -e ignore rump.halt; \ + done; \ + }" + tests="${tests} ${name}" +} + +atf_init_test_cases() +{ + IMG=fsimage + DIR=target + RUMP_SOCKET=test; + for i in ${tests}; do + atf_add_test_case $i + done +} diff --git a/contrib/netbsd-tests/fs/ffs/h_ffs_server.c b/contrib/netbsd-tests/fs/ffs/h_ffs_server.c new file mode 100644 index 000000000000..dd22d9faf1d8 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/h_ffs_server.c @@ -0,0 +1,113 @@ +/* $NetBSD: h_ffs_server.c,v 1.2 2012/08/24 20:25:50 jmmv Exp $ */ + +/* + * rump server for advanced quota tests + */ + +#include "../common/h_fsmacros.h" + +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include + +int background = 0; + +static void +usage(void) +{ + fprintf(stderr, "usage: %s [-b] [-l] diskimage bindurl\n", + getprogname()); + exit(1); +} + +static void +die(const char *reason, int error) +{ + + warnx("%s: %s", reason, strerror(error)); + if (background) + rump_daemonize_done(error); + exit(1); +} + +static sem_t sigsem; +static void +sigreboot(int sig) +{ + + sem_post(&sigsem); +} + +int +main(int argc, char **argv) +{ + int error; + struct ufs_args uargs; + const char *filename; + const char *serverurl; + int log = 0; + int ch; + + while ((ch = getopt(argc, argv, "bl")) != -1) { + switch(ch) { + case 'b': + background = 1; + break; + case 'l': + log = 1; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + if (argc != 2) + usage(); + + filename = argv[0]; + serverurl = argv[1]; + + if (background) { + error = rump_daemonize_begin(); + if (error) + errx(1, "rump daemonize: %s", strerror(error)); + } + + error = rump_init(); + if (error) + die("rump init failed", error); + + if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1) + die("mount point create", errno); + rump_pub_etfs_register("/diskdev", filename, RUMP_ETFS_BLK); + uargs.fspec = __UNCONST("/diskdev"); + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, (log) ? MNT_LOG : 0, + &uargs, sizeof(uargs)) == -1) + die("mount ffs", errno); + + error = rump_init_server(serverurl); + if (error) + die("rump server init failed", error); + if (background) + rump_daemonize_done(RUMP_DAEMONIZE_SUCCESS); + + sem_init(&sigsem, 0, 0); + signal(SIGTERM, sigreboot); + signal(SIGINT, sigreboot); + sem_wait(&sigsem); + + rump_sys_reboot(0, NULL); + /*NOTREACHED*/ + return 0; +} diff --git a/contrib/netbsd-tests/fs/ffs/h_quota2_tests.c b/contrib/netbsd-tests/fs/ffs/h_quota2_tests.c new file mode 100644 index 000000000000..59f3ea3b0917 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/h_quota2_tests.c @@ -0,0 +1,468 @@ +/* $NetBSD: h_quota2_tests.c,v 1.4 2012/09/30 21:26:57 bouyer Exp $ */ + +/* + * rump server for advanced quota tests + * this one includes functions to run against the filesystem before + * starting to handle rump requests from clients. + */ + +#include "../common/h_fsmacros.h" + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include "../../h_macros.h" + +int background = 0; + +#define TEST_NONROOT_ID 1 + +static int +quota_test0(const char *testopts) +{ + static char buf[512]; + int fd; + int error; + unsigned int i; + int chowner = 1; + for (i =0; testopts && i < strlen(testopts); i++) { + switch(testopts[i]) { + case 'C': + chowner = 0; + break; + default: + errx(1, "test4: unknown option %c", testopts[i]); + } + } + if (chowner) + rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID); + rump_sys_chmod(".", 0777); + if (rump_sys_setegid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_setegid"); + return error; + } + if (rump_sys_seteuid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_seteuid"); + return error; + } + fd = rump_sys_open("test_fillup", O_CREAT | O_RDWR, 0644); + if (fd < 0) { + error = errno; + warn("rump_sys_open"); + } else { + while (rump_sys_write(fd, buf, sizeof(buf)) == sizeof(buf)) + error = 0; + error = errno; + } + rump_sys_close(fd); + rump_sys_seteuid(0); + rump_sys_setegid(0); + return error; +} + +static int +quota_test1(const char *testopts) +{ + static char buf[512]; + int fd; + int error; + rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID); + rump_sys_chmod(".", 0777); + if (rump_sys_setegid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_setegid"); + return error; + } + if (rump_sys_seteuid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_seteuid"); + return error; + } + fd = rump_sys_open("test_fillup", O_CREAT | O_RDWR, 0644); + if (fd < 0) { + error = errno; + warn("rump_sys_open"); + } else { + /* + * write up to the soft limit, wait a bit, an try to + * keep on writing + */ + int i; + + /* write 2k: with the directory this makes 2.5K */ + for (i = 0; i < 4; i++) { + error = rump_sys_write(fd, buf, sizeof(buf)); + if (error != sizeof(buf)) + err(1, "write failed early"); + } + sleep(2); + /* now try to write an extra .5k */ + if (rump_sys_write(fd, buf, sizeof(buf)) != sizeof(buf)) + error = errno; + else + error = 0; + } + rump_sys_close(fd); + rump_sys_seteuid(0); + rump_sys_setegid(0); + return error; +} + +static int +quota_test2(const char *testopts) +{ + static char buf[512]; + int fd; + int error; + int i; + rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID); + rump_sys_chmod(".", 0777); + if (rump_sys_setegid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_setegid"); + return error; + } + if (rump_sys_seteuid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_seteuid"); + return error; + } + + for (i = 0; ; i++) { + sprintf(buf, "file%d", i); + fd = rump_sys_open(buf, O_CREAT | O_RDWR, 0644); + if (fd < 0) + break; + sprintf(buf, "test file no %d", i); + rump_sys_write(fd, buf, strlen(buf)); + rump_sys_close(fd); + } + error = errno; + + rump_sys_close(fd); + rump_sys_seteuid(0); + rump_sys_setegid(0); + return error; +} + +static int +quota_test3(const char *testopts) +{ + static char buf[512]; + int fd; + int error; + int i; + rump_sys_chown(".", TEST_NONROOT_ID, TEST_NONROOT_ID); + rump_sys_chmod(".", 0777); + if (rump_sys_setegid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_setegid"); + return error; + } + if (rump_sys_seteuid(TEST_NONROOT_ID) != 0) { + error = errno; + warn("rump_sys_seteuid"); + return error; + } + + /* + * create files one past the soft limit: one less as we already own the + * root directory + */ + for (i = 0; i < 4; i++) { + sprintf(buf, "file%d", i); + fd = rump_sys_open(buf, O_EXCL| O_CREAT | O_RDWR, 0644); + if (fd < 0) + err(1, "file create failed early"); + sprintf(buf, "test file no %d", i); + rump_sys_write(fd, buf, strlen(buf)); + rump_sys_close(fd); + } + /* now create an extra file after grace time: this should fail */ + sleep(2); + sprintf(buf, "file%d", i); + fd = rump_sys_open(buf, O_EXCL| O_CREAT | O_RDWR, 0644); + if (fd < 0) + error = errno; + else + error = 0; + + rump_sys_close(fd); + rump_sys_seteuid(0); + rump_sys_setegid(0); + return error; +} + +static int +quota_test4(const char *testopts) +{ + static char buf[512]; + int fd, fssfd; + struct fss_set fss; + unsigned int i; + int unl=0; + int unconf=0; + + /* + * take an internal snapshot of the filesystem, and create a new + * file with some data + */ + rump_sys_chown(".", 0, 0); + rump_sys_chmod(".", 0777); + + for (i =0; testopts && i < strlen(testopts); i++) { + switch(testopts[i]) { + case 'L': + unl++; + break; + case 'C': + unconf++; + break; + default: + errx(1, "test4: unknown option %c", testopts[i]); + } + } + + /* first create the snapshot */ + + fd = rump_sys_open(FSTEST_MNTNAME "/le_snap", O_CREAT | O_RDWR, 0777); + if (fd == -1) + err(1, "create " FSTEST_MNTNAME "/le_snap"); + rump_sys_close(fd); + fssfd = rump_sys_open("/dev/rfss0", O_RDWR); + if (fssfd == -1) + err(1, "cannot open fss"); + memset(&fss, 0, sizeof(fss)); + fss.fss_mount = __UNCONST("/mnt"); + fss.fss_bstore = __UNCONST(FSTEST_MNTNAME "/le_snap"); + fss.fss_csize = 0; + if (rump_sys_ioctl(fssfd, FSSIOCSET, &fss) == -1) + err(1, "create snapshot"); + if (unl) { + if (rump_sys_unlink(FSTEST_MNTNAME "/le_snap") == -1) + err(1, "unlink snapshot"); + } + + /* now create some extra files */ + + for (i = 0; i < 4; i++) { + sprintf(buf, "file%d", i); + fd = rump_sys_open(buf, O_EXCL| O_CREAT | O_RDWR, 0644); + if (fd < 0) + err(1, "create %s", buf); + sprintf(buf, "test file no %d", i); + rump_sys_write(fd, buf, strlen(buf)); + rump_sys_close(fd); + } + if (unconf) + if (rump_sys_ioctl(fssfd, FSSIOCCLR, NULL) == -1) + err(1, "unconfigure snapshot"); + return 0; +} + +static int +quota_test5(const char *testopts) +{ + static char buf[512]; + int fd; + int remount = 0; + int unlnk = 0; + int log = 0; + unsigned int i; + + for (i =0; testopts && i < strlen(testopts); i++) { + switch(testopts[i]) { + case 'L': + log++; + break; + case 'R': + remount++; + break; + case 'U': + unlnk++; + break; + default: + errx(1, "test4: unknown option %c", testopts[i]); + } + } + if (remount) { + struct ufs_args uargs; + uargs.fspec = __UNCONST("/diskdev"); + /* remount the fs read/write */ + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, + MNT_UPDATE | (log ? MNT_LOG : 0), + &uargs, sizeof(uargs)) == -1) + err(1, "mount ffs rw %s", FSTEST_MNTNAME); + } + + if (unlnk) { + /* + * open and unlink a file + */ + + fd = rump_sys_open("unlinked_file", + O_EXCL| O_CREAT | O_RDWR, 0644); + if (fd < 0) + err(1, "create %s", "unlinked_file"); + sprintf(buf, "test unlinked_file"); + rump_sys_write(fd, buf, strlen(buf)); + if (rump_sys_unlink("unlinked_file") == -1) + err(1, "unlink unlinked_file"); + if (rump_sys_fsync(fd) == -1) + err(1, "fsync unlinked_file"); + rump_sys_reboot(RUMP_RB_NOSYNC, NULL); + errx(1, "reboot failed"); + return 1; + } + return 0; +} + +struct quota_test { + int (*func)(const char *); + const char *desc; +}; + +struct quota_test quota_tests[] = { + { quota_test0, "write up to hard limit"}, + { quota_test1, "write beyond the soft limit after grace time"}, + { quota_test2, "create file up to hard limit"}, + { quota_test3, "create file beyond the soft limit after grace time"}, + { quota_test4, "take a snapshot and add some data"}, + { quota_test5, "open and unlink a file"}, +}; + +static void +usage(void) +{ + unsigned int test; + fprintf(stderr, "usage: %s [-b] [-l] test# diskimage bindurl\n", + getprogname()); + fprintf(stderr, "available tests:\n"); + for (test = 0; test < sizeof(quota_tests) / sizeof(quota_tests[0]); + test++) + fprintf(stderr, "\t%d: %s\n", test, quota_tests[test].desc); + exit(1); +} + +static void +die(const char *reason, int error) +{ + + warnx("%s: %s", reason, strerror(error)); + if (background) + rump_daemonize_done(error); + exit(1); +} + +static sem_t sigsem; +static void +sigreboot(int sig) +{ + + sem_post(&sigsem); +} + +int +main(int argc, char **argv) +{ + int error; + u_long test; + char *end; + struct ufs_args uargs; + const char *filename; + const char *serverurl; + const char *topts = NULL; + int mntopts = 0; + int ch; + + while ((ch = getopt(argc, argv, "blo:r")) != -1) { + switch(ch) { + case 'b': + background = 1; + break; + case 'l': + mntopts |= MNT_LOG; + break; + case 'r': + mntopts |= MNT_RDONLY; + break; + case 'o': + topts = optarg; + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + if (argc != 3) + usage(); + + filename = argv[1]; + serverurl = argv[2]; + + test = strtoul(argv[0], &end, 10); + if (*end != '\0') { + usage(); + } + if (test > sizeof(quota_tests) / sizeof(quota_tests[0])) { + usage(); + } + + if (background) { + error = rump_daemonize_begin(); + if (error) + errx(1, "rump daemonize: %s", strerror(error)); + } + + error = rump_init(); + if (error) + die("rump init failed", error); + + if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1) + err(1, "mount point create"); + rump_pub_etfs_register("/diskdev", filename, RUMP_ETFS_BLK); + uargs.fspec = __UNCONST("/diskdev"); + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, mntopts, + &uargs, sizeof(uargs)) == -1) + die("mount ffs", errno); + + if (rump_sys_chdir(FSTEST_MNTNAME) == -1) + err(1, "cd %s", FSTEST_MNTNAME); + error = quota_tests[test].func(topts); + if (error) { + fprintf(stderr, " test %lu: %s returned %d: %s\n", + test, quota_tests[test].desc, error, strerror(error)); + } + if (rump_sys_chdir("/") == -1) + err(1, "cd /"); + + error = rump_init_server(serverurl); + if (error) + die("rump server init failed", error); + if (background) + rump_daemonize_done(RUMP_DAEMONIZE_SUCCESS); + + sem_init(&sigsem, 0, 0); + signal(SIGTERM, sigreboot); + signal(SIGINT, sigreboot); + sem_wait(&sigsem); + + rump_sys_reboot(0, NULL); + /*NOTREACHED*/ + return 0; +} diff --git a/contrib/netbsd-tests/fs/ffs/quotas_common.sh b/contrib/netbsd-tests/fs/ffs/quotas_common.sh new file mode 100755 index 000000000000..0ad002f54ad5 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/quotas_common.sh @@ -0,0 +1,12 @@ +# $NetBSD: quotas_common.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ + +rump_quota_shutdown() +{ + for s in ${RUMP_SOCKETS_LIST}; do + atf_check -s exit:0 env RUMP_SERVER=unix://${s} rump.halt; + done +# check that the quota inode creation didn't corrupt the filesystem + atf_check -s exit:0 -o "match:already clean" \ + -o "match:Phase 6 - Check Quotas" \ + fsck_ffs -nf -F ${IMG} +} diff --git a/contrib/netbsd-tests/fs/ffs/t_clearquota.sh b/contrib/netbsd-tests/fs/ffs/t_clearquota.sh new file mode 100755 index 000000000000..f62a494730cd --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_clearquota.sh @@ -0,0 +1,91 @@ +# $NetBSD: t_clearquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ +# +# Copyright (c) 2011 Manuel Bouyer +# 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. +# + +for e in le be; do + for v in 1 2; do + for q in "user" "group"; do + test_case_root clear_${e}_${v}_${q} clear_quota \ + "clear quota with ${q} enabled" -b ${e} ${v} ${q} + done + test_case_root clear_${e}_${v}_"both" clear_quota \ + "clear quota with both enabled" -b ${e} ${v} "both" + test_case_root clear_${e}_${v}_"both_log" clear_quota \ + "clear quota for new id with both enabled, WAPBL" -bl ${e} ${v} "both" + done +done + +clear_quota() +{ + create_ffs_server $* + local q=$4 + local expect + local fail + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + +#set and check the expected quota + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \ + -t 2W/3D ${id} + atf_check -s exit:0 \ +-o "match:/mnt 0 10 40960 2weeks 0 20 51200 3days" \ +-o "match:Disk quotas for .*: $" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} + done +#now clear the quotas + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -c ${id} + done; + +#check that we do not get positive reply for any quota type + for q in u g ; do + atf_check -s exit:0 -o "not-match:/mnt" \ + -o "not-match:Disk quotas for .*: $" \ + -o "match:Disk quotas for .*: none$" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} + done + rump_quota_shutdown +} diff --git a/contrib/netbsd-tests/fs/ffs/t_fifos.c b/contrib/netbsd-tests/fs/ffs/t_fifos.c new file mode 100644 index 000000000000..fe1d4254a352 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_fifos.c @@ -0,0 +1,158 @@ +/* $NetBSD: t_fifos.c,v 1.5 2010/11/07 17:51:17 jmmv Exp $ */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "../../h_macros.h" + +ATF_TC_WITH_CLEANUP(fifos); +ATF_TC_HEAD(fifos, tc) +{ + atf_tc_set_md_var(tc, "descr", "test fifo support in ffs"); + atf_tc_set_md_var(tc, "timeout", "5"); +} + +#define teststr1 "raving & drooling" +#define teststr2 "haha, charade" + +static void * +w1(void *arg) +{ + int fd; + + fd = rump_sys_open("sheep", O_WRONLY); + if (fd == -1) + atf_tc_fail_errno("w1 open"); + if (rump_sys_write(fd, teststr1, sizeof(teststr1)) != sizeof(teststr1)) + atf_tc_fail_errno("w1 write"); + rump_sys_close(fd); + + return NULL; +} + +static void * +w2(void *arg) +{ + int fd; + + fd = rump_sys_open("pigs", O_WRONLY); + if (fd == -1) + atf_tc_fail_errno("w2 open"); + if (rump_sys_write(fd, teststr2, sizeof(teststr2)) != sizeof(teststr2)) + atf_tc_fail_errno("w2 write"); + rump_sys_close(fd); + + return NULL; +} + +static void * +r1(void *arg) +{ + char buf[32]; + int fd; + + fd = rump_sys_open("sheep", O_RDONLY); + if (fd == -1) + atf_tc_fail_errno("r1 open"); + if (rump_sys_read(fd, buf, sizeof(buf)) != sizeof(teststr1)) + atf_tc_fail_errno("r1 read"); + rump_sys_close(fd); + + if (strcmp(teststr1, buf) != 0) + atf_tc_fail("got invalid str, %s vs. %s", buf, teststr1); + + return NULL; +} + +static void * +r2(void *arg) +{ + char buf[32]; + int fd; + + fd = rump_sys_open("pigs", O_RDONLY); + if (fd == -1) + atf_tc_fail_errno("r2 open"); + if (rump_sys_read(fd, buf, sizeof(buf)) != sizeof(teststr2)) + atf_tc_fail_errno("r2 read"); + rump_sys_close(fd); + + if (strcmp(teststr2, buf) != 0) + atf_tc_fail("got invalid str, %s vs. %s", buf, teststr2); + + return NULL; +} + +#define IMGNAME "atf.img" + +const char *newfs = "newfs -F -s 10000 " IMGNAME; +#define FAKEBLK "/dev/sp00ka" + +ATF_TC_BODY(fifos, tc) +{ + struct ufs_args args; + pthread_t ptw1, ptw2, ptr1, ptr2; + + if (system(newfs) == -1) + atf_tc_fail_errno("newfs failed"); + + memset(&args, 0, sizeof(args)); + args.fspec = __UNCONST(FAKEBLK); + + rump_init(); + if (rump_sys_mkdir("/animals", 0777) == -1) + atf_tc_fail_errno("cannot create mountpoint"); + rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK); + if (rump_sys_mount(MOUNT_FFS, "/animals", 0, &args, sizeof(args))==-1) + atf_tc_fail_errno("rump_sys_mount failed"); + + /* create fifos */ + if (rump_sys_chdir("/animals") == 1) + atf_tc_fail_errno("chdir"); + if (rump_sys_mkfifo("pigs", S_IFIFO | 0777) == -1) + atf_tc_fail_errno("mknod1"); + if (rump_sys_mkfifo("sheep", S_IFIFO | 0777) == -1) + atf_tc_fail_errno("mknod2"); + + pthread_create(&ptw1, NULL, w1, NULL); + pthread_create(&ptw2, NULL, w2, NULL); + pthread_create(&ptr1, NULL, r1, NULL); + pthread_create(&ptr2, NULL, r2, NULL); + + pthread_join(ptw1, NULL); + pthread_join(ptw2, NULL); + pthread_join(ptr1, NULL); + pthread_join(ptr2, NULL); + + if (rump_sys_chdir("/") == 1) + atf_tc_fail_errno("chdir"); + + if (rump_sys_unmount("/animals", 0) == -1) + atf_tc_fail_errno("unmount failed"); +} + +ATF_TC_CLEANUP(fifos, tc) +{ + + unlink(IMGNAME); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, fifos); + return 0; +} diff --git a/contrib/netbsd-tests/fs/ffs/t_getquota.sh b/contrib/netbsd-tests/fs/ffs/t_getquota.sh new file mode 100755 index 000000000000..80f3cc7a6e76 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_getquota.sh @@ -0,0 +1,112 @@ +# $NetBSD: t_getquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ +# +# Copyright (c) 2011 Manuel Bouyer +# 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. +# + +for e in le be; do + for v in 1 2; do + for q in "user" "group"; do + test_case get_${e}_${v}_${q} get_quota \ + "get quota with ${q} enabled" -b ${e} ${v} ${q} + done + test_case get_${e}_${v}_"both" get_quota \ + "get quota with both enabled" -b ${e} ${v} "both" + done +done + +get_quota() +{ + create_ffs_server $* + local q=$4 + local expect + local fail + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + +#check that we can get the expected quota + for q in ${expect} ; do + atf_check -s exit:0 \ +-o "match:/mnt 0 - - 7days 1 - - 7days" \ +-o "match:Disk quotas for .*: $" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v + atf_check -s exit:0 \ +-o "match:-- 0 - - 1 - -" \ +-o "not-match:\+\+" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt + done + +#check that we do not get positive reply for non-expected quota + for q in ${fail} ; do + atf_check -s exit:0 -o "not-match:/mnt" \ + -o "not-match:Disk quotas for .*: $" \ + -o "match:Disk quotas for .*: none$" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v + atf_check -s exit:0 \ +-o "not-match:-- 0 - - 1 - -" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt + done + rump_quota_shutdown +} + +quota_walk_list() +{ + create_ffs_server $* + local q=$4 + local expect + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac +} diff --git a/contrib/netbsd-tests/fs/ffs/t_miscquota.sh b/contrib/netbsd-tests/fs/ffs/t_miscquota.sh new file mode 100755 index 000000000000..904ea37f8f6c --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_miscquota.sh @@ -0,0 +1,213 @@ +# $NetBSD: t_miscquota.sh,v 1.8 2013/01/22 06:24:11 dholland Exp $ +# +# Copyright (c) 2011 Manuel Bouyer +# 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. +# + +test_case_root walk_list_user quota_walk_list \ + "walk user quota list over several disk blocks" -b le 1 user + +test_case_root psnapshot_user quota_snap \ + "create a persistent shapshot of quota-enabled fs, and do some writes" \ + -b le 1 user + +test_case_root npsnapshot_user quota_snap \ + "create a non-persistent shapshot of quota-enabled fs, and do some writes" \ + -boL le 1 user + +test_case_root psnapshot_unconf_user quota_snap \ + "create a persistent shapshot of quota-enabled fs, and do some writes and unconf" \ + -boC le 1 user + +test_case_root npsnapshot_unconf_user quota_snap \ + "create a non-persistent shapshot of quota-enabled fs, and do some writes and unconf" \ + -boLC le 1 user + +test_case log_unlink quota_log \ + "an unlinked file cleaned by the log replay should update quota" \ + -l le 1 user + +test_case log_unlink_remount quota_log \ + "an unlinked file cleaned by the log replay after remount" \ + -oRL le 1 user + + +test_case_root default_deny_user quota_default_deny \ + "new quota entry denied by default entry" 5 -b le 1 user + +test_case_root default_deny_user_big quota_default_deny \ + "new quota entry denied by default entry, with list on more than one block" 5000 -b le 1 user + + +quota_walk_list() +{ + create_ffs_server $* + local q=$4 + local expect + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + # create 100 users, all in the same hash list + local i=1; + while [ $i -lt 101 ]; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -${expect} \ + -s10k/20 -h40M/50k -t 2W/3D $((i * 4096)) + i=$((i + 1)) + done + # do a repquota + atf_check -s exit:0 -o 'match:user 409600 block *81920 20 0' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -x -${expect} /mnt + rump_quota_shutdown +} + +quota_snap() +{ + local flag=$1; shift + create_ffs $* + local q=$3 + local expect + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + #start our server which takes a snapshot + atf_check -s exit:0 -o ignore \ + $(atf_get_srcdir)/h_quota2_tests ${flag} 4 ${IMG} ${RUMP_SERVER} + # create a few users + local i=1; + while [ $i -lt 11 ]; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -${expect} \ + -s10k/20 -h40M/50k -t 2W/3D $i + i=$((i + 1)) + done + # we should have 5 files (root + 4 regular files) + atf_check -s exit:0 \ + -o 'match:- - 7days 5 - - 7days' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -av + #shutdown and check filesystem + rump_quota_shutdown +} + +quota_log() +{ + local srv2args=$1; shift + create_ffs $* + local q=$3 + local expect + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + #start our server which create a file and unlink while keeping + # it open. The server halts itself without flush + atf_check -s exit:0 -o ignore \ + $(atf_get_srcdir)/h_quota2_tests -loU 5 ${IMG} ${RUMP_SERVER} + # we should have one unlinked file, but the log covers it. + atf_check -s exit:0 -o match:'3 files' -e ignore \ + fsck_ffs -nf -F ${IMG} + # have a kernel mount the fs again; it should cleanup the + # unlinked file + atf_check -o ignore -e ignore $(atf_get_srcdir)/h_quota2_tests \ + ${srv2args} -b 5 ${IMG} ${RUMP_SERVER} + #shutdown and check filesystem + rump_quota_shutdown +} + +quota_default_deny() +{ + local nusers=$1; shift + create_ffs_server $* + local q=$4 + local expect + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + # create $nusers users, so we are sure the free list has entries + # from block 1. Start from 10, as non-root id is 1. + # set default to deny all + ( echo "@format netbsd-quota-dump v1" + echo "# idtype id objtype hard soft usage expire grace" + echo "$q default block 0 0 0 0 0" + echo "$q default file 0 0 0 0 0" + local i=10; + while [ $i -lt $(($nusers + 10)) ]; do + echo "$q $i block 0 0 0 0 0" + echo "$q $i file 0 0 0 0 0" + i=$((i + 1)) + done + ) | atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quotarestore -d /mnt + atf_check -s exit:0 rump.halt + #now start the server which does the limits tests + $(atf_get_srcdir)/h_quota2_tests -oC -b 0 ${IMG} ${RUMP_SERVER} + rump_quota_shutdown +} diff --git a/contrib/netbsd-tests/fs/ffs/t_mount.c b/contrib/netbsd-tests/fs/ffs/t_mount.c new file mode 100644 index 000000000000..6a8f74f455f8 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_mount.c @@ -0,0 +1,138 @@ +/* $NetBSD: t_mount.c,v 1.13 2012/11/27 16:01:49 jakllsch Exp $ */ + +/* + * Basic tests for mounting + */ + +/* + * 48Kimage: + * Adapted for rump and atf from a testcase supplied + * by Hubert Feyrer on netbsd-users@ + */ + +#include + +#define FSTEST_IMGSIZE (96 * 512) +#include "../common/h_fsmacros.h" + +#include +#include + +#include + +#include + +#include +#include + +#include "../../h_macros.h" + +ATF_TC(48Kimage); +ATF_TC_HEAD(48Kimage, tc) +{ + atf_tc_set_md_var(tc, "descr", "mount small 48K ffs image"); +} + +ATF_TC_BODY(48Kimage, tc) +{ + void *tmp; + + atf_tc_expect_fail("PR kern/43573"); + FSTEST_CONSTRUCTOR(tc, ffs, tmp); + atf_tc_expect_pass(); + + FSTEST_DESTRUCTOR(tc, ffs, tmp); +} + +ATF_TC(fsbsizeovermaxphys); +ATF_TC_HEAD(fsbsizeovermaxphys, tc) +{ + + atf_tc_set_md_var(tc, "descr", "mounts file system with " + "blocksize > MAXPHYS"); + /* PR kern/43727 */ +} + +ATF_TC_BODY(fsbsizeovermaxphys, tc) +{ + char cmd[1024]; + struct ufs_args args; + struct statvfs svb; + + /* + * We cannot pass newfs parameters via the fstest interface, + * so do things the oldfashioned manual way. + */ + snprintf(cmd, sizeof(cmd), "newfs -G -b %d -F -s 10000 " + "ffs.img > /dev/null", MAXPHYS * 2); + if (system(cmd)) + atf_tc_fail("cannot create file system"); + + rump_init(); + if (rump_pub_etfs_register("/devdisk", "ffs.img", RUMP_ETFS_BLK)) + atf_tc_fail("cannot register rump fake device"); + + args.fspec = __UNCONST("/devdisk"); + + if (rump_sys_mkdir("/mp", 0777) == -1) + atf_tc_fail_errno("create mountpoint"); + + /* mount succeeded? bad omen. confirm we're in trouble. */ + if (rump_sys_mount(MOUNT_FFS, "/mp", 0, &args, sizeof(args)) != -1) { + rump_sys_statvfs1("/mp", &svb, ST_WAIT); + atf_tc_fail("not expecting to be alive"); + } + + /* otherwise we're do-ne */ +} + +ATF_TC(fsbsizeovermaxbsize); +ATF_TC_HEAD(fsbsizeovermaxbsize, tc) +{ + + atf_tc_set_md_var(tc, "descr", "mounts file system with " + "blocksize > MAXBSIZE"); +} + +ATF_TC_BODY(fsbsizeovermaxbsize, tc) +{ + char cmd[1024]; + struct ufs_args args; + struct statvfs svb; + + /* + * We cannot pass newfs parameters via the fstest interface, + * so do things the oldfashioned manual way. + */ + snprintf(cmd, sizeof(cmd), "newfs -G -b %d -F -s 10000 " + "ffs.img > /dev/null", MAXBSIZE * 2); + if (system(cmd)) + atf_tc_fail("cannot create file system"); + + rump_init(); + if (rump_pub_etfs_register("/devdisk", "ffs.img", RUMP_ETFS_BLK)) + atf_tc_fail("cannot register rump fake device"); + + args.fspec = __UNCONST("/devdisk"); + + if (rump_sys_mkdir("/mp", 0777) == -1) + atf_tc_fail_errno("create mountpoint"); + + /* mount succeeded? bad omen. confirm we're in trouble. */ + if (rump_sys_mount(MOUNT_FFS, "/mp", 0, &args, sizeof(args)) != -1) { + rump_sys_statvfs1("/mp", &svb, ST_WAIT); + atf_tc_fail("not expecting to be alive"); + } + + /* otherwise we're do-ne */ +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, 48Kimage); + ATF_TP_ADD_TC(tp, fsbsizeovermaxphys); + ATF_TP_ADD_TC(tp, fsbsizeovermaxbsize); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/fs/ffs/t_quota2_1.c b/contrib/netbsd-tests/fs/ffs/t_quota2_1.c new file mode 100644 index 000000000000..333f3c712708 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_quota2_1.c @@ -0,0 +1,114 @@ +/* $NetBSD: t_quota2_1.c,v 1.4 2012/03/15 02:02:22 joerg Exp $ */ + +/* + * Basic tests for quota2 + */ + +#include + +#include "../common/h_fsmacros.h" + +#include +#include + +#include + +#include + +#include +#include + +#include "../../h_macros.h" + +static void +do_quota(const atf_tc_t *tc, int n, const char *newfs_opts, int log) +{ + int i; + char buf[1024]; + int res; + int fd; + struct ufs_args uargs; + + snprintf(buf, sizeof(buf), "newfs -q user -q group -F -s 4000 -n %d " + "%s %s", (n + 3), newfs_opts, FSTEST_IMGNAME); + if (system(buf) == -1) + atf_tc_fail_errno("cannot create file system"); + + rump_init(); + if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1) + atf_tc_fail_errno("mount point create"); + + rump_pub_etfs_register("/diskdev", FSTEST_IMGNAME, RUMP_ETFS_BLK); + + uargs.fspec = __UNCONST("/diskdev"); + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, (log) ? MNT_LOG : 0, + &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs %s", FSTEST_MNTNAME); + + atf_tc_expect_pass(); + FSTEST_ENTER(); + RL(rump_sys_chown(".", 0, 0)); + for (i = 0 ; i < n; i++) { + sprintf(buf, "file%d", i); + RL(fd = rump_sys_open(buf, O_CREAT | O_RDWR, 0755)); + sprintf(buf, "test file no %d", i); + RL(rump_sys_write(fd, buf, strlen(buf))); + RL(rump_sys_fchown(fd, i, i+80000)); + rump_sys_close(fd); + } + FSTEST_EXIT(); + if (rump_sys_unmount(FSTEST_MNTNAME, 0) != 0) { + rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); + atf_tc_fail_errno("unmount failed"); + } + snprintf(buf, 1024, "fsck_ffs -fn -F %s", FSTEST_IMGNAME); + res = system(buf); + if (res != 0) + atf_tc_fail("fsck returned %d", res); +} + +#define DECL_TEST(nent, newops, name, descr, log) \ +ATF_TC(quota_##name); \ + \ +ATF_TC_HEAD(quota_##name, tc) \ +{ \ + atf_tc_set_md_var(tc, "descr", \ + "test quotas with %d users and groups, %s", \ + nent, descr); \ +} \ + \ +ATF_TC_BODY(quota_##name, tc) \ +{ \ + do_quota(tc, nent, newops, log); \ +} + +DECL_TEST(40, "-O1 -B le", 40_O1_le, "UFS1 little-endian", 0) +DECL_TEST(40, "-O1 -B be", 40_O1_be, "UFS1 big-endian", 0) + +DECL_TEST(40, "-O2 -B le", 40_O2_le, "UFS2 little-endian", 0) +DECL_TEST(40, "-O2 -B be", 40_O2_be, "UFS2 big-endian", 0) + +DECL_TEST(40, "-O1", 40_O1_log, "UFS1 log", 1) +DECL_TEST(40, "-O2", 40_O2_log, "UFS2 log", 1) + +DECL_TEST(1000, "-O1 -B le", 1000_O1_le, "UFS1 little-endian", 0) +DECL_TEST(1000, "-O1 -B be", 1000_O1_be, "UFS1 big-endian", 0) + +DECL_TEST(1000, "-O2 -B le", 1000_O2_le, "UFS2 little-endian", 0) +DECL_TEST(1000, "-O2 -B be", 1000_O2_be, "UFS2 big-endian", 0) + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, quota_40_O1_le); + ATF_TP_ADD_TC(tp, quota_40_O1_be); + ATF_TP_ADD_TC(tp, quota_40_O2_le); + ATF_TP_ADD_TC(tp, quota_40_O2_be); + ATF_TP_ADD_TC(tp, quota_40_O1_log); + ATF_TP_ADD_TC(tp, quota_40_O2_log); + ATF_TP_ADD_TC(tp, quota_1000_O1_le); + ATF_TP_ADD_TC(tp, quota_1000_O1_be); + ATF_TP_ADD_TC(tp, quota_1000_O2_le); + ATF_TP_ADD_TC(tp, quota_1000_O2_be); + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/fs/ffs/t_quota2_remount.c b/contrib/netbsd-tests/fs/ffs/t_quota2_remount.c new file mode 100644 index 000000000000..f648856bbf70 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_quota2_remount.c @@ -0,0 +1,139 @@ +/* $NetBSD: t_quota2_remount.c,v 1.4 2012/03/15 02:02:22 joerg Exp $ */ + +/* + * Basic tests for quota2 + */ + +#include + +#include "../common/h_fsmacros.h" + +#include +#include +#include + +#include + +#include + +#include +#include + +#include "../../h_macros.h" + +static void +do_quota(const atf_tc_t *tc, int n, const char *newfs_opts, int log) +{ + int i; + char buf[1024]; + int res; + int fd; + struct ufs_args uargs; + struct statvfs fst; + + snprintf(buf, sizeof(buf), "newfs -q user -q group -F -s 4000 -n %d " + "%s %s", (n + 3), newfs_opts, FSTEST_IMGNAME); + if (system(buf) == -1) + atf_tc_fail_errno("cannot create file system"); + + rump_init(); + if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1) + atf_tc_fail_errno("mount point create"); + + rump_pub_etfs_register("/diskdev", FSTEST_IMGNAME, RUMP_ETFS_BLK); + + uargs.fspec = __UNCONST("/diskdev"); + + /* read-only doens't have quota enabled */ + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, MNT_RDONLY, + &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs ro %s", FSTEST_MNTNAME); + + if (rump_sys_statvfs1(FSTEST_MNTNAME, &fst, 0) != 0) + atf_tc_fail_errno("statbfs %s (1)", FSTEST_MNTNAME); + + if ((fst.f_flag & ST_QUOTA) != 0) + atf_tc_fail("R/O filesystem has quota"); + + /* updating to read-write enables quota */ + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, + MNT_UPDATE | (log ? MNT_LOG : 0), &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs rw %s", FSTEST_MNTNAME); + + if (rump_sys_statvfs1(FSTEST_MNTNAME, &fst, 0) != 0) + atf_tc_fail_errno("statbfs %s (2)", FSTEST_MNTNAME); + + if ((fst.f_flag & ST_QUOTA) == 0) + atf_tc_fail("R/W filesystem has no quota"); + + /* we can update a second time */ + if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, + MNT_UPDATE | (log ? MNT_LOG : 0), &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs rw(2) %s", FSTEST_MNTNAME); + + if (rump_sys_statvfs1(FSTEST_MNTNAME, &fst, 0) != 0) + atf_tc_fail_errno("statbfs %s (3)", FSTEST_MNTNAME); + + if ((fst.f_flag & ST_QUOTA) == 0) + atf_tc_fail("R/W filesystem has no quota"); + + /* create some files so fsck has something to check */ + FSTEST_ENTER(); + RL(rump_sys_chown(".", 0, 0)); + for (i = 0 ; i < n; i++) { + sprintf(buf, "file%d", i); + RL(fd = rump_sys_open(buf, O_CREAT | O_RDWR, 0755)); + sprintf(buf, "test file no %d", i); + RL(rump_sys_write(fd, buf, strlen(buf))); + RL(rump_sys_fchown(fd, i, i+80000)); + rump_sys_close(fd); + } + FSTEST_EXIT(); + if (rump_sys_unmount(FSTEST_MNTNAME, 0) != 0) { + rump_pub_vfs_mount_print(FSTEST_MNTNAME, 1); + atf_tc_fail_errno("unmount failed"); + } + snprintf(buf, 1024, "fsck_ffs -fn -F %s", FSTEST_IMGNAME); + res = system(buf); + if (res != 0) + atf_tc_fail("fsck returned %d", res); +} + +#define DECL_TEST(nent, newops, name, descr, log) \ +ATF_TC(quota_##name); \ + \ +ATF_TC_HEAD(quota_##name, tc) \ +{ \ + atf_tc_set_md_var(tc, "descr", \ + "test filesystem remount with quotas, %s", descr); \ +} \ + \ +ATF_TC_BODY(quota_##name, tc) \ +{ \ + do_quota(tc, nent, newops, log); \ +} + +DECL_TEST(10, "-O1 -B le", 10_O1_le, "UFS1 little-endian", 0) +DECL_TEST(10, "-O1 -B be", 10_O1_be, "UFS1 big-endian", 0) + +#if 0 +/* + * this cause fsck to complain about summaries at the end. + * This sems to be related to -o log (reproductible on a fs with no + * quota enabled). not reproductible with a real kernel ... + */ +DECL_TEST(10, "-O1", 10_O1_log, "UFS1 log", 1) +DECL_TEST(10, "-O2", 10_O2_log, "UFS2 log", 1) +#endif + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, quota_10_O1_le); + ATF_TP_ADD_TC(tp, quota_10_O1_be); +#if 0 + ATF_TP_ADD_TC(tp, quota_10_O1_log); + ATF_TP_ADD_TC(tp, quota_10_O2_log); +#endif + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/fs/ffs/t_quotalimit.sh b/contrib/netbsd-tests/fs/ffs/t_quotalimit.sh new file mode 100755 index 000000000000..16e47b7a8fb8 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_quotalimit.sh @@ -0,0 +1,345 @@ +# $NetBSD: t_quotalimit.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ +# +# Copyright (c) 2011 Manuel Bouyer +# 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. +# + +for e in le; do + for v in 1; do + for q in "user" "group"; do + test_case_root limit_${e}_${v}_${q} limit_quota \ + "hit hard limit quota with ${q} enabled" -b ${e} ${v} ${q} + test_case_root limit_${e}_${v}_${q}_log limit_quota \ + "hit hard limit quota with ${q} enabled, WAPBL" -bl ${e} ${v} ${q} + test_case_root slimit_${e}_${v}_${q} limit_softquota \ + "hit soft limit quota with ${q} enabled after grace time" \ + -b ${e} ${v} ${q} + test_case_root inolimit_${e}_${v}_${q} limit_iquota \ + "hit hard limit ino quota with ${q} enabled" -b ${e} ${v} ${q} + test_case_root inolimit_${e}_${v}_${q}_log limit_iquota \ + "hit hard limit ino quota with ${q} enabled, WAPBL" -bl ${e} ${v} ${q} + test_case_root sinolimit_${e}_${v}_${q} limit_softiquota \ + "hit soft limit ino quota with ${q} enabled after grace time" \ + -b ${e} ${v} ${q} + test_case_root herit_defq_${e}_${v}_${q} inherit_defaultquota \ + "new id herit from default for ${q} quota" -b ${e} ${v} ${q} + test_case_root herit_defq_${e}_${v}_${q}_log inherit_defaultquota \ + "new id herit from default for ${q} quota, WAPBL" -bl ${e} ${v} ${q} + test_case_root herit_idefq_${e}_${v}_${q}_log inherit_defaultiquota \ + "new id herit from default for ${q} ino quota, WAPBL" -bl ${e} ${v} ${q} + done + done +done + +limit_quota() +{ + create_ffs_server $* + local q=$4 + local expect + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2k/4 -h3k/6 \ + -t 2h/2h ${id} + done + atf_check -s exit:0 rump.halt + + #now start the server which does the limits tests + atf_check -s exit:0 -o ignore \ +-e match:'test 0: write up to hard limit returned 69: Disc quota exceeded' \ + $(atf_get_srcdir)/h_quota2_tests -b 0 ${IMG} ${RUMP_SERVER} + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'/mnt 3072 B\* 2048 B 3072 B 2:0 2 4 6 ' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} + atf_check -s exit:0 \ + -o match:'daemon \+- 3 2 3 2:0 2 4 6' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt + done + rump_quota_shutdown +} + +limit_softquota() +{ + create_ffs_server $* + local q=$4 + local expect + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2k/4 -h3k/6 \ + -t 1s/1d ${id} + done + atf_check -s exit:0 rump.halt + + #now start the server which does the limits tests + atf_check -s exit:0 -o ignore \ +-e match:'test 1: write beyond the soft limit after grace time returned 69: Disc quota exceeded' \ + $(atf_get_srcdir)/h_quota2_tests -b 1 ${IMG} ${RUMP_SERVER} + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'/mnt 2560 B\* 2048 B 3072 B none 2 4 6 ' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} + atf_check -s exit:0 \ + -o match:'daemon \+- 2 2 3 none 2 4 6' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt + done + rump_quota_shutdown +} + +limit_iquota() +{ + create_ffs_server $* + local q=$4 + local expect + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2m/4 -h3m/6 \ + -t 2h/2h ${id} + done + atf_check -s exit:0 rump.halt + + #now start the server which does the limits tests + atf_check -s exit:0 -o ignore \ +-e match:'test 2: create file up to hard limit returned 69: Disc quota exceeded' \ + $(atf_get_srcdir)/h_quota2_tests -b 2 ${IMG} ${RUMP_SERVER} + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'/mnt 3072 B 2048 K 3072 K 6 \* 4 6 2:0' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} + atf_check -s exit:0 \ + -o match:'daemon -\+ 3 2048 3072 6 4 6 2:0' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt + done + rump_quota_shutdown +} + +limit_softiquota() +{ + create_ffs_server $* + local q=$4 + local expect + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2m/4 -h3m/6 \ + -t 1d/1s ${id} + done + atf_check -s exit:0 rump.halt + + #now start the server which does the limits tests + atf_check -s exit:0 -o ignore \ +-e match:'test 3: create file beyond the soft limit after grace time returned 69: Disc quota exceeded' \ + $(atf_get_srcdir)/h_quota2_tests -b 3 ${IMG} ${RUMP_SERVER} + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'/mnt 2560 B 2048 K 3072 K 5 \* 4 6 none' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} + atf_check -s exit:0 \ + -o match:'daemon -\+ 2 2048 3072 5 4 6 none' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt + done + rump_quota_shutdown +} + +inherit_defaultquota() +{ + create_ffs_server $* + local q=$4 + local expect + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2k/4 -h3k/6 \ + -t 2h/2h -d + done + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'Disk quotas for .*id 1\): none' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -v ${id} + done + atf_check -s exit:0 rump.halt + + #now start the server which does the limits tests + atf_check -s exit:0 -o ignore \ +-e match:'test 0: write up to hard limit returned 69: Disc quota exceeded' \ + $(atf_get_srcdir)/h_quota2_tests -b 0 ${IMG} ${RUMP_SERVER} + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'/mnt 3072 B\* 2048 B 3072 B 2:0 2 4 6 ' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} + atf_check -s exit:0 \ + -o match:'daemon \+- 3 2 3 2:0 2 4 6' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt + done + rump_quota_shutdown +} + +inherit_defaultiquota() +{ + create_ffs_server $* + local q=$4 + local expect + local id=1 + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + + for q in ${expect} ; do + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2m/4 -h3m/6 \ + -t 2h/2h -d + done + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'Disk quotas for .*id 1\): none' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -v ${id} + done + atf_check -s exit:0 rump.halt + + #now start the server which does the limits tests + atf_check -s exit:0 -o ignore \ +-e match:'test 2: create file up to hard limit returned 69: Disc quota exceeded' \ + $(atf_get_srcdir)/h_quota2_tests -b 2 ${IMG} ${RUMP_SERVER} + for q in ${expect} ; do + atf_check -s exit:0 \ + -o match:'/mnt 3072 B 2048 K 3072 K 6 \* 4 6 2:0' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} + atf_check -s exit:0 \ + -o match:'daemon -\+ 3 2048 3072 6 4 6 2:0' \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt + done + rump_quota_shutdown +} diff --git a/contrib/netbsd-tests/fs/ffs/t_setquota.sh b/contrib/netbsd-tests/fs/ffs/t_setquota.sh new file mode 100755 index 000000000000..5795fe4d46b6 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_setquota.sh @@ -0,0 +1,203 @@ +# $NetBSD: t_setquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ +# +# Copyright (c) 2011 Manuel Bouyer +# 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. +# + +for e in le be; do + for v in 1 2; do + for q in "user" "group"; do + test_case_root set_${e}_${v}_${q} set_quota \ + "set quota with ${q} enabled" -b ${e} ${v} ${q} + test_case_root set_new_${e}_${v}_${q} set_quota_new \ + "set quota for new id with ${q} enabled" -b ${e} ${v} ${q} + test_case_root set_default_${e}_${v}_${q} set_quota_default \ + "set default quota with ${q} enabled" -b ${e} ${v} ${q} + done + test_case_root set_${e}_${v}_"both" set_quota \ + "set quota with both enabled" -b ${e} ${v} "both" + test_case_root set_new_${e}_${v}_"both" set_quota_new \ + "set quota for new id with both enabled" -b ${e} ${v} "both" + test_case_root set_new_${e}_${v}_"both_log" set_quota_new \ + "set quota for new id with both enabled, WAPBL" -bl ${e} ${v} "both" + test_case_root set_default_${e}_${v}_"both" set_quota_default \ + "set default quota with both enabled" -b ${e} ${v} "both" + done +done + +set_quota() +{ + create_ffs_server $* + local q=$4 + local expect + local fail + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + +#check that we can set the expected quota + for q in ${expect} ; do + local id=$(id -${q}) + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \ + -t 2W/3D ${id} + atf_check -s exit:0 \ +-o "match:/mnt 0 10 40960 2weeks 1 20 51200 3days" \ +-o "match:Disk quotas for .*: $" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v + atf_check -s exit:0 \ +-o "match:-- 0 10 40960 1 20 51200" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt + done + +#check that we do not get positive reply for non-expected quota + for q in ${fail} ; do + local id=$(id -${q}) + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k ${id} + atf_check -s exit:0 -o "not-match:/mnt" \ + -o "not-match:Disk quotas for .*: $" \ + -o "match:Disk quotas for .*: none$" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v + atf_check -s exit:0 \ +-o "not-match:-- 0 - -" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt + done + rump_quota_shutdown +} + +set_quota_new() +{ + create_ffs_server $* + local q=$4 + local expect + local fail + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + +#check that we can set the expected quota + for q in ${expect} ; do + local id=1 + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \ + -t 120W/255D ${id} + atf_check -s exit:0 \ +-o "match:/mnt 0 10 40960 2years 0 20 51200 9months" \ +-o "match:Disk quotas for .*: $" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} + done + +#check that we do not get positive reply for non-expected quota + for q in ${fail} ; do + local id=$(id -${q}) + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k ${id} + atf_check -s exit:0 -o "not-match:/mnt" \ + -o "not-match:Disk quotas for .*: $" \ + -o "match:Disk quotas for .*: none$" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} + done + rump_quota_shutdown +} + +set_quota_default() +{ + create_ffs_server $* + local q=$4 + local expect + local fail + + case ${q} in + user) + expect=u + fail=g + ;; + group) + expect=g + fail=u + ;; + both) + expect="u g" + fail="" + ;; + *) + atf_fail "wrong quota type" + ;; + esac + +#check that we can set the expected quota + for q in ${expect} ; do + local id="-d" + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \ + -t 2H2M/3540 ${id} + atf_check -s exit:0 \ +-o "match:/mnt 0 10 40960 2:2 0 20 51200 59" \ +-o "match:Default (user|group) disk quotas: $" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} + done + +#check that we do not get positive reply for non-expected quota + for q in ${fail} ; do + local id="-d" + atf_check -s exit:0 \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k ${id} + atf_check -s exit:0 -o "not-match:/mnt" \ + -o "not-match:Default (user|group) disk quotas: $" \ + -o "match:Default (user|group) disk quotas: none$" \ + env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} + done + rump_quota_shutdown +} diff --git a/contrib/netbsd-tests/fs/ffs/t_snapshot.c b/contrib/netbsd-tests/fs/ffs/t_snapshot.c new file mode 100644 index 000000000000..180a8ccd92b0 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_snapshot.c @@ -0,0 +1,43 @@ +/* $NetBSD: t_snapshot.c,v 1.6 2013/02/06 09:05:01 hannken Exp $ */ + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "../../h_macros.h" + +#define IMGNAME "ffs.img" +#define NEWFS "newfs -F -s 10000 " IMGNAME +#define FSCK "fsck_ffs -fn -F" +#define BAKNAME "/mnt/le_snapp" + +static void +mount_diskfs(const char *fspec, const char *path) +{ + struct ufs_args uargs; + + uargs.fspec = __UNCONST(fspec); + + if (rump_sys_mount(MOUNT_FFS, path, 0, &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs %s", path); +} + +static void +begin(void) +{ + + /* empty */ +} + +#include "../common/snapshot.c" diff --git a/contrib/netbsd-tests/fs/ffs/t_snapshot_log.c b/contrib/netbsd-tests/fs/ffs/t_snapshot_log.c new file mode 100644 index 000000000000..e1ce17e1006a --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_snapshot_log.c @@ -0,0 +1,46 @@ +/* $NetBSD: t_snapshot_log.c,v 1.2 2013/02/06 09:05:01 hannken Exp $ */ + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "../../h_macros.h" + +#define IMGNAME "ffs.img" +#define NEWFS "newfs -F -s 10000 " IMGNAME +#define FSCK "fsck_ffs -fn -F" +#define BAKNAME "/mnt/le_snapp" + +static void +mount_diskfs(const char *fspec, const char *path) +{ + struct ufs_args uargs; + static int flags = MNT_LOG; + + uargs.fspec = __UNCONST(fspec); + + if (rump_sys_mount(MOUNT_FFS, + path, flags, &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs %s", path); + flags = 0; +} + +static void +begin(void) +{ + + /* empty */ +} + +#include "../common/snapshot.c" diff --git a/contrib/netbsd-tests/fs/ffs/t_snapshot_v2.c b/contrib/netbsd-tests/fs/ffs/t_snapshot_v2.c new file mode 100644 index 000000000000..393f3d41a6c3 --- /dev/null +++ b/contrib/netbsd-tests/fs/ffs/t_snapshot_v2.c @@ -0,0 +1,43 @@ +/* $NetBSD: t_snapshot_v2.c,v 1.2 2013/02/06 09:05:01 hannken Exp $ */ + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "../../h_macros.h" + +#define IMGNAME "ffs.img" +#define NEWFS "newfs -F -s 10000 -O 2 " IMGNAME +#define FSCK "fsck_ffs -fn -F" +#define BAKNAME "/mnt/le_snapp" + +static void +mount_diskfs(const char *fspec, const char *path) +{ + struct ufs_args uargs; + + uargs.fspec = __UNCONST(fspec); + + if (rump_sys_mount(MOUNT_FFS, path, 0, &uargs, sizeof(uargs)) == -1) + atf_tc_fail_errno("mount ffs %s", path); +} + +static void +begin(void) +{ + + /* empty */ +} + +#include "../common/snapshot.c" diff --git a/contrib/netbsd-tests/fs/fifofs/t_fifo.c b/contrib/netbsd-tests/fs/fifofs/t_fifo.c new file mode 100644 index 000000000000..c4a2060a6ebc --- /dev/null +++ b/contrib/netbsd-tests/fs/fifofs/t_fifo.c @@ -0,0 +1,237 @@ +/* Test case written by Bharat Joshi */ +#include +__RCSID("$NetBSD: t_fifo.c,v 1.1 2011/12/21 00:17:07 christos Exp $"); + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef STANDALONE +#include +#endif + +#define FIFO_FILE_PATH "./fifo_file" +#define NUM_MESSAGES 20 +#define MSG_SIZE 240 +#define MESSAGE "I am fine" + +static int verbose = 0; + +/* + * child_writer + * + * Function that runs in child context and opens and write to the FIFO. + */ +static void +child_writer(void) +{ + ssize_t rv; + int fd; + size_t count; + char message[MSG_SIZE] = MESSAGE; + static const struct timespec ts = { 0, 10000 }; + + /* Open the fifo in write-mode */ + for (;;) { + fd = open(FIFO_FILE_PATH, O_WRONLY, 0); + if (fd == -1) { + if (errno == EINTR) + continue; + err(1, "Child: can't open fifo in write mode"); + } + break; + } + + for (count = 0; count < NUM_MESSAGES; count++) { + rv = write(fd, message, MSG_SIZE); + if (rv == -1) { + warn("Child: Failed to write"); + break; + } + if (rv != MSG_SIZE) + warnx("Child: wrote only %zd", rv); + nanosleep(&ts, NULL); + } + + close(fd); + if (verbose) { + printf("Child: Closed the fifo file\n"); + fflush(stdout); + } +} + +/* + * _sigchild_handler + * + * Called when a sigchild is delivered + */ +static void +sigchild_handler(int signo) +{ + if (verbose) { + if (signo == SIGCHLD) { + printf("Got sigchild\n"); + } else { + printf("Got %d signal\n", signo); + } + fflush(stdout); + } + +} + +static int +run(void) +{ + pid_t pid; + ssize_t rv; + int fd, status; + size_t buf_size = MSG_SIZE; + char buf[MSG_SIZE]; + struct sigaction action; + static const struct timespec ts = { 0, 500000000 }; + + /* Catch sigchild Signal */ + memset(&action, 0, sizeof(action)); + action.sa_handler = sigchild_handler; + sigemptyset(&action.sa_mask); + + if (sigaction(SIGCHLD, &action, NULL) == -1) + err(1, "sigaction"); + + (void)unlink(FIFO_FILE_PATH); + /* First create a fifo */ + if (mkfifo(FIFO_FILE_PATH, S_IRUSR | S_IWUSR) == -1) + err(1, "mkfifo"); + + switch ((pid = fork())) { + case -1: + err(1, "fork"); + case 0: + /* Open the file in write mode so that subsequent read + * from parent side does not block the parent.. + */ + if ((fd = open(FIFO_FILE_PATH, O_WRONLY, 0)) == -1) + err(1, "failed to open fifo"); + + /* In child */ + child_writer(); + return 0; + + default: + break; + } + + if (verbose) { + printf("Child pid is %d\n", pid ); + fflush(stdout); + } + + /* In parent */ + for (;;) { + if ((fd = open(FIFO_FILE_PATH, O_RDONLY, 0)) == -1) { + if (errno == EINTR) + continue; + else + err(1, "Failed to open the fifo in read mode"); + } + /* Read mode is opened */ + break; + + } + + nanosleep(&ts, NULL); + if (verbose) { + printf("Was sleeping...\n"); + fflush(stdout); + } + + for (;;) { + rv = read(fd, buf, buf_size); + + if (rv == -1) { + warn("Failed to read"); + if (errno == EINTR) { + if (verbose) { + printf("Parent interrupted, " + "continuing...\n"); + fflush(stdout); + } + continue; + } + + break; + } + + if (rv == 0) { + if (verbose) { + printf("Writers have closed, looks like we " + "are done\n"); + fflush(stdout); + } + break; + } + + if (verbose) { + printf("Received %zd bytes message '%s'\n", rv, buf); + fflush(stdout); + } + } + + close(fd); + + if (verbose) { + printf("We are done.. now reap the child"); + fflush(stdout); + } + + // Read the child... + while (waitpid(pid, &status, 0) == -1) + if (errno != EINTR) { + warn("Failed to reap the child"); + return 1; + } + + if (verbose) { + printf("We are done completely\n"); + fflush(stdout); + } + return 0; +} + +#ifndef STANDALONE +ATF_TC(parent_child); + +ATF_TC_HEAD(parent_child, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checks that when a fifo is shared " + "between a reader parent and a writer child, that read will " + "return EOF, and not get stuck after the child exits"); +} + +ATF_TC_BODY(parent_child, tc) +{ + ATF_REQUIRE(run() == 0); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, parent_child); + + return atf_no_error(); +} +#else +int +main(void) +{ + verbose = 1; + return run(); +} +#endif diff --git a/contrib/netbsd-tests/fs/h_funcs.subr b/contrib/netbsd-tests/fs/h_funcs.subr new file mode 100644 index 000000000000..1216aaf2124a --- /dev/null +++ b/contrib/netbsd-tests/fs/h_funcs.subr @@ -0,0 +1,63 @@ +#!/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 + 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 + [ ${found} = yes ] || \ + atf_skip "The kernel does not include support the " \ + "\`${name}' file system" +} diff --git a/contrib/netbsd-tests/fs/hfs/colon.hfs.bz2.uue b/contrib/netbsd-tests/fs/hfs/colon.hfs.bz2.uue new file mode 100644 index 000000000000..9240e7befa80 --- /dev/null +++ b/contrib/netbsd-tests/fs/hfs/colon.hfs.bz2.uue @@ -0,0 +1,35 @@ +begin 644 colon.hfs.bz2 +M0EIH.3%!629363%?)5P``$+____[_UOQ>_]__^_O\+____1K30045,CBA$'P +M'DA:2!KIT`3V\VRA*B& +M`$,"8C$P$T9!HR:81B,":`D20A3T:GI`9``#(>H-`:-```:````````````` +M08!#1B:`R:83)ID`&$:-,`F`)A!H9`Q,@#``"8F3`3`30%241HC(4_4GJ>U- +M1Y31IM)ID`]3(T>H`#0#0T`:!H!A&@!H`````*9A\>L.>@+P;@Y:4C2%YM29 +M)Z`H>8SU&'"0U30JHOQ^.'A/7!GQK%#A5RVH"2$4VDL&T@ +M65#T*A/GU+(_VI$+*$`TJ"4J1(B1S&-YV+\J^"\Z6EK+@TU[0OQJ+;*HW.MN +M=HTL,CQHCE$C3#EW'>#8!IGYY[*)]U$!0W6L;#U:*4X6IT<@^*5!16E)%(:* +MA["$B&JX1022R8T4#20D@+ZHA_2_9$72HDSJ-FJ"7Z15%U2`@<>BJGD5'+*A +M@M6>?K^MS^LOC8I)EI6[`O3`#CCKU:M6F6A00-$/:LH+!E7(G33<))OZ27I4`@;= +M4C<-$,N=UX98G_0DK)BTS-^)R+8NZ,B3JU:@85&-MM@FCNQW/?= +M'ZL4BR[\&3S\>.K"S#1Z&>2I>^+16EM54PV3%K7M$"E`.N2"E*,8-@V.E<3$ +M,K\RU$&5E//5.'K6A+44]9=\"WF$J@Q1!43!WLA!?"XLR2GOU6G-,W]92)1` +MC@M4A4'FVAA`Q&&_%1B@L_`Z;T`0>[W6SCI%W&=H%Y>2"#E>IN[R3+(:S +MLMC<>N$1&APB(&6_#U<"!5*#IDA;MLNX`J(:/B8I,UNWB3CDPU2.@"(ORCKK +MK(1*"RZ+9V>$I2"PLER`U4BFIY'VTJ#\NYN2-9DRCIP1([QBLNKT:%1K"-P5 +MY)2NL9KM8=ACP>MLBS&J(00HA*QYRUL:'A%8F5]&22@@@D,;3[C,4.9$P)DK +M>\N+DK'4TLDI*LD&>8DEV@DT9B\,_CR;`,Y-E8*MM?Z*?BPU`I[I5^G-B$$A. +M\7&8DC*:*',@VKX0HL8O)DL<-9GG!8>NK.2XS2I.;Z3%Q9OIL8?(6-*DEGHW +MX^&A?%APXI:C@,A/&<6=)7#$UI;1Y6A'C<#/EW-*T(8WC9=`B`%\)M5HIS[\ +MV1%+H,,()X19<,:)U:Y?V\-T!^]'A\%%%+Z6.PQ"QI$]3#11IRB<#.9-L)^! +MB-WJYVQVMP^;7V*W5MG' +MKUWYE^[,*T:U)Y]NUI,00H%8>74G/?LJ0K)51^BXZ+AI*2O[PI`V*%Q@X\YV +M!V?D08"^;*TYO4R)T6G5:M;_M5M*;H4V)1IKCL$01$`#1R%N5,'_B[DBG"A( +%&*^2K@"^ +` +end diff --git a/contrib/netbsd-tests/fs/hfs/t_pathconvert.c b/contrib/netbsd-tests/fs/hfs/t_pathconvert.c new file mode 100644 index 000000000000..307de709be8b --- /dev/null +++ b/contrib/netbsd-tests/fs/hfs/t_pathconvert.c @@ -0,0 +1,83 @@ +/* $NetBSD: t_pathconvert.c,v 1.5 2011/02/25 20:54:18 martin Exp $ */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "../../h_macros.h" + +ATF_TC(colonslash); +ATF_TC_HEAD(colonslash, tc) +{ + atf_tc_set_md_var(tc, "descr", "HFS+ colons/slashes (PR kern/44523)"); + atf_tc_set_md_var(tc, "timeout", "20"); +} + +#define IMGNAME "colon.hfs" +#define FAKEBLK "/dev/blk" +#define FUNNY_FILENAME "foo:bar" +ATF_TC_BODY(colonslash, tc) +{ + struct hfs_args args; + int dirfd, fd; + char thecmd[1024]; + char buf[DIRBLKSIZ]; + struct dirent *dirent; + int offset, nbytes; + bool ok = false; + + snprintf(thecmd, sizeof(thecmd), "uudecode %s/colon.hfs.bz2.uue", + atf_tc_get_config_var(tc, "srcdir")); + RZ(system(thecmd)); + + snprintf(thecmd, sizeof(thecmd), "bunzip2 " IMGNAME ".bz2"); + RZ(system(thecmd)); + + memset(&args, 0, sizeof args); + args.fspec = __UNCONST(FAKEBLK); + RZ(rump_init()); + + RL(rump_sys_mkdir("/mp", 0777)); + RZ(rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK)); + RL(rump_sys_mount(MOUNT_HFS, "/mp", 0, &args, sizeof args)); + + RL(dirfd = rump_sys_open("/mp", O_RDONLY)); + + RL(nbytes = rump_sys_getdents(dirfd, buf, sizeof buf)); + + for (offset = 0; offset < nbytes; offset += dirent->d_reclen) { + dirent = (struct dirent *)(buf + offset); + if (strchr(dirent->d_name, '/')) + atf_tc_fail("dirent with slash: %s", dirent->d_name); + if (0 == strcmp(FUNNY_FILENAME, dirent->d_name)) + ok = true; + } + + if (!ok) + atf_tc_fail("no dirent for file: %s", FUNNY_FILENAME); + + RL(rump_sys_close(dirfd)); + RL(fd = rump_sys_open("/mp/" FUNNY_FILENAME, O_RDONLY)); + RL(rump_sys_close(fd)); + RL(rump_sys_unmount("/mp", 0)); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, colonslash); + return 0; +} diff --git a/contrib/netbsd-tests/fs/kernfs/t_basic.c b/contrib/netbsd-tests/fs/kernfs/t_basic.c new file mode 100644 index 000000000000..e5ba4a77e1b7 --- /dev/null +++ b/contrib/netbsd-tests/fs/kernfs/t_basic.c @@ -0,0 +1,133 @@ +/* $NetBSD: t_basic.c,v 1.3 2010/05/31 23:44:54 pooka Exp $ */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "../../h_macros.h" + +ATF_TC(getdents); +ATF_TC_HEAD(getdents, tc) +{ + + atf_tc_set_md_var(tc, "descr", "kernfs directory contains files"); +} + +static void +mountkernfs(void) +{ + + rump_init(); + + if (rump_sys_mkdir("/kern", 0777) == -1) + atf_tc_fail_errno("mkdir /kern"); + if (rump_sys_mount(MOUNT_KERNFS, "/kern", 0, NULL, 0) == -1) + atf_tc_fail_errno("could not mount kernfs"); +} + +ATF_TC_BODY(getdents, tc) +{ + struct dirent *dent; + char buf[8192]; + int dfd; + + mountkernfs(); + + if ((dfd = rump_sys_open("/kern", O_RDONLY)) == -1) + atf_tc_fail_errno("can't open directory"); + if (rump_sys_getdents(dfd, buf, sizeof(buf)) == -1) + atf_tc_fail_errno("getdents"); + + /* + * Check that we get the first three values (., .., boottime). + * Make more complete by autogenerating list from kernfs_vnops.c? + */ + dent = (void *)buf; + ATF_REQUIRE_STREQ(dent->d_name, "."); + dent = _DIRENT_NEXT(dent); + ATF_REQUIRE_STREQ(dent->d_name, ".."); + dent = _DIRENT_NEXT(dent); + ATF_REQUIRE_STREQ(dent->d_name, "boottime"); + + /* done */ +} + +ATF_TC(hostname); +ATF_TC_HEAD(hostname, tc) +{ + + atf_tc_set_md_var(tc, "descr", "/kern/hostname changes hostname"); +} + +static char * +getthehost(void) +{ + static char buf[8192]; + int mib[2]; + size_t blen; + + mib[0] = CTL_KERN; + mib[1] = KERN_HOSTNAME; + blen = sizeof(buf); + if (rump_sys___sysctl(mib, 2, buf, &blen, NULL, 0) == -1) + atf_tc_fail_errno("sysctl gethostname"); + + return buf; +} + +#define NEWHOSTNAME "turboton roos-berg" +ATF_TC_BODY(hostname, tc) +{ + char buf[8192]; + char *shost, *p; + int fd; + + mountkernfs(); + if ((fd = rump_sys_open("/kern/hostname", O_RDWR)) == -1) + atf_tc_fail_errno("open hostname"); + + /* check initial match */ + shost = getthehost(); + buf[0] = '\0'; + if (rump_sys_read(fd, buf, sizeof(buf)) == -1) + atf_tc_fail_errno("read hostname"); + p = strchr(buf, '\n'); + if (p) + *p = '\0'; + ATF_REQUIRE_STREQ_MSG(buf, shost, "initial hostname mismatch"); + + /* check changing hostname works */ + if (rump_sys_pwrite(fd, NEWHOSTNAME, strlen(NEWHOSTNAME), 0) + != strlen(NEWHOSTNAME)) { + atf_tc_fail_errno("write new hostname"); + } + + shost = getthehost(); + ATF_REQUIRE_STREQ_MSG(NEWHOSTNAME, shost, "modified hostname mismatch"); + + /* done */ +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, hostname); + ATF_TP_ADD_TC(tp, getdents); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/fs/lfs/t_pr.c b/contrib/netbsd-tests/fs/lfs/t_pr.c new file mode 100644 index 000000000000..97cb1dbbbf77 --- /dev/null +++ b/contrib/netbsd-tests/fs/lfs/t_pr.c @@ -0,0 +1,60 @@ +/* $NetBSD: t_pr.c,v 1.6 2011/02/22 18:41:05 pooka Exp $ */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "../../h_macros.h" + +ATF_TC(mknod); +ATF_TC_HEAD(mknod, tc) +{ + + atf_tc_set_md_var(tc, "descr", "mknod(2) hangs on LFS (PR kern/43503)"); + atf_tc_set_md_var(tc, "timeout", "20"); +} + +#define IMGNAME "disk.img" +#define FAKEBLK "/dev/blk" +ATF_TC_BODY(mknod, tc) +{ + struct ufs_args args; + + /* hmm, maybe i should fix newfs_lfs instead? */ + if (system("newfs_lfs -D -F -s 10000 ./" IMGNAME) == -1) + atf_tc_fail_errno("newfs failed"); + + memset(&args, 0, sizeof(args)); + args.fspec = __UNCONST(FAKEBLK); + + rump_init(); + if (rump_sys_mkdir("/mp", 0777) == -1) + atf_tc_fail_errno("cannot create mountpoint"); + rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK); + if (rump_sys_mount(MOUNT_LFS, "/mp", 0, &args, sizeof(args)) == -1) + atf_tc_fail_errno("rump_sys_mount failed"); + + //atf_tc_expect_timeout("PR kern/43503"); + if (rump_sys_mknod("/mp/node", S_IFCHR | 0777, 0) == -1) + atf_tc_fail_errno("mknod failed"); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, mknod); + return 0; +} diff --git a/contrib/netbsd-tests/fs/msdosfs/t_snapshot.c b/contrib/netbsd-tests/fs/msdosfs/t_snapshot.c new file mode 100644 index 000000000000..8b5708f843a3 --- /dev/null +++ b/contrib/netbsd-tests/fs/msdosfs/t_snapshot.c @@ -0,0 +1,51 @@ +/* $NetBSD: t_snapshot.c,v 1.3 2014/06/10 13:15:18 martin Exp $ */ + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "../../h_macros.h" + +#define IMGNAME "msdosfs.img" +#define NEWFS "newfs_msdos -C 5M " IMGNAME +#define FSCK "fsck_msdos -fn" +#define BAKNAME "/stor/snap" + +static void +mount_diskfs(const char *fspec, const char *path) +{ + struct msdosfs_args margs; + + memset(&margs, 0, sizeof(margs)); + margs.fspec = __UNCONST(fspec); + margs.version = MSDOSFSMNT_VERSION; + + if (rump_sys_mount(MOUNT_MSDOS, path, 0, &margs, sizeof(margs)) == -1) + err(1, "mount msdosfs %s", path); +} + +static void +begin(void) +{ + struct tmpfs_args targs = { .ta_version = TMPFS_ARGS_VERSION, }; + + if (rump_sys_mkdir("/stor", 0777) == -1) + atf_tc_fail_errno("mkdir /stor"); + if (rump_sys_mount(MOUNT_TMPFS, "/stor", 0, &targs,sizeof(targs)) == -1) + atf_tc_fail_errno("mount storage"); +} + +#include "../common/snapshot.c" diff --git a/contrib/netbsd-tests/fs/nfs/nfsservice/README b/contrib/netbsd-tests/fs/nfs/nfsservice/README new file mode 100644 index 000000000000..8cfa8af62949 --- /dev/null +++ b/contrib/netbsd-tests/fs/nfs/nfsservice/README @@ -0,0 +1,16 @@ + $NetBSD: README,v 1.1 2010/07/26 15:53:00 pooka Exp $ + +This directory contains the necessary bits to get an NFS server +running in a rump kernel. In essence, it's: + + * rpcbind + * mountd + * nfsd + +Additionally, you need the libc rpc code which is in +tests/fs/common/nfsrpc. + +TODO: make the standard nfs userspace services usable (the challenge +comes from rpc being in libc). + +questions? ==> pooka@netbsd.org diff --git a/contrib/netbsd-tests/fs/nfs/nfsservice/exports b/contrib/netbsd-tests/fs/nfs/nfsservice/exports new file mode 100644 index 000000000000..6cc8c5fb80e9 --- /dev/null +++ b/contrib/netbsd-tests/fs/nfs/nfsservice/exports @@ -0,0 +1,12 @@ +# $NetBSD: exports,v 1.2 2010/12/31 18:11:27 pooka Exp $ +# + +# +# The export dir is currently hardcoded and is exposed to the +# world, where "world" in this case means inside the rump shmif +# IP network, i.e. not a very big world. Probably needs some +# adjustments if we want to test NFS features more carefully, +# but this is enough for the current VFS level tests. +# +/myexport -noresvport -noresvmnt -maproot=0:0 10.3.2.2 +/myexport -ro -noresvport -noresvmnt -maproot=0:0 10.4.2.2 diff --git a/contrib/netbsd-tests/fs/nfs/nfsservice/getmntinfo.c b/contrib/netbsd-tests/fs/nfs/nfsservice/getmntinfo.c new file mode 100644 index 000000000000..0c0587a7aba5 --- /dev/null +++ b/contrib/netbsd-tests/fs/nfs/nfsservice/getmntinfo.c @@ -0,0 +1,85 @@ +/* $NetBSD: getmntinfo.c,v 1.1 2010/07/26 15:53:00 pooka Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. 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. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 +#if defined(LIBC_SCCS) && !defined(lint) +#if 0 +static char sccsid[] = "@(#)getmntinfo.c 8.1 (Berkeley) 6/4/93"; +#else +__RCSID("$NetBSD: getmntinfo.c,v 1.1 2010/07/26 15:53:00 pooka Exp $"); +#endif +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#define getvfsstat(a,b,c) rump_sys_getvfsstat(a,b,c) + +/* + * Return information about mounted filesystems. + */ +int +getmntinfo(mntbufp, flags) + struct statvfs **mntbufp; + int flags; +{ + static struct statvfs *mntbuf; + static int mntsize; + static size_t bufsize; + + _DIAGASSERT(mntbufp != NULL); + + if (mntsize <= 0 && + (mntsize = getvfsstat(NULL, (size_t)0, MNT_NOWAIT)) == -1) + return (0); + if (bufsize > 0 && + (mntsize = getvfsstat(mntbuf, bufsize, flags)) == -1) + return (0); + while (bufsize <= mntsize * sizeof(struct statvfs)) { + if (mntbuf) + free(mntbuf); + bufsize = (mntsize + 1) * sizeof(struct statvfs); + if ((mntbuf = malloc(bufsize)) == NULL) + return (0); + if ((mntsize = getvfsstat(mntbuf, bufsize, flags)) == -1) + return (0); + } + *mntbufp = mntbuf; + return (mntsize); +} diff --git a/contrib/netbsd-tests/fs/nfs/nfsservice/mountd.c b/contrib/netbsd-tests/fs/nfs/nfsservice/mountd.c new file mode 100644 index 000000000000..b3625f684d15 --- /dev/null +++ b/contrib/netbsd-tests/fs/nfs/nfsservice/mountd.c @@ -0,0 +1,2575 @@ +/* $NetBSD: mountd.c,v 1.8 2013/10/19 17:45:00 christos Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Herb Hasler and Rick Macklem at The University of Guelph. + * + * 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. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 +#ifndef lint +__COPYRIGHT("@(#) Copyright (c) 1989, 1993\ + The Regents of the University of California. All rights reserved."); +#endif /* not lint */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; +#else +__RCSID("$NetBSD: mountd.c,v 1.8 2013/10/19 17:45:00 christos Exp $"); +#endif +#endif /* not lint */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "pathnames.h" + +#ifdef IPSEC +#include +#ifndef IPSEC_POLICY_IPSEC /* no ipsec support on old ipsec */ +#undef IPSEC +#endif +#include "ipsec.h" +#endif + +#include "svc_fdset.h" + +#include + +/* + * Structures for keeping the mount list and export list + */ +struct mountlist { + struct mountlist *ml_next; + char ml_host[RPCMNT_NAMELEN + 1]; + char ml_dirp[RPCMNT_PATHLEN + 1]; + int ml_flag;/* XXX more flags (same as dp_flag) */ +}; + +struct dirlist { + struct dirlist *dp_left; + struct dirlist *dp_right; + int dp_flag; + struct hostlist *dp_hosts; /* List of hosts this dir exported to */ + char dp_dirp[1]; /* Actually malloc'd to size of dir */ +}; +/* dp_flag bits */ +#define DP_DEFSET 0x1 +#define DP_HOSTSET 0x2 +#define DP_KERB 0x4 +#define DP_NORESMNT 0x8 + +struct exportlist { + struct exportlist *ex_next; + struct dirlist *ex_dirl; + struct dirlist *ex_defdir; + int ex_flag; + fsid_t ex_fs; + char *ex_fsdir; + char *ex_indexfile; +}; +/* ex_flag bits */ +#define EX_LINKED 0x1 + +struct netmsk { + struct sockaddr_storage nt_net; + int nt_len; + char *nt_name; +}; + +union grouptypes { + struct addrinfo *gt_addrinfo; + struct netmsk gt_net; +}; + +struct grouplist { + int gr_type; + union grouptypes gr_ptr; + struct grouplist *gr_next; +}; +/* Group types */ +#define GT_NULL 0x0 +#define GT_HOST 0x1 +#define GT_NET 0x2 + +struct hostlist { + int ht_flag;/* Uses DP_xx bits */ + struct grouplist *ht_grp; + struct hostlist *ht_next; +}; + +struct fhreturn { + int fhr_flag; + int fhr_vers; + size_t fhr_fhsize; + union { + uint8_t v2[NFSX_V2FH]; + uint8_t v3[NFSX_V3FHMAX]; + } fhr_fh; +}; + +/* Global defs */ +static char *add_expdir __P((struct dirlist **, char *, int)); +static void add_dlist __P((struct dirlist **, struct dirlist *, + struct grouplist *, int)); +static void add_mlist __P((char *, char *, int)); +static int check_dirpath __P((const char *, size_t, char *)); +static int check_options __P((const char *, size_t, struct dirlist *)); +static int chk_host __P((struct dirlist *, struct sockaddr *, int *, int *)); +static int del_mlist __P((char *, char *, struct sockaddr *)); +static struct dirlist *dirp_search __P((struct dirlist *, char *)); +static int do_nfssvc __P((const char *, size_t, struct exportlist *, + struct grouplist *, int, struct uucred *, char *, int, struct statvfs *)); +static int do_opt __P((const char *, size_t, char **, char **, + struct exportlist *, struct grouplist *, int *, int *, struct uucred *)); +static struct exportlist *ex_search __P((fsid_t *)); +static int parse_directory __P((const char *, size_t, struct grouplist *, + int, char *, struct exportlist **, struct statvfs *)); +static int parse_host_netgroup __P((const char *, size_t, struct exportlist *, + struct grouplist *, char *, int *, struct grouplist **)); +static struct exportlist *get_exp __P((void)); +static void free_dir __P((struct dirlist *)); +static void free_exp __P((struct exportlist *)); +static void free_grp __P((struct grouplist *)); +static void free_host __P((struct hostlist *)); +void get_exportlist __P((int)); +static int get_host __P((const char *, size_t, const char *, + struct grouplist *)); +static struct hostlist *get_ht __P((void)); +static void get_mountlist __P((void)); +static int get_net __P((char *, struct netmsk *, int)); +static void free_exp_grp __P((struct exportlist *, struct grouplist *)); +static struct grouplist *get_grp __P((void)); +static void hang_dirp __P((struct dirlist *, struct grouplist *, + struct exportlist *, int)); +static void mntsrv __P((struct svc_req *, SVCXPRT *)); +static void nextfield __P((char **, char **)); +static void parsecred __P((char *, struct uucred *)); +static int put_exlist __P((struct dirlist *, XDR *, struct dirlist *, int *)); +static int scan_tree __P((struct dirlist *, struct sockaddr *)); +static void send_umntall __P((int)); +#if 0 +static int umntall_each __P((caddr_t, struct sockaddr_in *)); +#endif +static int xdr_dir __P((XDR *, char *)); +static int xdr_explist __P((XDR *, caddr_t)); +static int xdr_fhs __P((XDR *, caddr_t)); +static int xdr_mlist __P((XDR *, caddr_t)); +static int bitcmp __P((void *, void *, int)); +static int netpartcmp __P((struct sockaddr *, struct sockaddr *, int)); +static int sacmp __P((struct sockaddr *, struct sockaddr *)); +static int allones __P((struct sockaddr_storage *, int)); +static int countones __P((struct sockaddr *)); +static void bind_resv_port __P((int, sa_family_t, in_port_t)); +static void no_nfs(int); +static struct exportlist *exphead; +static struct mountlist *mlhead; +static struct grouplist *grphead; +static char *exname; +static struct uucred def_anon = { + 1, + (uid_t) -2, + (gid_t) -2, + 0, + { 0 } +}; + +static int opt_flags; +static int have_v6 = 1; +static const int ninumeric = NI_NUMERICHOST; + +/* Bits for above */ +#define OP_MAPROOT 0x001 +#define OP_MAPALL 0x002 +#define OP_KERB 0x004 +#define OP_MASK 0x008 +#define OP_NET 0x010 +#define OP_ALLDIRS 0x040 +#define OP_NORESPORT 0x080 +#define OP_NORESMNT 0x100 +#define OP_MASKLEN 0x200 + +static int debug = 1; +#if 0 +static void SYSLOG __P((int, const char *,...)); +#endif +int main __P((int, char *[])); + +/* + * If this is non-zero, -noresvport and -noresvmnt are implied for + * each export. + */ +static int noprivports; + +#define C2FD(_c_) ((int)(uintptr_t)(_c_)) +static int +rumpread(void *cookie, char *buf, int count) +{ + + return rump_sys_read(C2FD(cookie), buf, count); +} + +static int +rumpwrite(void *cookie, const char *buf, int count) +{ + + return rump_sys_write(C2FD(cookie), buf, count); +} + +static off_t +rumpseek(void *cookie, off_t off, int whence) +{ + + return rump_sys_lseek(C2FD(cookie), off, whence); +} + +static int +rumpclose(void *cookie) +{ + + return rump_sys_close(C2FD(cookie)); +} + +int __sflags(const char *, int *); /* XXX */ +static FILE * +rumpfopen(const char *path, const char *opts) +{ + int fd, oflags; + + __sflags(opts, &oflags); + fd = rump_sys_open(path, oflags, 0777); + if (fd == -1) + return NULL; + + return funopen((void *)(uintptr_t)fd, + rumpread, rumpwrite, rumpseek, rumpclose); +} + +/* + * Make sure mountd signal handler is executed from a thread context + * instead of the signal handler. This avoids the signal handler + * ruining our kernel context. + */ +static sem_t exportsem; +static void +signal_get_exportlist(int sig) +{ + + sem_post(&exportsem); +} + +static void * +exportlist_thread(void *arg) +{ + + for (;;) { + sem_wait(&exportsem); + get_exportlist(0); + } + + return NULL; +} + +/* + * Mountd server for NFS mount protocol as described in: + * NFS: Network File System Protocol Specification, RFC1094, Appendix A + * The optional arguments are the exports file name + * default: _PATH_EXPORTS + * "-d" to enable debugging + * and "-n" to allow nonroot mount. + */ +void *mountd_main(void *); +void * +mountd_main(void *arg) +{ + SVCXPRT *udptransp, *tcptransp; + struct netconfig *udpconf, *tcpconf; + int udpsock, tcpsock; + int xcreated = 0; + int maxrec = RPC_MAXDATASIZE; + in_port_t forcedport = 0; + extern sem_t gensem; + pthread_t ptdummy; + + alloc_fdset(); + +#if 0 + while ((c = getopt(argc, argv, "dNnrp:" ADDOPTS)) != -1) + switch (c) { +#ifdef IPSEC + case 'P': + if (ipsecsetup_test(policy = optarg)) + errx(1, "Invalid ipsec policy `%s'", policy); + break; +#endif + case 'p': + /* A forced port "0" will dynamically allocate a port */ + forcedport = atoi(optarg); + break; + case 'd': + debug = 1; + break; + case 'N': + noprivports = 1; + break; + /* Compatibility */ + case 'n': + case 'r': + break; + default: + fprintf(stderr, "usage: %s [-dNn]" +#ifdef IPSEC + " [-P policy]" +#endif + " [-p port] [exportsfile]\n", getprogname()); + exit(1); + }; + argc -= optind; + argv += optind; +#endif + + sem_init(&exportsem, 0, 0); + pthread_create(&ptdummy, NULL, exportlist_thread, NULL); + + grphead = NULL; + exphead = NULL; + mlhead = NULL; + exname = _PATH_EXPORTS; + openlog("mountd", LOG_PID | (debug ? LOG_PERROR : 0), LOG_DAEMON); + (void)signal(SIGSYS, no_nfs); + + if (debug) + (void)fprintf(stderr, "Getting export list.\n"); + get_exportlist(0); + if (debug) + (void)fprintf(stderr, "Getting mount list.\n"); + get_mountlist(); + if (debug) + (void)fprintf(stderr, "Here we go.\n"); + if (debug == 0) { + daemon(0, 0); + (void)signal(SIGINT, SIG_IGN); + (void)signal(SIGQUIT, SIG_IGN); + } + (void)signal(SIGHUP, signal_get_exportlist); + (void)signal(SIGTERM, send_umntall); + pidfile(NULL); + + rpcb_unset(RPCPROG_MNT, RPCMNT_VER1, NULL); + rpcb_unset(RPCPROG_MNT, RPCMNT_VER3, NULL); + + udpsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + tcpsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + + udpconf = getnetconfigent("udp"); + tcpconf = getnetconfigent("tcp"); + + rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec); + + if (udpsock != -1 && udpconf != NULL) { + bind_resv_port(udpsock, AF_INET, forcedport); +#ifdef IPSEC + if (policy) + ipsecsetup(AF_INET, udpsock, policy); +#endif + udptransp = svc_dg_create(udpsock, 0, 0); + if (udptransp != NULL) { + if (!svc_reg(udptransp, RPCPROG_MNT, RPCMNT_VER1, + mntsrv, udpconf) || + !svc_reg(udptransp, RPCPROG_MNT, RPCMNT_VER3, + mntsrv, udpconf)) { + syslog(LOG_WARNING, "can't register UDP service"); + } + else { + xcreated++; + } + } else { + syslog(LOG_WARNING, "can't create UDP service"); + } + + } + + if (tcpsock != -1 && tcpconf != NULL) { + bind_resv_port(tcpsock, AF_INET, forcedport); +#ifdef IPSEC + if (policy) + ipsecsetup(AF_INET, tcpsock, policy); +#endif + listen(tcpsock, SOMAXCONN); + tcptransp = svc_vc_create(tcpsock, RPC_MAXDATASIZE, + RPC_MAXDATASIZE); + if (tcptransp != NULL) { + if (!svc_reg(tcptransp, RPCPROG_MNT, RPCMNT_VER1, + mntsrv, tcpconf) || + !svc_reg(tcptransp, RPCPROG_MNT, RPCMNT_VER3, + mntsrv, tcpconf)) + syslog(LOG_WARNING, "can't register TCP service"); + else + xcreated++; + } else + syslog(LOG_WARNING, "can't create TCP service"); + + } + + if (xcreated == 0) { + syslog(LOG_ERR, "could not create any services"); + exit(1); + } + + sem_post(&gensem); + svc_run(); + syslog(LOG_ERR, "Mountd died"); + exit(1); +} + +/* + * The mount rpc service + */ +void +mntsrv(rqstp, transp) + struct svc_req *rqstp; + SVCXPRT *transp; +{ + struct exportlist *ep; + struct dirlist *dp; + struct fhreturn fhr; + struct stat stb; + struct statvfs fsb; + char host[NI_MAXHOST], numerichost[NI_MAXHOST]; + int lookup_failed = 1; + struct sockaddr *saddr; + u_short sport; + char rpcpath[RPCMNT_PATHLEN + 1], dpath[MAXPATHLEN]; + long bad = EACCES; + int defset, hostset, ret; + sigset_t sighup_mask; + struct sockaddr_in6 *sin6; + struct sockaddr_in *sin; + size_t fh_size; + int error = 0; + + (void)sigemptyset(&sighup_mask); + (void)sigaddset(&sighup_mask, SIGHUP); + saddr = svc_getrpccaller(transp)->buf; + switch (saddr->sa_family) { + case AF_INET6: + sin6 = (struct sockaddr_in6 *)saddr; + sport = ntohs(sin6->sin6_port); + break; + case AF_INET: + sin = (struct sockaddr_in *)saddr; + sport = ntohs(sin->sin_port); + break; + default: + syslog(LOG_ERR, "request from unknown address family"); + return; + } + lookup_failed = getnameinfo(saddr, saddr->sa_len, host, sizeof host, + NULL, 0, 0); + if (getnameinfo(saddr, saddr->sa_len, numerichost, + sizeof numerichost, NULL, 0, ninumeric) != 0) + strlcpy(numerichost, "?", sizeof(numerichost)); + ret = 0; + switch (rqstp->rq_proc) { + case NULLPROC: + if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) + syslog(LOG_ERR, "Can't send reply"); + return; + case MOUNTPROC_MNT: + if (debug) + fprintf(stderr, + "got mount request from %s\n", numerichost); + if (!svc_getargs(transp, xdr_dir, rpcpath)) { + if (debug) + fprintf(stderr, "-> garbage args\n"); + svcerr_decode(transp); + return; + } + if (debug) + fprintf(stderr, + "-> rpcpath: %s\n", rpcpath); + /* + * Get the real pathname and make sure it is a file or + * directory that exists. + */ +#if 0 + if (realpath(rpcpath, dpath) == 0 || +#endif + strcpy(dpath, rpcpath); + if (rump_sys_stat(dpath, &stb) < 0 || + (!S_ISDIR(stb.st_mode) && !S_ISREG(stb.st_mode)) || + rump_sys_statvfs1(dpath, &fsb, ST_WAIT) < 0) { + (void)chdir("/"); /* Just in case realpath doesn't */ + if (debug) + (void)fprintf(stderr, "-> stat failed on %s\n", + dpath); + if (!svc_sendreply(transp, (xdrproc_t)xdr_long, (caddr_t) &bad)) + syslog(LOG_ERR, "Can't send reply"); + return; + } + if (debug) + fprintf(stderr, + "-> dpath: %s\n", dpath); + /* Check in the exports list */ + (void)sigprocmask(SIG_BLOCK, &sighup_mask, NULL); + ep = ex_search(&fsb.f_fsidx); + hostset = defset = 0; + if (ep && (chk_host(ep->ex_defdir, saddr, &defset, + &hostset) || ((dp = dirp_search(ep->ex_dirl, dpath)) && + chk_host(dp, saddr, &defset, &hostset)) || + (defset && scan_tree(ep->ex_defdir, saddr) == 0 && + scan_tree(ep->ex_dirl, saddr) == 0))) { + if ((hostset & DP_HOSTSET) == 0) { + hostset = defset; + } + if (sport >= IPPORT_RESERVED && + !(hostset & DP_NORESMNT)) { + syslog(LOG_NOTICE, + "Refused mount RPC from host %s port %d", + numerichost, sport); + svcerr_weakauth(transp); + goto out; + } + fhr.fhr_flag = hostset; + fhr.fhr_vers = rqstp->rq_vers; + /* Get the file handle */ + memset(&fhr.fhr_fh, 0, sizeof(fhr.fhr_fh)); /* for v2 */ + fh_size = sizeof(fhr.fhr_fh); + error = 0; + if (rump_sys_getfh(dpath, &fhr.fhr_fh, &fh_size) < 0) { + bad = error; + //syslog(LOG_ERR, "Can't get fh for %s %d %d", dpath, error, fh_size); + if (!svc_sendreply(transp, (xdrproc_t)xdr_long, + (char *)&bad)) + syslog(LOG_ERR, "Can't send reply"); + goto out; + } + if ((fhr.fhr_vers == 1 && fh_size > NFSX_V2FH) || + fh_size > NFSX_V3FHMAX) { + bad = EINVAL; /* XXX */ + if (!svc_sendreply(transp, (xdrproc_t)xdr_long, + (char *)&bad)) + syslog(LOG_ERR, "Can't send reply"); + goto out; + } + fhr.fhr_fhsize = fh_size; + if (!svc_sendreply(transp, (xdrproc_t)xdr_fhs, (char *) &fhr)) + syslog(LOG_ERR, "Can't send reply"); + if (!lookup_failed) + add_mlist(host, dpath, hostset); + else + add_mlist(numerichost, dpath, hostset); + if (debug) + (void)fprintf(stderr, "Mount successful.\n"); + } else { + if (!svc_sendreply(transp, (xdrproc_t)xdr_long, (caddr_t) &bad)) + syslog(LOG_ERR, "Can't send reply"); + } +out: + (void)sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); + return; + case MOUNTPROC_DUMP: + if (!svc_sendreply(transp, (xdrproc_t)xdr_mlist, NULL)) + syslog(LOG_ERR, "Can't send reply"); + return; + case MOUNTPROC_UMNT: + if (!svc_getargs(transp, xdr_dir, dpath)) { + svcerr_decode(transp); + return; + } + if (!lookup_failed) + ret = del_mlist(host, dpath, saddr); + ret |= del_mlist(numerichost, dpath, saddr); + if (ret) { + svcerr_weakauth(transp); + return; + } + if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) + syslog(LOG_ERR, "Can't send reply"); + return; + case MOUNTPROC_UMNTALL: + if (!lookup_failed) + ret = del_mlist(host, NULL, saddr); + ret |= del_mlist(numerichost, NULL, saddr); + if (ret) { + svcerr_weakauth(transp); + return; + } + if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) + syslog(LOG_ERR, "Can't send reply"); + return; + case MOUNTPROC_EXPORT: + case MOUNTPROC_EXPORTALL: + if (!svc_sendreply(transp, (xdrproc_t)xdr_explist, NULL)) + syslog(LOG_ERR, "Can't send reply"); + return; + + + default: + svcerr_noproc(transp); + return; + } +} + +/* + * Xdr conversion for a dpath string + */ +static int +xdr_dir(xdrsp, dirp) + XDR *xdrsp; + char *dirp; +{ + + return (xdr_string(xdrsp, &dirp, RPCMNT_PATHLEN)); +} + +/* + * Xdr routine to generate file handle reply + */ +static int +xdr_fhs(xdrsp, cp) + XDR *xdrsp; + caddr_t cp; +{ + struct fhreturn *fhrp = (struct fhreturn *) cp; + long ok = 0, len, auth; + + if (!xdr_long(xdrsp, &ok)) + return (0); + switch (fhrp->fhr_vers) { + case 1: + return (xdr_opaque(xdrsp, (caddr_t)&fhrp->fhr_fh, NFSX_V2FH)); + case 3: + len = fhrp->fhr_fhsize; + if (!xdr_long(xdrsp, &len)) + return (0); + if (!xdr_opaque(xdrsp, (caddr_t)&fhrp->fhr_fh, len)) + return (0); + if (fhrp->fhr_flag & DP_KERB) + auth = RPCAUTH_KERB4; + else + auth = RPCAUTH_UNIX; + len = 1; + if (!xdr_long(xdrsp, &len)) + return (0); + return (xdr_long(xdrsp, &auth)); + }; + return (0); +} + +int +xdr_mlist(xdrsp, cp) + XDR *xdrsp; + caddr_t cp; +{ + struct mountlist *mlp; + int trueval = 1; + int falseval = 0; + char *strp; + + mlp = mlhead; + while (mlp) { + if (!xdr_bool(xdrsp, &trueval)) + return (0); + strp = &mlp->ml_host[0]; + if (!xdr_string(xdrsp, &strp, RPCMNT_NAMELEN)) + return (0); + strp = &mlp->ml_dirp[0]; + if (!xdr_string(xdrsp, &strp, RPCMNT_PATHLEN)) + return (0); + mlp = mlp->ml_next; + } + if (!xdr_bool(xdrsp, &falseval)) + return (0); + return (1); +} + +/* + * Xdr conversion for export list + */ +int +xdr_explist(xdrsp, cp) + XDR *xdrsp; + caddr_t cp; +{ + struct exportlist *ep; + int falseval = 0; + int putdef; + sigset_t sighup_mask; + + (void)sigemptyset(&sighup_mask); + (void)sigaddset(&sighup_mask, SIGHUP); + (void)sigprocmask(SIG_BLOCK, &sighup_mask, NULL); + ep = exphead; + while (ep) { + putdef = 0; + if (put_exlist(ep->ex_dirl, xdrsp, ep->ex_defdir, &putdef)) + goto errout; + if (ep->ex_defdir && putdef == 0 && + put_exlist(ep->ex_defdir, xdrsp, NULL, &putdef)) + goto errout; + ep = ep->ex_next; + } + (void)sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); + if (!xdr_bool(xdrsp, &falseval)) + return (0); + return (1); +errout: + (void)sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL); + return (0); +} + +/* + * Called from xdr_explist() to traverse the tree and export the + * directory paths. Assumes SIGHUP has already been masked. + */ +int +put_exlist(dp, xdrsp, adp, putdefp) + struct dirlist *dp; + XDR *xdrsp; + struct dirlist *adp; + int *putdefp; +{ + struct grouplist *grp; + struct hostlist *hp; + int trueval = 1; + int falseval = 0; + int gotalldir = 0; + char *strp; + + if (dp) { + if (put_exlist(dp->dp_left, xdrsp, adp, putdefp)) + return (1); + if (!xdr_bool(xdrsp, &trueval)) + return (1); + strp = dp->dp_dirp; + if (!xdr_string(xdrsp, &strp, RPCMNT_PATHLEN)) + return (1); + if (adp && !strcmp(dp->dp_dirp, adp->dp_dirp)) { + gotalldir = 1; + *putdefp = 1; + } + if ((dp->dp_flag & DP_DEFSET) == 0 && + (gotalldir == 0 || (adp->dp_flag & DP_DEFSET) == 0)) { + hp = dp->dp_hosts; + while (hp) { + grp = hp->ht_grp; + if (grp->gr_type == GT_HOST) { + if (!xdr_bool(xdrsp, &trueval)) + return (1); + strp = + grp->gr_ptr.gt_addrinfo->ai_canonname; + if (!xdr_string(xdrsp, &strp, + RPCMNT_NAMELEN)) + return (1); + } else if (grp->gr_type == GT_NET) { + if (!xdr_bool(xdrsp, &trueval)) + return (1); + strp = grp->gr_ptr.gt_net.nt_name; + if (!xdr_string(xdrsp, &strp, + RPCMNT_NAMELEN)) + return (1); + } + hp = hp->ht_next; + if (gotalldir && hp == NULL) { + hp = adp->dp_hosts; + gotalldir = 0; + } + } + } + if (!xdr_bool(xdrsp, &falseval)) + return (1); + if (put_exlist(dp->dp_right, xdrsp, adp, putdefp)) + return (1); + } + return (0); +} + +static int +parse_host_netgroup(line, lineno, ep, tgrp, cp, has_host, grp) + const char *line; + size_t lineno; + struct exportlist *ep; + struct grouplist *tgrp; + char *cp; + int *has_host; + struct grouplist **grp; +{ + const char *hst, *usr, *dom; + int netgrp; + + if (ep == NULL) { + syslog(LOG_ERR, "\"%s\", line %ld: No current export", + line, (unsigned long)lineno); + return 0; + } + setnetgrent(cp); + netgrp = getnetgrent(&hst, &usr, &dom); + do { + if (*has_host) { + (*grp)->gr_next = get_grp(); + *grp = (*grp)->gr_next; + } + if (netgrp) { + if (hst == NULL) { + syslog(LOG_ERR, + "\"%s\", line %ld: No host in netgroup %s", + line, (unsigned long)lineno, cp); + goto bad; + } + if (get_host(line, lineno, hst, *grp)) + goto bad; + } else if (get_host(line, lineno, cp, *grp)) + goto bad; + *has_host = TRUE; + } while (netgrp && getnetgrent(&hst, &usr, &dom)); + + endnetgrent(); + return 1; +bad: + endnetgrent(); + return 0; + +} + +static int +parse_directory(line, lineno, tgrp, got_nondir, cp, ep, fsp) + const char *line; + size_t lineno; + struct grouplist *tgrp; + int got_nondir; + char *cp; + struct exportlist **ep; + struct statvfs *fsp; +{ + int error = 0; + + if (!check_dirpath(line, lineno, cp)) + return 0; + + if (rump_sys_statvfs1(cp, fsp, ST_WAIT) == -1) { + syslog(LOG_ERR, "\"%s\", line %ld: statvfs for `%s' failed: %m %d", + line, (unsigned long)lineno, cp, error); + return 0; + } + + if (got_nondir) { + syslog(LOG_ERR, + "\"%s\", line %ld: Directories must precede files", + line, (unsigned long)lineno); + return 0; + } + if (*ep) { + if ((*ep)->ex_fs.__fsid_val[0] != fsp->f_fsidx.__fsid_val[0] || + (*ep)->ex_fs.__fsid_val[1] != fsp->f_fsidx.__fsid_val[1]) { + syslog(LOG_ERR, + "\"%s\", line %ld: filesystem ids disagree", + line, (unsigned long)lineno); + return 0; + } + } else { + /* + * See if this directory is already + * in the list. + */ + *ep = ex_search(&fsp->f_fsidx); + if (*ep == NULL) { + *ep = get_exp(); + (*ep)->ex_fs = fsp->f_fsidx; + (*ep)->ex_fsdir = estrdup(fsp->f_mntonname); + if (debug) + (void)fprintf(stderr, + "Making new ep fs=0x%x,0x%x\n", + fsp->f_fsidx.__fsid_val[0], fsp->f_fsidx.__fsid_val[1]); + } else { + if (debug) + (void)fprintf(stderr, + "Found ep fs=0x%x,0x%x\n", + fsp->f_fsidx.__fsid_val[0], fsp->f_fsidx.__fsid_val[1]); + } + } + + return 1; +} + + +/* + * Get the export list + */ +/* ARGSUSED */ +void +get_exportlist(n) + int n; +{ + struct exportlist *ep, *ep2; + struct grouplist *grp, *tgrp; + struct exportlist **epp; + struct dirlist *dirhead; + struct statvfs fsb, *fsp; + struct addrinfo *ai; + struct uucred anon; + char *cp, *endcp, *dirp, savedc; + int has_host, exflags, got_nondir, dirplen, num, i; + FILE *exp_file; + char *line; + size_t lineno = 0, len; + + + /* + * First, get rid of the old list + */ + ep = exphead; + while (ep) { + ep2 = ep; + ep = ep->ex_next; + free_exp(ep2); + } + exphead = NULL; + + dirp = NULL; + dirplen = 0; + grp = grphead; + while (grp) { + tgrp = grp; + grp = grp->gr_next; + free_grp(tgrp); + } + grphead = NULL; + + /* + * And delete exports that are in the kernel for all local + * file systems. + */ + num = getmntinfo(&fsp, MNT_NOWAIT); + for (i = 0; i < num; i++) { + struct mountd_exports_list mel; + + /* Delete all entries from the export list. */ + mel.mel_path = fsp->f_mntonname; + mel.mel_nexports = 0; + if (rump_sys_nfssvc(NFSSVC_SETEXPORTSLIST, &mel) == -1 && + errno != EOPNOTSUPP) + syslog(LOG_ERR, "Can't delete exports for %s (%m)", + fsp->f_mntonname); + + fsp++; + } + + /* + * Read in the exports file and build the list, calling + * mount() as we go along to push the export rules into the kernel. + */ + exname = _PATH_EXPORTS; + if ((exp_file = rumpfopen(exname, "r")) == NULL) { + /* + * Don't exit here; we can still reload the config + * after a SIGHUP. + */ + if (debug) + (void)fprintf(stderr, "Can't open %s: %s\n", exname, + strerror(errno)); + return; + } + dirhead = NULL; + while ((line = fparseln(exp_file, &len, &lineno, NULL, 0)) != NULL) { + if (debug) + (void)fprintf(stderr, "Got line %s\n", line); + cp = line; + nextfield(&cp, &endcp); + if (cp == endcp) + goto nextline; /* skip empty line */ + /* + * Set defaults. + */ + has_host = FALSE; + anon = def_anon; + exflags = MNT_EXPORTED; + got_nondir = 0; + opt_flags = 0; + ep = NULL; + + if (noprivports) { + opt_flags |= OP_NORESMNT | OP_NORESPORT; + exflags |= MNT_EXNORESPORT; + } + + /* + * Create new exports list entry + */ + len = endcp - cp; + tgrp = grp = get_grp(); + while (len > 0) { + if (len > RPCMNT_NAMELEN) { + *endcp = '\0'; + syslog(LOG_ERR, + "\"%s\", line %ld: name `%s' is too long", + line, (unsigned long)lineno, cp); + goto badline; + } + switch (*cp) { + case '-': + /* + * Option + */ + if (ep == NULL) { + syslog(LOG_ERR, + "\"%s\", line %ld: No current export list", + line, (unsigned long)lineno); + goto badline; + } + if (debug) + (void)fprintf(stderr, "doing opt %s\n", + cp); + got_nondir = 1; + if (do_opt(line, lineno, &cp, &endcp, ep, grp, + &has_host, &exflags, &anon)) + goto badline; + break; + + case '/': + /* + * Directory + */ + savedc = *endcp; + *endcp = '\0'; + + if (!parse_directory(line, lineno, tgrp, + got_nondir, cp, &ep, &fsb)) + goto badline; + /* + * Add dirpath to export mount point. + */ + dirp = add_expdir(&dirhead, cp, len); + dirplen = len; + + *endcp = savedc; + break; + + default: + /* + * Host or netgroup. + */ + savedc = *endcp; + *endcp = '\0'; + + if (!parse_host_netgroup(line, lineno, ep, + tgrp, cp, &has_host, &grp)) + goto badline; + + got_nondir = 1; + + *endcp = savedc; + break; + } + + cp = endcp; + nextfield(&cp, &endcp); + len = endcp - cp; + } + if (check_options(line, lineno, dirhead)) + goto badline; + + if (!has_host) { + grp->gr_type = GT_HOST; + if (debug) + (void)fprintf(stderr, + "Adding a default entry\n"); + /* add a default group and make the grp list NULL */ + ai = emalloc(sizeof(struct addrinfo)); + ai->ai_flags = 0; + ai->ai_family = AF_INET; /* XXXX */ + ai->ai_socktype = SOCK_DGRAM; + /* setting the length to 0 will match anything */ + ai->ai_addrlen = 0; + ai->ai_flags = AI_CANONNAME; + ai->ai_canonname = estrdup("Default"); + ai->ai_addr = NULL; + ai->ai_next = NULL; + grp->gr_ptr.gt_addrinfo = ai; + + } else if ((opt_flags & OP_NET) && tgrp->gr_next) { + /* + * Don't allow a network export coincide with a list of + * host(s) on the same line. + */ + syslog(LOG_ERR, + "\"%s\", line %ld: Mixed exporting of networks and hosts is disallowed", + line, (unsigned long)lineno); + goto badline; + } + /* + * Loop through hosts, pushing the exports into the kernel. + * After loop, tgrp points to the start of the list and + * grp points to the last entry in the list. + */ + grp = tgrp; + do { + if (do_nfssvc(line, lineno, ep, grp, exflags, &anon, + dirp, dirplen, &fsb)) + goto badline; + } while (grp->gr_next && (grp = grp->gr_next)); + + /* + * Success. Update the data structures. + */ + if (has_host) { + hang_dirp(dirhead, tgrp, ep, opt_flags); + grp->gr_next = grphead; + grphead = tgrp; + } else { + hang_dirp(dirhead, NULL, ep, opt_flags); + free_grp(tgrp); + } + tgrp = NULL; + dirhead = NULL; + if ((ep->ex_flag & EX_LINKED) == 0) { + ep2 = exphead; + epp = &exphead; + + /* + * Insert in the list in alphabetical order. + */ + while (ep2 && strcmp(ep2->ex_fsdir, ep->ex_fsdir) < 0) { + epp = &ep2->ex_next; + ep2 = ep2->ex_next; + } + if (ep2) + ep->ex_next = ep2; + *epp = ep; + ep->ex_flag |= EX_LINKED; + } + goto nextline; +badline: + free_exp_grp(ep, grp); +nextline: + if (dirhead) { + free_dir(dirhead); + dirhead = NULL; + } + free(line); + } + (void)fclose(exp_file); +} + +/* + * Allocate an export list element + */ +static struct exportlist * +get_exp() +{ + struct exportlist *ep; + + ep = emalloc(sizeof(struct exportlist)); + (void)memset(ep, 0, sizeof(struct exportlist)); + return (ep); +} + +/* + * Allocate a group list element + */ +static struct grouplist * +get_grp() +{ + struct grouplist *gp; + + gp = emalloc(sizeof(struct grouplist)); + (void)memset(gp, 0, sizeof(struct grouplist)); + return (gp); +} + +/* + * Clean up upon an error in get_exportlist(). + */ +static void +free_exp_grp(ep, grp) + struct exportlist *ep; + struct grouplist *grp; +{ + struct grouplist *tgrp; + + if (ep && (ep->ex_flag & EX_LINKED) == 0) + free_exp(ep); + while (grp) { + tgrp = grp; + grp = grp->gr_next; + free_grp(tgrp); + } +} + +/* + * Search the export list for a matching fs. + */ +static struct exportlist * +ex_search(fsid) + fsid_t *fsid; +{ + struct exportlist *ep; + + ep = exphead; + return ep; + while (ep) { + if (ep->ex_fs.__fsid_val[0] == fsid->__fsid_val[0] && + ep->ex_fs.__fsid_val[1] == fsid->__fsid_val[1]) + return (ep); + ep = ep->ex_next; + } + return (ep); +} + +/* + * Add a directory path to the list. + */ +static char * +add_expdir(dpp, cp, len) + struct dirlist **dpp; + char *cp; + int len; +{ + struct dirlist *dp; + + dp = emalloc(sizeof(struct dirlist) + len); + dp->dp_left = *dpp; + dp->dp_right = NULL; + dp->dp_flag = 0; + dp->dp_hosts = NULL; + (void)strcpy(dp->dp_dirp, cp); + *dpp = dp; + return (dp->dp_dirp); +} + +/* + * Hang the dir list element off the dirpath binary tree as required + * and update the entry for host. + */ +void +hang_dirp(dp, grp, ep, flags) + struct dirlist *dp; + struct grouplist *grp; + struct exportlist *ep; + int flags; +{ + struct hostlist *hp; + struct dirlist *dp2; + + if (flags & OP_ALLDIRS) { + if (ep->ex_defdir) + free(dp); + else + ep->ex_defdir = dp; + if (grp == NULL) { + ep->ex_defdir->dp_flag |= DP_DEFSET; + if (flags & OP_KERB) + ep->ex_defdir->dp_flag |= DP_KERB; + if (flags & OP_NORESMNT) + ep->ex_defdir->dp_flag |= DP_NORESMNT; + } else + while (grp) { + hp = get_ht(); + if (flags & OP_KERB) + hp->ht_flag |= DP_KERB; + if (flags & OP_NORESMNT) + hp->ht_flag |= DP_NORESMNT; + hp->ht_grp = grp; + hp->ht_next = ep->ex_defdir->dp_hosts; + ep->ex_defdir->dp_hosts = hp; + grp = grp->gr_next; + } + } else { + + /* + * Loop through the directories adding them to the tree. + */ + while (dp) { + dp2 = dp->dp_left; + add_dlist(&ep->ex_dirl, dp, grp, flags); + dp = dp2; + } + } +} + +/* + * Traverse the binary tree either updating a node that is already there + * for the new directory or adding the new node. + */ +static void +add_dlist(dpp, newdp, grp, flags) + struct dirlist **dpp; + struct dirlist *newdp; + struct grouplist *grp; + int flags; +{ + struct dirlist *dp; + struct hostlist *hp; + int cmp; + + dp = *dpp; + if (dp) { + cmp = strcmp(dp->dp_dirp, newdp->dp_dirp); + if (cmp > 0) { + add_dlist(&dp->dp_left, newdp, grp, flags); + return; + } else if (cmp < 0) { + add_dlist(&dp->dp_right, newdp, grp, flags); + return; + } else + free(newdp); + } else { + dp = newdp; + dp->dp_left = NULL; + *dpp = dp; + } + if (grp) { + + /* + * Hang all of the host(s) off of the directory point. + */ + do { + hp = get_ht(); + if (flags & OP_KERB) + hp->ht_flag |= DP_KERB; + if (flags & OP_NORESMNT) + hp->ht_flag |= DP_NORESMNT; + hp->ht_grp = grp; + hp->ht_next = dp->dp_hosts; + dp->dp_hosts = hp; + grp = grp->gr_next; + } while (grp); + } else { + dp->dp_flag |= DP_DEFSET; + if (flags & OP_KERB) + dp->dp_flag |= DP_KERB; + if (flags & OP_NORESMNT) + dp->dp_flag |= DP_NORESMNT; + } +} + +/* + * Search for a dirpath on the export point. + */ +static struct dirlist * +dirp_search(dp, dirp) + struct dirlist *dp; + char *dirp; +{ + int cmp; + + if (dp) { + cmp = strcmp(dp->dp_dirp, dirp); + if (cmp > 0) + return (dirp_search(dp->dp_left, dirp)); + else if (cmp < 0) + return (dirp_search(dp->dp_right, dirp)); + else + return (dp); + } + return (dp); +} + +/* + * Some helper functions for netmasks. They all assume masks in network + * order (big endian). + */ +static int +bitcmp(void *dst, void *src, int bitlen) +{ + int i; + u_int8_t *p1 = dst, *p2 = src; + u_int8_t bitmask; + int bytelen, bitsleft; + + bytelen = bitlen / 8; + bitsleft = bitlen % 8; + + if (debug) { + printf("comparing:\n"); + for (i = 0; i < (bitsleft ? bytelen + 1 : bytelen); i++) + printf("%02x", p1[i]); + printf("\n"); + for (i = 0; i < (bitsleft ? bytelen + 1 : bytelen); i++) + printf("%02x", p2[i]); + printf("\n"); + } + + for (i = 0; i < bytelen; i++) { + if (*p1 != *p2) + return 1; + p1++; + p2++; + } + + for (i = 0; i < bitsleft; i++) { + bitmask = 1 << (7 - i); + if ((*p1 & bitmask) != (*p2 & bitmask)) + return 1; + } + + return 0; +} + +static int +netpartcmp(struct sockaddr *s1, struct sockaddr *s2, int bitlen) +{ + void *src, *dst; + + if (s1->sa_family != s2->sa_family) + return 1; + + switch (s1->sa_family) { + case AF_INET: + src = &((struct sockaddr_in *)s1)->sin_addr; + dst = &((struct sockaddr_in *)s2)->sin_addr; + if (bitlen > sizeof(((struct sockaddr_in *)s1)->sin_addr) * 8) + return 1; + break; + case AF_INET6: + src = &((struct sockaddr_in6 *)s1)->sin6_addr; + dst = &((struct sockaddr_in6 *)s2)->sin6_addr; + if (((struct sockaddr_in6 *)s1)->sin6_scope_id != + ((struct sockaddr_in6 *)s2)->sin6_scope_id) + return 1; + if (bitlen > sizeof(((struct sockaddr_in6 *)s1)->sin6_addr) * 8) + return 1; + break; + default: + return 1; + } + + return bitcmp(src, dst, bitlen); +} + +static int +allones(struct sockaddr_storage *ssp, int bitlen) +{ + u_int8_t *p; + int bytelen, bitsleft, i; + int zerolen; + + switch (ssp->ss_family) { + case AF_INET: + p = (u_int8_t *)&((struct sockaddr_in *)ssp)->sin_addr; + zerolen = sizeof (((struct sockaddr_in *)ssp)->sin_addr); + break; + case AF_INET6: + p = (u_int8_t *)&((struct sockaddr_in6 *)ssp)->sin6_addr; + zerolen = sizeof (((struct sockaddr_in6 *)ssp)->sin6_addr); + break; + default: + return -1; + } + + memset(p, 0, zerolen); + + bytelen = bitlen / 8; + bitsleft = bitlen % 8; + + if (bytelen > zerolen) + return -1; + + for (i = 0; i < bytelen; i++) + *p++ = 0xff; + + for (i = 0; i < bitsleft; i++) + *p |= 1 << (7 - i); + + return 0; +} + +static int +countones(struct sockaddr *sa) +{ + void *mask; + int i, bits = 0, bytelen; + u_int8_t *p; + + switch (sa->sa_family) { + case AF_INET: + mask = (u_int8_t *)&((struct sockaddr_in *)sa)->sin_addr; + bytelen = 4; + break; + case AF_INET6: + mask = (u_int8_t *)&((struct sockaddr_in6 *)sa)->sin6_addr; + bytelen = 16; + break; + default: + return 0; + } + + p = mask; + + for (i = 0; i < bytelen; i++, p++) { + if (*p != 0xff) { + for (bits = 0; bits < 8; bits++) { + if (!(*p & (1 << (7 - bits)))) + break; + } + break; + } + } + + return (i * 8 + bits); +} + +static int +sacmp(struct sockaddr *sa1, struct sockaddr *sa2) +{ + void *p1, *p2; + int len; + + if (sa1->sa_family != sa2->sa_family) + return 1; + + switch (sa1->sa_family) { + case AF_INET: + p1 = &((struct sockaddr_in *)sa1)->sin_addr; + p2 = &((struct sockaddr_in *)sa2)->sin_addr; + len = 4; + break; + case AF_INET6: + p1 = &((struct sockaddr_in6 *)sa1)->sin6_addr; + p2 = &((struct sockaddr_in6 *)sa2)->sin6_addr; + len = 16; + if (((struct sockaddr_in6 *)sa1)->sin6_scope_id != + ((struct sockaddr_in6 *)sa2)->sin6_scope_id) + return 1; + break; + default: + return 1; + } + + return memcmp(p1, p2, len); +} + +/* + * Scan for a host match in a directory tree. + */ +static int +chk_host(dp, saddr, defsetp, hostsetp) + struct dirlist *dp; + struct sockaddr *saddr; + int *defsetp; + int *hostsetp; +{ + struct hostlist *hp; + struct grouplist *grp; + struct addrinfo *ai; + + if (dp) { + if (dp->dp_flag & DP_DEFSET) + *defsetp = dp->dp_flag; + hp = dp->dp_hosts; + while (hp) { + grp = hp->ht_grp; + switch (grp->gr_type) { + case GT_HOST: + ai = grp->gr_ptr.gt_addrinfo; + for (; ai; ai = ai->ai_next) { + if (!sacmp(ai->ai_addr, saddr)) { + *hostsetp = + (hp->ht_flag | DP_HOSTSET); + return (1); + } + } + break; + case GT_NET: + if (!netpartcmp(saddr, + (struct sockaddr *) + &grp->gr_ptr.gt_net.nt_net, + grp->gr_ptr.gt_net.nt_len)) { + *hostsetp = (hp->ht_flag | DP_HOSTSET); + return (1); + } + break; + }; + hp = hp->ht_next; + } + } + return (0); +} + +/* + * Scan tree for a host that matches the address. + */ +static int +scan_tree(dp, saddr) + struct dirlist *dp; + struct sockaddr *saddr; +{ + int defset, hostset; + + if (dp) { + if (scan_tree(dp->dp_left, saddr)) + return (1); + if (chk_host(dp, saddr, &defset, &hostset)) + return (1); + if (scan_tree(dp->dp_right, saddr)) + return (1); + } + return (0); +} + +/* + * Traverse the dirlist tree and free it up. + */ +static void +free_dir(dp) + struct dirlist *dp; +{ + + if (dp) { + free_dir(dp->dp_left); + free_dir(dp->dp_right); + free_host(dp->dp_hosts); + free(dp); + } +} + +/* + * Parse the option string and update fields. + * Option arguments may either be -in + atf_check -o inline:'x\n' sort in +} + +atf_test_case null_bytes +null_bytes_head() +{ + atf_set "descr" "Tests the behavior of null bytes" +} +null_bytes_body() +{ + printf '\0b\n\0a\n' >in + atf_check -o inline:'\0a\n\0b\n' sort -S in +} + +atf_test_case long_records +long_records_head() +{ + atf_set "descr" "Tests long lines and keys" +} +long_records_body() +{ + awk 'BEGIN { x="x" + for(i=1; i<=12; i++) x = x x + for(i=15; i<=25; i++) print x i +}' >in + + awk 'BEGIN { x="x" + for(i=1; i<=12; i++) x = x x + for(i=25; i>=15; i--) print x i +}' >out + + atf_check -o file:out sort -r in + atf_check -o file:out sort -k 1,1r -k 1 in +} + +atf_test_case long_file +long_file_head() +{ + atf_set "descr" "Tests with a long file to try to force intermediate" \ + "files" +} +long_file_body() +{ + awk 'BEGIN { for(i=0; i<20000; i++) print rand() }' >in + sort -S -r in | awk '$0 "x" != x { print ; x = $0 "x" }' >out + atf_check -o file:out sort -u -r in +} + +atf_test_case any_char +any_char_head() +{ + atf_set "descr" "Tests with files containing non-printable/extended" \ + "characters" +} +any_char_body() +{ + atf_check -o file:$(atf_get_srcdir)/d_any_char_dflag_out.txt \ + sort -d -k 2 $(atf_get_srcdir)/d_any_char_in.txt + + atf_check -o file:$(atf_get_srcdir)/d_any_char_fflag_out.txt \ + sort -f -k 2 $(atf_get_srcdir)/d_any_char_in.txt + + atf_check -o file:$(atf_get_srcdir)/d_any_char_iflag_out.txt \ + sort -i -k 2 $(atf_get_srcdir)/d_any_char_in.txt +} + +atf_test_case bflag +bflag_head() +{ + atf_set "descr" "Tests the -b flag" +} +bflag_body() +{ + cat >in <in <in <expout <in <expout <in <out <in <in <in <out <in <xx" + atf_check -e ignore sort -c -t: -k2n xx + + atf_check -x "sort -S -k2,2.1b -k2 in >xx" + atf_check -e ignore sort -c -t: -k3n xx + + atf_check -x "sort -S -k2.3 -k2 in >xx" + atf_check -e ignore sort -c -t: -k4n xx + + atf_check -x "sort -S -k2b,2.3 -k2 in >xx" + atf_check -e ignore sort -c -t: -k5n xx + + atf_check -x "sort -S -k2.3,2.1b -k2 in >xx" + atf_check -e ignore sort -c -t: -k6n xx + + atf_check -x "sort -S -k2,2.1b -k2r in >xx" + atf_check -e ignore sort -c -t: -k7n xx + + atf_check -x "sort -S -b -k2,2 -k2 in >xx" + atf_check -e ignore sort -c -t: -k8n xx + + # XXX This test is broken. The standard is not clear on the behavior. + #atf_check -x "sort -S -b -k2,2b -k2 in >xx" + #atf_check -e ignore sort -c -t: -k3n xx +} + +atf_test_case kflag_no_end +kflag_no_end_head() +{ + atf_set "descr" "Tests the -k flag with a field without end" +} +kflag_no_end_body() +{ + cat >in <out <in1 <in2 <out <in <in <out <in <expout <in <expout <in <expout <in <expout <in <out <in1 <in2 <out <in <in <in <out <in <out <out <out <in <expout <in <expout <in <expout <in <expout <./+0 + + atf_check -o file:+0 sort -- +0 +} + +atf_test_case plus_nonmonotone +plus_nonmonotone_head() +{ + atf_set "descr" "Tests += addressing: apparently nonmonotone field" \ + "specs" +} +plus_nonmonotone_body() +{ + cat >in <./+0 + echo 'more contents' >in + cat ./+0 in >expout + + atf_check -o file:expout sort in +0 +} + +atf_test_case plus_bad_tempfile +plus_bad_tempfile_head() +{ + atf_set "descr" "Tests +- addressing: intermediate wrong behavior" \ + "that raised a '+0: No such file or directory' error" +} +plus_bad_tempfile_body() +{ + echo 'good contents' >in + atf_check -o file:in sort -T /tmp +0 in +} + +atf_test_case plus_rflag_invalid +plus_rflag_invalid_head() +{ + atf_set "descr" "Tests +- addressing: invalid record delimiter" +} +plus_rflag_invalid_body() +{ + ( + echo 'z b m f' + echo 'y c o e' + echo 'x a n h' + echo 'x a n g' + ) | tr '\n' '+' >in + + atf_check -o inline:'x a n g+x a n h+z b m f+y c o e+' \ + sort -R + -k2 in +} + +atf_test_case plus_tflag +plus_tflag_head() +{ + atf_set "descr" "Tests +- addressing: using -T caused a 'No such file" \ + "or directory' error" +} +plus_tflag_body() +{ + mkdir ./+ + yes | sed 200000q | sort -T + >/dev/null || atf_fail "program failed" +} + +atf_test_case plus_no_end +plus_no_end_head() +{ + atf_set "descr" "Tests +- addressing: field without end" +} +plus_no_end_body() +{ + cat >in <out </dev/null 2>&1" +} + +atf_test_case stdin +stdin_head() { + atf_set "descr" "Test that tmux(1) does not crash the system " \ + "when stdin(4) is closed (PR kern/46463)" +} + +stdin_body() { + stdincrash +} + +atf_init_test_cases() +{ + atf_add_test_case stdin +} diff --git a/contrib/netbsd-tests/usr.bin/tr/t_basic.sh b/contrib/netbsd-tests/usr.bin/tr/t_basic.sh new file mode 100755 index 000000000000..4515d114a800 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/tr/t_basic.sh @@ -0,0 +1,195 @@ +# $NetBSD: t_basic.sh,v 1.3 2013/08/11 01:50:02 dholland Exp $ +# +# Copyright (c) 2013 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by David A. Holland. +# +# 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. +# + +# +# tr -d: delete character +# +atf_test_case dopt +dopt_head() { + atf_set "descr" "Tests for tr -d" +} + +dopt_body() { + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -d x' + atf_check -o inline:'abde\n' -x 'echo abcde | tr -d c' + atf_check -o inline:'ace\n' -x 'echo abcde | tr -d bd' + atf_check -o inline:'ae\n' -x 'echo abcde | tr -d b-d' + atf_check -o inline:'b\n' -x 'echo abcde | tr -d ac-e' + atf_check -o inline:'d\n' -x 'echo abcde | tr -d a-ce' + atf_check -o inline:'aei\n' -x 'echo abcdefghi | tr -d b-df-h' + + atf_check -o inline:'' -x 'echo abcde | tr -c -d x' + atf_check -o inline:'c' -x 'echo abcde | tr -c -d c' + atf_check -o inline:'bd' -x 'echo abcde | tr -c -d bd' + atf_check -o inline:'bcd' -x 'echo abcde | tr -c -d b-d' + atf_check -o inline:'acde' -x 'echo abcde | tr -c -d ac-e' + atf_check -o inline:'abce' -x 'echo abcde | tr -c -d a-ce' + atf_check -o inline:'bcdfgh' -x 'echo abcdefghi | tr -c -d b-df-h' + + # see if escape codes work + atf_check -o inline:'splice' -x '(echo spl; echo ice) | tr -d '"'\n'" + atf_check -o inline:'splice' -x '(echo spl; echo ice) | tr -d '"'\012'" + + # see if escape codes work when followed by other things + atf_check -o inline:'slice' -x '(echo spl; echo ice) | tr -d '"'\n'p" + atf_check -o inline:'slice' -x '(echo spl; echo ice) | tr -d '"'\012'p" + + # see if the [=x=] syntax works + atf_check -o inline:'abde\n' -x 'echo abcde | tr -d '"'[=c=]'" + atf_check -o inline:'bde\n' -x 'echo abcde | tr -d '"'[=c=]'a" + + # make sure 0 works + # (ignore stderr as dd blabbers to it) + atf_check -e ignore -o inline:'ab\n' \ + -x '(echo -n a; dd if=/dev/zero bs=3 count=1; echo b) | tr -d '"'\0'" + + # test posix classes + atf_check -o inline:'.\n' -x 'echo aAzZ.123 | tr -d '"'[:alnum:]'" + atf_check -o inline:'.123\n' -x 'echo aAzZ.123 | tr -d '"'[:alpha:]'" + atf_check -o inline:'az\n' -x 'echo "a z" | tr -d '"'[:blank:]'" + atf_check -o inline:'az' -x '(echo a; echo z) | tr -d '"'[:cntrl:]'" + atf_check -o inline:'aAzZ.\n' -x 'echo aAzZ.123 | tr -d '"'[:digit:]'" + atf_check -o inline:' \n' -x 'echo "a z.123" | tr -d '"'[:graph:]'" + atf_check -o inline:'AZ.123\n' -x 'echo aAzZ.123 | tr -d '"'[:lower:]'" + atf_check -o inline:'\n' -x 'echo aAzZ.123 | tr -d '"'[:print:]'" + atf_check -o inline:'aAzZ12\n' -x 'echo aAzZ.12 | tr -d '"'[:punct:]'" + atf_check -o inline:'az' -x 'echo "a z" | tr -d '"'[:space:]'" + atf_check -o inline:'az.123\n' -x 'echo aAzZ.123 | tr -d '"'[:upper:]'" + atf_check -o inline:'zZ.\n' -x 'echo aAzZ.123 | tr -d '"'[:xdigit:]'" +} + +# +# tr -s: squeeze duplicate character runs +# +atf_test_case sopt +sopt_head() { + atf_set "descr" "Tests for tr -s" +} + +sopt_body() { + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -s x' + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -s c' + atf_check -o inline:'abcde\n' -x 'echo abccccde | tr -s c' + atf_check -o inline:'abcde\n' -x 'echo abbbcddde | tr -s bd' + atf_check -o inline:'abcde\n' -x 'echo abbbcccddde | tr -s b-d' + + atf_check -o inline:'acac\n' -x 'echo acac | tr -s c' + atf_check -o inline:'acac\n' -x 'echo accacc | tr -s c' + + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -c -s x' + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -c -s c' + atf_check -o inline:'abcccde\n' -x 'echo abcccde | tr -c -s c' + atf_check -o inline:'abbbcddde\n' -x 'echo abbbcddde | tr -c -s bd' + atf_check -o inline:'abbbccddde\n' -x 'echo abbbccddde | tr -c -s b-d' + atf_check -o inline:'abcccde\n' -x 'echo aaabcccde | tr -c -s b-d' +} + +# +# tr -ds: both -d and -s at once +# +atf_test_case dsopt +dsopt_head() { + atf_set "descr" "Tests for tr -ds" +} + +dsopt_body() { + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -ds x y' + atf_check -o inline:'abde\n' -x 'echo abcde | tr -ds c x' + atf_check -o inline:'abcde\n' -x 'echo abcde | tr -ds x c' + atf_check -o inline:'abde\n' -x 'echo abcde | tr -ds c c' + atf_check -o inline:'abde\n' -x 'echo abcccde | tr -ds c x' + atf_check -o inline:'abcde\n' -x 'echo abcccde | tr -ds x c' + atf_check -o inline:'abde\n' -x 'echo abcccde | tr -ds c c' + + # -c complements only the first string + atf_check -o inline:'' -x 'echo abcde | tr -c -ds x y' + atf_check -o inline:'c' -x 'echo abcde | tr -c -ds c x' + atf_check -o inline:'' -x 'echo abcde | tr -c -ds x c' + atf_check -o inline:'c' -x 'echo abcde | tr -c -ds c c' + atf_check -o inline:'ccc' -x 'echo abcccde | tr -c -ds c x' + atf_check -o inline:'' -x 'echo abcccde | tr -c -ds x c' + atf_check -o inline:'c' -x 'echo abcccde | tr -c -ds c c' +} + +# +# test substitution +# +atf_test_case subst +subst_head() { + atf_set "descr" "Tests for tr substitution" +} + +subst_body() { + atf_check -o inline:'abcde\n' -x 'echo abcde | tr a-c a-c' + atf_check -o inline:'cbade\n' -x 'echo abcde | tr a-c cba' + atf_check -o inline:'abcde\n' -x 'echo abcde | tr a-z a-z' + atf_check -o inline:'bcdef\n' -x 'echo abcde | tr a-z b-za' + atf_check -o inline:'zabcd\n' -x 'echo abcde | tr b-za a-z' + atf_check -o inline:'bbbbb\n' -x 'echo ababa | tr a b' + atf_check -o inline:'furrfu\n' -x 'echo sheesh | tr a-z n-za-m' + atf_check -o inline:'furrfu\n' -x 'echo sheesh | tr n-za-m a-z' + + atf_check -o inline:'ABCDE\n' -x 'echo abcde | tr a-z A-Z' + atf_check -o inline:'ABC\n' \ + -x 'echo abc | tr '"'[:lower:]' '[:upper:]'" + + # If you don't give enough substitution chars the last is repeated. + atf_check -o inline:'bozoo\n' -x 'echo abcde | tr a-z bozo' + atf_check -o inline:'qaaaa\n' -x 'echo abcde | tr a-z qa' + + # You can use -s with substitution. + atf_check -o inline:'cbade\n' -x 'echo abcde | tr -s a-c cba' + atf_check -o inline:'cbaddee\n' -x 'echo aabbccddee | tr -s a-c cba' +} + +# +# test substitution with -c (does not currently work) +# +atf_test_case csubst +csubst_head() { + atf_set "descr" "Tests for tr substitution with -c" +} + +csubst_body() { + atf_check -o inline:'abcde\n' -x \ + 'echo abcde | tr -c '"'\0-ac-\377' b" + atf_check -o inline:'abcde\n' -x \ + 'echo abcde | tr -c '"'\0-ad-\377' bc" + atf_check -o inline:'QUACK\n' -x \ + 'echo ABCDE | tr -c '"'\0-@' QUACK" +} + +atf_init_test_cases() { + atf_add_test_case dopt + atf_add_test_case sopt + atf_add_test_case dsopt + atf_add_test_case subst + atf_add_test_case csubst +} diff --git a/contrib/netbsd-tests/usr.bin/unifdef/d_basic.in b/contrib/netbsd-tests/usr.bin/unifdef/d_basic.in new file mode 100644 index 000000000000..9de6a94a0773 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/unifdef/d_basic.in @@ -0,0 +1,25 @@ +#if defined(__FreeBSD__) +#include +#else +#include +#endif + +#if defined(__FreeBSD__) + #include + #include + #include + #include + #include + #include +#else +#include +#endif + +#if defined(__FreeBSD__) +#endif + +#ifdef __FreeBSD__ +#include +#else +#include +#endif diff --git a/contrib/netbsd-tests/usr.bin/unifdef/d_basic.out b/contrib/netbsd-tests/usr.bin/unifdef/d_basic.out new file mode 100644 index 000000000000..2d52e9e7ae29 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/unifdef/d_basic.out @@ -0,0 +1,6 @@ +#include + +#include + + +#include diff --git a/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh b/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh new file mode 100755 index 000000000000..43ca2808d7fa --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh @@ -0,0 +1,62 @@ +# $NetBSD: t_basic.sh,v 1.6 2012/10/15 17:49:58 njoly Exp $ +# +# Copyright (c) 2011 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Jukka Ruohonen. +# +# 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 basic +basic_head() { + atf_set "descr" "A basic test of unifdef(1) (PR bin/42628)" + atf_set "require.progs" "unifdef" +} + +basic_body() { + + atf_check -s ignore -o file:$(atf_get_srcdir)/d_basic.out \ + -x "unifdef -U__FreeBSD__ $(atf_get_srcdir)/d_basic.in" +} + +atf_test_case lastline +lastline_head() { + atf_set "descr" "Checks with directive on last line (PR bin/47068)" +} + +lastline_body() { + + # With newline after cpp directive + printf '#ifdef foo\n#endif\n' >input + atf_check -o file:input unifdef -Ubar input + + # Without newline after cpp directive + printf '#ifdef foo\n#endif' >input + atf_check -o file:input unifdef -Ubar input +} + +atf_init_test_cases() { + atf_add_test_case basic + atf_add_test_case lastline +} diff --git a/contrib/netbsd-tests/usr.bin/vmstat/t_vmstat.sh b/contrib/netbsd-tests/usr.bin/vmstat/t_vmstat.sh new file mode 100755 index 000000000000..66769007e3b6 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/vmstat/t_vmstat.sh @@ -0,0 +1,48 @@ +# $NetBSD: t_vmstat.sh,v 1.1 2014/01/07 16:47:13 gson Exp $ +# +# Copyright (c) 2013 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 default +default_head() { + atf_set "descr" "Test that vmstat(1) returns success when run with no arguments" +} +default_body() { + atf_check -s exit:0 -o ignore -e empty vmstat +} + +atf_test_case opt_s +opt_s_head() { + atf_set "descr" "Test that vmstat(1) returns success when run with -s (PR 44518)" +} +opt_s_body() { + atf_check -s exit:0 -o ignore -e empty vmstat -s +} + +atf_init_test_cases() +{ + atf_add_test_case default + atf_add_test_case opt_s +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_alignof.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_alignof.c new file mode 100644 index 000000000000..4a661346305b --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_alignof.c @@ -0,0 +1,6 @@ +/* __alignof__ */ +int +main(void) +{ + return __alignof__(short); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_complex_num.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_complex_num.c new file mode 100644 index 000000000000..c3c952e7b722 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_complex_num.c @@ -0,0 +1,7 @@ +double cabs(double _Complex); + +double cabs(double _Complex foo) +{ + double d = __real__ foo; + return d + 0.1fi; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_complex_split.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_complex_split.c new file mode 100644 index 000000000000..7b3d1a1d501e --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_complex_split.c @@ -0,0 +1,8 @@ +int b(double a) { + return a == 0; +} +void a(void) { + double _Complex z = 0; + if (b(__real__ z) && b(__imag__ z)) + return; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt.c new file mode 100644 index 000000000000..f32a963c76b0 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt.c @@ -0,0 +1,5 @@ +void sample(void) +{ + int i = 0; i += 1; + int j = 0; j += 1; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt2.c new file mode 100644 index 000000000000..960d392350ca --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt2.c @@ -0,0 +1,6 @@ +typedef int int_t; +int main(void) { +int i = 0; i += 1; +int_t j = 0; j += 1; +return 0; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt3.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt3.c new file mode 100644 index 000000000000..278fe1bb713c --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_decls_after_stmt3.c @@ -0,0 +1,5 @@ +void sample(int i) +{ + i += 1; + int j = 0; j += 1; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_for_loops.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_for_loops.c new file mode 100644 index 000000000000..48e380cb3600 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_for_loops.c @@ -0,0 +1,15 @@ +/* c99 for loops */ +extern void foo(int); + +int +main(void) +{ + // Test the basic functionality + for (int i = 0; i < 10; i++) + foo(i); + + // Test that the scope of the iterator is correct + for (int i = 0; i < 10; i++) + continue; + return 0; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_func.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_func.c new file mode 100644 index 000000000000..b827bfa9f6bc --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_func.c @@ -0,0 +1,7 @@ +/* C99 __func__ */ + +void +foo(const char *p) { + p = __func__; + foo(p); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_recursive_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_recursive_init.c new file mode 100644 index 000000000000..347644ffe107 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_recursive_init.c @@ -0,0 +1,13 @@ +/* C99 recursive struct/union initialization */ +struct top { + int i; + char c; + union onion { + short us; + char uc; + } u; + char *s; +} c[] = { + { .s = "foo", .c = 'b', .u = { .uc = 'c' } }, + { .i = 1, .c = 'a', .u = { .us = 2 } }, +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_struct_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_struct_init.c new file mode 100644 index 000000000000..a94cbd163897 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_struct_init.c @@ -0,0 +1,10 @@ +/* C99 struct initialization */ +struct { + int i; + char *s; +} c[] = { + { .i = 2, }, + { .s = "foo" }, + { .i = 1, .s = "bar" }, + { .s = "foo", .i = -1 }, +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init1.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init1.c new file mode 100644 index 000000000000..0e1a1a8323d9 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init1.c @@ -0,0 +1,8 @@ +/* C99 union initialization */ +union { + int i; + char *s; +} c[] = { + { i: 1 }, + { s: "foo" } +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init2.c new file mode 100644 index 000000000000..51d34d450f21 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init2.c @@ -0,0 +1,8 @@ +/* C99 union initialization */ +union { + int i[10]; + short s; +} c[] = { + { s: 2 }, + { i: { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } }, +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init3.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init3.c new file mode 100644 index 000000000000..f5e8b59f4621 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_init3.c @@ -0,0 +1,8 @@ +/* C99 union initialization */ +struct { + int i[10]; + char *s; +} c[] = { + { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, + "foo" }, +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c9x_array_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c9x_array_init.c new file mode 100644 index 000000000000..66f0e9ec158e --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c9x_array_init.c @@ -0,0 +1,6 @@ +/* C9X array initializers */ +int foo[256] = { + [2] = 1, + [3] = 2, + [4 ... 5] = 3 +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c new file mode 100644 index 000000000000..df907cd7a3cd --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c @@ -0,0 +1,16 @@ +/* C9X struct/union member init, with nested union and trailing member */ +union node { + void *next; + char *data; +}; +struct foo { + int b; + union node n; + int c; +}; + +struct foo f = { + .b = 1, + .n = { .next = 0, }, + .c = 1 +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_init.c new file mode 100644 index 000000000000..36986e800ac4 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_init.c @@ -0,0 +1,27 @@ +/* cast initialization */ +typedef unsigned char u_char; +typedef unsigned int size_t; +struct sockaddr_x25 { + u_char x25_len; + u_char x25_family; + short x25_net; + char x25_addr[16]; + struct x25opts { + char op_flags; + char op_psize; + char op_wsize; + char op_speed; + } x25_opts; + short x25_udlen; + char x25_udata[16]; +}; + +struct sockaddr_x25 x25_dgmask = { + (unsigned char)(unsigned char)(unsigned int)(unsigned long)(&((( struct sockaddr_x25 *)0)->x25_udata[1])) , + 0, + 0, + {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, + {0, 0, 0, 0}, + -1, + {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_init2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_init2.c new file mode 100644 index 000000000000..9597d3580397 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_init2.c @@ -0,0 +1,7 @@ +/* cast initialization as the rhs of a - operand */ +struct sockaddr_dl { + char sdl_data[2]; +}; + +int npdl_datasize = sizeof(struct sockaddr_dl) - +((int) ((unsigned long)&((struct sockaddr_dl *) 0)->sdl_data[0])); diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_lhs.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_lhs.c new file mode 100644 index 000000000000..eb865695535f --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cast_lhs.c @@ -0,0 +1,7 @@ +/* pointer casts are valid lhs lvalues */ +struct sockaddr { }; +void +foo() { + unsigned long p = 6; + ((struct sockaddr *)p) = 0; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_compound_literals1.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_compound_literals1.c new file mode 100644 index 000000000000..cd1987ae17de --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_compound_literals1.c @@ -0,0 +1,11 @@ +/* compound literals */ + +struct p { + short a, b, c, d; +}; + +foo() +{ + struct p me = (struct p) {1, 2, 3, 4}; + me.a = me.b; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_compound_literals2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_compound_literals2.c new file mode 100644 index 000000000000..e4ffb929873f --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_compound_literals2.c @@ -0,0 +1,18 @@ +/* compound literals */ + +struct p { + short a, b, c, d; +} zz = { + 1, 2, 3, 4 +}; + +struct p *bar(int i) +{ + static struct p q[10]; + return &q[i]; +} + +foo() +{ + *bar(1) = (struct p) { 1, 2, 3, 4 }; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_constant_conv1.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_constant_conv1.c new file mode 100644 index 000000000000..53795c5fe858 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_constant_conv1.c @@ -0,0 +1,9 @@ +/* Flag information-losing constant conversion in argument lists */ + +int f(unsigned int); + +void +should_fail() +{ + f(-1); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_constant_conv2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_constant_conv2.c new file mode 100644 index 000000000000..87066c96b5a8 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_constant_conv2.c @@ -0,0 +1,9 @@ +/* Flag information-losing constant conversion in argument lists */ + +int f(unsigned int); + +void +should_fail() +{ + f(2.1); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cvt_constant.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cvt_constant.c new file mode 100644 index 000000000000..aa74509fa42e --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cvt_constant.c @@ -0,0 +1,8 @@ +/* the second assignment assumes failed before */ +int +main(void) { + double x = 1; + int foo = 0; + if (foo) + x = 1; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cvt_in_ternary.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cvt_in_ternary.c new file mode 100644 index 000000000000..4a6149c67224 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_cvt_in_ternary.c @@ -0,0 +1,13 @@ +/* CVT node handling in ?: operator */ +typedef unsigned long int size_t; +struct filecore_direntry { + unsigned len:32; +}; +int +main(void) +{ + struct filecore_direntry dirent = { 0 }; + size_t uio_resid = 0; + size_t bytelen = (((dirent.len)<(uio_resid))?(dirent.len):(uio_resid)); + return bytelen; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c new file mode 100644 index 000000000000..ba4a338d29ae --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_ellipsis_in_switch.c @@ -0,0 +1,11 @@ +int x(void) +{ + int i = 33; + switch (i) { + case 1 ... 40: + break; + default: + break; + } + return 0; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c new file mode 100644 index 000000000000..d970be182648 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c @@ -0,0 +1,7 @@ +/* GCC compound statements */ + +foo(unsigned long z) +{ + z = ({ unsigned long tmp; tmp = 1; tmp; }); + foo(z); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c new file mode 100644 index 000000000000..fa1ee67302c5 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements2.c @@ -0,0 +1,14 @@ +/* GCC compound statements with non-expressions */ +struct cpu_info { + int bar; +}; + +int +main(void) +{ + return ({ + struct cpu_info *__ci; + __asm__ volatile("movl %%fs:4,%0":"=r" (__ci)); + __ci; + })->bar; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements3.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements3.c new file mode 100644 index 000000000000..29e9063dcf4a --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_compound_statements3.c @@ -0,0 +1,10 @@ +/* GCC compound statements with void type */ + +void +main(void) +{ + ({ + void *v; + __asm__ volatile("noop"); + }); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_extension.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_extension.c new file mode 100644 index 000000000000..d8bd8f5fe944 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_extension.c @@ -0,0 +1,6 @@ +/* extension */ +void a(void) { + double __logbw = 1; + if (__extension__(({ __typeof((__logbw)) x_ = (__logbw); !__builtin_isinf((x_)) && !__builtin_isnan((x_)); }))) + __logbw = 1; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_func.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_func.c new file mode 100644 index 000000000000..459919de2955 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_func.c @@ -0,0 +1,7 @@ +/* gcc __FUNCTION__ */ + +void +foo(const char *p) { + p = __FUNCTION__; + foo(p); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_variable_array_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_variable_array_init.c new file mode 100644 index 000000000000..d5b01ad0c2d2 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_gcc_variable_array_init.c @@ -0,0 +1,7 @@ +/* gcc: variable array initializer */ +void foo(int i) +{ + int array[i]; + while (i--) + foo(array[i] = 0); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_incorrect_array_size.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_incorrect_array_size.c new file mode 100644 index 000000000000..c86c0d6b3b70 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_incorrect_array_size.c @@ -0,0 +1,3 @@ +struct foo { + int a[-1]; +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_long_double_int.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_long_double_int.c new file mode 100644 index 000000000000..a5a644e3e3d4 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_long_double_int.c @@ -0,0 +1,7 @@ +/* PR 39639: writing "long double" gave "long int" */ + +int +fail(long double *a, long int *b) +{ + return a == b; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_nested_structs.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_nested_structs.c new file mode 100644 index 000000000000..edd3396bd224 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_nested_structs.c @@ -0,0 +1,21 @@ +/* Nested struct */ +typedef void *EditLine; +typedef void *History; + +typedef struct { + EditLine *el; + History *hist; +} el_mode_t; + +struct el_modes_s { + el_mode_t command; + el_mode_t string; + el_mode_t filec; + el_mode_t mime_enc; +}; + +struct el_modes_s elm = { + .command = { .el = 0, .hist = 0, }, + .string = { .el = 0, .hist = 0, }, + .filec = { .el = 0, .hist = 0, }, +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_nolimit_init.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_nolimit_init.c new file mode 100644 index 000000000000..68e71b4df050 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_nolimit_init.c @@ -0,0 +1,4 @@ +/* no limit initializers */ +char foo[][4] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_packed_structs.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_packed_structs.c new file mode 100644 index 000000000000..71b438496f92 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_packed_structs.c @@ -0,0 +1,35 @@ +/* packed tests */ + +struct in_addr { + int x; +}; +struct ip_timestamp { + char ipt_code; + char ipt_len; + char ipt_ptr; + unsigned int ipt_flg:4, + ipt_oflw:4; + union ipt_timestamp { + int ipt_time[1]; + struct ipt_ta { + struct in_addr ipt_addr; + int ipt_time; + } ipt_ta[1] __packed; + } ipt_timestamp __packed; +} __packed; + +typedef struct __packed { + int x; +} t; + +struct x { + char c; + long l; +} __packed; + +struct y { + char c; + long l; +}; + +int a[sizeof(struct y) - sizeof(struct x) - 1]; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c new file mode 100644 index 000000000000..0208944a2d12 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_shift_to_narrower_type.c @@ -0,0 +1,24 @@ +// Test that type shifts that result to narrower types don't produce warnings. + +void +foo(void) { + unsigned long l = 100; + unsigned long long ll = 100; + unsigned int i = 100; + unsigned short s = 100; + unsigned char c = 1; + + l = ll >> 32; +// i = ll >> 31; + i = ll >> 32; + s = ll >> 48; + c = ll >> 56; + s = i >> 16; + c = i >> 24; + c = s >> 8; + (void)≪ + (void)&l; + (void)&i; + (void)&s; + (void)&c; +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv1.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv1.c new file mode 100644 index 000000000000..d9e470e941b9 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv1.c @@ -0,0 +1,11 @@ +/* Flag information-losing type conversion in argument lists */ + +int f(unsigned int); + +void +should_fail() +{ + long long x = 20; + + f(x); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv2.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv2.c new file mode 100644 index 000000000000..7c2e1f478ecd --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv2.c @@ -0,0 +1,11 @@ +/* Flag information-losing type conversion in argument lists */ + +int f(float); + +void +should_fail() +{ + double x = 2.0; + + f(x); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv3.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv3.c new file mode 100644 index 000000000000..bc6a8e695ada --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_type_conv3.c @@ -0,0 +1,10 @@ +/* Flag information-losing type conversion in argument lists */ + +int f(unsigned int); + +void +should_fail() +{ + + f(0x7fffffffffffffffLL); +} diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_typename_as_var.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_typename_as_var.c new file mode 100644 index 000000000000..248dc7558b52 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_typename_as_var.c @@ -0,0 +1,14 @@ +typedef char h[10]; + +typedef struct { + int i; + char *c; +} fh; + +struct foo { + fh h; + struct { + int x; + int y; + } fl; +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_zero_sized_arrays.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_zero_sized_arrays.c new file mode 100644 index 000000000000..9c06c6b5e413 --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_zero_sized_arrays.c @@ -0,0 +1,3 @@ +struct foo { +int a[0]; +}; diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/t_integration.sh b/contrib/netbsd-tests/usr.bin/xlint/lint1/t_integration.sh new file mode 100755 index 000000000000..9575f9664d3b --- /dev/null +++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/t_integration.sh @@ -0,0 +1,132 @@ +# $NetBSD: t_integration.sh,v 1.4 2014/04/21 19:10:41 christos Exp $ +# +# Copyright (c) 2008, 2010 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. +# + +LINT1=/usr/libexec/lint1 + +Names= + +check_valid() +{ + atf_check -s exit:0 ${LINT1} -g -S "$(atf_get_srcdir)/$1" /dev/null +} + +check_invalid() +{ + atf_check -s not-exit:0 -o ignore -e ignore ${LINT1} -g -S -w \ + "$(atf_get_srcdir)/$1" /dev/null +} + +test_case() +{ + local result="${1}"; shift + local name="${1}"; shift + local descr="${*}" + + atf_test_case ${name} + eval "${name}_head() { + atf_set \"descr\" \"${descr}\"; + atf_set \"require.progs\" \"${LINT1}\"; + }" + eval "${name}_body() { + ${result} d_${name}.c; + }" + + Names="${Names} ${name}" +} + +test_case check_valid c99_struct_init "Checks C99 struct initialization" +test_case check_valid c99_union_init1 "Checks C99 union initialization" +test_case check_valid c99_union_init2 "Checks C99 union initialization" +test_case check_valid c99_union_init3 "Checks C99 union initialization" +test_case check_valid c99_recursive_init "Checks C99 recursive struct/union" \ + "initialization" +test_case check_valid c9x_recursive_init "Checks C9X struct/union member" \ + "init, with nested union and trailing member" +test_case check_valid nested_structs "Checks nested structs" +test_case check_valid packed_structs "Checks packed structs" + +test_case check_valid cast_init "Checks cast initialization" +test_case check_valid cast_init2 "Checks cast initialization as the rhs of a" \ + "- operand" +test_case check_valid cast_lhs "Checks whether pointer casts are valid lhs" \ + "lvalues" + +test_case check_valid gcc_func "Checks GCC __FUNCTION__" +test_case check_valid c99_func "Checks C99 __func__" + +test_case check_valid gcc_variable_array_init "Checks GCC variable array" \ + "initializers" +test_case check_valid c9x_array_init "Checks C9X array initializers" +test_case check_valid c99_decls_after_stmt "Checks C99 decls after statements" +test_case check_valid c99_decls_after_stmt3 "Checks C99 decls after statements" +test_case check_valid nolimit_init "Checks no limit initializers" +test_case check_valid zero_sized_arrays "Checks zero sized arrays" + +test_case check_valid compound_literals1 "Checks compound literals" +test_case check_valid compound_literals2 "Checks compound literals" +test_case check_valid gcc_compound_statements1 "Checks GCC compound statements" +test_case check_valid gcc_compound_statements2 "Checks GCC compound" \ + "statements with non-expressions" +test_case check_valid gcc_compound_statements3 "Checks GCC compound" \ + "statements with void type" +# XXX: Because of polymorphic __builtin_isnan and expression has null effect +# test_case check_valid gcc_extension "Checks GCC __extension__ and __typeof__" + +test_case check_valid cvt_in_ternary "Checks CVT nodes handling in ?" \ +test_case check_valid cvt_constant "Checks constant conversion" +test_case check_valid ellipsis_in_switch "Checks ellipsis in switch()" +test_case check_valid c99_complex_num "Checks C99 complex numbers" +test_case check_valid c99_complex_split "Checks C99 complex access" +test_case check_valid c99_for_loops "Checks C99 for loops" +test_case check_valid alignof "Checks __alignof__" +test_case check_valid shift_to_narrower_type "Checks that type shifts that" \ + "result in narrower types do not produce warnings" + +test_case check_invalid constant_conv1 "Checks failing on information-losing" \ + "constant conversion in argument lists" +test_case check_invalid constant_conv2 "Checks failing on information-losing" \ + "constant conversion in argument lists" + +test_case check_invalid type_conv1 "Checks failing on information-losing" \ + "type conversion in argument lists" +test_case check_invalid type_conv2 "Checks failing on information-losing" \ + "type conversion in argument lists" +test_case check_invalid type_conv3 "Checks failing on information-losing" \ + "type conversion in argument lists" + +test_case check_invalid incorrect_array_size "Checks failing on incorrect" \ + "array sizes" + +test_case check_invalid long_double_int "Checks for confusion of 'long" \ + "double' with 'long int'; PR 39639" + +atf_init_test_cases() +{ + for name in ${Names}; do + atf_add_test_case ${name} + done +} diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_convert.in b/contrib/netbsd-tests/usr.sbin/mtree/d_convert.in new file mode 100644 index 000000000000..6a1abb07e1b0 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_convert.in @@ -0,0 +1,40 @@ +# Similar to d_create.out, but a few entries have been deleted; nlink, +# size and sha256 attributes have been removed; and the order has been +# changed to test sorting. + +# . +. type=dir + a.symlink.1 type=link link=a.file.1 + top.dangling type=link link=nonexistent + top.symlink.b \ + type=link link=b + +# ./b +b type=dir + b.file.2 type=file + b.file.1 type=file +# end ./b, up to "." +.. + + top.file.1 type=file + +# ./a +a type=dir + a.file.2 type=file + +# ./a/1 +1 type=dir + a1.file.1 type=file +# end ./a/1, up to "./a" +.. + + a.file.1 type=file + +# ./a/2 +2 type=dir +# end ./a/2, up to "./a" +.. + +# end ./a, up to "." +.. + diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_convert_C.out b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_C.out new file mode 100644 index 000000000000..de4d9f6e5a2d --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_C.out @@ -0,0 +1,14 @@ +. type=dir +./a.symlink.1 type=link link=a.file.1 +./top.dangling type=link link=nonexistent +./top.symlink.b type=link link=b +./b type=dir +./b/b.file.2 type=file +./b/b.file.1 type=file +./top.file.1 type=file +./a type=dir +./a/a.file.2 type=file +./a/1 type=dir +./a/1/a1.file.1 type=file +./a/a.file.1 type=file +./a/2 type=dir diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_convert_C_S.out b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_C_S.out new file mode 100644 index 000000000000..bd03cc458859 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_C_S.out @@ -0,0 +1,14 @@ +. type=dir +./a.symlink.1 type=link link=a.file.1 +./top.dangling type=link link=nonexistent +./top.file.1 type=file +./top.symlink.b type=link link=b +./a type=dir +./a/a.file.1 type=file +./a/a.file.2 type=file +./a/1 type=dir +./a/1/a1.file.1 type=file +./a/2 type=dir +./b type=dir +./b/b.file.1 type=file +./b/b.file.2 type=file diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_convert_D.out b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_D.out new file mode 100644 index 000000000000..c059478131a0 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_D.out @@ -0,0 +1,14 @@ +type=dir . +type=link link=a.file.1 ./a.symlink.1 +type=link link=nonexistent ./top.dangling +type=link link=b ./top.symlink.b +type=dir ./b +type=file ./b/b.file.2 +type=file ./b/b.file.1 +type=file ./top.file.1 +type=dir ./a +type=file ./a/a.file.2 +type=dir ./a/1 +type=file ./a/1/a1.file.1 +type=file ./a/a.file.1 +type=dir ./a/2 diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_convert_D_S.out b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_D_S.out new file mode 100644 index 000000000000..a777a0b0112f --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_convert_D_S.out @@ -0,0 +1,14 @@ +type=dir . +type=link link=a.file.1 ./a.symlink.1 +type=link link=nonexistent ./top.dangling +type=file ./top.file.1 +type=link link=b ./top.symlink.b +type=dir ./a +type=file ./a/a.file.1 +type=file ./a/a.file.2 +type=dir ./a/1 +type=file ./a/1/a1.file.1 +type=dir ./a/2 +type=dir ./b +type=file ./b/b.file.1 +type=file ./b/b.file.2 diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_merge.in b/contrib/netbsd-tests/usr.sbin/mtree/d_merge.in new file mode 100644 index 000000000000..9efd04b018c8 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_merge.in @@ -0,0 +1,27 @@ +# The last entry for any duplicate node should take precedence. + +. type=dir + +# directory "a" with only one entry, changing from dir to link +./a type=dir +./a/change-dir-to-link type=dir mode=0755 +./a/change-dir-to-link type=link mode=0755 + +# directory "b" with only one entry, changing from link to dir +./b type=dir +./b/change-link-to-dir type=link mode=0755 +./b/change-link-to-dir type=dir mode=0755 + +# directory "c" with multiple entries, one changing from dir to link +./c type=dir +./c/aaa type=file +./c/zzz type=file +./c/change-dir-to-link type=dir mode=0755 +./c/change-dir-to-link type=link mode=0755 + +# directory "d" with multiple entries, one changing from link to dir +./d type=dir +./d/aaa type=file +./d/zzz type=file +./d/change-link-to-dir type=link mode=0755 +./d/change-link-to-dir type=dir mode=0755 diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_merge_C_M.out b/contrib/netbsd-tests/usr.sbin/mtree/d_merge_C_M.out new file mode 100644 index 000000000000..dea996699ffc --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_merge_C_M.out @@ -0,0 +1,13 @@ +. type=dir +./a type=dir +./a/change-dir-to-link type=link mode=0755 +./b type=dir +./b/change-link-to-dir type=dir mode=0755 +./c type=dir +./c/aaa type=file +./c/zzz type=file +./c/change-dir-to-link type=link mode=0755 +./d type=dir +./d/aaa type=file +./d/zzz type=file +./d/change-link-to-dir type=dir mode=0755 diff --git a/contrib/netbsd-tests/usr.sbin/mtree/d_merge_C_M_S.out b/contrib/netbsd-tests/usr.sbin/mtree/d_merge_C_M_S.out new file mode 100644 index 000000000000..9f02beae7a2b --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/d_merge_C_M_S.out @@ -0,0 +1,13 @@ +. type=dir +./a type=dir +./a/change-dir-to-link type=link mode=0755 +./b type=dir +./b/change-link-to-dir type=dir mode=0755 +./c type=dir +./c/aaa type=file +./c/change-dir-to-link type=link mode=0755 +./c/zzz type=file +./d type=dir +./d/aaa type=file +./d/zzz type=file +./d/change-link-to-dir type=dir mode=0755 diff --git a/contrib/netbsd-tests/usr.sbin/mtree/mtree_d_create.out b/contrib/netbsd-tests/usr.sbin/mtree/mtree_d_create.out new file mode 100644 index 000000000000..389ec653e076 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/mtree_d_create.out @@ -0,0 +1,55 @@ +# user: x +# machine: x +# tree: x +# date: x + +# . +/set type=file nlink=1 +. type=dir nlink=4 + a.symlink.1 type=link link=a.file.1 + top.dangling \ + type=link link=nonexistent + top.file.1 size=18 \ + sha256=74c53aaf0cd9543b7efad969de1058ee38859134ba467500b849811fc3513195 + top.symlink.b \ + type=link link=b + +# ./a +a type=dir nlink=4 + a.file.1 size=18 \ + sha256=bdbea62f7ccdf862f22254ea871d523845250010d5f233896e800142a859eef2 + a.file.2 size=18 \ + sha256=77876d113fe1b45a41f8d1d3e178aaad7f91fcd93d3df782690625b74ad90fe6 + a.hardlink.b2 \ + nlink=2 size=18 \ + sha256=784fd6b95fe5054d87bf268de51dea043031c5e985f668d4f51e1c759b0f9333 + +# ./a/1 +1 type=dir nlink=2 + a1.file.1 size=21 \ + sha256=a062cd272facdd38c4fdeff2a18947b28c99a28a8fe51f88468978740382e592 +# ./a/1 +.. + + +# ./a/2 +2 type=dir nlink=2 +# ./a/2 +.. + +# ./a +.. + + +# ./b +b type=dir nlink=2 + b.file.1 nlink=2 size=18 \ + sha256=5754b0d97a8238ea0e495ab871667dcab8f1d684e323290ae76f70c47de18998 + b.file.2 nlink=2 size=18 \ + sha256=784fd6b95fe5054d87bf268de51dea043031c5e985f668d4f51e1c759b0f9333 + b.hardlink.1 \ + nlink=2 size=18 \ + sha256=5754b0d97a8238ea0e495ab871667dcab8f1d684e323290ae76f70c47de18998 +# ./b +.. + diff --git a/contrib/netbsd-tests/usr.sbin/mtree/netbsd6_d_create.out b/contrib/netbsd-tests/usr.sbin/mtree/netbsd6_d_create.out new file mode 100644 index 000000000000..389ec653e076 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/netbsd6_d_create.out @@ -0,0 +1,55 @@ +# user: x +# machine: x +# tree: x +# date: x + +# . +/set type=file nlink=1 +. type=dir nlink=4 + a.symlink.1 type=link link=a.file.1 + top.dangling \ + type=link link=nonexistent + top.file.1 size=18 \ + sha256=74c53aaf0cd9543b7efad969de1058ee38859134ba467500b849811fc3513195 + top.symlink.b \ + type=link link=b + +# ./a +a type=dir nlink=4 + a.file.1 size=18 \ + sha256=bdbea62f7ccdf862f22254ea871d523845250010d5f233896e800142a859eef2 + a.file.2 size=18 \ + sha256=77876d113fe1b45a41f8d1d3e178aaad7f91fcd93d3df782690625b74ad90fe6 + a.hardlink.b2 \ + nlink=2 size=18 \ + sha256=784fd6b95fe5054d87bf268de51dea043031c5e985f668d4f51e1c759b0f9333 + +# ./a/1 +1 type=dir nlink=2 + a1.file.1 size=21 \ + sha256=a062cd272facdd38c4fdeff2a18947b28c99a28a8fe51f88468978740382e592 +# ./a/1 +.. + + +# ./a/2 +2 type=dir nlink=2 +# ./a/2 +.. + +# ./a +.. + + +# ./b +b type=dir nlink=2 + b.file.1 nlink=2 size=18 \ + sha256=5754b0d97a8238ea0e495ab871667dcab8f1d684e323290ae76f70c47de18998 + b.file.2 nlink=2 size=18 \ + sha256=784fd6b95fe5054d87bf268de51dea043031c5e985f668d4f51e1c759b0f9333 + b.hardlink.1 \ + nlink=2 size=18 \ + sha256=5754b0d97a8238ea0e495ab871667dcab8f1d684e323290ae76f70c47de18998 +# ./b +.. + diff --git a/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh b/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh new file mode 100755 index 000000000000..20fda75e02ea --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh @@ -0,0 +1,422 @@ +# $NetBSD: t_mtree.sh,v 1.6 2013/02/05 16:49:42 christos Exp $ +# +# Copyright (c) 2009, 2012 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. +# + +# Postprocess mtree output, canonicalising portions that +# are expected to differ from one run to another. +# + +h_postprocess() +{ + sed -e ' + /^# user: /s/:.*/: x/ + /^# machine: /s/:.*/: x/ + /^# tree: /s/:.*/: x/ + /^# date: /s/:.*/: x/ + ' \ + -e '/type=dir/s/ size=[0-9]*//' +} + +h_check() +{ + diff -Nru "$1" "$2" || atf_fail "files $1 and $2 differ" +} + + +atf_test_case mtree_create +atf_test_case netbsd6_create +create_head() +{ + atf_set "descr" "Create a specfile describing a directory tree" +} + +create_setup() +{ + # create some directories + rm -fr create + mkdir -p create/a/1 create/a/2 create/b + # create some files + for file in create/top.file.1 \ + create/a/a.file.1 \ + create/a/a.file.2 \ + create/a/1/a1.file.1 \ + create/b/b.file.1 \ + create/b/b.file.2 + do + echo "$file" >$file + done + # hard link to file in same dir + ln create/b/b.file.1 create/b/b.hardlink.1 + # hard link to file in another dir + ln create/b/b.file.2 create/a/a.hardlink.b2 + # symlink to file + ln -s a.file.1 create/a.symlink.1 + # symlink to dir + ln -s b create/top.symlink.b + # dangling symlink + ln -s nonexistent create/top.dangling +} + +create_body() +{ + create_setup + + # run mtree and check output + ( cd create && mtree -F ${FLAVOR} -c -k type,nlink,link,size,sha256 ) >output.raw \ + || atf_fail "mtree exit status $?" + h_postprocess output + h_check "$(atf_get_srcdir)/${FLAVOR}_d_create.out" output +} + +mtree_create_head() +{ + FLAVOR=mtree create_head +} +netbsd6_create_head() +{ + FLAVOR=netbsd6 create_head +} + +mtree_create_body() +{ + FLAVOR=mtree create_body +} +netbsd6_create_body() +{ + FLAVOR=netbsd6 create_body +} + + +atf_test_case mtree_check +atf_test_case netbsd6_check +check_head() +{ + atf_set "descr" "Check a directory tree against a specfile" +} + +check_body() +{ + # we use the same directory tree and specfile as in the "create" test + create_setup + + # run mtree and check output + ( cd create && mtree -F ${FLAVOR} ) <"$(atf_get_srcdir)/${FLAVOR}_d_create.out" >output \ + || atf_fail "mtree exit status $?" + h_check /dev/null output +} + +mtree_check_head() +{ + FLAVOR=mtree check_head +} +netbsd6_check_head() +{ + FLAVOR=netbsd6 check_head +} + +mtree_check_body() +{ + FLAVOR=mtree check_body +} +netbsd6_check_body() +{ + FLAVOR=netbsd6 check_body +} + + +atf_test_case mtree_convert_C +atf_test_case netbsd6_convert_C +convert_C_head() +{ + atf_set "descr" "Convert a specfile to mtree -C format, unsorted" +} + +convert_C_body() +{ + mtree -F ${FLAVOR} -C -K all <"$(atf_get_srcdir)/d_convert.in" >output + h_check "$(atf_get_srcdir)/d_convert_C.out" output +} + +mtree_convert_C_head() +{ + FLAVOR=mtree convert_C_head +} +netbsd6_convert_C_head() +{ + FLAVOR=netbsd6 convert_C_head +} + +mtree_convert_C_body() +{ + FLAVOR=mtree convert_C_body +} +netbsd6_convert_C_body() +{ + FLAVOR=netbsd6 convert_C_body +} + + +atf_test_case mtree_convert_C_S +atf_test_case netbsd6_convert_C_S +convert_C_S_head() +{ + atf_set "descr" "Convert a specfile to mtree -C format, sorted" +} + +convert_C_S_body() +{ + mtree -F ${FLAVOR} -C -S -K all <"$(atf_get_srcdir)/d_convert.in" >output + h_check "$(atf_get_srcdir)/d_convert_C_S.out" output +} + +mtree_convert_C_S_head() +{ + FLAVOR=mtree convert_C_S_head +} +netbsd6_convert_C_S_head() +{ + FLAVOR=netbsd6 convert_C_S_head +} + +mtree_convert_C_S_body() +{ + FLAVOR=mtree convert_C_S_body +} +netbsd6_convert_C_S_body() +{ + FLAVOR=netbsd6 convert_C_S_body +} + + +atf_test_case mtree_convert_D +atf_test_case netbsd6_convert_D +convert_D_head() +{ + atf_set "descr" "Convert a specfile to mtree -D format, unsorted" +} + +convert_D_body() +{ + mtree -F ${FLAVOR} -D -K all <"$(atf_get_srcdir)/d_convert.in" >output + h_check "$(atf_get_srcdir)/d_convert_D.out" output +} + +mtree_convert_D_head() +{ + FLAVOR=mtree convert_D_head +} +netbsd6_convert_D_head() +{ + FLAVOR=netbsd6 convert_D_head +} + +mtree_convert_D_body() +{ + FLAVOR=mtree convert_D_body +} +netbsd6_convert_D_body() +{ + FLAVOR=netbsd6 convert_D_body +} + + +atf_test_case mtree_convert_D_S +atf_test_case netbsd6_convert_D_S +convert_D_S_head() +{ + atf_set "descr" "Convert a specfile to mtree -D format, sorted" +} + +convert_D_S_body() +{ + mtree -F ${FLAVOR} -D -S -K all <"$(atf_get_srcdir)/d_convert.in" >output + h_check "$(atf_get_srcdir)/d_convert_D_S.out" output +} + +mtree_convert_D_S_head() +{ + FLAVOR=mtree convert_D_S_head +} +netbsd6_convert_D_S_head() +{ + FLAVOR=netbsd6 convert_D_S_head +} + +mtree_convert_D_S_body() +{ + FLAVOR=mtree convert_D_S_body +} +netbsd6_convert_D_S_body() +{ + FLAVOR=netbsd6 convert_D_S_body +} + + +atf_test_case mtree_ignore +atf_test_case netbs6_ignore +ignore_head() +{ + atf_set "descr" "Test that -d ignores symlinks (PR bin/41061)" +} + +ignore_body() +{ + mkdir newdir + mtree -F ${FLAVOR} -c | mtree -F ${FLAVOR} -Ck uid,gid,mode > mtree.spec + ln -s newdir otherdir + + # This yields "extra: otherdir" even with -d. + # (PR bin/41061) + atf_check -s ignore -o empty -e empty -x "mtree -F ${FLAVOR} -d < mtree.spec" + + # Delete the symlink and re-verify. + # + rm otherdir + atf_check -s ignore -o empty -e empty -x "mtree -F ${FLAVOR} -d < mtree.spec" +} + +mtree_ignore_head() +{ + FLAVOR=mtree ignore_head +} +netbsd6_ignore_head() +{ + FLAVOR=netbsd6 ignore_head +} + +mtree_ignore_body() +{ + FLAVOR=mtree ignore_body +} +netbsd6_ignore_body() +{ + FLAVOR=netbsd6 ignore_body +} + + +atf_test_case mtree_merge +atf_test_case netbsd6_merge +merge_head() +{ + atf_set "descr" "Merge records of different type" +} + +merge_body() +{ + mtree -F ${FLAVOR} -C -M -K all <"$(atf_get_srcdir)/d_merge.in" >output + h_check "$(atf_get_srcdir)/d_merge_C_M.out" output + # same again, with sorting + mtree -F ${FLAVOR} -C -M -S -K all <"$(atf_get_srcdir)/d_merge.in" >output + h_check "$(atf_get_srcdir)/d_merge_C_M_S.out" output +} + +mtree_merge_head() +{ + FLAVOR=mtree merge_head +} +netbsd6_merge_head() +{ + FLAVOR=netbsd6 merge_head +} + +mtree_merge_body() +{ + FLAVOR=mtree merge_body +} +netbsd6_merge_body() +{ + FLAVOR=netbsd6 merge_body +} + + +atf_test_case mtree_nonemptydir +atf_test_case netbsd6_nonemptydir +nonemptydir_head() +{ + atf_set "descr" "Test that new non-empty " \ + "directories are recorded (PR bin/25693)" +} + +nonemptydir_body() +{ + mkdir testdir + cd testdir + + mtree -F ${FLAVOR} -c > mtree.spec + + if [ ! -f mtree.spec ]; then + atf_fail "mtree failed" + fi + + touch bar + atf_check -s ignore -o save:output -x "mtree -F ${FLAVOR} -f mtree.spec" + + if [ ! -n "$(egrep "extra: bar" output)" ]; then + atf_fail "mtree did not record changes (PR bin/25693)" + fi +} + +mtree_nonemptydir_head() +{ + FLAVOR=mtree nonemptydir_head +} +netbsd6_nonemptydir_head() +{ + FLAVOR=netbsd6 nonemptydir_head +} + +mtree_nonemptydir_body() +{ + FLAVOR=mtree nonemptydir_body +} +netbsd6_nonemptydir_body() +{ + FLAVOR=netbsd6 nonemptydir_body +} + + +atf_init_test_cases() +{ + atf_add_test_case mtree_create + atf_add_test_case mtree_check + atf_add_test_case mtree_convert_C + atf_add_test_case mtree_convert_C_S + atf_add_test_case mtree_convert_D + atf_add_test_case mtree_convert_D_S + atf_add_test_case mtree_ignore + atf_add_test_case mtree_merge + atf_add_test_case mtree_nonemptydir + + atf_add_test_case netbsd6_create + atf_add_test_case netbsd6_check + atf_add_test_case netbsd6_convert_C + atf_add_test_case netbsd6_convert_C_S + atf_add_test_case netbsd6_convert_D + atf_add_test_case netbsd6_convert_D_S + atf_add_test_case netbsd6_ignore + atf_add_test_case netbsd6_merge + atf_add_test_case netbsd6_nonemptydir +} diff --git a/contrib/netbsd-tests/usr.sbin/tcpdump/t_tcpdump.sh b/contrib/netbsd-tests/usr.sbin/tcpdump/t_tcpdump.sh new file mode 100755 index 000000000000..5cd89b41abe4 --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/tcpdump/t_tcpdump.sh @@ -0,0 +1,59 @@ +# $NetBSD: t_tcpdump.sh,v 1.4 2014/09/20 06:08:07 ozaki-r Exp $ +# +# Copyright (c) 2012 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Jukka Ruohonen. +# +# 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. +# +prom() { + atf_check -s ignore -o ignore -e ignore -x "tcpdump -c 1 -i $1" & + sleep 2; kill $! >/dev/null 2>&1 +} + +atf_test_case promiscuous +promiscuous_head() { + atf_set "require.user" "root" + atf_set "descr" "Test that switching an interface into and out " \ + "of promiscuous mode does not lockup (PR kern/46328)" +} + +promiscuous_body() { + + for i in $(ifconfig -l); do + case $i in + bridge*) + echo "Skipping $i" + continue + ;; + esac + + echo "Testing $i" + prom $i + done +} + +atf_init_test_cases() { + atf_add_test_case promiscuous +} diff --git a/contrib/netbsd-tests/usr.sbin/traceroute/t_traceroute.sh b/contrib/netbsd-tests/usr.sbin/traceroute/t_traceroute.sh new file mode 100755 index 000000000000..cc2b2f40f89b --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/traceroute/t_traceroute.sh @@ -0,0 +1,128 @@ +# $NetBSD: t_traceroute.sh,v 1.5 2013/02/19 21:08:25 joerg Exp $ +# +# Copyright (c) 2010 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. +# + +netserver=\ +"rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif" + +atf_test_case basic cleanup +basic_head() +{ + + atf_set "descr" "Does a simple three-hop traceroute" + atf_set "require.progs" "rump_server" +} + +cfgendpt () +{ + + sock=${1} + addr=${2} + route=${3} + bus=${4} + + export RUMP_SERVER=${sock} + atf_check -s exit:0 rump.ifconfig shmif0 create + atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${bus} + atf_check -s exit:0 rump.ifconfig shmif0 inet ${addr} netmask 0xffffff00 + atf_check -s exit:0 -o ignore rump.route add default ${route} +} + +threeservers() +{ + + atf_check -s exit:0 ${netserver} unix://commsock1 + atf_check -s exit:0 ${netserver} unix://commsock2 + atf_check -s exit:0 ${netserver} unix://commsock3 + + # configure endpoints + cfgendpt unix://commsock1 1.2.3.4 1.2.3.1 bus1 + cfgendpt unix://commsock3 2.3.4.5 2.3.4.1 bus2 + + # configure the router + export RUMP_SERVER=unix://commsock2 + atf_check -s exit:0 rump.ifconfig shmif0 create + atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1 + atf_check -s exit:0 rump.ifconfig shmif0 inet 1.2.3.1 netmask 0xffffff00 + + atf_check -s exit:0 rump.ifconfig shmif1 create + atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus2 + atf_check -s exit:0 rump.ifconfig shmif1 inet 2.3.4.1 netmask 0xffffff00 +} + +threecleanup() +{ + env RUMP_SERVER=unix://commsock1 rump.halt + env RUMP_SERVER=unix://commsock2 rump.halt + env RUMP_SERVER=unix://commsock3 rump.halt +} + +threetests() +{ + + threeservers + export RUMP_SERVER=unix://commsock1 + atf_check -s exit:0 -o inline:'1.2.3.1\n2.3.4.5\n' -e ignore -x \ + "rump.traceroute ${1} -n 2.3.4.5 | awk '{print \$2}'" + export RUMP_SERVER=unix://commsock3 + atf_check -s exit:0 -o inline:'2.3.4.1\n1.2.3.4\n' -e ignore -x \ + "rump.traceroute ${1} -n 1.2.3.4 | awk '{print \$2}'" +} + +basic_body() +{ + threetests +} + +basic_cleanup() +{ + threecleanup +} + +atf_test_case basic_icmp cleanup +basic_icmp_head() +{ + + atf_set "descr" "Does an ICMP-based three-hop traceroute" + atf_set "require.progs" "rump_server" +} + +basic_icmp_body() +{ + threetests -I +} + +basic_icmp_cleanup() +{ + threecleanup +} + +atf_init_test_cases() +{ + + atf_add_test_case basic + atf_add_test_case basic_icmp +} diff --git a/contrib/netbsd-tests/usr.sbin/useradd/t_useradd.sh b/contrib/netbsd-tests/usr.sbin/useradd/t_useradd.sh new file mode 100755 index 000000000000..c55818e07f0b --- /dev/null +++ b/contrib/netbsd-tests/usr.sbin/useradd/t_useradd.sh @@ -0,0 +1,50 @@ +# $NetBSD: t_useradd.sh,v 1.1 2012/04/19 18:51:36 jruoho Exp $ +# +# Copyright (c) 2012 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Jukka Ruohonen. +# +# 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. +# +username="test5678901234567" + +atf_test_case longname cleanup +longname_head() { + atf_set "require.user" "root" + atf_set "descr" "Test that usernames longer than 16 " \ + "characters are allowed (PR bin/39546)" +} + +longname_body() { + atf_expect_fail "PR bin/39546" + atf_check -s exit:0 -o ignore -e ignore -x "useradd $username" +} + +longname_cleanup() { + atf_check -s ignore -o ignore -e ignore -x "userdel $username" +} + +atf_init_test_cases() { + atf_add_test_case longname +}