Importing NetBSD "Kyua" test framework

To do so, a few dependencies have been imported:

 * external/bsd/lutok
 * external/mit/lua
 * external/public-domain/sqlite
 * external/public-domain/xz

The Kyua framework is the new generation of ATF (Automated Test
Framework), it is composed of:

 * external/bsd/atf
 * external/bsd/kyua-atf-compat
 * external/bsd/kyua-cli
 * external/bsd/kyua-tester
 * tests

Kyua/ATF being written in C++, it depends on libstdc++ which is
provided by GCC. As this is not part of the sources, Kyua is only
compiled when the native GCC utils are installed.

To install Kyua do the following:

 * In a cross-build enviromnent, add the following to the build.sh
   commandline: -V MKBINUTILS=yes -V MKGCCCMDS=yes

WARNING:
  At this point the import is still experimental, and not supported
  on native builds (a.k.a make build).

Change-Id: I26aee23c5bbd2d64adcb7c1beb98fe0d479d7ada
This commit is contained in:
2013-02-26 09:24:42 +01:00
committed by Gerrit Code Review
parent 003ff52ebb
commit 11be35a165
2893 changed files with 502052 additions and 2630 deletions

13
tests/usr.bin/Makefile Normal file
View File

@@ -0,0 +1,13 @@
# $NetBSD: Makefile,v 1.17 2012/11/20 08:02:06 agc Exp $
#
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin
TESTS_SUBDIRS= awk basename bzip2 cc cmp config cut \
diff dirname find grep gzip id infocmp jot m4 make mkdep \
nbperf netpgpverify pr rump_server shmif_dumpbus sdiff \
sed sort tmux unifdef xlint
.include <bsd.test.mk>

View File

@@ -0,0 +1,34 @@
# $NetBSD: Makefile,v 1.2 2012/03/11 18:35:59 jruoho Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/awk
TESTS_SH= t_awk
NOMAN= # defined
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_period.awk
FILES+= d_period.in
FILES+= d_period.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
FILES+= d_assign_NF.awk
FILES+= d_assign_NF.in
FILES+= d_assign_NF.out
.include <bsd.test.mk>

View File

@@ -0,0 +1,16 @@
# $NetBSD: d_assign_NF.awk,v 1.1 2012/03/11 18:35:59 jruoho Exp $
{
NF = 2
print "$0=`" $0 "`"
print "$3=`" $3 "`"
print "$4=`" $4 "`"
NF = 3
print "$0=`" $0 "`"
print "$3=`" $3 "`"
print "$4=`" $4 "`"
NF = 4
print "$0=`" $0 "`"
print "$3=`" $3 "`"
print "$4=`" $4 "`"
}

View File

@@ -0,0 +1 @@
1 2 3

View File

@@ -0,0 +1,9 @@
$0=`1 2`
$3=``
$4=``
$0=`1 2 `
$3=``
$4=``
$0=`1 2 `
$3=``
$4=``

View File

@@ -0,0 +1,3 @@
# $NetBSD: d_big_regexp.awk,v 1.1 2012/03/11 18:36:00 jruoho 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 2012/03/11 18:36:00 jruoho Exp $
END {
print NF;
}

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 2012/03/11 18:36:00 jruoho Exp $
END {
print $0;
}

View File

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

View File

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

View File

@@ -0,0 +1 @@
{print x + $1 + 0.125}

View File

@@ -0,0 +1 @@
0,25

View File

@@ -0,0 +1 @@
0.625

View File

@@ -0,0 +1,7 @@
# $NetBSD: d_string1.awk,v 1.1 2012/03/11 18:36:00 jruoho 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 2012/03/11 18:36:00 jruoho 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 2012/03/11 18:36:01 jruoho Exp $
END {
print toupper($0);
}

View File

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

View File

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

378
tests/usr.bin/awk/t_awk.sh Normal file
View File

@@ -0,0 +1,378 @@
# $NetBSD: t_awk.sh,v 1.5 2012/12/10 20:30:06 christos Exp $
#
# Copyright (c) 2012 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Christos Zoulas
#
# 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.
#
awk=awk
h_check()
{
local fname=d_$1
for sfx in in out awk; do
cp -r $(atf_get_srcdir)/$fname.$sfx .
done
shift 1
atf_check -o file:$fname.out -x "awk $@ -f $fname.awk < $fname.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_test_case period
period_head() {
atf_set "descr" "Checks that the period character is recognised" \
"in awk program regardless of locale (bin/42320)"
}
period_body() {
export LANG=ru_RU.KOI8-R
h_check period -v x=0.5
}
atf_test_case assign_NF
assign_NF_head() {
atf_set "descr" 'Checks that assign to NF changes $0 and $n (PR/44063)'
}
assign_NF_body() {
h_check assign_NF
}
atf_test_case single_char_rs
single_char_rs_head() {
atf_set "descr" "Test awk(1) with single character RS"
}
single_char_rs_body() {
atf_check \
-o "inline:1\n2\n\n3\n\n\n4\n\n" \
-x "echo 1a2aa3aaa4 | $awk 1 RS=a"
}
atf_test_case two_char_rs
two_char_rs_head() {
atf_set "descr" "Test awk(1) with two characters RS"
}
two_char_rs_body() {
atf_check \
-o "inline:1\n2\n3\n4\n\n" \
-x "echo 1ab2ab3ab4 | $awk 1 RS=ab"
}
atf_test_case single_char_regex_group_rs
single_char_regex_group_rs_head() {
atf_set "descr" "Test awk(1) with single character regex group RS"
}
single_char_regex_group_rs_body() {
atf_check \
-o "inline:1\n2\n\n3\n\n\n4\n\n" \
-x "echo 1a2aa3aaa4 | $awk 1 RS='[a]'"
}
atf_test_case two_char_regex_group_rs
two_char_regex_group_rs_head() {
atf_set "descr" "Test awk(1) with two characters regex group RS"
}
two_char_regex_group_rs_body() {
atf_check \
-o "inline:1\n2\n\n3\n\n\n4\n\n" \
-x "echo 1a2ab3aba4 | $awk 1 RS='[ab]'"
}
atf_test_case single_char_regex_star_rs
single_char_regex_star_rs_head() {
atf_set "descr" "Test awk(1) with single character regex star RS"
}
single_char_regex_star_rs_body() {
atf_check \
-o "inline:1\n2\n3\n4\n\n" \
-x "echo 1a2aa3aaa4 | $awk 1 RS='a*'"
}
atf_test_case two_char_regex_star_rs
two_char_regex_star_rs_head() {
atf_set "descr" "Test awk(1) with two characters regex star RS"
}
two_char_regex_star_rs_body() {
atf_check \
-o "inline:1\n2\n3\n4\n\n" \
-x "echo 1a2aa3aaa4 | $awk 1 RS='aa*'"
}
atf_test_case regex_two_star_rs
regex_two_star_rs_head() {
atf_set "descr" "Test awk(1) with regex two star RS"
}
regex_two_star_rs_body() {
atf_check \
-o "inline:1\n2\n3\n4\n\n" \
-x "echo 1a2ab3aab4 | $awk 1 RS='aa*b*'"
}
atf_test_case regex_or_1_rs
regex_or_1_rs_head() {
atf_set "descr" "Test awk(1) with regex | case 1 RS"
}
regex_or_1_rs_body() {
atf_check \
-o "inline:1a\nc\n\n" \
-x "echo 1abc | $awk 1 RS='abcde|b'"
}
atf_test_case regex_or_2_rs
regex_or_2_rs_head() {
atf_set "descr" "Test awk(1) with regex | case 2 RS"
}
regex_or_2_rs_body() {
atf_check \
-o "inline:1a\ncdf2\n\n" \
-x "echo 1abcdf2 | $awk 1 RS='abcde|b'"
}
atf_test_case regex_or_3_rs
regex_or_3_rs_head() {
atf_set "descr" "Test awk(1) with regex | case 3 RS"
}
regex_or_3_rs_body() {
atf_check \
-o "inline:1\n\nf2\n\n" \
-x "echo 1abcdebf2 | $awk 1 RS='abcde|b'"
}
atf_test_case regex_or_4_rs
regex_or_4_rs_head() {
atf_set "descr" "Test awk(1) with regex | case 4 RS"
}
regex_or_4_rs_body() {
atf_check \
-o "inline:1\nbcdf2\n\n" \
-x "echo 1abcdf2 | $awk 1 RS='abcde|a'"
}
atf_test_case regex_caret_1_rs
regex_caret_1_rs_head() {
atf_set "descr" "Test awk(1) with regex ^ case 1 RS"
}
regex_caret_1_rs_body() {
atf_check \
-o "inline:\n1a2a3a\n\n" \
-x "echo a1a2a3a | $awk 1 RS='^a'"
}
atf_test_case regex_caret_2_rs
regex_caret_2_rs_head() {
atf_set "descr" "Test awk(1) with regex ^ case 2 RS"
}
regex_caret_2_rs_body() {
atf_check \
-o "inline:\naa1a2a\n\n" \
-x "echo aaa1a2a | $awk 1 RS='^a'"
}
atf_test_case regex_dollar_1_rs
regex_dollar_1_rs_head() {
atf_set "descr" "Test awk(1) with regex $ case 1 RS"
}
regex_dollar_1_rs_body() {
atf_check \
-o "inline:a1a2a3a\n\n" \
-x "echo a1a2a3a | $awk 1 RS='a$'"
}
atf_test_case regex_dollar_2_rs
regex_dollar_2_rs_head() {
atf_set "descr" "Test awk(1) with regex $ case 2 RS"
}
regex_dollar_2_rs_body() {
atf_check \
-o "inline:a1a2aaa\n\n" \
-x "echo a1a2aaa | $awk 1 RS='a$'"
}
atf_test_case regex_reallocation_rs
regex_reallocation_rs_head() {
atf_set "descr" "Test awk(1) with regex reallocation RS"
}
regex_reallocation_rs_body() {
atf_check \
-o "inline:a\na\na\na\na\na\na\na\na\na10000\n\n" \
-x "jot -s a 10000 | $awk 'NR>1' RS='999[0-9]'"
}
atf_test_case empty_rs
empty_rs_head() {
atf_set "descr" "Test awk(1) with empty RS"
}
empty_rs_body() {
atf_check \
-o "inline:foo\n" \
-x "echo foo | $awk 1 RS=''"
}
atf_test_case newline_rs
newline_rs_head() {
atf_set "descr" "Test awk(1) with newline RS"
}
newline_rs_body() {
atf_check \
-o "inline:r1f1:r1f2\nr2f1:r2f2\n" \
-x "printf '\n\n\nr1f1\nr1f2\n\nr2f1\nr2f2\n\n\n' | $awk '{\$1=\$1}1' RS= OFS=:"
}
atf_test_case modify_subsep
modify_subsep_head() {
atf_set "descr" "Test awk(1) SUPSEP modification (PR/47306)"
}
modify_subsep_body() {
atf_check \
-o "inline:1\n1\n1\n" \
-x "printf '1\n1 2\n' | \
$awk '1{ arr[\$1 SUBSEP \$2 SUBSEP ++cnt[\$1]]=1} {for (f in arr) print arr[f];}'"
}
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
atf_add_test_case period
atf_add_test_case assign_NF
atf_add_test_case single_char_rs
atf_add_test_case two_char_rs
atf_add_test_case single_char_regex_group_rs
atf_add_test_case two_char_regex_group_rs
atf_add_test_case two_char_regex_star_rs
atf_add_test_case single_char_regex_star_rs
atf_add_test_case regex_two_star_rs
atf_add_test_case regex_or_1_rs
atf_add_test_case regex_or_2_rs
atf_add_test_case regex_or_3_rs
atf_add_test_case regex_caret_1_rs
atf_add_test_case regex_caret_2_rs
atf_add_test_case regex_dollar_1_rs
atf_add_test_case regex_dollar_2_rs
atf_add_test_case regex_reallocation_rs
atf_add_test_case empty_rs
atf_add_test_case newline_rs
atf_add_test_case modify_subsep
}

View File

@@ -0,0 +1,8 @@
# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:12 jruoho Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/basename
TESTS_SH= t_basename
.include <bsd.test.mk>

View File

@@ -0,0 +1,62 @@
# $NetBSD: t_basename.sh,v 1.1 2012/03/17 16:33:12 jruoho 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.
#
atf_test_case basic
basic_head()
{
atf_set "descr" "Checks basic functionality"
}
basic_body()
{
atf_check -o inline:"bin\n" basename /usr/bin
atf_check -o inline:"usr\n" basename /usr
atf_check -o inline:"/\n" basename /
atf_check -o inline:"/\n" basename ///
atf_check -o inline:"usr\n" basename /usr//
atf_check -o inline:"bin\n" basename //usr//bin
atf_check -o inline:"usr\n" basename usr
atf_check -o inline:"bin\n" basename usr/bin
}
atf_test_case suffix
suffix_head()
{
atf_set "descr" "Checks removing of provided suffix"
}
suffix_body()
{
atf_check -o inline:"bi\n" basename /usr/bin n
atf_check -o inline:"bin\n" basename /usr/bin bin
atf_check -o inline:"/\n" basename / /
atf_check -o inline:"g\n" basename /usr/bin/gcc cc
}
atf_init_test_cases()
{
atf_add_test_case basic
atf_add_test_case suffix
}

View File

@@ -0,0 +1,21 @@
# $NetBSD: Makefile,v 1.3 2012/05/07 08:51:47 wiz Exp $
NOMAN= # defined
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/bzip2
TESTS_SH= t_bzip2
DIST= ${NETBSDSRCDIR}/external/bsd/bzip2/dist
.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 2012/03/17 16:33:12 jruoho 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,9 @@
# $NetBSD: Makefile,v 1.1 2012/03/17 17:15:29 jruoho Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/cc
TESTS_SH= t_hello
.include <bsd.test.mk>

144
tests/usr.bin/cc/t_hello.sh Normal file
View File

@@ -0,0 +1,144 @@
# $NetBSD: t_hello.sh,v 1.2 2012/07/21 12:30:55 martin Exp $
#
# Copyright (c) 2011 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
atf_test_case hello
hello_head() {
atf_set "descr" "compile and run \"hello world\""
atf_set "require.progs" "cc"
}
atf_test_case hello_pic
hello_pic_head() {
atf_set "descr" "compile and run PIC \"hello world\""
atf_set "require.progs" "cc"
}
atf_test_case hello_pie
hello_pie_head() {
atf_set "descr" "compile and run position independend (PIE) \"hello world\""
atf_set "require.progs" "cc"
}
atf_test_case hello32
hello32_head() {
atf_set "descr" "compile and run \"hello world\" for/in netbsd32 emulation"
atf_set "require.progs" "cc file diff cat"
}
hello_body() {
cat > test.c << EOF
#include <stdio.h>
#include <stdlib.h>
int main(void) {printf("hello world\n");exit(0);}
EOF
atf_check -s exit:0 -o ignore -e ignore cc -o hello test.c
atf_check -s exit:0 -o inline:"hello world\n" ./hello
}
hello_pic_body() {
cat > test.c << EOF
#include <stdlib.h>
int main(void) {callpic();exit(0);}
EOF
cat > pic.c << EOF
#include <stdio.h>
int callpic(void) {printf("hello world\n");}
EOF
atf_check -s exit:0 -o ignore -e ignore \
cc -fPIC -dPIC -shared -o libtest.so pic.c
atf_check -s exit:0 -o ignore -e ignore \
cc -o hello test.c -L. -ltest
export LD_LIBRARY_PATH=.
atf_check -s exit:0 -o inline:"hello world\n" ./hello
}
hello_pie_body() {
# check whether this arch supports -pie
if ! cc -pie -dM -E - < /dev/null 2>/dev/null >/dev/null; then
atf_skip "cc -pie not supported on this architecture"
fi
cat > test.c << EOF
#include <stdio.h>
#include <stdlib.h>
int main(void) {printf("hello world\n");exit(0);}
EOF
atf_check -s exit:0 -o ignore -e ignore cc -fpie -pie -o hello test.c
atf_check -s exit:0 -o inline:"hello world\n" ./hello
}
hello32_body() {
# check whether this arch is 64bit
if ! cc -dM -E - < /dev/null | fgrep -q _LP64; then
atf_skip "this is not a 64 bit architecture"
fi
if ! cc -m32 -dM -E - < /dev/null 2>/dev/null > ./def32; then
atf_skip "cc -m32 not supported on this architecture"
else
if fgrep -q _LP64 ./def32; then
atf_fail "cc -m32 does not generate netbsd32 binaries"
fi
fi
cat > test.c << EOF
#include <stdio.h>
#include <stdlib.h>
int main(void) {printf("hello world\n");exit(0);}
EOF
atf_check -s exit:0 -o ignore -e ignore cc -o hello32 -m32 test.c
atf_check -s exit:0 -o ignore -e ignore cc -o hello64 test.c
file -b ./hello32 > ./ftype32
file -b ./hello64 > ./ftype64
if diff ./ftype32 ./ftype64 >/dev/null; then
atf_fail "generated binaries do not differ"
fi
echo "32bit binaries on this platform are:"
cat ./ftype32
echo "While native (64bit) binaries are:"
cat ./ftype64
atf_check -s exit:0 -o inline:"hello world\n" ./hello32
# do another test with static 32bit binaries
cat > test.c << EOF
#include <stdio.h>
#include <stdlib.h>
int main(void) {printf("hello static world\n");exit(0);}
EOF
atf_check -s exit:0 -o ignore -e ignore cc -o hello -m32 \
-static test.c
atf_check -s exit:0 -o inline:"hello static world\n" ./hello
}
atf_init_test_cases()
{
atf_add_test_case hello
atf_add_test_case hello_pic
atf_add_test_case hello_pie
atf_add_test_case hello32
}

View File

@@ -0,0 +1,8 @@
# $NetBSD: Makefile,v 1.1 2012/03/19 07:05:18 jruoho Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/cmp
TESTS_SH= t_cmp
.include <bsd.test.mk>

View File

@@ -0,0 +1,67 @@
# $NetBSD: t_cmp.sh,v 1.1 2012/03/19 07:05:18 jruoho Exp $
#
# Copyright (c) 2012 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Jukka Ruohonen.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
atf_test_case missing
missing_head() {
atf_set "descr" "Test that cmp(1) with '-s' is silent " \
"when files are missing (PR bin/2642)"
}
missing_body() {
echo a > a
atf_check -s not-exit:0 -o empty -e empty -x "cmp -s a x"
atf_check -s not-exit:0 -o empty -e empty -x "cmp -s x a"
atf_check -s not-exit:0 -o empty -e empty -x "cmp -s x y"
atf_check -s not-exit:0 -o empty -e empty -x "cmp -s y x"
}
atf_test_case skip
skip_head() {
atf_set "descr" "Test that cmp(1) handles skip " \
"parameters correctly (PR bin/23836)"
}
skip_body() {
echo 0123456789abcdef > a
echo abcdef > b
atf_check -s exit:0 -o empty -e empty -x "cmp a b '10'"
atf_check -s exit:0 -o empty -e empty -x "cmp a b '0xa'"
atf_check -s exit:1 -o not-empty -e empty -x "cmp a b '9'"
}
atf_init_test_cases()
{
atf_add_test_case missing
atf_add_test_case skip
}

View File

@@ -0,0 +1,26 @@
# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:12 jruoho Exp $
SUBDIR= support
NOMAN= # defined
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/config
TESTS_SH= t_config
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>

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 ?

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 ?

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 2012/03/17 16:33:12 jruoho Exp $
SUBDIR= arch conf
.include <bsd.subdir.mk>

View File

@@ -0,0 +1,5 @@
# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:12 jruoho Exp $
SUBDIR= regress
.include <bsd.subdir.mk>

View File

@@ -0,0 +1,5 @@
# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:12 jruoho Exp $
SUBDIR= conf
.include <bsd.subdir.mk>

View File

@@ -0,0 +1,15 @@
# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:12 jruoho Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/config
ATFFILE= no
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,13 @@
# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:12 jruoho Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/config
ATFFILE= no
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,91 @@
# $NetBSD: t_config.sh,v 1.1 2012/03/17 16:33:12 jruoho Exp $
#
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
run_and_check_pass()
{
local name="${1}"; shift
mkdir compile
supportdir="$(atf_get_srcdir)/support"
config="$(atf_get_srcdir)/d_${name}"
atf_check -o ignore \
config -s "${supportdir}" -b "compile/${name}" "${config}"
}
run_and_check_fail()
{
local name="${1}"; shift
mkdir compile
supportdir="$(atf_get_srcdir)/support"
config="$(atf_get_srcdir)/d_${name}"
atf_check -o ignore -e ignore -s ne:0 \
config -s "${supportdir}" -b "compile/${name}" "${config}"
}
# Defines a test case for config(1).
test_case()
{
local name="${1}"; shift
local type="${1}"; shift
local descr="${*}"
atf_test_case "${name}"
eval "${name}_head() { \
atf_set descr \"${descr}\"; \
atf_set require.progs \"config\"; \
}"
eval "${name}_body() { \
run_and_check_${type} '${name}'; \
}"
}
test_case shadow_instance pass "Checks correct handling of shadowed instances"
test_case loop pass "Checks correct handling of loops"
test_case loop2 pass "Checks correct handling of devices that can be their" \
"own parents"
test_case pseudo_parent pass "Checks correct handling of children of pseudo" \
"devices (PR/32329)"
test_case postponed_orphan fail "Checks that config catches adding an" \
"instance of a child of a negated instance as error"
test_case no_pseudo fail "Checks that config catches ommited 'pseudo-device'" \
"as error (PR/34111)"
test_case deffs_redef fail "Checks that config doesn't allow a deffs to use" \
"the same name as a previous defflag/defparam"
atf_init_test_cases()
{
atf_add_test_case shadow_instance
atf_add_test_case loop
atf_add_test_case loop2
atf_add_test_case pseudo_parent
atf_add_test_case postponed_orphan
atf_add_test_case no_pseudo
atf_add_test_case deffs_redef
}

View File

@@ -0,0 +1,20 @@
# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:13 jruoho Exp $
NOMAN= # defined
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/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

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

View File

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

130
tests/usr.bin/cut/t_cut.sh Normal file
View File

@@ -0,0 +1,130 @@
# $NetBSD: t_cut.sh,v 1.1 2012/03/17 16:33:13 jruoho 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
}

View File

@@ -0,0 +1,13 @@
# $NetBSD: Makefile,v 1.1 2011/05/03 15:13:50 jruoho Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/diff
TESTS_SH= t_diff
FILESDIR= ${TESTSDIR}
FILES+= d_mallocv1.in
FILES+= d_mallocv2.in
.include <bsd.test.mk>

View File

@@ -0,0 +1,5 @@
18086b1e91f730facb2d6e1b
c562653b24814eb3651b1e68301a3c14b96302bb
6d017f7aef74662ed8dd51eef14281eaad223298db370bfaca
30c04231cb3de404e4b8a5359a74066fd963291d7986be835834ab07870c097682a953bfff38784780eef844de47fb36c34f8e034c96cfa64d9cb5decee472138236e9fb79e9fe1fba6b7757b970f22477d167832206900473f09f3e8c822db6d9a8273340ed6743d99638d6cf192d821b6f33d23278b1a929f303a80865c426d01add11b2f2416babd13e70b44d8eeb731c09c7163af9d1a23cbe20ddb08b0f67ecaa2eed511263a67e9c12e59ef113f0b9e4e4e140b43896078a7571c61826ba099b3dd8c4b096a9785b4434e97ea99e662ba6fdb60a41547ccae4c67d3e1f3ef515198e91f009c75c9e80fda90d13ee29d8aad5d87cc2437ce60e6ce55700837fb0815bfd2495f8aa1a33fe67c1ae28a885506a78ca6257f5a5f2a8042e28680acc83b1aecb3a9cb51911126f2f0deaf14fcfa5f165e9a5c3f8f2d1c3f4683b2d75927a7bc802d63b680a5e22768cc0439854ccd49e58a002794f541bddd6ef6fbd4f9869843a72d0ae9d438c90353a46c0c9863a16b1de206c717ab7ce6ea6f648a38efa12b70bbe3388b35adec7a789ea98de217520d7d6ce699841e17e5946bf5a8b3c7a2c3e2d6767422baf3159ff08d913ec78011ab7d34bc24af26c24a8d46f7261c7705a7b270e27590c29583c659a0df8dada4e7a0532f115040165d18f74a55a4f39bb1dcfd865e94a
488ca910cc447e121b2a19450239e75d24

View File

@@ -0,0 +1,5 @@
18086b1e91f730facb2d6e1b
c562653b24814eb3651b1e68301a3c14b96302bb
6d017f7aef74662ed8dd51eef14281eaad223298db370bfaca
30c04231cb3de404e4b8a5359a74066fd963291d7986be835834ab07870c097682a953bfff38784780eef844de47fb36c34f8e034c96cfa64d9cb5decee472138236e9fb79e9fe1fba6b7757b970f22477d167832206900473f09f3e8c822db6d9a8273340ed6743d99638d6cf192d821b6f33d23278b1a929f303a80865c426d01add11b2f2416babd13e70b44d8eeb731c09c7163af9d1a23cbe20ddb08b0f67ecaa2eed511263a67e9c12e59ef113f0b9e4e4e140b43896078a7571c61826ba099b3dd8c4b096a9785b4434e97ea99e662ba6fdb60a41547ccae4c67d3e1f3ef515198e91f009c75c9e80fda90d13ee29d8aad5d87cc2437ce60e6ce55700837fb0815bfd2495f8aa1a33fe67c1ae28a885506a78ca6257f5a5f2a8042e28680acc83b1aecb3a9cb51911126f2f0deaf14fcfa5f165e9a5c3f8f2d1c3f4683b2d75927a7bc802d63b680a5e22768cc0439854ccd49e58a002794f541bddd6ef6fbd4f9869843a72d0ae9d438c90353a46c0c9863a16b1de206c717ab7ce6ea6f648a38efa12b70bbe3388b35adec7a789ea98de217520d7d6ce699841e17e5946bf5a8b3c7a2c3e2d6767422baf3159ff08d913ec78011ab7d34bc24af26c24a8d46f7261c7705a7b270e27590c29583c659a0df8dada4e7a0532f115040165d18f74a55a4f39bb1dcfd865e94a
488ca910cc447e121b2a19450239e75d24

View File

@@ -0,0 +1,75 @@
# $NetBSD: t_diff.sh,v 1.3 2012/03/13 05:40:00 jruoho Exp $
#
# Copyright (c) 2011 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Jukka Ruohonen.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
atf_test_case mallocv
mallocv_head() {
atf_set "descr" "Test diff(1) with MALLOC_OPTIONS=V (cf. PR bin/26453)"
}
mallocv_body() {
atf_check -s ignore \
-e not-inline:"diff: memory exhausted\n" \
-x "env MALLOC_OPTIONS=V diff " \
"$(atf_get_srcdir)/d_mallocv1.in" \
"$(atf_get_srcdir)/d_mallocv2.in"
}
atf_test_case nomallocv
nomallocv_head() {
atf_set "descr" "Test diff(1) with no MALLOC_OPTIONS=V"
}
nomallocv_body() {
atf_check -s exit:0 \
-e inline:"" \
-x "diff " \
"$(atf_get_srcdir)/d_mallocv1.in" \
"$(atf_get_srcdir)/d_mallocv2.in"
}
atf_test_case same
same_head() {
atf_set "descr" "Test diff(1) with identical files"
}
same_body() {
atf_check -s exit:0 \
-e inline:"" \
-x "diff $(atf_get_srcdir)/t_diff $(atf_get_srcdir)/t_diff"
}
atf_init_test_cases() {
atf_add_test_case mallocv
atf_add_test_case nomallocv
atf_add_test_case same
}

View File

@@ -0,0 +1,8 @@
# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:13 jruoho Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/dirname
TESTS_SH= t_dirname
.include <bsd.test.mk>

View File

@@ -0,0 +1,49 @@
# $NetBSD: t_dirname.sh,v 1.1 2012/03/17 16:33:13 jruoho 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.
#
atf_test_case basic
basic_head()
{
atf_set "descr" "Checks basic functionality"
}
basic_body()
{
atf_check -o inline:"/\n" dirname /
atf_check -o inline:"/\n" dirname //
atf_check -o inline:"/usr\n" dirname /usr/bin/
atf_check -o inline:"//usr\n" dirname //usr//bin//
atf_check -o inline:".\n" dirname usr
atf_check -o inline:".\n" dirname ""
atf_check -o inline:"/\n" dirname /usr
atf_check -o inline:"/usr\n" dirname /usr/bin
atf_check -o inline:"usr\n" dirname usr/bin
}
atf_init_test_cases()
{
atf_add_test_case basic
}

View File

@@ -0,0 +1,8 @@
# $NetBSD: Makefile,v 1.1 2012/03/18 12:40:42 jruoho Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/find
TESTS_SH= t_find
.include <bsd.test.mk>

View File

@@ -0,0 +1,73 @@
# $NetBSD: t_find.sh,v 1.6 2012/03/19 12:58:41 jruoho Exp $
#
# Copyright (c) 2012 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Jukka Ruohonen.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
atf_test_case emptyperm
emptyperm_head() {
atf_set "descr" "Test that 'find -empty' does not error out " \
"when directory access is denied (PR bin/44179)"
atf_set "require.user" "unprivileged"
}
emptyperm_body() {
# The case assumes that at least some directories
# in /var are unavailable for the user '_tests'.
#
# TODO: Parse the output.file for actual verification.
#
atf_check -s exit:1 -o save:output.file \
-e not-empty -x "find /var -empty -type d"
}
atf_test_case exit
exit_head() {
atf_set "descr" "Test that find(1) with -exit works (PR bin/44973)"
}
exit_body() {
atf_check -o ignore \
-s exit:0 -x "find /etc -type f -exit"
}
atf_test_case exit_status
exit_status_head() {
atf_set "descr" "Test exit status from 'find -exit'"
}
exit_status_body() {
num=$(jot -r 1 0 99)
atf_check -o ignore -e ignore -s exit:$num -x "find / -exit $num"
}
atf_init_test_cases() {
atf_add_test_case emptyperm
atf_add_test_case exit
atf_add_test_case exit_status
}

View File

@@ -0,0 +1,39 @@
# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:13 jruoho Exp $
NOMAN= # defined
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/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.in
FILES+= d_file_exp.out
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>

View File

@@ -0,0 +1,20 @@
123
1123
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
2123
3123
4123
5123
6123
7123
8123
9123

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,2 @@
-0.[24]0
0.[35]0

View File

@@ -0,0 +1,6 @@
-0.50
-0.40
-0.30
-0.20
0.30
0.50

View File

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

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

View File

@@ -0,0 +1,246 @@
# $NetBSD: t_grep.sh,v 1.2 2013/05/17 15:39:17 christos 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_basic.out" -x \
'jot 10000 | grep 123'
}
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 $(uname) /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.out" -x \
'jot 21 -1 1.00 | grep -f '"$(atf_get_srcdir)"'/d_file_exp.in'
}
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
}

View File

@@ -0,0 +1,8 @@
# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:13 jruoho Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/gzip
TESTS_SH= t_gzip
.include <bsd.test.mk>

View File

@@ -0,0 +1,110 @@
# $NetBSD: t_gzip.sh,v 1.1 2012/03/17 16:33:13 jruoho 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.
#
atf_test_case concatenated
concatenated_head()
{
atf_set "descr" "Checks concatenated gzipped data"
}
concatenated_body()
{
echo -n "aaaa" | gzip > tmp.gz
echo -n "bbbb" | gzip >> tmp.gz
atf_check -o inline:"aaaabbbb" gzip -d tmp.gz -c
}
atf_test_case pipe
pipe_head()
{
atf_set "descr" "Checks input from pipe"
}
pipe_body()
{
atf_check -x "dd if=/dev/zero count=102400 2>/dev/null \
| gzip -c | dd bs=1 2>/dev/null | gzip -tc"
}
atf_test_case truncated
truncated_head()
{
atf_set "descr" "Checks that gzip fails on truncated data"
}
truncated_body()
{
cat >truncated.gz.uue <<EOF
begin-base64 644 truncated.gz
H4sIAAAAAAAAA0tMSk7hAgCspIpYCg==
====
EOF
uudecode -m truncated.gz.uue
atf_check -s ne:0 -e ignore gzip -d truncated.gz
}
atf_test_case crcerror
crcerror_head()
{
atf_set "descr" "Checks that gzip fails on crc error"
}
crcerror_body()
{
cat >crcerror.gz.uue <<EOF
begin-base64 644 crcerror.gz
H4sIAAAAAAAAA0tMSk7hAgCspFhYBQAAAA==
====
EOF
uudecode -m crcerror.gz.uue
atf_check -s ne:0 -e ignore gzip -d crcerror.gz
}
atf_test_case good
good_head()
{
atf_set "descr" "Checks decompressing correct file"
}
good_body()
{
cat >good.gz.uue <<EOF
begin-base64 644 good.gz
H4sICC8G8UAAA2FiY2QAS0xKTuECAKykilgFAAAA
====
EOF
uudecode -m good.gz.uue
atf_check gzip -d good.gz
}
atf_init_test_cases()
{
atf_add_test_case concatenated
atf_add_test_case pipe
atf_add_test_case truncated
atf_add_test_case crcerror
atf_add_test_case good
}

24
tests/usr.bin/id/Makefile Normal file
View File

@@ -0,0 +1,24 @@
# $NetBSD: Makefile,v 1.1 2012/03/17 16:33:14 jruoho Exp $
NOMAN= # defined
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/id
TESTS_SH= t_groups
TESTS_SH+= t_id
TESTS_SH+= t_whoami
BINDIR= ${TESTSDIR}
PROG= h_id
.if defined(__MINIX)
.PATH: ${NETBSDSRCDIR}/commands/id
.else
.PATH: ${NETBSDSRCDIR}/usr.bin/id
.endif # defined(__MINIX)
SRCS= id.c pwgr.c
COPTS.id.c += -Wno-format-nonliteral
.include <bsd.test.mk>

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