Add the util tests developed as part of the atfify GSoC 2008 project.

Initial done work by Lukasz Strzygowsky and reorganization of files done
by me.
This commit is contained in:
jmmv 2009-02-13 05:19:51 +00:00
parent 79362ba3ea
commit fbaeb3b2ac
157 changed files with 4796 additions and 3 deletions

View File

@ -1,14 +1,17 @@
# $NetBSD: Makefile,v 1.4 2007/12/31 15:32:14 ad Exp $
# $NetBSD: Makefile,v 1.5 2009/02/13 05:19:51 jmmv Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/util
SUBDIR= df id ps sh
SUBDIR= awk bzip2 config cut df grep id m4 make ps sdiff sh
TESTS_SH= t_cp
TESTS_SH= t_basename
TESTS_SH+= t_cp
TESTS_SH+= t_dd
TESTS_SH+= t_dirname
TESTS_SH+= t_expr
TESTS_SH+= t_gzip
TESTS_SH+= t_pax
TESTS_SH+= t_tar

6
tests/util/awk/Atffile Normal file
View File

@ -0,0 +1,6 @@
Content-Type: application/X-atf-atffile; version="1"
X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2009/02/13 05:19:51 jmmv Exp $"
prop: test-suite = "NetBSD"
tp: t_awk

30
tests/util/awk/Makefile Normal file
View File

@ -0,0 +1,30 @@
# $NetBSD: Makefile,v 1.1 2009/02/13 05:19:51 jmmv Exp $
NOMAN= # defined
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/util/awk
TESTS_SH= t_awk
FILESDIR= ${TESTSDIR}
FILES= d_big_regexp.awk
FILES+= d_big_regexp.in
FILES+= d_big_regexp.out
FILES+= d_end1.awk
FILES+= d_end1.in
FILES+= d_end1.out
FILES+= d_end2.awk
FILES+= d_end2.in
FILES+= d_end2.out
FILES+= d_string1.awk
FILES+= d_string1.out
FILES+= d_tolower.awk
FILES+= d_tolower.in
FILES+= d_tolower.out
FILES+= d_toupper.awk
FILES+= d_toupper.in
FILES+= d_toupper.out
.include <bsd.test.mk>

View File

@ -0,0 +1,3 @@
# $NetBSD: d_big_regexp.awk,v 1.1 2009/02/13 05:19:51 jmmv Exp $
/^[^_][^ ]*_NNIFO([ ]+[^_]+[^ ]*_(CC|INR|JJFO|JJMA|JJPG|NNIFG|NNIFO|NNIMPG|NNIMR|NNING|PP3FD|PQINO|PQMO|PSFR|RQ|TC|VIIR3|VPIPN|VPLIPF|NOTAG|RQR))*$/

View File

@ -0,0 +1 @@
1_NNIFO 1_PSFR 1_JJFO 1_NNIFO 1_INR 1_NNIMR 1_CC 1_NNING 1_RQ 1_VPLIPF 1_NNIFG 1_JJPG 1_NNIMPG 1_PQINO 1_VPIPN 1_PP3FD 1_JJMA 1_PQMO 1_TC 1_VIIR3

View File

@ -0,0 +1 @@
1_NNIFO 1_PSFR 1_JJFO 1_NNIFO 1_INR 1_NNIMR 1_CC 1_NNING 1_RQ 1_VPLIPF 1_NNIFG 1_JJPG 1_NNIMPG 1_PQINO 1_VPIPN 1_PP3FD 1_JJMA 1_PQMO 1_TC 1_VIIR3

View File

@ -0,0 +1,5 @@
# $NetBSD: d_end1.awk,v 1.1 2009/02/13 05:19:51 jmmv Exp $
END {
print NF;
}

1
tests/util/awk/d_end1.in Normal file
View File

@ -0,0 +1 @@
a b c d

View File

@ -0,0 +1 @@
4

View File

@ -0,0 +1,5 @@
# $NetBSD: d_end2.awk,v 1.1 2009/02/13 05:19:51 jmmv Exp $
END {
print $0;
}

1
tests/util/awk/d_end2.in Normal file
View File

@ -0,0 +1 @@
a b c d

View File

@ -0,0 +1 @@
a b c d

View File

@ -0,0 +1,7 @@
# $NetBSD: d_string1.awk,v 1.1 2009/02/13 05:19:51 jmmv Exp $
BEGIN {
print "A\
B";
print "CD"
}

View File

@ -0,0 +1,2 @@
AB
CD

View File

@ -0,0 +1,5 @@
# $NetBSD: d_tolower.awk,v 1.1 2009/02/13 05:19:51 jmmv Exp $
END {
print tolower($0);
}

View File

@ -0,0 +1 @@
ABCÆØÅ

View File

@ -0,0 +1 @@
abcæøå

View File

@ -0,0 +1,5 @@
# $NetBSD: d_toupper.awk,v 1.1 2009/02/13 05:19:51 jmmv Exp $
END {
print toupper($0);
}

View File

@ -0,0 +1 @@
abcæøå

View File

@ -0,0 +1 @@
ABCÆØÅ

91
tests/util/awk/t_awk.sh Normal file
View File

@ -0,0 +1,91 @@
# $NetBSD: t_awk.sh,v 1.1 2009/02/13 05:19:51 jmmv Exp $
#
# 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.
#
h_check()
{
for sfx in in out awk; do
cp -r $(atf_get_srcdir)/d_$1.$sfx .
done
atf_check -o file:d_$1.out -x "awk -f d_$1.awk < d_$1.in"
}
atf_test_case big_regexp
big_regexp_head()
{
atf_set "descr" "Checks matching long regular expressions (PR/33392)"
}
big_regexp_body()
{
h_check big_regexp
}
atf_test_case end
end_head()
{
atf_set "descr" "Checks that the last line of the input" \
"is available under END pattern (PR/29659)"
}
end_body()
{
h_check end1
h_check end2
}
atf_test_case string1
string1_head()
{
atf_set "descr" "Checks escaping newlines in string literals"
}
string1_body()
{
for sfx in out awk; do
cp -r $(atf_get_srcdir)/d_string1.$sfx .
done
atf_check -o file:d_string1.out awk -f d_string1.awk
}
atf_test_case multibyte
multibyte_head()
{
atf_set "descr" "Checks multibyte charsets support" \
"in tolower and toupper (PR/36394)"
}
multibyte_body()
{
export LANG=en_US.UTF-8
h_check tolower
h_check toupper
}
atf_init_test_cases()
{
atf_add_test_case big_regexp
atf_add_test_case end
atf_add_test_case string1
atf_add_test_case multibyte
}

6
tests/util/bzip2/Atffile Normal file
View File

@ -0,0 +1,6 @@
Content-Type: application/X-atf-atffile; version="1"
X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2009/02/13 05:19:51 jmmv Exp $"
prop: test-suite = "NetBSD"
tp: t_bzip2

21
tests/util/bzip2/Makefile Normal file
View File

@ -0,0 +1,21 @@
# $NetBSD: Makefile,v 1.1 2009/02/13 05:19:51 jmmv Exp $
NOMAN= # defined
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/util/bzip2
TESTS_SH= t_bzip2
DIST= ${NETBSDSRCDIR}/dist/bzip2
.PATH: ${DIST}
FILESDIR= ${TESTSDIR}
.for f in sample1.bz2 sample1.ref sample2.bz2 sample2.ref \
sample3.bz2 sample3.ref
FILES+= ${f}
FILESNAME_${f}= d_${f}
.endfor
.include <bsd.test.mk>

View File

@ -0,0 +1,52 @@
# $NetBSD: t_bzip2.sh,v 1.1 2009/02/13 05:19:51 jmmv Exp $
#
# 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 basic
basic_head()
{
atf_set "descr" "Checks basic functionality"
}
basic_body()
{
atf_check -o file:$(atf_get_srcdir)/d_sample1.bz2 \
bzip2 -1c $(atf_get_srcdir)/d_sample1.ref
atf_check -o file:$(atf_get_srcdir)/d_sample2.bz2 \
bzip2 -2c $(atf_get_srcdir)/d_sample2.ref
atf_check -o file:$(atf_get_srcdir)/d_sample3.bz2 \
bzip2 -3c $(atf_get_srcdir)/d_sample3.ref
atf_check -o file:$(atf_get_srcdir)/d_sample1.ref \
bzip2 -dc $(atf_get_srcdir)/d_sample1.bz2
atf_check -o file:$(atf_get_srcdir)/d_sample2.ref \
bzip2 -dc $(atf_get_srcdir)/d_sample2.bz2
atf_check -o file:$(atf_get_srcdir)/d_sample3.ref \
bzip2 -dsc $(atf_get_srcdir)/d_sample3.bz2
}
atf_init_test_cases()
{
atf_add_test_case basic
}

View File

@ -0,0 +1,6 @@
Content-Type: application/X-atf-atffile; version="1"
X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2009/02/13 05:19:51 jmmv Exp $"
prop: test-suite = "NetBSD"
tp: t_config

View File

@ -0,0 +1,32 @@
# $NetBSD: Makefile,v 1.1 2009/02/13 05:19:51 jmmv Exp $
SUBDIR= support
NOMAN= # defined
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/util/config
TESTS_SH= t_config
CLEANFILES+= t_config.sh
t_config.sh: t_config.awk t_config.in
${TOOL_AWK} -f ${.CURDIR}/t_config.awk ${.CURDIR}/t_config.in >t_config.sh.tmp
mv t_config.sh.tmp t_config.sh
FILESDIR= ${TESTSDIR}
FILES= d_deffs_redef
FILES+= d_loop
FILES+= d_loop2
FILES+= d_no_pseudo
FILES+= d_postponed_orphan
FILES+= d_pseudo_parent
FILES+= d_shadow_instance
FILES+= support/arch/regress/conf/Makefile.regress
FILES+= support/arch/regress/conf/files.regress
FILES+= support/arch/regress/conf/std.regress
FILES+= support/conf/files
.include <bsd.test.mk>
.include <bsd.subdir.mk>

View File

@ -0,0 +1,10 @@
include "arch/regress/conf/std.regress"
maxusers 4
file-system REGRESSFS
master0 at root
defflag NOT_A_FS
deffs NOT_A_FS
config regress root on ?

23
tests/util/config/d_loop Normal file
View File

@ -0,0 +1,23 @@
include "arch/regress/conf/std.regress"
maxusers 4
file-system REGRESSFS
master0 at root
# The following definitions build a loop of 'looper' devices.
# This tests how well the code that look for orphans handle loops.
#
# In that case, while the loopchild devices will always be seen in
# time, the code has to make sure it reaches all the loopbaby
# devices.
looper0 at master0
looper1 at looper0
loopchild0 at looper0
loopchild1 at looper1
loopbaby0 at loopchild0
loopbaby1 at loopchild1
config regress root on ?

16
tests/util/config/d_loop2 Normal file
View File

@ -0,0 +1,16 @@
include "arch/regress/conf/std.regress"
maxusers 4
file-system REGRESSFS
master0 at root
# Devices that are their own parent must be handled properly
# when the instance is negated.
looper* at master0
looper* at looper?
looper1 at looper0
no looper* at looper?
config regress root on ?

View File

@ -0,0 +1,14 @@
include "arch/regress/conf/std.regress"
maxusers 4
file-system REGRESSFS
master0 at root
# Simply negating a pseudo-device should yield an error.
pseudo-device pseudodev
no pseudodev
config regress root on ?

View File

@ -0,0 +1,21 @@
include "arch/regress/conf/std.regress"
maxusers 4
file-system REGRESSFS
master0 at root
parenti* at master?
# Here, parenti is negated before the child* instance is declared. That
# means the child* instance does not qualify as an explicit orphan and
# therefore should _not_ be ignored.
#
# config(1) should error out on that config file.
no parenti
child* at parenti?
config regress root on ?

View File

@ -0,0 +1,13 @@
include "arch/regress/conf/std.regress"
maxusers 4
file-system REGRESSFS
# Pseudo-devices can have children on interface attributes,
# which means they don't necessarily have to explicitly
# define locators (see pseudodev definition).
pseudo-device pseudodev
child* at pseudodev?
config regress root on ?

View File

@ -0,0 +1,25 @@
include "arch/regress/conf/std.regress"
maxusers 4
file-system REGRESSFS
master0 at root
parenti* at master?
parentii* at master?
# The second child* instance (attaching at parentii) is useless: it will be
# shadowed by the first one, which is semantically the same, from a parentii
# device's point of view.
#
# The two child* instances are aliases, and at some point the orphan-checking
# code skipped some aliases, in the shadowing situation and some others.
#
# This test should pass, the lines are valid, even though the second one is
# useless.
child* at hook?
child* at parentii?
config regress root on ?

View File

@ -0,0 +1,5 @@
# $NetBSD: Makefile,v 1.1 2009/02/13 05:19:51 jmmv Exp $
SUBDIR= arch conf
.include <bsd.subdir.mk>

View File

@ -0,0 +1,5 @@
# $NetBSD: Makefile,v 1.1 2009/02/13 05:19:51 jmmv Exp $
SUBDIR= regress
.include <bsd.subdir.mk>

View File

@ -0,0 +1,5 @@
# $NetBSD: Makefile,v 1.1 2009/02/13 05:19:51 jmmv Exp $
SUBDIR= conf
.include <bsd.subdir.mk>

View File

@ -0,0 +1,16 @@
# $NetBSD: Makefile,v 1.1 2009/02/13 05:19:51 jmmv Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/util/config
NOATFFILE= # defined
FILESDIR= ${TESTSDIR}/support/arch/regress/conf
FILES= Makefile.regress
FILES+= files.regress
FILES+= std.regress
.include <bsd.test.mk>
.include <bsd.files.mk>
.include <bsd.prog.mk>

View File

@ -0,0 +1,41 @@
=== INCLUDES BEGIN ===
%INCLUDES
=== INCLUDES END ===
=== OBJS BEGIN ===
%OBJS
=== OBJS END ===
=== CFILES BEGIN ===
%CFILES
=== CFILES END ===
=== SFILES BEGIN ===
%SFILES
=== SFILES END ===
=== LOAD BEGIN ===
%LOAD
=== LOAD END ===
=== RULES BEGIN ===
%RULES
=== RULES END ===
=== MAKEOPTIONSAPPEND BEGIN ===
%MAKEOPTIONSAPPEND
=== MAKEOPTIONSAPPEND END ===

View File

@ -0,0 +1,2 @@
maxpartitions 8
maxusers 2 4 8

View File

@ -0,0 +1 @@
machine regress

View File

@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.1 2009/02/13 05:19:51 jmmv Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/util/config
NOATFFILE= # defined
FILESDIR= ${TESTSDIR}/support/conf
FILES= files
.include <bsd.test.mk>
.include <bsd.files.mk>
.include <bsd.prog.mk>

View File

@ -0,0 +1,26 @@
deffs REGRESSFS
device master { }
attach master at root
define hook { }
device parentii: hook
attach parentii at master
device parenti: hook
attach parenti at master
device child
attach child at hook
device looper { }
attach looper at master with looper_master
attach looper at looper with looper_looper
device loopchild { }
attach loopchild at looper
device loopbaby
attach loopbaby at loopchild
defpseudo pseudodev: hook

View File

@ -0,0 +1,57 @@
# $NetBSD: t_config.awk,v 1.1 2009/02/13 05:19:51 jmmv Exp $
#
# Copyright (c) 2008 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
BEGIN {
FS = ":";
};
/^tc:/ {
printf "atf_test_case %s\n", $3;
printf "%s_head()\n", $3;
print "{"
printf " atf_set \"descr\" \"%s\"\n", $4;
print "}"
printf "%s_body()\n", $3;
print "{"
printf " h_%s %s\n", $2, d_$3;
print "}"
print ""
tcs[count++] = $3;
next
}
/^tc_list/ {
for (i = 0; i < count; i++) {
printf(" atf_add_test_case %s\n", tcs[i]);
}
next
}
{ print }

View File

@ -0,0 +1,59 @@
# $NetBSD: t_config.in,v 1.1 2009/02/13 05:19:51 jmmv Exp $
#
# Copyright (c) 2008 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
h_pass()
{
mkdir compile
supportdir="$(atf_get_srcdir)/support"
config="$(atf_get_srcdir)/d_$1"
atf_check -o ignore \
config -s "${supportdir}" -b "compile/$1" "${config}"
}
h_fail()
{
mkdir compile
supportdir="$(atf_get_srcdir)/support"
config="$(atf_get_srcdir)/d_$1"
atf_check -o ignore -e ignore -s ne:0 \
config -s "${supportdir}" -b "compile/$1" "${config}"
}
tc:pass:shadow_instance:Checks correct handling of shadowed instances
tc:pass:loop:Checks correct handling of loops
tc:pass:loop2:Checks correct handling of devices that can be their own parents
tc:pass:pseudo_parent:Checks correct handling of children of pseudo devices (PR/32329)
tc:fail:postponed_orphan:Checks that config catches adding an instance of a child of a negated instance as error
tc:fail:no_pseudo:Checks that config catches ommited 'pseudo-device' as error (PR/34111)
tc:fail:deffs_redef:Checks that config doesn't allow a deffs to use the same name as a previous defflag/defparam
atf_init_test_cases()
{
tc_list
}

6
tests/util/cut/Atffile Normal file
View File

@ -0,0 +1,6 @@
Content-Type: application/X-atf-atffile; version="1"
X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2009/02/13 05:19:51 jmmv Exp $"
prop: test-suite = "NetBSD"
tp: t_cut

20
tests/util/cut/Makefile Normal file
View File

@ -0,0 +1,20 @@
# $NetBSD: Makefile,v 1.1 2009/02/13 05:19:51 jmmv Exp $
NOMAN= # defined
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/util/cut
TESTS_SH= t_cut
FILESDIR= ${TESTSDIR}
FILES= d_basic.out
FILES+= d_cut.in
FILES+= d_dflag.out
FILES+= d_dsflag.out
FILES+= d_latin1.in
FILES+= d_sflag.out
FILES+= d_utf8.in
.include <bsd.test.mk>

View File

@ -0,0 +1,88 @@
----- test: cut -f 1 d_cut.in -----
1
12
qwe
1
12:34:56
qwe:rty:uio:p[]:asd:fgh:jkl:zxc:vbn:nm
:qwe:::rty:uio::p[]:asd:fgh:jkl:zxc:vbn:nm
----- test: cut -f 2 d_cut.in -----
1
34
12
1
12:34:56
qwe:rty:uio:p[]:asd:fgh:jkl:zxc:vbn:nm
:qwe:::rty:uio::p[]:asd:fgh:jkl:zxc:vbn:nm
----- test: cut -f 3 d_cut.in -----
1
56
rty
1
12:34:56
qwe:rty:uio:p[]:asd:fgh:jkl:zxc:vbn:nm
:qwe:::rty:uio::p[]:asd:fgh:jkl:zxc:vbn:nm
----- test: cut -f 1-2 d_cut.in -----
1
12 34
12
qwe
1
12:34:56
qwe:rty:uio:p[]:asd:fgh:jkl:zxc:vbn:nm
:qwe:::rty:uio::p[]:asd:fgh:jkl:zxc:vbn:nm
----- test: cut -f 2,3 d_cut.in -----
1
34 56
12
rty
1
12:34:56
qwe:rty:uio:p[]:asd:fgh:jkl:zxc:vbn:nm
:qwe:::rty:uio::p[]:asd:fgh:jkl:zxc:vbn:nm
----- test: cut -f 4 d_cut.in -----
1
34
uio
1
12:34:56
qwe:rty:uio:p[]:asd:fgh:jkl:zxc:vbn:nm
:qwe:::rty:uio::p[]:asd:fgh:jkl:zxc:vbn:nm
----- test: cut -f 1-3,4-7 d_cut.in -----
1
12 34 56
12 34 56
qwe rty uio p[] asd
1
12:34:56
qwe:rty:uio:p[]:asd:fgh:jkl:zxc:vbn:nm
:qwe:::rty:uio::p[]:asd:fgh:jkl:zxc:vbn:nm
----- test: cut -f 1,2-7 d_cut.in -----
1
12 34 56
12 34 56
qwe rty uio p[] asd
1
12:34:56
qwe:rty:uio:p[]:asd:fgh:jkl:zxc:vbn:nm
:qwe:::rty:uio::p[]:asd:fgh:jkl:zxc:vbn:nm

10
tests/util/cut/d_cut.in Normal file
View File

@ -0,0 +1,10 @@
1
12 34 56
12 34 56
qwe rty uio p[] asd fgh jkl zxc vbn nm
1
12:34:56
qwe:rty:uio:p[]:asd:fgh:jkl:zxc:vbn:nm
:qwe:::rty:uio::p[]:asd:fgh:jkl:zxc:vbn:nm

View File

@ -0,0 +1,88 @@
----- test: cut -f 1 -d : d_cut.in -----
1
12 34 56
12 34 56
qwe rty uio p[] asd fgh jkl zxc vbn nm
1
12
qwe
----- test: cut -f 2 -d : d_cut.in -----
1
12 34 56
12 34 56
qwe rty uio p[] asd fgh jkl zxc vbn nm
1
34
rty
qwe
----- test: cut -f 3 -d : d_cut.in -----
1
12 34 56
12 34 56
qwe rty uio p[] asd fgh jkl zxc vbn nm
1
56
uio
----- test: cut -f 1-2 -d : d_cut.in -----
1
12 34 56
12 34 56
qwe rty uio p[] asd fgh jkl zxc vbn nm
1
12:34
qwe:rty
:qwe
----- test: cut -f 2,3 -d : d_cut.in -----
1
12 34 56
12 34 56
qwe rty uio p[] asd fgh jkl zxc vbn nm
1
34:56
rty:uio
qwe:
----- test: cut -f 4 -d : d_cut.in -----
1
12 34 56
12 34 56
qwe rty uio p[] asd fgh jkl zxc vbn nm
1
p[]
----- test: cut -f 1-3,4-7 -d : d_cut.in -----
1
12 34 56
12 34 56
qwe rty uio p[] asd fgh jkl zxc vbn nm
1
12:34:56
qwe:rty:uio:p[]:asd:fgh:jkl
:qwe:::rty:uio:
----- test: cut -f 1,2-7 -d : d_cut.in -----
1
12 34 56
12 34 56
qwe rty uio p[] asd fgh jkl zxc vbn nm
1
12:34:56
qwe:rty:uio:p[]:asd:fgh:jkl
:qwe:::rty:uio:

View File

@ -0,0 +1,32 @@
----- test: cut -f 1 -d : -s d_cut.in -----
12
qwe
----- test: cut -f 2 -d : -s d_cut.in -----
34
rty
qwe
----- test: cut -f 3 -d : -s d_cut.in -----
56
uio
----- test: cut -f 1-2 -d : -s d_cut.in -----
12:34
qwe:rty
:qwe
----- test: cut -f 2,3 -d : -s d_cut.in -----
34:56
rty:uio
qwe:
----- test: cut -f 4 -d : -s d_cut.in -----
p[]
----- test: cut -f 1-3,4-7 -d : -s d_cut.in -----
12:34:56
qwe:rty:uio:p[]:asd:fgh:jkl
:qwe:::rty:uio:
----- test: cut -f 1,2-7 -d : -s d_cut.in -----
12:34:56
qwe:rty:uio:p[]:asd:fgh:jkl
:qwe:::rty:uio:

View File

@ -0,0 +1,4 @@
fooÄ:bar:Äbaz
FooÄ:Bar:ÄBaz
FOoÄ:BAr:ÄBAz
FOOÄ:BAR:ÄBAZ

View File

@ -0,0 +1,32 @@
----- test: cut -f 1 -s d_cut.in -----
12
qwe
----- test: cut -f 2 -s d_cut.in -----
34
12
----- test: cut -f 3 -s d_cut.in -----
56
rty
----- test: cut -f 1-2 -s d_cut.in -----
12 34
12
qwe
----- test: cut -f 2,3 -s d_cut.in -----
34 56
12
rty
----- test: cut -f 4 -s d_cut.in -----
34
uio
----- test: cut -f 1-3,4-7 -s d_cut.in -----
12 34 56
12 34 56
qwe rty uio p[] asd
----- test: cut -f 1,2-7 -s d_cut.in -----
12 34 56
12 34 56
qwe rty uio p[] asd

4
tests/util/cut/d_utf8.in Normal file
View File

@ -0,0 +1,4 @@
fooÄ:bar:Äbaz
FooÄ:Bar:ÄBaz
FOoÄ:BAr:ÄBAz
FOOÄ:BAR:ÄBAZ

130
tests/util/cut/t_cut.sh Normal file
View File

@ -0,0 +1,130 @@
# $NetBSD: t_cut.sh,v 1.1 2009/02/13 05:19:51 jmmv Exp $
#
# 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.
#
h_run()
{
file="${1}"; shift
opts="${*}"
for fields in 1 2 3 1-2 2,3 4 1-3,4-7 1,2-7
do
opts="-f ${fields} $@"
echo "----- test: cut ${opts} $(basename $file) -----"
cut $opts "$file" || atf_fail "command failed: cut ${opts} $file"
done
}
h_check()
{
diff -Nru "$1" "$2" || atf_fail "files $1 and $2 differ"
}
atf_test_case basic
basic_head()
{
atf_set "descr" "Checks basic functionality"
}
basic_body()
{
h_run "$(atf_get_srcdir)/d_cut.in" > out
h_check out "$(atf_get_srcdir)/d_basic.out"
}
atf_test_case sflag
sflag_head()
{
atf_set "descr" "Checks -s flag"
}
sflag_body()
{
h_run "$(atf_get_srcdir)/d_cut.in" -s > out
h_check out "$(atf_get_srcdir)/d_sflag.out"
}
atf_test_case dflag
dflag_head()
{
atf_set "descr" "Checks -d flag"
}
dflag_body()
{
h_run "$(atf_get_srcdir)/d_cut.in" -d ":" > out
h_check out "$(atf_get_srcdir)/d_dflag.out"
}
atf_test_case dsflag
dsflag_head()
{
atf_set "descr" "Checks -s and -d flags combined"
}
dsflag_body()
{
h_run "$(atf_get_srcdir)/d_cut.in" -d ":" -s > out
h_check out "$(atf_get_srcdir)/d_dsflag.out"
}
atf_test_case latin1
latin1_head()
{
atf_set "descr" "Checks support for non-ascii characters"
}
latin1_body()
{
export LC_ALL=C
atf_check -o inline:"bar\nBar\nBAr\nBAR\n" \
cut -b 6,7,8 "$(atf_get_srcdir)/d_latin1.in"
atf_check -o inline:"bar\nBar\nBAr\nBAR\n" \
cut -c 6,7,8 "$(atf_get_srcdir)/d_latin1.in"
}
atf_test_case utf8
utf8_head()
{
atf_set "descr" "Checks support for multibyte characters"
}
utf8_body()
{
export LC_ALL=en_US.UTF-8
atf_check -o inline:":ba\n:Ba\n:BA\n:BA\n" \
cut -b 6,7,8 "$(atf_get_srcdir)/d_utf8.in"
atf_check -o inline:"bar\nBar\nBAr\nBAR\n" \
cut -c 6,7,8 "$(atf_get_srcdir)/d_utf8.in"
}
atf_init_test_cases()
{
atf_add_test_case basic
atf_add_test_case sflag
atf_add_test_case dflag
atf_add_test_case dsflag
atf_add_test_case latin1
atf_add_test_case utf8
}

6
tests/util/grep/Atffile Normal file
View File

@ -0,0 +1,6 @@
Content-Type: application/X-atf-atffile; version="1"
X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2009/02/13 05:19:51 jmmv Exp $"
prop: test-suite = "NetBSD"
tp: t_grep

38
tests/util/grep/Makefile Normal file
View File

@ -0,0 +1,38 @@
# $NetBSD: Makefile,v 1.1 2009/02/13 05:19:51 jmmv Exp $
NOMAN= # defined
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/util/grep
TESTS_SH= t_grep
FILESDIR= ${TESTSDIR}
FILES= d_basic.out
FILES+= d_begin_end_a.out
FILES+= d_begin_end_b.out
FILES+= d_binary.out
FILES+= d_context2_a.out
FILES+= d_context2_b.out
FILES+= d_context2_c.out
FILES+= d_context_a.in
FILES+= d_context_a.out
FILES+= d_context_b.in
FILES+= d_context_b.out
FILES+= d_context_c.out
FILES+= d_context_d.out
FILES+= d_egrep.out
FILES+= d_file_exp.inout
FILES+= d_ignore_case.out
FILES+= d_input
FILES+= d_invert.in
FILES+= d_invert.out
FILES+= d_recurse.out
FILES+= d_recurse_symlink.err
FILES+= d_recurse_symlink.out
FILES+= d_whole_line.out
FILES+= d_word_regexps.out
FILES+= d_zgrep.out
.include <bsd.test.mk>

119
tests/util/grep/d_basic.out Normal file
View File

@ -0,0 +1,119 @@
aa
aal
aalii
aam
aardvark
aardwolf
Afrikaans
ahaaina
Alcaaba
amaas
assbaa
baa
baahling
Baal
baal
Baalath
Baalish
Baalism
Baalist
Baalite
Baalitical
Baalize
Baalshem
baar
Balaam
Balaamite
Balaamitical
balmacaan
Bastaard
bataan
baviaantje
bazaar
berghaan
Bilaan
caam
caama
caaming
caapeba
caatinga
cabaan
Canaan
Canaanite
Canaanitess
Canaanitic
Canaanitish
chaa
daalder
Danaan
encraal
enkraal
golandaas
Graafian
haab
haaf
heemraad
Isaac
Jaalin
knorhaan
kraal
laager
laang
Landsmaal
maam
maamselle
macaasim
malaanonang
molengraaffite
mushaa
naa
naam
Naaman
Naassenes
nagmaal
paal
paar
paauw
paraaminobenzoic
praam
raad
raash
reaal
Rigsmaal
Riksmaal
saa
Saan
Saarbrucken
salaam
salaamlike
Sangraal
saraad
schaapsteker
schoolmaam
schoolmaamish
Senaah
shaatnez
skokiaan
springhaas
staab
Staatsrat
taa
Taal
Taalbond
taar
Takhaar
taysaam
teewhaap
tetraamylose
Transvaal
Transvaaler
Transvaalian
Tzaam
vaagmer
vaalite
Vaalpens
Waac
waag
waapa
waar
Waasi

View File

@ -0,0 +1 @@
Front of the line

View File

@ -0,0 +1 @@
This is a another line with a Front and an ending

View File

@ -0,0 +1 @@
Binary file /bin/sh matches

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,10 @@
A pig is a jolly companion,
Boar, sow, barrow, or gilt --
A pig is a pal, who'll boost your morale,
Though mountains may topple and tilt.
When they've blackballed, bamboozled, and burned you,
When they've turned on you, Tory and Whig,
Though you may be thrown over by Tabby and Rover,
You'll never go wrong with a pig, a pig,
You'll never go wrong with a pig!
-- Thomas Pynchon, "Gravity's Rainbow"

View File

@ -0,0 +1,5 @@
A pig is a pal, who'll boost your morale,
Though mountains may topple and tilt.
When they've blackballed, bamboozled, and burned you,
When they've turned on you, Tory and Whig,
Though you may be thrown over by Tabby and Rover,

View File

@ -0,0 +1,3 @@
This is to test output of context from multiple files.
Dave was a happy pig who wandered around the orchard eating
apples all day long.

View File

@ -0,0 +1,4 @@
Though mountains may topple and tilt.
When they've blackballed, bamboozled, and burned you,
When they've turned on you, Tory and Whig,
Though you may be thrown over by Tabby and Rover,

View File

@ -0,0 +1,5 @@
Boar, sow, barrow, or gilt --
A pig is a pal, who'll boost your morale,
Though mountains may topple and tilt.
When they've blackballed, bamboozled, and burned you,
When they've turned on you, Tory and Whig,

View File

@ -0,0 +1,13 @@
d_context_a.in:A pig is a jolly companion,
d_context_a.in-Boar, sow, barrow, or gilt --
d_context_a.in:A pig is a pal, who'll boost your morale,
d_context_a.in-Though mountains may topple and tilt.
--
d_context_a.in-Though you may be thrown over by Tabby and Rover,
d_context_a.in:You'll never go wrong with a pig, a pig,
d_context_a.in:You'll never go wrong with a pig!
d_context_a.in- -- Thomas Pynchon, "Gravity's Rainbow"
--
d_context_b.in-This is to test output of context from multiple files.
d_context_b.in:Dave was a happy pig who wandered around the orchard eating
d_context_b.in-apples all day long.

View File

@ -0,0 +1 @@
Special characters [, $, ^, *

View File

@ -0,0 +1,119 @@
aa
aal
aalii
aam
aardvark
aardwolf
Afrikaans
ahaaina
Alcaaba
amaas
assbaa
baa
baahling
Baal
baal
Baalath
Baalish
Baalism
Baalist
Baalite
Baalitical
Baalize
Baalshem
baar
Balaam
Balaamite
Balaamitical
balmacaan
Bastaard
bataan
baviaantje
bazaar
berghaan
Bilaan
caam
caama
caaming
caapeba
caatinga
cabaan
Canaan
Canaanite
Canaanitess
Canaanitic
Canaanitish
chaa
daalder
Danaan
encraal
enkraal
golandaas
Graafian
haab
haaf
heemraad
Isaac
Jaalin
knorhaan
kraal
laager
laang
Landsmaal
maam
maamselle
macaasim
malaanonang
molengraaffite
mushaa
naa
naam
Naaman
Naassenes
nagmaal
paal
paar
paauw
paraaminobenzoic
praam
raad
raash
reaal
Rigsmaal
Riksmaal
saa
Saan
Saarbrucken
salaam
salaamlike
Sangraal
saraad
schaapsteker
schoolmaam
schoolmaamish
Senaah
shaatnez
skokiaan
springhaas
staab
Staatsrat
taa
Taal
Taalbond
taar
Takhaar
taysaam
teewhaap
tetraamylose
Transvaal
Transvaaler
Transvaalian
Tzaam
vaagmer
vaalite
Vaalpens
Waac
waag
waapa
waar
Waasi

View File

@ -0,0 +1,2 @@
Mostly I prefer lower case to upper case,
but UpPeR cAsE has its merits too.

12
tests/util/grep/d_input Normal file
View File

@ -0,0 +1,12 @@
dot.separated@words
kkseparatedkk
Front of the line
This is a another line with a Front and an ending
Special characters [, $, ^, *
Here is another ending.
Mostly I prefer lower case to upper case,
but UpPeR cAsE has its merits too.
matchme

View File

@ -0,0 +1,10 @@
fish
fish
dog
cat
fish
fish
poodle
fish

View File

@ -0,0 +1,5 @@
dog
cat
poodle

View File

@ -0,0 +1,2 @@
recurse/a/f/favourite-fish:haddock
recurse/d/fish:haddock

View File

@ -0,0 +1 @@
grep: warning: test/c/d/d: recursive directory loop

View File

@ -0,0 +1 @@
test/c/match:Test string

View File

@ -0,0 +1 @@
matchme

View File

@ -0,0 +1 @@
dot.separated@words

View File

@ -0,0 +1,2 @@
Front of the line
This is a another line with a Front and an ending

247
tests/util/grep/t_grep.sh Normal file
View File

@ -0,0 +1,247 @@
# $NetBSD: t_grep.sh,v 1.1 2009/02/13 05:19:52 jmmv Exp $
#
# 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.
#
words="/usr/share/dict/words"
atf_test_case basic
basic_head()
{
atf_set "descr" "Checks basic functionality"
}
basic_body()
{
atf_check -o file:"$(atf_get_srcdir)/d_basic.out" grep aa "${words}"
}
atf_test_case binary
binary_head()
{
atf_set "descr" "Checks handling of binary files"
}
binary_body()
{
atf_check -o file:"$(atf_get_srcdir)/d_binary.out" grep NetBSD /bin/sh
}
atf_test_case recurse
recurse_head()
{
atf_set "descr" "Checks recursive searching"
}
recurse_body()
{
mkdir -p recurse/a/f recurse/d
echo -e "cod\ndover sole\nhaddock\nhalibut\npilchard" > recurse/d/fish
echo -e "cod\nhaddock\nplaice" > recurse/a/f/favourite-fish
atf_check -o file:"$(atf_get_srcdir)/d_recurse.out" grep -r haddock recurse
}
atf_test_case recurse_symlink
recurse_symlink_head()
{
atf_set "descr" "Checks symbolic link recursion"
}
recurse_symlink_body()
{
mkdir -p test/c/d
(cd test/c/d && ln -s ../d .)
echo "Test string" > test/c/match
atf_check -o file:"$(atf_get_srcdir)/d_recurse_symlink.out" \
-e file:"$(atf_get_srcdir)/d_recurse_symlink.err" \
grep -r string test
}
atf_test_case word_regexps
word_regexps_head()
{
atf_set "descr" "Checks word-regexps"
}
word_regexps_body()
{
atf_check -o file:"$(atf_get_srcdir)/d_word_regexps.out" \
grep -w separated $(atf_get_srcdir)/d_input
}
atf_test_case begin_end
begin_end_head()
{
atf_set "descr" "Checks handling of line beginnings and ends"
}
begin_end_body()
{
atf_check -o file:"$(atf_get_srcdir)/d_begin_end_a.out" \
grep ^Front "$(atf_get_srcdir)/d_input"
atf_check -o file:"$(atf_get_srcdir)/d_begin_end_b.out" \
grep ending$ "$(atf_get_srcdir)/d_input"
}
atf_test_case ignore_case
ignore_case_head()
{
atf_set "descr" "Checks ignore-case option"
}
ignore_case_body()
{
atf_check -o file:"$(atf_get_srcdir)/d_ignore_case.out" \
grep -i Upper "$(atf_get_srcdir)/d_input"
}
atf_test_case invert
invert_head()
{
atf_set "descr" "Checks selecting non-matching lines with -v option"
}
invert_body()
{
atf_check -o file:"$(atf_get_srcdir)/d_invert.out" \
grep -v fish "$(atf_get_srcdir)/d_invert.in"
}
atf_test_case whole_line
whole_line_head()
{
atf_set "descr" "Checks whole-line matching with -x flag"
}
whole_line_body()
{
atf_check -o file:"$(atf_get_srcdir)/d_whole_line.out" \
grep -x matchme "$(atf_get_srcdir)/d_input"
}
atf_test_case negative
negative_head()
{
atf_set "descr" "Checks handling of files with no matches"
}
negative_body()
{
atf_check -s ne:0 grep "not a hope in hell" "$(atf_get_srcdir)/d_input"
}
atf_test_case context
context_head()
{
atf_set "descr" "Checks displaying context with -A, -B and -C flags"
}
context_body()
{
cp $(atf_get_srcdir)/d_context_*.* .
atf_check -o file:d_context_a.out grep -C2 bamboo d_context_a.in
atf_check -o file:d_context_b.out grep -A3 tilt d_context_a.in
atf_check -o file:d_context_c.out grep -B4 Whig d_context_a.in
atf_check -o file:d_context_d.out grep -C1 pig d_context_a.in d_context_b.in
}
atf_test_case file_exp
file_exp_head()
{
atf_set "descr" "Checks reading expressions from file"
}
file_exp_body()
{
atf_check -o file:"$(atf_get_srcdir)/d_file_exp.inout" \
grep -f "$(atf_get_srcdir)/d_file_exp.inout" "${words}"
}
atf_test_case egrep
egrep_head()
{
atf_set "descr" "Checks matching special characters with egrep"
}
egrep_body()
{
atf_check -o file:"$(atf_get_srcdir)/d_egrep.out" \
egrep '\?|\*$$' "$(atf_get_srcdir)/d_input"
}
atf_test_case zgrep
zgrep_head()
{
atf_set "descr" "Checks handling of gzipped files with zgrep"
}
zgrep_body()
{
cp "$(atf_get_srcdir)/d_input" .
gzip d_input || atf_fail "gzip failed"
atf_check -o file:"$(atf_get_srcdir)/d_zgrep.out" zgrep -h line d_input.gz
}
atf_test_case nonexistent
nonexistent_head()
{
atf_set "descr" "Checks that -s flag suppresses error" \
"messages about nonexistent files"
}
nonexistent_body()
{
atf_check -s ne:0 grep -s foobar nonexistent
}
atf_test_case context2
context2_head()
{
atf_set "descr" "Checks displaying context with -z flag"
}
context2_body()
{
printf "haddock\000cod\000plaice\000" > test1
printf "mackeral\000cod\000crab\000" > test2
atf_check -o file:"$(atf_get_srcdir)/d_context2_a.out" \
grep -z -A1 cod test1 test2
atf_check -o file:"$(atf_get_srcdir)/d_context2_b.out" \
grep -z -B1 cod test1 test2
atf_check -o file:"$(atf_get_srcdir)/d_context2_c.out" \
grep -z -C1 cod test1 test2
}
atf_init_test_cases()
{
atf_add_test_case basic
atf_add_test_case binary
atf_add_test_case recurse
atf_add_test_case recurse_symlink
atf_add_test_case word_regexps
atf_add_test_case begin_end
atf_add_test_case ignore_case
atf_add_test_case invert
atf_add_test_case whole_line
atf_add_test_case negative
atf_add_test_case context
atf_add_test_case file_exp
atf_add_test_case egrep
atf_add_test_case zgrep
atf_add_test_case nonexistent
atf_add_test_case context2
}

6
tests/util/m4/Atffile Normal file
View File

@ -0,0 +1,6 @@
Content-Type: application/X-atf-atffile; version="1"
X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2009/02/13 05:19:52 jmmv Exp $"
prop: test-suite = "NetBSD"
tp: t_m4

19
tests/util/m4/Makefile Normal file
View File

@ -0,0 +1,19 @@
# $NetBSD: Makefile,v 1.1 2009/02/13 05:19:52 jmmv Exp $
NOMAN= # defined
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/util/m4
TESTS_SH= t_m4
FILESDIR= ${TESTSDIR}
FILES= d_ff_after_dnl.m4.uue
FILES+= d_ff_after_dnl.out
FILES+= d_m4wrap-P.m4
FILES+= d_m4wrap-P.out
FILES+= d_m4wrap.m4
FILES+= d_m4wrap.out
.include <bsd.test.mk>

View File

@ -0,0 +1,9 @@
$NetBSD: d_ff_after_dnl.m4.uue,v 1.1 2009/02/13 05:19:52 jmmv Exp $
begin 644 d_ff_after_dnl.m4
M"0E42$E3(%-(3U5,1"!32$]7(%50("A,24Y%(#$I"F1N;`D)5$A)4R!32$]5
M3$0@3D]4(%-(3U<@55`@*$Q)3D4@,BD*9&YL_PD)5$A)4R!32$]53$0@3D]4
M(%-(3U<@55`@*$Q)3D4@,RD*9&YL"?\)5$A)4R!32$]53$0@3D]4(%-(3U<@
K55`@*$Q)3D4@-"D*"0E42$E3(%-(3U5,1"!32$]7(%50("A,24Y%(#4I"E<@
`
end

View File

@ -0,0 +1,2 @@
THIS SHOULD SHOW UP (LINE 1)
THIS SHOULD SHOW UP (LINE 5)

View File

@ -0,0 +1,5 @@
m4_dnl $NetBSD: d_m4wrap-P.m4,v 1.1 2009/02/13 05:19:52 jmmv Exp $
m4_define(`ateof', `TEXT AT EOF
')m4_dnl
m4_m4wrap(`ateof()')m4_dnl
TEXT IN BODY

View File

@ -0,0 +1,2 @@
TEXT IN BODY
TEXT AT EOF

View File

@ -0,0 +1,5 @@
dnl $NetBSD: d_m4wrap.m4,v 1.1 2009/02/13 05:19:52 jmmv Exp $
define(`ateof', `TEXT AT EOF
')dnl
m4wrap(`ateof()')dnl
TEXT IN BODY

View File

@ -0,0 +1,2 @@
TEXT IN BODY
TEXT AT EOF

50
tests/util/m4/t_m4.sh Normal file
View File

@ -0,0 +1,50 @@
# $NetBSD: t_m4.sh,v 1.1 2009/02/13 05:19:52 jmmv Exp $
#
# 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 eof
eof_head()
{
atf_set "descr" "Checks that m4 doesn't confuse 0xFF with EOF"
}
eof_body()
{
cp "$(atf_get_srcdir)/d_ff_after_dnl.m4.uue" .
uudecode d_ff_after_dnl.m4.uue
atf_check -o file:"$(atf_get_srcdir)/d_ff_after_dnl.out" \
m4 d_ff_after_dnl.m4
atf_check -o file:"$(atf_get_srcdir)/d_m4wrap.out" \
m4 "$(atf_get_srcdir)/d_m4wrap.m4"
atf_check -o file:"$(atf_get_srcdir)/d_m4wrap-P.out" \
m4 -P "$(atf_get_srcdir)/d_m4wrap-P.m4"
}
atf_init_test_cases()
{
atf_add_test_case eof
}

6
tests/util/make/Atffile Normal file
View File

@ -0,0 +1,6 @@
Content-Type: application/X-atf-atffile; version="1"
X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2009/02/13 05:19:52 jmmv Exp $"
prop: test-suite = "NetBSD"
tp: t_make

47
tests/util/make/Makefile Normal file
View File

@ -0,0 +1,47 @@
# $NetBSD: Makefile,v 1.1 2009/02/13 05:19:52 jmmv Exp $
NOMAN= # defined
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/util/make
TESTS_SH= t_make
CLEANFILES+= t_make.sh
t_make.sh: t_make.awk t_make.in
${TOOL_AWK} -f ${.CURDIR}/t_make.awk ${.CURDIR}/t_make.in > t_make.sh
FILESDIR= ${TESTSDIR}
FILES= d_comment.mk
FILES+= d_comment.out
FILES+= d_cond1.mk
FILES+= d_cond1.out
FILES+= d_dotwait.mk
FILES+= d_dotwait.out
FILES+= d_export.mk
FILES+= d_export.out
FILES+= d_export_all.mk
FILES+= d_export_all.out
FILES+= d_moderrs.mk
FILES+= d_moderrs.out
FILES+= d_modmatch.mk
FILES+= d_modmatch.out
FILES+= d_modmisc.mk
FILES+= d_modmisc.out
FILES+= d_modorder.mk
FILES+= d_modorder.out
FILES+= d_modts.mk
FILES+= d_modts.out
FILES+= d_modword.mk
FILES+= d_modword.out
FILES+= d_posix.mk
FILES+= d_posix.out
FILES+= d_qequals.mk
FILES+= d_qequals.out
FILES+= d_ternary.mk
FILES+= d_ternary.out
FILES+= d_varcmd.mk
FILES+= d_varcmd.out
.include <bsd.test.mk>

View File

@ -0,0 +1,31 @@
# This is a comment
.if ${MACHINE_ARCH} == something
FOO=bar
.endif
#\
Multiline comment
BAR=# defined
FOOBAR= # defined
# This is an escaped comment \
that keeps going until the end of this line
# Another escaped comment \
that \
goes \
on
# This is NOT an escaped comment due to the double backslashes \\
all: hi foo bar
@echo comment testing done
hi:
@echo comment testing start
foo:
@echo this is $@
bar:
@echo This is how a comment looks: '# comment'

View File

@ -0,0 +1,4 @@
comment testing start
this is foo
This is how a comment looks: # comment
comment testing done

102
tests/util/make/d_cond1.mk Normal file
View File

@ -0,0 +1,102 @@
# $NetBSD: d_cond1.mk,v 1.1 2009/02/13 05:19:52 jmmv Exp $
# hard code these!
TEST_UNAME_S= NetBSD
TEST_UNAME_M= sparc
TEST_MACHINE= i386
.if ${TEST_UNAME_S}
Ok=var,
.endif
.if ("${TEST_UNAME_S}")
Ok+=(\"var\"),
.endif
.if (${TEST_UNAME_M} != ${TEST_MACHINE})
Ok+=(var != var),
.endif
.if ${TEST_UNAME_M} != ${TEST_MACHINE}
Ok+= var != var,
.endif
.if !((${TEST_UNAME_M} != ${TEST_MACHINE}) && defined(X))
Ok+= !((var != var) && defined(name)),
.endif
# from bsd.obj.mk
MKOBJ?=no
.if ${MKOBJ} == "no"
o= no
Ok+= var == "quoted",
.else
.if defined(notMAKEOBJDIRPREFIX) || defined(norMAKEOBJDIR)
.if defined(notMAKEOBJDIRPREFIX)
o=${MAKEOBJDIRPREFIX}${__curdir}
.else
o= ${MAKEOBJDIR}
.endif
.endif
o= o
.endif
# repeat the above to check we get the same result
.if ${MKOBJ} == "no"
o2= no
.else
.if defined(notMAKEOBJDIRPREFIX) || defined(norMAKEOBJDIR)
.if defined(notMAKEOBJDIRPREFIX)
o2=${MAKEOBJDIRPREFIX}${__curdir}
.else
o2= ${MAKEOBJDIR}
.endif
.endif
o2= o
.endif
PRIMES=2 3 5 7 11
NUMBERS=1 2 3 4 5
n=2
.if ${PRIMES:M$n} == ""
X=not
.else
X=
.endif
.if ${MACHINE_ARCH} == no-such
A=one
.else
.if ${MACHINE_ARCH} == not-this
.if ${MACHINE_ARCH} == something-else
A=unlikely
.else
A=no
.endif
.endif
A=other
# We expect an extra else warning - we're not skipping here
.else
A=this should be an error
.endif
.if $X != ""
.if $X == not
B=one
.else
B=other
# We expect an extra else warning - we are skipping here
.else
B=this should be an error
.endif
.else
B=unknown
.endif
.if "quoted" == quoted
C=clever
.else
C=dim
.endif
all:
@echo "$n is $X prime"
@echo "A='$A' B='$B' C='$C' o='$o,${o2}'"
@echo "Passed:${.newline} ${Ok:S/,/${.newline}/}"
@echo "${NUMBERS:@n@$n is ${("${PRIMES:M$n}" == ""):?not:} prime${.newline}@}"

View File

@ -0,0 +1,18 @@
make: "cond1.mk" line 75: warning: extra else
make: "cond1.mk" line 85: warning: extra else
2 is prime
A='other' B='unknown' C='clever' o='no,no'
Passed:
var
("var")
(var != var)
var != var
!((var != var) && defined(name))
var == quoted
1 is not prime
2 is prime
3 is prime
4 is not prime
5 is prime

View File

@ -0,0 +1,61 @@
# $NetBSD: d_dotwait.mk,v 1.1 2009/02/13 05:19:52 jmmv Exp $
THISMAKEFILE:= ${.PARSEDIR}/${.PARSEFILE}
TESTS= simple recursive shared cycle
PAUSE= sleep 1
# Use a .for loop rather than dependencies here, to ensure
# that the tests are run one by one, with parallelism
# only within tests.
# Ignore "--- target ---" lines printed by parallel make.
all:
.for t in ${TESTS}
@${.MAKE} -f ${THISMAKEFILE} -j4 $t | grep -v "^--- "
.endfor
#
# Within each test, the names of the sub-targets follow these
# conventions:
# * If it's expected that two or more targets may be made in parallel,
# then the target names will differ only in an alphabetic component
# such as ".a" or ".b".
# * If it's expected that two or more targets should be made in sequence
# then the target names will differ in numeric components, such that
# lexical ordering of the target names matches the expected order
# in which the targets should be made.
#
# Targets may echo ${PARALLEL_TARG} to print a modified version
# of their own name, in which alphabetic components like ".a" or ".b"
# are converted to ".*". Two targets that are expected to
# be made in parallel will thus print the same strings, so that the
# output is independent of the order in which these targets are made.
#
PARALLEL_TARG= ${.TARGET:C/\.[a-z]/.*/g:Q}
.DEFAULT:
@echo ${PARALLEL_TARG}; ${PAUSE}; echo ${PARALLEL_TARG}
_ECHOUSE: .USE
@echo ${PARALLEL_TARG}; ${PAUSE}; echo ${PARALLEL_TARG}
# simple: no recursion, no cycles
simple: simple.1 .WAIT simple.2
# recursive: all children of the left hand side of the .WAIT
# must be made before any child of the right hand side.
recursive: recursive.1.99 .WAIT recursive.2.99
recursive.1.99: recursive.1.1.a recursive.1.1.b _ECHOUSE
recursive.2.99: recursive.2.1.a recursive.2.1.b _ECHOUSE
# shared: both shared.1.99 and shared.2.99 depend on shared.0.
# shared.0 must be made first, even though it is a child of
# the right hand side of the .WAIT.
shared: shared.1.99 .WAIT shared.2.99
shared.1.99: shared.0 _ECHOUSE
shared.2.99: shared.2.1 shared.0 _ECHOUSE
# cycle: the cyclic dependency must not cause infinite recursion
# leading to stack overflow and a crash.
cycle: cycle.1.99 .WAIT cycle.2.99
cycle.2.99: cycle.2.98 _ECHOUSE
cycle.2.98: cycle.2.97 _ECHOUSE
cycle.2.97: cycle.2.99 _ECHOUSE

View File

@ -0,0 +1,29 @@
simple.1
simple.1
simple.2
simple.2
recursive.1.1.*
recursive.1.1.*
recursive.1.1.*
recursive.1.1.*
recursive.1.99
recursive.1.99
recursive.2.1.*
recursive.2.1.*
recursive.2.1.*
recursive.2.1.*
recursive.2.99
recursive.2.99
shared.0
shared.0
shared.1.99
shared.1.99
shared.2.1
shared.2.1
shared.2.99
shared.2.99
make: Graph cycles through `cycle.2.99'
make: Graph cycles through `cycle.2.98'
make: Graph cycles through `cycle.2.97'
cycle.1.99
cycle.1.99

View File

@ -0,0 +1,22 @@
# $NetBSD: d_export.mk,v 1.1 2009/02/13 05:19:52 jmmv Exp $
UT_TEST=export
UT_FOO=foo${BAR}
UT_FU=fubar
UT_ZOO=hoopie
UT_NO=all
# belive it or not, we expect this one to come out with $UT_FU unexpanded.
UT_DOLLAR= This is $$UT_FU
.export UT_FU UT_FOO
.export UT_DOLLAR
# this one will be ignored
.export .MAKE.PID
BAR=bar is ${UT_FU}
.MAKE.EXPORTED+= UT_ZOO UT_TEST
all:
@env | grep '^UT_' | sort

Some files were not shown because too many files have changed in this diff Show More