From owner-svn-src-head@freebsd.org Thu Mar 23 03:28:28 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 22526D19019; Thu, 23 Mar 2017 03:28:28 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D139ECDD; Thu, 23 Mar 2017 03:28:27 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2N3SRSt073131; Thu, 23 Mar 2017 03:28:27 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2N3SPPG073110; Thu, 23 Mar 2017 03:28:25 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703230328.v2N3SPPG073110@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 23 Mar 2017 03:28:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r315776 - in head: . usr.bin/col/tests usr.bin/diff/tests usr.bin/ident/tests usr.bin/mkimg/tests usr.bin/sdiff/tests usr.bin/soelim/tests usr.sbin/pw/tests X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 03:28:28 -0000 Author: ngie Date: Thu Mar 23 03:28:24 2017 New Revision: 315776 URL: https://svnweb.freebsd.org/changeset/base/315776 Log: Rename tests from to _test to match the FreeBSD test suite naming scheme usr.bin/diff/diff_test was renamed to usr.bin/diff/netbsd_diff_test to avoid collisions with the renamed FreeBSD test. MFC after: 1 week Sponsored by: Dell EMC Isilon Added: head/usr.bin/col/tests/col_test.sh - copied unchanged from r315775, head/usr.bin/col/tests/col.sh head/usr.bin/diff/tests/diff_test.sh - copied unchanged from r315775, head/usr.bin/diff/tests/diff.sh head/usr.bin/ident/tests/ident_test.sh - copied unchanged from r315775, head/usr.bin/ident/tests/ident.sh head/usr.bin/mkimg/tests/mkimg_test.sh - copied unchanged from r315775, head/usr.bin/mkimg/tests/mkimg.sh head/usr.bin/sdiff/tests/sdiff_test.sh - copied unchanged from r315775, head/usr.bin/sdiff/tests/sdiff.sh head/usr.bin/soelim/tests/soelim_test.sh - copied unchanged from r315775, head/usr.bin/soelim/tests/soelim.sh head/usr.sbin/pw/tests/pw_config_test.sh - copied unchanged from r315775, head/usr.sbin/pw/tests/pw_config.sh head/usr.sbin/pw/tests/pw_etcdir_test.sh - copied unchanged from r315775, head/usr.sbin/pw/tests/pw_etcdir.sh head/usr.sbin/pw/tests/pw_groupadd_test.sh - copied unchanged from r315775, head/usr.sbin/pw/tests/pw_groupadd.sh head/usr.sbin/pw/tests/pw_groupdel_test.sh - copied unchanged from r315775, head/usr.sbin/pw/tests/pw_groupdel.sh head/usr.sbin/pw/tests/pw_groupmod_test.sh - copied unchanged from r315775, head/usr.sbin/pw/tests/pw_groupmod.sh head/usr.sbin/pw/tests/pw_lock_test.sh - copied unchanged from r315775, head/usr.sbin/pw/tests/pw_lock.sh head/usr.sbin/pw/tests/pw_useradd_test.sh - copied unchanged from r315775, head/usr.sbin/pw/tests/pw_useradd.sh head/usr.sbin/pw/tests/pw_userdel_test.sh - copied unchanged from r315775, head/usr.sbin/pw/tests/pw_userdel.sh head/usr.sbin/pw/tests/pw_usermod_test.sh - copied unchanged from r315775, head/usr.sbin/pw/tests/pw_usermod.sh head/usr.sbin/pw/tests/pw_usernext_test.sh - copied unchanged from r315775, head/usr.sbin/pw/tests/pw_usernext.sh Deleted: head/usr.bin/col/tests/col.sh head/usr.bin/diff/tests/diff.sh head/usr.bin/ident/tests/ident.sh head/usr.bin/mkimg/tests/mkimg.sh head/usr.bin/sdiff/tests/sdiff.sh head/usr.bin/soelim/tests/soelim.sh head/usr.sbin/pw/tests/pw_config.sh head/usr.sbin/pw/tests/pw_etcdir.sh head/usr.sbin/pw/tests/pw_groupadd.sh head/usr.sbin/pw/tests/pw_groupdel.sh head/usr.sbin/pw/tests/pw_groupmod.sh head/usr.sbin/pw/tests/pw_lock.sh head/usr.sbin/pw/tests/pw_useradd.sh head/usr.sbin/pw/tests/pw_userdel.sh head/usr.sbin/pw/tests/pw_usermod.sh head/usr.sbin/pw/tests/pw_usernext.sh Modified: head/ObsoleteFiles.inc head/usr.bin/col/tests/Makefile head/usr.bin/diff/tests/Makefile head/usr.bin/ident/tests/Makefile head/usr.bin/mkimg/tests/Makefile head/usr.bin/sdiff/tests/Makefile head/usr.bin/soelim/tests/Makefile head/usr.sbin/pw/tests/Makefile Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Thu Mar 23 02:57:08 2017 (r315775) +++ head/ObsoleteFiles.inc Thu Mar 23 03:28:24 2017 (r315776) @@ -38,6 +38,23 @@ # xargs -n1 | sort | uniq -d; # done +# 20170322: rename to _test to match the FreeBSD test suite name scheme +OLD_FILES+=usr/tests/usr.bin/col/col +OLD_FILES+=usr/tests/usr.bin/diff/diff +OLD_FILES+=usr/tests/usr.bin/ident/ident +OLD_FILES+=usr/tests/usr.bin/mkimg/mkimg +OLD_FILES+=usr/tests/usr.bin/sdiff/sdiff +OLD_FILES+=usr/tests/usr.bin/soelim/soelim +OLD_FILES+=usr/tests/usr.sbin/pw/pw_config_test +OLD_FILES+=usr/tests/usr.sbin/pw/pw_etcdir_test +OLD_FILES+=usr/tests/usr.sbin/pw/pw_lock_test +OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupadd_test +OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupdel_test +OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupmod_test +OLD_FILES+=usr/tests/usr.sbin/pw/pw_useradd_test +OLD_FILES+=usr/tests/usr.sbin/pw/pw_userdel_test +OLD_FILES+=usr/tests/usr.sbin/pw/pw_usermod_test +OLD_FILES+=usr/tests/usr.sbin/pw/pw_usernext_test # 20170322: garbage collect old references to igb(4) OLD_FILES+=usr/share/man/man4/if_igb.4.gz OLD_FILES+=usr/share/man/man4/igb.4.gz Modified: head/usr.bin/col/tests/Makefile ============================================================================== --- head/usr.bin/col/tests/Makefile Thu Mar 23 02:57:08 2017 (r315775) +++ head/usr.bin/col/tests/Makefile Thu Mar 23 03:28:24 2017 (r315776) @@ -2,7 +2,7 @@ PACKAGE= tests -ATF_TESTS_SH= col +ATF_TESTS_SH= col_test ${PACKAGE}FILES+= \ rlf.in \ Copied: head/usr.bin/col/tests/col_test.sh (from r315775, head/usr.bin/col/tests/col.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/col/tests/col_test.sh Thu Mar 23 03:28:24 2017 (r315776, copy of r315775, head/usr.bin/col/tests/col.sh) @@ -0,0 +1,33 @@ +# $FreeBSD$ + +atf_test_case rlf + +rlf_head() +{ + atf_set "descr" "testing reverse line feed" +} +rlf_body() +{ + atf_check \ + -o inline:"a b\n" \ + -e empty \ + -s exit:0 \ + col < $(atf_get_srcdir)/rlf.in + + atf_check \ + -o inline:"a b\n" \ + -e empty \ + -s exit:0 \ + col < $(atf_get_srcdir)/rlf2.in + + atf_check \ + -o inline:"a b\n" \ + -e empty \ + -s exit:0 \ + col -x < $(atf_get_srcdir)/rlf2.in +} + +atf_init_test_cases() +{ + atf_add_test_case rlf +} Modified: head/usr.bin/diff/tests/Makefile ============================================================================== --- head/usr.bin/diff/tests/Makefile Thu Mar 23 02:57:08 2017 (r315775) +++ head/usr.bin/diff/tests/Makefile Thu Mar 23 03:28:24 2017 (r315776) @@ -2,7 +2,7 @@ PACKAGE= tests -ATF_TESTS_SH= diff +ATF_TESTS_SH= diff_test ${PACKAGE}FILES+= \ input1.in \ @@ -21,13 +21,14 @@ ${PACKAGE}FILES+= \ unified_c9999.out \ unified_9999.out -NETBSD_ATF_TESTS_SH+= diff_test +NETBSD_ATF_TESTS_SH+= netbsd_diff_test ${PACKAGE}FILES+= \ d_mallocv1.in \ d_mallocv2.in -ATF_TESTS_SH_SED_diff_test+= -e 's,t_diff,diff_test,g' +ATF_TESTS_SH_SED_netbsd_diff_test+= -e 's,t_diff,netbsd_diff_test,g' +ATF_TESTS_SH_SRC_netbsd_diff_test= t_diff.sh .include Copied: head/usr.bin/diff/tests/diff_test.sh (from r315775, head/usr.bin/diff/tests/diff.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/diff/tests/diff_test.sh Thu Mar 23 03:28:24 2017 (r315776, copy of r315775, head/usr.bin/diff/tests/diff.sh) @@ -0,0 +1,53 @@ +# $FreeBSD$ + +atf_test_case simple +atf_test_case unified + +simple_body() +{ + atf_check -o file:$(atf_get_srcdir)/simple.out -s eq:1 \ + diff "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" + + atf_check -o file:$(atf_get_srcdir)/simple_e.out -s eq:1 \ + diff -e "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" + + atf_check -o file:$(atf_get_srcdir)/simple_u.out -s eq:1 \ + diff -u -L input1 -L input2 "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" + + atf_check -o file:$(atf_get_srcdir)/simple_n.out -s eq:1 \ + diff -n "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" + + atf_check -o inline:"Files $(atf_get_srcdir)/input1.in and $(atf_get_srcdir)/input2.in differ\n" -s eq:1 \ + diff -q "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" + + atf_check \ + diff -q "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input1.in" + + atf_check -o file:$(atf_get_srcdir)/simple_i.out -s eq:1 \ + diff -i "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" + + atf_check -o file:$(atf_get_srcdir)/simple_w.out -s eq:1 \ + diff -w "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" + + atf_check -o file:$(atf_get_srcdir)/simple_b.out -s eq:1 \ + diff -b "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" + + atf_check -o file:$(atf_get_srcdir)/simple_p.out -s eq:1 \ + diff --label input_c1.in --label input_c2.in -p "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" +} + +unified_body() +{ + atf_check -o file:$(atf_get_srcdir)/unified_p.out -s eq:1 \ + diff -up -L input_c1.in -L input_c2.in "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" + atf_check -o file:$(atf_get_srcdir)/unified_c9999.out -s eq:1 \ + diff -u -c9999 -L input_c1.in -L input_c2.in "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" + atf_check -o file:$(atf_get_srcdir)/unified_9999.out -s eq:1 \ + diff -u9999 -L input_c1.in -L input_c2.in "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" +} + +atf_init_test_cases() +{ + atf_add_test_case simple + atf_add_test_case unified +} Modified: head/usr.bin/ident/tests/Makefile ============================================================================== --- head/usr.bin/ident/tests/Makefile Thu Mar 23 02:57:08 2017 (r315775) +++ head/usr.bin/ident/tests/Makefile Thu Mar 23 03:28:24 2017 (r315776) @@ -2,7 +2,7 @@ PACKAGE= tests -ATF_TESTS_SH= ident +ATF_TESTS_SH= ident_test ${PACKAGE}FILES+= \ test.in \ test.out \ Copied: head/usr.bin/ident/tests/ident_test.sh (from r315775, head/usr.bin/ident/tests/ident.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/ident/tests/ident_test.sh Thu Mar 23 03:28:24 2017 (r315776, copy of r315775, head/usr.bin/ident/tests/ident.sh) @@ -0,0 +1,16 @@ +# $FreeBSD$ + +atf_test_case ident +ident_body() { + atf_check -o file:$(atf_get_srcdir)/test.out \ + ident < $(atf_get_srcdir)/test.in + atf_check -o match:'Foo.*' -s exit:1 \ + -e inline:"ident warning: no id keywords in $(atf_get_srcdir)/testnoid\n" \ + ident $(atf_get_srcdir)/test.in $(atf_get_srcdir)/testnoid + atf_check -o match:'Foo.*' -s exit:1 \ + ident -q $(atf_get_srcdir)/test.in $(atf_get_srcdir)/testnoid +} +atf_init_test_cases() +{ + atf_add_test_case ident +} Modified: head/usr.bin/mkimg/tests/Makefile ============================================================================== --- head/usr.bin/mkimg/tests/Makefile Thu Mar 23 02:57:08 2017 (r315775) +++ head/usr.bin/mkimg/tests/Makefile Thu Mar 23 03:28:24 2017 (r315776) @@ -2,7 +2,7 @@ PACKAGE= tests -ATF_TESTS_SH= mkimg +ATF_TESTS_SH= mkimg_test SOURCES!= cd ${.CURDIR}; echo *.uu ${PACKAGE}FILES+= ${SOURCES:S,.gz.uu,,g} Copied: head/usr.bin/mkimg/tests/mkimg_test.sh (from r315775, head/usr.bin/mkimg/tests/mkimg.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/mkimg/tests/mkimg_test.sh Thu Mar 23 03:28:24 2017 (r315776, copy of r315775, head/usr.bin/mkimg/tests/mkimg.sh) @@ -0,0 +1,164 @@ +# $FreeBSD$ + +mkimg_blksz_list="512 4096" +mkimg_format_list="qcow qcow2 raw vhd vhdf vmdk" +mkimg_geom_list="1x1 63x255" +mkimg_scheme_list="apm bsd ebr gpt mbr vtoc8" + +bootcode() +{ + case $1 in + bsd) echo 8192 ;; + gpt|mbr) echo 512 ;; + *) echo 0 ;; + esac + return 0 +} + +mkcontents() +{ + local byte count name + + byte=$1 + count=$2 + + name=_tmp-$byte-$count.bin + jot -b $byte $(($count/2)) > $name + echo $name + return 0 +} + +makeimage() +{ + local blksz bootarg bootsz format geom nhds nsecs partarg pfx scheme + + format=$1 + scheme=$2 + blksz=$3 + geom=$4 + pfx=$5 + shift 5 + + nsecs=${geom%x*} + nhds=${geom#*x} + + bootsz=`bootcode $scheme` + if test $bootsz -gt 0; then + bootarg="-b `mkcontents B $bootsz`" + else + bootarg="" + fi + + partarg="" + for P in $*; do + partarg="$partarg -p $P" + done + if test -z "$partarg"; then + local swap ufs + swap="-p freebsd-swap::128K" + ufs="-p freebsd-ufs:=`mkcontents P 4194304`" + partarg="$ufs $swap" + fi + + imagename=$pfx-$geom-$blksz-$scheme.$format + + mkimg -y -f $format -o $imagename -s $scheme -P $blksz -H $nhds -T $nsecs \ + $bootarg $partarg + echo $imagename + return 0 +} + +mkimg_rebase() +{ + local baseline image result tmpfile update + + image=$1 + result=$2 + + baseline=$image.gz.uu + update=yes + + if test -f $baseline; then + tmpfile=_tmp-baseline + uudecode -p $baseline | gunzip -c > $tmpfile + if cmp -s $tmpfile $result; then + update=no + fi + fi + + if test $update = yes; then + # Prevent keyword expansion when writing the keyword. + (echo -n '# $'; echo -n FreeBSD; echo '$') > $baseline + gzip -c $result | uuencode $image.gz >> $baseline + fi + + rm $image $result _tmp-* + return 0 +} + +mkimg_test() +{ + local blksz format geom scheme + + geom=$1 + blksz=$2 + scheme=$3 + format=$4 + + case $scheme in + ebr|mbr) + bsd=`makeimage raw bsd $blksz $geom _tmp` + partinfo="freebsd:=$bsd" + ;; + *) + partinfo="" + ;; + esac + image=`makeimage $format $scheme $blksz $geom img $partinfo` + result=$image.out + hexdump -C $image > $result + if test "x$mkimg_update_baseline" = "xyes"; then + mkimg_rebase $image $result + else + baseline=`atf_get_srcdir`/$image + atf_check -s exit:0 cmp -s $baseline $result + fi + return 0 +} + +atf_test_case rebase +rebase_body() +{ + local nm + + mkimg_update_baseline=yes + for nm in $mkimg_tests; do + ${nm}_body + done + return 0 +} + +atf_init_test_cases() +{ + local B F G S nm + + for G in $mkimg_geom_list; do + for B in $mkimg_blksz_list; do + for S in $mkimg_scheme_list; do + for F in $mkimg_format_list; do + nm="${S}_${G}_${B}_${F}" + atf_test_case $nm + eval "${nm}_body() { mkimg_test $G $B $S $F; }" + mkimg_tests="${mkimg_tests} ${nm}" + atf_add_test_case $nm + done + done + done + done + + # XXX hack to make updating the baseline easier + if test "${__RUNNING_INSIDE_ATF_RUN}" != "internal-yes-value"; then + atf_add_test_case rebase + fi +} + Modified: head/usr.bin/sdiff/tests/Makefile ============================================================================== --- head/usr.bin/sdiff/tests/Makefile Thu Mar 23 02:57:08 2017 (r315775) +++ head/usr.bin/sdiff/tests/Makefile Thu Mar 23 03:28:24 2017 (r315776) @@ -2,7 +2,7 @@ PACKAGE= tests -ATF_TESTS_SH= sdiff +ATF_TESTS_SH= sdiff_test ${PACKAGE}FILES+= \ d_dot.in \ Copied: head/usr.bin/sdiff/tests/sdiff_test.sh (from r315775, head/usr.bin/sdiff/tests/sdiff.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/sdiff/tests/sdiff_test.sh Thu Mar 23 03:28:24 2017 (r315776, copy of r315775, head/usr.bin/sdiff/tests/sdiff.sh) @@ -0,0 +1,207 @@ +# $NetBSD: t_sdiff.sh,v 1.1 2012/03/17 16:33:15 jruoho Exp $ +# $FreeBSD$ +# +# Copyright (c) 2008, 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. +# + +atf_test_case flags +flags_head() +{ + atf_set "descr" "Checks -l, -s and -w flags" +} +flags_body() +{ + atf_check -o file:$(atf_get_srcdir)/d_flags_l.out -s eq:1 \ + sdiff -l "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input2" + + atf_check -o file:$(atf_get_srcdir)/d_flags_s.out -s eq:1 \ + sdiff -s "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input2" + + atf_check -o file:$(atf_get_srcdir)/d_flags_w.out -s eq:1 \ + sdiff -w 125 "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input2" +} + +atf_test_case iflags +iflags_head() +{ + atf_set "descr" "Checks flags -l, -s and -w combined with -I" +} +iflags_body() +{ + tail1="-w 125 -I .*filename.* $(atf_get_srcdir)/d_input1 $(atf_get_srcdir)/d_input2" + tail2="-w 125 -I .*filename.* $(atf_get_srcdir)/d_input2 $(atf_get_srcdir)/d_input1" + + atf_check -o file:$(atf_get_srcdir)/d_iflags_a1.out -s eq:1 sdiff ${tail1} + atf_check -o file:$(atf_get_srcdir)/d_iflags_a2.out -s eq:1 sdiff ${tail2} + atf_check -o file:$(atf_get_srcdir)/d_iflags_b1.out -s eq:1 sdiff -s ${tail1} + atf_check -o file:$(atf_get_srcdir)/d_iflags_b2.out -s eq:1 sdiff -s ${tail2} + atf_check -o file:$(atf_get_srcdir)/d_iflags_c1.out -s eq:1 sdiff -l ${tail1} + atf_check -o file:$(atf_get_srcdir)/d_iflags_c2.out -s eq:1 sdiff -l ${tail2} + atf_check -o file:$(atf_get_srcdir)/d_iflags_d1.out -s eq:1 sdiff -s ${tail1} + atf_check -o file:$(atf_get_srcdir)/d_iflags_d2.out -s eq:1 sdiff -s ${tail2} +} + +atf_test_case tabs +tabs_head() +{ + atf_set "descr" "Checks comparing files containing tabs" +} +tabs_body() +{ + atf_check -o file:$(atf_get_srcdir)/d_tabs.out -s eq:1 \ + sdiff "$(atf_get_srcdir)/d_tabs1.in" "$(atf_get_srcdir)/d_tabs2.in" +} + +atf_test_case tabends +tabends_head() +{ + atf_set "descr" "Checks correct handling of lines ended with tabs" +} +tabends_body() +{ + atf_check -o file:$(atf_get_srcdir)/d_tabends_a.out -s eq:1 \ + sdiff -w30 "$(atf_get_srcdir)/d_tabends.in" /dev/null + + atf_check -o file:$(atf_get_srcdir)/d_tabends_b.out -s eq:1 \ + sdiff -w30 /dev/null "$(atf_get_srcdir)/d_tabends.in" + + atf_check -o file:$(atf_get_srcdir)/d_tabends_c.out -s eq:1 \ + sdiff -w19 "$(atf_get_srcdir)/d_tabends.in" /dev/null +} + +atf_test_case merge +merge_head() +{ + atf_set "descr" "Checks interactive merging" +} +merge_body() +{ + merge_tail="-o merge.out $(atf_get_srcdir)/d_input1 \ +$(atf_get_srcdir)/d_input2 >/dev/null ; cat merge.out" + + cp $(atf_get_srcdir)/d_input* . + + atf_check -o file:d_input1 -x "yes l | sdiff ${merge_tail}" + atf_check -o file:d_input2 -x "yes r | sdiff ${merge_tail}" + + atf_check -o file:d_input1 -x \ + "yes el | EDITOR=cat VISUAL=cat sdiff ${merge_tail}" + atf_check -o file:d_input2 -x \ + "yes er | EDITOR=cat VISUAL=cat sdiff ${merge_tail}" + + atf_check -o file:d_input1 -x "yes l | sdiff -s ${merge_tail}" + atf_check -o file:d_input2 -x "yes r | sdiff -s ${merge_tail}" + atf_check -o file:d_input1 -x "yes l | sdiff -l ${merge_tail}" + atf_check -o file:d_input2 -x "yes r | sdiff -l ${merge_tail}" + atf_check -o file:d_input1 -x "yes l | sdiff -ls ${merge_tail}" + atf_check -o file:d_input2 -x "yes r | sdiff -ls ${merge_tail}" + + atf_check -o file:d_input1 -x "{ while :; do echo s; echo l; \ +echo v; echo l; done; } | sdiff ${merge_tail}" + + atf_check -o file:d_input2 -x "{ while :; do echo s; echo r; \ +echo v; echo r; done; } | sdiff ${merge_tail}" +} + +atf_test_case same +same_head() +{ + atf_set "descr" "Checks comparing file with itself" +} +same_body() +{ + atf_check -o file:$(atf_get_srcdir)/d_same.out \ + sdiff "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input1" +} + +atf_test_case oneline +oneline_head() +{ + atf_set "descr" "Checks comparing one-line files" +} +oneline_body() +{ + atf_check -o file:$(atf_get_srcdir)/d_oneline_a.out -s eq:1 \ + sdiff /dev/null "$(atf_get_srcdir)/d_oneline.in" + + atf_check -o file:$(atf_get_srcdir)/d_oneline_b.out -s eq:1 \ + sdiff "$(atf_get_srcdir)/d_oneline.in" /dev/null +} + +atf_test_case dot +dot_head() +{ + atf_set "descr" "Checks comparing with file containing only one character" +} +dot_body() +{ + echo ". <" > expout + atf_check -o file:expout -s eq:1 sdiff "$(atf_get_srcdir)/d_dot.in" /dev/null + + echo " > ." > expout + atf_check -o file:expout -s eq:1 sdiff /dev/null "$(atf_get_srcdir)/d_dot.in" +} + +atf_test_case stdin +stdin_head() +{ + atf_set "descr" "Checks reading data from stdin" +} +stdin_body() +{ + echo " > stdin" > expout + atf_check -o file:expout -s eq:1 -x \ + "echo stdin | sdiff /dev/null /dev/stdin" + + echo "stdin <" > expout + atf_check -o file:expout -s eq:1 -x \ + "echo stdin | sdiff /dev/stdin /dev/null" +} + +atf_test_case short +short_head() +{ + atf_set "descr" "Checks premature stop of merging" +} +short_body() +{ + atf_check -o file:$(atf_get_srcdir)/d_short.out -x \ + "printf \"r\\nl\\nr\\nl\" | sdiff -o merge.out $(atf_get_srcdir)/d_input1 \ +$(atf_get_srcdir)/d_input2 >/dev/null ; cat merge.out" +} + +atf_init_test_cases() +{ + atf_add_test_case flags + atf_add_test_case iflags + atf_add_test_case tabs + atf_add_test_case tabends + atf_add_test_case merge + atf_add_test_case same + atf_add_test_case oneline + atf_add_test_case dot + atf_add_test_case stdin + atf_add_test_case short +} Modified: head/usr.bin/soelim/tests/Makefile ============================================================================== --- head/usr.bin/soelim/tests/Makefile Thu Mar 23 02:57:08 2017 (r315775) +++ head/usr.bin/soelim/tests/Makefile Thu Mar 23 03:28:24 2017 (r315776) @@ -2,7 +2,7 @@ PACKAGE= tests -ATF_TESTS_SH= soelim +ATF_TESTS_SH= soelim_test ${PACKAGE}FILES+= nonexisting.in \ basic.in \ Copied: head/usr.bin/soelim/tests/soelim_test.sh (from r315775, head/usr.bin/soelim/tests/soelim.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/soelim/tests/soelim_test.sh Thu Mar 23 03:28:24 2017 (r315776, copy of r315775, head/usr.bin/soelim/tests/soelim.sh) @@ -0,0 +1,103 @@ +# $FreeBSD$ + +atf_test_case stdin +stdin_head() +{ + atf_set "descr" "stdin functionality" +} + +stdin_body() +{ + # no file after .so + atf_check \ + -o inline:".so\n" \ + -e empty \ + -s exit:0 \ + soelim <<-EOF +.so +EOF + + # only space after .so + atf_check \ + -o inline:".so \n" \ + -e empty \ + -s exit:0 \ + soelim <<-EOF +.so +EOF + + # explicit stdin + atf_check \ + -o inline:".so\n" \ + -e empty \ + -s exit:0 \ + soelim - <<-EOF +.so +EOF + + atf_check \ + -o empty \ + -e inline:"soelim: can't open 'afile': No such file or directory\n" \ + -s exit:1 \ + soelim <<-EOF +.so afile +EOF + + atf_check \ + -o inline:".soafile\n" \ + -e empty \ + -s exit:0 \ + soelim <<-EOF +.soafile +EOF + + atf_check \ + -o empty \ + -e inline:"soelim: can't open 'afile': No such file or directory\n" \ + -s exit:1 \ + soelim -C <<-EOF +.soafile +EOF +} + +atf_test_case files +files_head() +{ + atf_set "descr" "testing files" +} + +files_body() +{ + atf_check \ + -o inline:"This is a test\n" \ + -e inline:"soelim: can't open 'nonexistingfile': No such file or directory\n" \ + -s exit:1 \ + soelim $(atf_get_srcdir)/nonexisting.in + + cp $(atf_get_srcdir)/basic . + atf_check \ + -o file:$(atf_get_srcdir)/basic.out \ + -e empty \ + -s exit:0 \ + soelim $(atf_get_srcdir)/basic.in + + rm -f basic + atf_check \ + -o file:$(atf_get_srcdir)/basic.out \ + -e empty \ + -s exit:0 \ + soelim -I$(atf_get_srcdir) $(atf_get_srcdir)/basic.in + + atf_check \ + -o file:$(atf_get_srcdir)/basic-with-space.out \ + -e empty \ + -s exit:0 \ + soelim -I$(atf_get_srcdir) $(atf_get_srcdir)/basic-with-space.in + +} + +atf_init_test_cases() +{ + atf_add_test_case stdin + atf_add_test_case files +} Modified: head/usr.sbin/pw/tests/Makefile ============================================================================== --- head/usr.sbin/pw/tests/Makefile Thu Mar 23 02:57:08 2017 (r315775) +++ head/usr.sbin/pw/tests/Makefile Thu Mar 23 03:28:24 2017 (r315776) @@ -8,16 +8,16 @@ PROGS+= crypt WARNS?= 6 LIBADD+= crypt -ATF_TESTS_SH= pw_etcdir \ - pw_lock \ - pw_config \ - pw_groupadd \ - pw_groupdel \ - pw_groupmod \ - pw_useradd \ - pw_userdel \ - pw_usermod \ - pw_usernext +ATF_TESTS_SH= pw_etcdir_test \ + pw_lock_test \ + pw_config_test \ + pw_groupadd_test \ + pw_groupdel_test \ + pw_groupmod_test \ + pw_useradd_test \ + pw_userdel_test \ + pw_usermod_test \ + pw_usernext_test .for tp in ${ATF_TESTS_SH} TEST_METADATA.${tp}+= required_user="root" Copied: head/usr.sbin/pw/tests/pw_config_test.sh (from r315775, head/usr.sbin/pw/tests/pw_config.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/pw/tests/pw_config_test.sh Thu Mar 23 03:28:24 2017 (r315776, copy of r315775, head/usr.sbin/pw/tests/pw_config.sh) @@ -0,0 +1,26 @@ +# $FreeBSD$ + +# Import helper functions +. $(atf_get_srcdir)/helper_functions.shin + +atf_test_case generate_config +generate_config_body() { + atf_check -s exit:0 \ + ${PW} useradd -D -C ${HOME}/foo.conf + atf_check -o file:$(atf_get_srcdir)/pw.conf \ + cat ${HOME}/foo.conf +} + +atf_test_case modify_config_uid_gid_boundaries +modify_config_uid_gid_boundaries_body() { + atf_check -s exit:0 \ + ${PW} useradd -D -C ${HOME}/foo.conf \ + -u 2000,5000 -i 2100,6000 + atf_check -o file:$(atf_get_srcdir)/pw-modified.conf \ + cat ${HOME}/foo.conf +} + +atf_init_test_cases() { + atf_add_test_case generate_config + atf_add_test_case modify_config_uid_gid_boundaries +} Copied: head/usr.sbin/pw/tests/pw_etcdir_test.sh (from r315775, head/usr.sbin/pw/tests/pw_etcdir.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/pw/tests/pw_etcdir_test.sh Thu Mar 23 03:28:24 2017 (r315776, copy of r315775, head/usr.sbin/pw/tests/pw_etcdir.sh) @@ -0,0 +1,18 @@ +# $FreeBSD$ + +# When the '-V directory' option is provided, the directory must exist +atf_test_case etcdir_must_exist +etcdir_must_exist_head() { + atf_set "descr" "When the '-V directory' option is provided, the directory must exist" +} + +etcdir_must_exist_body() { + local fakedir="/this_directory_does_not_exist" + atf_check -e inline:"pw: no such directory \`$fakedir'\n" \ + -s exit:72 -x pw -V ${fakedir} usershow root +} + +atf_init_test_cases() { + atf_add_test_case etcdir_must_exist +} + Copied: head/usr.sbin/pw/tests/pw_groupadd_test.sh (from r315775, head/usr.sbin/pw/tests/pw_groupadd.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/pw/tests/pw_groupadd_test.sh Thu Mar 23 03:28:24 2017 (r315776, copy of r315775, head/usr.sbin/pw/tests/pw_groupadd.sh) @@ -0,0 +1,26 @@ +# $FreeBSD$ + +# Import helper functions +. $(atf_get_srcdir)/helper_functions.shin + +atf_test_case group_add_gid_too_large +group_add_gid_too_large_body() { + populate_etc_skel + atf_check -s exit:64 -e inline:"pw: Bad id '9999999999999': too large\n" \ + ${PW} groupadd -n test1 -g 9999999999999 +} + +atf_test_case group_add_already_exists +group_add_already_exists_body() { + populate_etc_skel + + atf_check -s exit:0 ${PW} groupadd foo + atf_check -s exit:65 \ + -e inline:"pw: group name \`foo' already exists\n" \ + ${PW} groupadd foo +} + +atf_init_test_cases() { + atf_add_test_case group_add_gid_too_large + atf_add_test_case group_add_already_exists +} Copied: head/usr.sbin/pw/tests/pw_groupdel_test.sh (from r315775, head/usr.sbin/pw/tests/pw_groupdel.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/pw/tests/pw_groupdel_test.sh Thu Mar 23 03:28:24 2017 (r315776, copy of r315775, head/usr.sbin/pw/tests/pw_groupdel.sh) @@ -0,0 +1,24 @@ +# $FreeBSD$ + +# Import helper functions +. $(atf_get_srcdir)/helper_functions.shin + + +# Test to make sure we do not accidentially delete wheel when trying to delete +# an unknown group +atf_test_case group_do_not_delete_wheel_if_group_unknown +group_do_not_delete_wheel_if_group_unknown_head() { + atf_set "descr" "Make sure we do not consider gid 0 an unknown group" +} +group_do_not_delete_wheel_if_group_unknown_body() { + populate_etc_skel + atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x ${PW} groupshow wheel + atf_check -e inline:"pw: Bad id 'I_do_not_exist': invalid\n" -s exit:64 -x \ + ${PW} groupdel -g I_do_not_exist + atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x ${PW} groupshow wheel +} + + +atf_init_test_cases() { + atf_add_test_case group_do_not_delete_wheel_if_group_unknown +} Copied: head/usr.sbin/pw/tests/pw_groupmod_test.sh (from r315775, head/usr.sbin/pw/tests/pw_groupmod.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/pw/tests/pw_groupmod_test.sh Thu Mar 23 03:28:24 2017 (r315776, copy of r315775, head/usr.sbin/pw/tests/pw_groupmod.sh) @@ -0,0 +1,118 @@ +# $FreeBSD$ + +# Import helper functions +. $(atf_get_srcdir)/helper_functions.shin + + +# Test adding & removing a user from a group +atf_test_case groupmod_user +groupmod_user_body() { + populate_etc_skel + atf_check -s exit:0 ${PW} addgroup test + atf_check -s exit:0 ${PW} groupmod test -m root + atf_check -s exit:0 -o match:"^test:\*:1001:root$" \ + grep "^test:\*:.*:root$" $HOME/group + atf_check -s exit:0 ${PW} groupmod test -d root + atf_check -s exit:0 -o match:"^test:\*:1001:$" \ + grep "^test:\*:.*:$" $HOME/group +} + + +# Test adding and removing a user that does not exist +atf_test_case groupmod_invalid_user +groupmod_invalid_user_body() { + populate_etc_skel + atf_check -s exit:0 ${PW} addgroup test + atf_check -s exit:67 -e match:"does not exist" ${PW} groupmod test -m foo + atf_check -s exit:0 ${PW} groupmod test -d foo +} + +atf_test_case groupmod_bug_193704 +groupmod_bug_193704_head() { + atf_set "descr" "Regression test for the #193704 bug" +} +groupmod_bug_193704_body() { + populate_etc_skel + atf_check -s exit:0 -x ${PW} groupadd test + atf_check -s exit:0 -x ${PW} groupmod test -l newgroupname + atf_check -s exit:65 -e match:"^pw: unknown group" -x ${PW} groupshow test +} + +atf_test_case usermod_bug_185666 +usermod_bug_185666_head() { + atf_set "descr" "Regression test for the #185666 bug" +} + +usermod_bug_185666_body() { + populate_etc_skel + atf_check -s exit:0 -x ${PW} useradd testuser + atf_check -s exit:0 -x ${PW} groupadd testgroup + atf_check -s exit:0 -x ${PW} groupadd testgroup2 + atf_check -s exit:0 -x ${PW} usermod testuser -G testgroup + atf_check -o inline:"testuser:*:1001:\n" -x ${PW} groupshow testuser + atf_check -o inline:"testgroup:*:1002:testuser\n" -x ${PW} groupshow testgroup + atf_check -o inline:"testgroup2:*:1003:\n" -x ${PW} groupshow testgroup2 + atf_check -s exit:0 -x ${PW} usermod testuser -G testgroup2 + atf_check -o inline:"testuser:*:1001:\n" -x ${PW} groupshow testuser + atf_check -o inline:"testgroup:*:1002:\n" -x ${PW} groupshow testgroup + atf_check -o inline:"testgroup2:*:1003:testuser\n" -x ${PW} groupshow testgroup2 +} + +atf_test_case do_not_duplicate_group_on_gid_change +do_not_duplicate_group_on_gid_change_head() { + atf_set "descr" "Do not duplicate group on gid change" +} + +do_not_duplicate_group_on_gid_change_body() { + populate_etc_skel + atf_check -s exit:0 -x ${PW} groupadd testgroup + atf_check -s exit:0 -x ${PW} groupmod testgroup -g 12345 + # use grep to see if the entry has not be duplicated + atf_check -o inline:"testgroup:*:12345:\n" -s exit:0 -x grep "^testgroup" ${HOME}/group +} + +atf_test_case groupmod_rename +groupmod_rename_body() { + populate_etc_skel + + atf_check -s exit:0 ${PW} groupadd foo + atf_check -s exit:0 ${PW} groupmod foo -l bar + atf_check -s exit:0 -o match:"^bar:.*" \ + grep "^bar:.*" ${HOME}/group +} + +atf_test_case groupmod_members +groupmod_members_body() { + populate_etc_skel + + for i in user1 user2 user3 user4; do + atf_check -s exit:0 ${PW} useradd $i + done + + atf_check -s exit:0 ${PW} groupadd foo -M "user1, user2" + atf_check -o inline:"foo:*:1005:user1,user2\n" -s exit:0 \ + ${PW} groupshow foo + atf_check -s exit:0 ${PW} groupmod foo -m "user3, user4" + atf_check -o inline:"foo:*:1005:user1,user2,user3,user4\n" -s exit:0 \ + ${PW} groupshow foo + atf_check -s exit:0 ${PW} groupmod foo -M "user1, user4" + atf_check -o inline:"foo:*:1005:user1,user4\n" -s exit:0 \ + ${PW} groupshow foo + # what about duplicates + atf_check -s exit:0 ${PW} groupmod foo -m "user1, user2, user3, user4" + atf_check -o inline:"foo:*:1005:user1,user4,user2,user3\n" -s exit:0 \ + ${PW} groupshow foo + atf_check -s exit:0 ${PW} groupmod foo -d "user1, user3" + atf_check -o inline:"foo:*:1005:user4,user2\n" -s exit:0 \ + ${PW} groupshow foo +} + +atf_init_test_cases() { + atf_add_test_case groupmod_user + atf_add_test_case groupmod_invalid_user + atf_add_test_case groupmod_bug_193704 + atf_add_test_case usermod_bug_185666 + atf_add_test_case do_not_duplicate_group_on_gid_change + atf_add_test_case groupmod_rename + atf_add_test_case groupmod_members +} Copied: head/usr.sbin/pw/tests/pw_lock_test.sh (from r315775, head/usr.sbin/pw/tests/pw_lock.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/pw/tests/pw_lock_test.sh Thu Mar 23 03:28:24 2017 (r315776, copy of r315775, head/usr.sbin/pw/tests/pw_lock.sh) @@ -0,0 +1,42 @@ +# $FreeBSD$ + +# Import helper functions +. $(atf_get_srcdir)/helper_functions.shin + +# Test locking and unlocking a user account +atf_test_case user_locking cleanup +user_locking_body() { + populate_etc_skel + ${PW} useradd test || atf_fail "Creating test user" + ${PW} lock test || atf_fail "Locking the user" + atf_check -s exit:0 -o match:"^test:\*LOCKED\*\*:1001:" \ + grep "^test:\*LOCKED\*\*:1001:" $HOME/master.passwd + ${PW} unlock test || atf_fail "Locking the user" + atf_check -s exit:0 -o match:"^test:\*:1001:" \ + grep "^test:\*:1001:" $HOME/master.passwd +} + +atf_test_case numeric_locking cleanup +numeric_locking_body() { + populate_etc_skel + ${PW} useradd test || atf_fail "Creating test user" + ${PW} lock 1001 || atf_fail "Locking the user" + atf_check -s exit:0 -o match:"^test:\*LOCKED\*\*:1001:" \ + grep "^test:\*LOCKED\*\*:1001:" $HOME/master.passwd + ${PW} unlock 1001 || atf_fail "Unlocking the user" + atf_check -s exit:0 -o match:"^test:\*:1001:" \ + grep "^test:\*:1001:" $HOME/master.passwd + # Now numeric names + ${PW} useradd -n 1001 || atf_fail "Creating test user" + ${PW} lock 1001 || atf_fail "Locking the user" + atf_check -s exit:0 -o match:"^1001:\*LOCKED\*\*:1002:" \ + grep "^1001:\*LOCKED\*\*:1002:" $HOME/master.passwd + ${PW} unlock 1001 || atf_fail "Unlocking the user" + atf_check -s exit:0 -o match:"^1001:\*:1002:" \ + grep "^1001:\*:1002:" $HOME/master.passwd +} + *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***