diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/Makefile | 8 | ||||
-rw-r--r-- | usr.sbin/mtree/Makefile | 24 | ||||
-rw-r--r-- | usr.sbin/mtree/d_convert.in | 40 | ||||
-rw-r--r-- | usr.sbin/mtree/d_convert_C.out | 14 | ||||
-rw-r--r-- | usr.sbin/mtree/d_convert_C_S.out | 14 | ||||
-rw-r--r-- | usr.sbin/mtree/d_convert_D.out | 14 | ||||
-rw-r--r-- | usr.sbin/mtree/d_convert_D_S.out | 14 | ||||
-rw-r--r-- | usr.sbin/mtree/d_merge.in | 27 | ||||
-rw-r--r-- | usr.sbin/mtree/d_merge_C_M.out | 13 | ||||
-rw-r--r-- | usr.sbin/mtree/d_merge_C_M_S.out | 13 | ||||
-rw-r--r-- | usr.sbin/mtree/mtree_d_create.out | 55 | ||||
-rw-r--r-- | usr.sbin/mtree/netbsd6_d_create.out | 55 | ||||
-rwxr-xr-x | usr.sbin/mtree/t_mtree.sh | 422 | ||||
-rw-r--r-- | usr.sbin/tcpdump/Makefile | 9 | ||||
-rwxr-xr-x | usr.sbin/tcpdump/t_tcpdump.sh | 59 | ||||
-rw-r--r-- | usr.sbin/traceroute/Makefile | 10 | ||||
-rwxr-xr-x | usr.sbin/traceroute/t_traceroute.sh | 128 | ||||
-rw-r--r-- | usr.sbin/useradd/Makefile | 11 | ||||
-rwxr-xr-x | usr.sbin/useradd/t_useradd.sh | 50 |
19 files changed, 980 insertions, 0 deletions
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile new file mode 100644 index 000000000000..1a4d1e090df7 --- /dev/null +++ b/usr.sbin/Makefile @@ -0,0 +1,8 @@ +# $NetBSD: Makefile,v 1.4 2012/04/19 18:51:35 jruoho Exp $ +.include <bsd.own.mk> + +TESTSDIR= ${TESTSBASE}/usr.sbin + +TESTS_SUBDIRS+= mtree tcpdump traceroute useradd + +.include <bsd.test.mk> diff --git a/usr.sbin/mtree/Makefile b/usr.sbin/mtree/Makefile new file mode 100644 index 000000000000..51fef9bd3f17 --- /dev/null +++ b/usr.sbin/mtree/Makefile @@ -0,0 +1,24 @@ +# $NetBSD: Makefile,v 1.2 2013/01/02 18:11:44 christos Exp $ + +NOMAN= # defined + +.include <bsd.own.mk> + +TESTSDIR= ${TESTSBASE}/usr.sbin/mtree + +TESTS_SH= t_mtree + +FILESDIR= ${TESTSDIR} + +FILES+= d_convert.in +FILES+= d_convert_C.out +FILES+= d_convert_C_S.out +FILES+= d_convert_D.out +FILES+= d_convert_D_S.out +FILES+= netbsd6_d_create.out +FILES+= mtree_d_create.out +FILES+= d_merge.in +FILES+= d_merge_C_M.out +FILES+= d_merge_C_M_S.out + +.include <bsd.test.mk> diff --git a/usr.sbin/mtree/d_convert.in b/usr.sbin/mtree/d_convert.in new file mode 100644 index 000000000000..6a1abb07e1b0 --- /dev/null +++ b/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/usr.sbin/mtree/d_convert_C.out b/usr.sbin/mtree/d_convert_C.out new file mode 100644 index 000000000000..de4d9f6e5a2d --- /dev/null +++ b/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/usr.sbin/mtree/d_convert_C_S.out b/usr.sbin/mtree/d_convert_C_S.out new file mode 100644 index 000000000000..bd03cc458859 --- /dev/null +++ b/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/usr.sbin/mtree/d_convert_D.out b/usr.sbin/mtree/d_convert_D.out new file mode 100644 index 000000000000..c059478131a0 --- /dev/null +++ b/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/usr.sbin/mtree/d_convert_D_S.out b/usr.sbin/mtree/d_convert_D_S.out new file mode 100644 index 000000000000..a777a0b0112f --- /dev/null +++ b/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/usr.sbin/mtree/d_merge.in b/usr.sbin/mtree/d_merge.in new file mode 100644 index 000000000000..9efd04b018c8 --- /dev/null +++ b/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/usr.sbin/mtree/d_merge_C_M.out b/usr.sbin/mtree/d_merge_C_M.out new file mode 100644 index 000000000000..dea996699ffc --- /dev/null +++ b/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/usr.sbin/mtree/d_merge_C_M_S.out b/usr.sbin/mtree/d_merge_C_M_S.out new file mode 100644 index 000000000000..9f02beae7a2b --- /dev/null +++ b/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/usr.sbin/mtree/mtree_d_create.out b/usr.sbin/mtree/mtree_d_create.out new file mode 100644 index 000000000000..389ec653e076 --- /dev/null +++ b/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/usr.sbin/mtree/netbsd6_d_create.out b/usr.sbin/mtree/netbsd6_d_create.out new file mode 100644 index 000000000000..389ec653e076 --- /dev/null +++ b/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/usr.sbin/mtree/t_mtree.sh b/usr.sbin/mtree/t_mtree.sh new file mode 100755 index 000000000000..20fda75e02ea --- /dev/null +++ b/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.raw >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/usr.sbin/tcpdump/Makefile b/usr.sbin/tcpdump/Makefile new file mode 100644 index 000000000000..b93c5083ce36 --- /dev/null +++ b/usr.sbin/tcpdump/Makefile @@ -0,0 +1,9 @@ +# $NetBSD: Makefile,v 1.2 2012/04/14 12:43:05 jruoho Exp $ + +.include <bsd.own.mk> + +TESTSDIR= ${TESTSBASE}/usr.sbin/tcpdump + +TESTS_SH= t_tcpdump + +.include <bsd.test.mk> diff --git a/usr.sbin/tcpdump/t_tcpdump.sh b/usr.sbin/tcpdump/t_tcpdump.sh new file mode 100755 index 000000000000..5cd89b41abe4 --- /dev/null +++ b/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/usr.sbin/traceroute/Makefile b/usr.sbin/traceroute/Makefile new file mode 100644 index 000000000000..5a2fa5392ddd --- /dev/null +++ b/usr.sbin/traceroute/Makefile @@ -0,0 +1,10 @@ +# $NetBSD: Makefile,v 1.1 2010/12/15 00:13:52 pooka Exp $ +# + +.include <bsd.own.mk> + +TESTSDIR= ${TESTSBASE}/usr.sbin/traceroute + +TESTS_SH= t_traceroute + +.include <bsd.test.mk> diff --git a/usr.sbin/traceroute/t_traceroute.sh b/usr.sbin/traceroute/t_traceroute.sh new file mode 100755 index 000000000000..cc2b2f40f89b --- /dev/null +++ b/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/usr.sbin/useradd/Makefile b/usr.sbin/useradd/Makefile new file mode 100644 index 000000000000..eaf2ea44fd38 --- /dev/null +++ b/usr.sbin/useradd/Makefile @@ -0,0 +1,11 @@ +# $NetBSD: Makefile,v 1.1 2012/04/19 18:51:35 jruoho Exp $ + +NOMAN= # defined + +.include <bsd.own.mk> + +TESTSDIR= ${TESTSBASE}/usr.sbin/useradd + +TESTS_SH= t_useradd + +.include <bsd.test.mk> diff --git a/usr.sbin/useradd/t_useradd.sh b/usr.sbin/useradd/t_useradd.sh new file mode 100755 index 000000000000..c55818e07f0b --- /dev/null +++ b/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 +} |