svn commit: r316256 - in stable/11: . usr.bin/col/tests usr.bin/ident/tests usr.bin/mkimg/tests usr.bin/sdiff/tests usr.bin/soelim/tests usr.sbin/pw/tests

Ngie Cooper ngie at FreeBSD.org
Thu Mar 30 06:20:27 UTC 2017


Author: ngie
Date: Thu Mar 30 06:20:24 2017
New Revision: 316256
URL: https://svnweb.freebsd.org/changeset/base/316256

Log:
  MFC r315776:
  
  Rename tests from <foo> to <foo>_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.

Added:
  stable/11/usr.bin/col/tests/col_test.sh
     - copied unchanged from r315776, head/usr.bin/col/tests/col_test.sh
  stable/11/usr.bin/ident/tests/ident_test.sh
     - copied unchanged from r315776, head/usr.bin/ident/tests/ident_test.sh
  stable/11/usr.bin/mkimg/tests/mkimg_test.sh
     - copied unchanged from r315776, head/usr.bin/mkimg/tests/mkimg_test.sh
  stable/11/usr.bin/sdiff/tests/sdiff_test.sh
     - copied unchanged from r315776, head/usr.bin/sdiff/tests/sdiff_test.sh
  stable/11/usr.bin/soelim/tests/soelim_test.sh
     - copied unchanged from r315776, head/usr.bin/soelim/tests/soelim_test.sh
  stable/11/usr.sbin/pw/tests/pw_config_test.sh
     - copied unchanged from r315776, head/usr.sbin/pw/tests/pw_config_test.sh
  stable/11/usr.sbin/pw/tests/pw_etcdir_test.sh
     - copied unchanged from r315776, head/usr.sbin/pw/tests/pw_etcdir_test.sh
  stable/11/usr.sbin/pw/tests/pw_groupadd_test.sh
     - copied unchanged from r315776, head/usr.sbin/pw/tests/pw_groupadd_test.sh
  stable/11/usr.sbin/pw/tests/pw_groupdel_test.sh
     - copied unchanged from r315776, head/usr.sbin/pw/tests/pw_groupdel_test.sh
  stable/11/usr.sbin/pw/tests/pw_groupmod_test.sh
     - copied unchanged from r315776, head/usr.sbin/pw/tests/pw_groupmod_test.sh
  stable/11/usr.sbin/pw/tests/pw_lock_test.sh
     - copied unchanged from r315776, head/usr.sbin/pw/tests/pw_lock_test.sh
  stable/11/usr.sbin/pw/tests/pw_useradd_test.sh
     - copied unchanged from r315776, head/usr.sbin/pw/tests/pw_useradd_test.sh
  stable/11/usr.sbin/pw/tests/pw_userdel_test.sh
     - copied unchanged from r315776, head/usr.sbin/pw/tests/pw_userdel_test.sh
  stable/11/usr.sbin/pw/tests/pw_usermod_test.sh
     - copied unchanged from r315776, head/usr.sbin/pw/tests/pw_usermod_test.sh
  stable/11/usr.sbin/pw/tests/pw_usernext_test.sh
     - copied unchanged from r315776, head/usr.sbin/pw/tests/pw_usernext_test.sh
Deleted:
  stable/11/usr.bin/col/tests/col.sh
  stable/11/usr.bin/ident/tests/ident.sh
  stable/11/usr.bin/sdiff/tests/sdiff.sh
  stable/11/usr.bin/soelim/tests/soelim.sh
  stable/11/usr.sbin/pw/tests/pw_config.sh
  stable/11/usr.sbin/pw/tests/pw_etcdir.sh
  stable/11/usr.sbin/pw/tests/pw_groupadd.sh
  stable/11/usr.sbin/pw/tests/pw_groupdel.sh
  stable/11/usr.sbin/pw/tests/pw_groupmod.sh
  stable/11/usr.sbin/pw/tests/pw_lock.sh
  stable/11/usr.sbin/pw/tests/pw_useradd.sh
  stable/11/usr.sbin/pw/tests/pw_userdel.sh
  stable/11/usr.sbin/pw/tests/pw_usermod.sh
  stable/11/usr.sbin/pw/tests/pw_usernext.sh
Modified:
  stable/11/ObsoleteFiles.inc
  stable/11/usr.bin/col/tests/Makefile
  stable/11/usr.bin/ident/tests/Makefile
  stable/11/usr.bin/mkimg/tests/Makefile
  stable/11/usr.bin/sdiff/tests/Makefile
  stable/11/usr.bin/soelim/tests/Makefile
  stable/11/usr.sbin/pw/tests/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/ObsoleteFiles.inc
==============================================================================
--- stable/11/ObsoleteFiles.inc	Thu Mar 30 06:14:36 2017	(r316255)
+++ stable/11/ObsoleteFiles.inc	Thu Mar 30 06:20:24 2017	(r316256)
@@ -38,6 +38,22 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20170322: rename <x> to <x>_test to match the FreeBSD test suite name scheme
+OLD_FILES+=usr/tests/usr.bin/col/col
+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
 # 20170308: rename some tests
 OLD_FILES+=usr/tests/bin/pwait/pwait
 OLD_FILES+=usr/tests/usr.bin/timeout/timeout

Modified: stable/11/usr.bin/col/tests/Makefile
==============================================================================
--- stable/11/usr.bin/col/tests/Makefile	Thu Mar 30 06:14:36 2017	(r316255)
+++ stable/11/usr.bin/col/tests/Makefile	Thu Mar 30 06:20:24 2017	(r316256)
@@ -2,7 +2,7 @@
 
 PACKAGE=	tests
 
-ATF_TESTS_SH=	col
+ATF_TESTS_SH=	col_test
 
 ${PACKAGE}FILES+=	\
 		rlf.in \

Copied: stable/11/usr.bin/col/tests/col_test.sh (from r315776, head/usr.bin/col/tests/col_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/usr.bin/col/tests/col_test.sh	Thu Mar 30 06:20:24 2017	(r316256, copy of r315776, head/usr.bin/col/tests/col_test.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: stable/11/usr.bin/ident/tests/Makefile
==============================================================================
--- stable/11/usr.bin/ident/tests/Makefile	Thu Mar 30 06:14:36 2017	(r316255)
+++ stable/11/usr.bin/ident/tests/Makefile	Thu Mar 30 06:20:24 2017	(r316256)
@@ -2,7 +2,7 @@
 
 PACKAGE=	tests
 
-ATF_TESTS_SH=	ident
+ATF_TESTS_SH=	ident_test
 ${PACKAGE}FILES+=	\
 		test.in \
 		test.out \

Copied: stable/11/usr.bin/ident/tests/ident_test.sh (from r315776, head/usr.bin/ident/tests/ident_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/usr.bin/ident/tests/ident_test.sh	Thu Mar 30 06:20:24 2017	(r316256, copy of r315776, head/usr.bin/ident/tests/ident_test.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: stable/11/usr.bin/mkimg/tests/Makefile
==============================================================================
--- stable/11/usr.bin/mkimg/tests/Makefile	Thu Mar 30 06:14:36 2017	(r316255)
+++ stable/11/usr.bin/mkimg/tests/Makefile	Thu Mar 30 06:20:24 2017	(r316256)
@@ -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: stable/11/usr.bin/mkimg/tests/mkimg_test.sh (from r315776, head/usr.bin/mkimg/tests/mkimg_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/usr.bin/mkimg/tests/mkimg_test.sh	Thu Mar 30 06:20:24 2017	(r316256, copy of r315776, head/usr.bin/mkimg/tests/mkimg_test.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: stable/11/usr.bin/sdiff/tests/Makefile
==============================================================================
--- stable/11/usr.bin/sdiff/tests/Makefile	Thu Mar 30 06:14:36 2017	(r316255)
+++ stable/11/usr.bin/sdiff/tests/Makefile	Thu Mar 30 06:20:24 2017	(r316256)
@@ -2,7 +2,7 @@
 
 PACKAGE=	tests
 
-ATF_TESTS_SH=	sdiff
+ATF_TESTS_SH=	sdiff_test
 
 ${PACKAGE}FILES+=	\
 	d_dot.in \

Copied: stable/11/usr.bin/sdiff/tests/sdiff_test.sh (from r315776, head/usr.bin/sdiff/tests/sdiff_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/usr.bin/sdiff/tests/sdiff_test.sh	Thu Mar 30 06:20:24 2017	(r316256, copy of r315776, head/usr.bin/sdiff/tests/sdiff_test.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: stable/11/usr.bin/soelim/tests/Makefile
==============================================================================
--- stable/11/usr.bin/soelim/tests/Makefile	Thu Mar 30 06:14:36 2017	(r316255)
+++ stable/11/usr.bin/soelim/tests/Makefile	Thu Mar 30 06:20:24 2017	(r316256)
@@ -2,7 +2,7 @@
 
 PACKAGE=	tests
 
-ATF_TESTS_SH=	soelim
+ATF_TESTS_SH=	soelim_test
 
 ${PACKAGE}FILES+=		nonexisting.in \
 		basic.in \

Copied: stable/11/usr.bin/soelim/tests/soelim_test.sh (from r315776, head/usr.bin/soelim/tests/soelim_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/usr.bin/soelim/tests/soelim_test.sh	Thu Mar 30 06:20:24 2017	(r316256, copy of r315776, head/usr.bin/soelim/tests/soelim_test.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: stable/11/usr.sbin/pw/tests/Makefile
==============================================================================
--- stable/11/usr.sbin/pw/tests/Makefile	Thu Mar 30 06:14:36 2017	(r316255)
+++ stable/11/usr.sbin/pw/tests/Makefile	Thu Mar 30 06:20:24 2017	(r316256)
@@ -7,16 +7,16 @@ BINDIR=		${TESTSDIR}
 PROGS+=		crypt
 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: stable/11/usr.sbin/pw/tests/pw_config_test.sh (from r315776, head/usr.sbin/pw/tests/pw_config_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/usr.sbin/pw/tests/pw_config_test.sh	Thu Mar 30 06:20:24 2017	(r316256, copy of r315776, head/usr.sbin/pw/tests/pw_config_test.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: stable/11/usr.sbin/pw/tests/pw_etcdir_test.sh (from r315776, head/usr.sbin/pw/tests/pw_etcdir_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/usr.sbin/pw/tests/pw_etcdir_test.sh	Thu Mar 30 06:20:24 2017	(r316256, copy of r315776, head/usr.sbin/pw/tests/pw_etcdir_test.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: stable/11/usr.sbin/pw/tests/pw_groupadd_test.sh (from r315776, head/usr.sbin/pw/tests/pw_groupadd_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/usr.sbin/pw/tests/pw_groupadd_test.sh	Thu Mar 30 06:20:24 2017	(r316256, copy of r315776, head/usr.sbin/pw/tests/pw_groupadd_test.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: stable/11/usr.sbin/pw/tests/pw_groupdel_test.sh (from r315776, head/usr.sbin/pw/tests/pw_groupdel_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/usr.sbin/pw/tests/pw_groupdel_test.sh	Thu Mar 30 06:20:24 2017	(r316256, copy of r315776, head/usr.sbin/pw/tests/pw_groupdel_test.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: stable/11/usr.sbin/pw/tests/pw_groupmod_test.sh (from r315776, head/usr.sbin/pw/tests/pw_groupmod_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/usr.sbin/pw/tests/pw_groupmod_test.sh	Thu Mar 30 06:20:24 2017	(r316256, copy of r315776, head/usr.sbin/pw/tests/pw_groupmod_test.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: stable/11/usr.sbin/pw/tests/pw_lock_test.sh (from r315776, head/usr.sbin/pw/tests/pw_lock_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/usr.sbin/pw/tests/pw_lock_test.sh	Thu Mar 30 06:20:24 2017	(r316256, copy of r315776, head/usr.sbin/pw/tests/pw_lock_test.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
+}
+
+atf_init_test_cases() {
+	atf_add_test_case user_locking
+	atf_add_test_case numeric_locking
+}

Copied: stable/11/usr.sbin/pw/tests/pw_useradd_test.sh (from r315776, head/usr.sbin/pw/tests/pw_useradd_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/usr.sbin/pw/tests/pw_useradd_test.sh	Thu Mar 30 06:20:24 2017	(r316256, copy of r315776, head/usr.sbin/pw/tests/pw_useradd_test.sh)
@@ -0,0 +1,422 @@
+# $FreeBSD$
+
+# Import helper functions
+. $(atf_get_srcdir)/helper_functions.shin
+
+# Test add user
+atf_test_case user_add
+user_add_body() {
+	populate_etc_skel
+
+	atf_check -s exit:0 ${PW} useradd test
+	atf_check -s exit:0 -o match:"^test:.*" \
+		grep "^test:.*" $HOME/master.passwd
+}
+
+# Test add user with option -N
+atf_test_case user_add_noupdate
+user_add_noupdate_body() {
+	populate_etc_skel
+
+	atf_check -s exit:0 -o match:"^test:.*" ${PW} useradd test -N
+	atf_check -s exit:1 -o empty grep "^test:.*" $HOME/master.passwd
+}
+
+# Test add user with comments
+atf_test_case user_add_comments
+user_add_comments_body() {
+	populate_etc_skel
+
+	atf_check -s exit:0 ${PW} useradd test -c "Test User,work,123,456"
+	atf_check -s exit:0 -o match:"^test:.*:Test User,work,123,456:" \
+		grep "^test:.*:Test User,work,123,456:" $HOME/master.passwd
+}
+
+# Test add user with comments and option -N
+atf_test_case user_add_comments_noupdate
+user_add_comments_noupdate_body() {
+	populate_etc_skel
+
+	atf_check -s exit:0 -o match:"^test:.*:Test User,work,123,456:" \
+		${PW} useradd test -c "Test User,work,123,456" -N
+	atf_check -s exit:1 -o empty grep "^test:.*" $HOME/master.passwd
+}
+
+# Test add user with invalid comments
+atf_test_case user_add_comments_invalid
+user_add_comments_invalid_body() {
+	populate_etc_skel
+
+	atf_check -s exit:65 -e match:"invalid character" \
+		${PW} useradd test -c "Test User,work,123:456,456"
+	atf_check -s exit:1 -o empty \
+		grep "^test:.*:Test User,work,123:456,456:" $HOME/master.passwd
+}
+
+# Test add user with invalid comments and option -N
+atf_test_case user_add_comments_invalid_noupdate
+user_add_comments_invalid_noupdate_body() {
+	populate_etc_skel
+
+	atf_check -s exit:65 -e match:"invalid character" \
+		${PW} useradd test -c "Test User,work,123:456,456" -N
+	atf_check -s exit:1 -o empty grep "^test:.*" $HOME/master.passwd
+}
+
+# Test add user with alternate homedir
+atf_test_case user_add_homedir
+user_add_homedir_body() {
+	populate_etc_skel
+
+	atf_check -s exit:0 ${PW} useradd test -d /foo/bar
+	atf_check -s exit:0 -o match:"^test:\*:.*::0:0:User &:/foo/bar:.*" \
+		${PW} usershow test
+}
+
+# Test add user with account expiration as an epoch date
+atf_test_case user_add_account_expiration_epoch
+user_add_account_expiration_epoch_body() {

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-all mailing list