regress: move tests for platform tools to tools-platform

This commit is contained in:
rillig 2020-05-02 07:24:31 +00:00
parent f0046984bc
commit 0ce31b3a1e
10 changed files with 47 additions and 58 deletions

View file

@ -1,5 +1,5 @@
#! /bin/sh
# $NetBSD: awk-test.sh,v 1.8 2006/05/31 13:10:49 rillig Exp $
# $NetBSD: awk.test,v 1.1 2020/05/02 07:24:32 rillig Exp $
#
set -e

View file

@ -1,5 +1,5 @@
#! /bin/sh
# $NetBSD: sed-test.sh,v 1.1 2006/09/20 07:39:55 rillig Exp $
# $NetBSD: sed.test,v 1.1 2020/05/02 07:24:32 rillig Exp $
#
set -e

View file

@ -1,5 +1,5 @@
#! /bin/sh
# $NetBSD: sh.test,v 1.1 2020/05/01 18:37:59 rillig Exp $
# $NetBSD: sh.test,v 1.2 2020/05/02 07:24:32 rillig Exp $
#
# Tests for the shell that is available as ${SH} in Makefiles.
#
@ -39,3 +39,15 @@ assert_that "%: ${pathname%/*}" --equals "%: first/second/third"
# Make sure that $(...) subshells work.
assert_that "subshell: $(echo world | tr 'world' 'hello')" \
--equals "subshell: hello"
# In NetBSD 7, /bin/sh handled backslashes in word expansions incorrectly.
# See https://gnats.netbsd.org/43469.
line='#define bindir "/usr/bin" /* bar */'
case $MACHINE_PLATFORM in
(NetBSD-[0-7].*-*)
assert_that "${line%%/\**}" --equals '#define bindir "'
;;
(*)
assert_that "${line%%/\**}" --equals '#define bindir "/usr/bin" '
;;
esac

View file

@ -1,5 +1,5 @@
#! /bin/sh
# $NetBSD: sort-test.sh,v 1.1 2006/06/25 21:47:28 rillig Exp $
# $NetBSD: sort.test,v 1.1 2020/05/02 07:24:32 rillig Exp $
#
set -e

View file

@ -1,4 +1,4 @@
# $NetBSD: spec,v 1.1 2020/05/01 18:37:59 rillig Exp $
# $NetBSD: spec,v 1.2 2020/05/02 07:24:32 rillig Exp $
#
# Tests for the platform-provided tools.
#
@ -6,6 +6,10 @@
# In that environment, only the PATH is set, and it points to a
# directory containing only the tools from mk/tools/tools.${OPSYS}.mk.
#
# Additionally, MACHINE_PLATFORM is set, so that the tests can expect
# different results depending on the platform. This is used for
# documenting bugs that have been fixed in a certain version.
#
# The individual tests may create arbitrary files in their current
# working directory.
#
@ -22,10 +26,16 @@ do_test() {
-f "$regressdir/zzz-prepare-tools.mk" \
"prepare-platform-tools"
)
machine_platform=$(
cd ../../pkgtools/digest \
&& $TEST_MAKE show-var VARNAME=MACHINE_PLATFORM
)
for testfile in *.test; do
mkdir "$tmpdir/work"
(cd "$tmpdir/work" && "$bindir/env" -i PATH="$bindir" \
(cd "$tmpdir/work" && "$bindir/env" -i \
MACHINE_PLATFORM="$machine_platform" \
PATH="$bindir" \
"sh" "$regressdir/$testfile") \
|| TEST_EXITSTATUS=$?
rm -rf "$tmpdir/work"

View file

@ -1,5 +1,5 @@
#! /bin/sh
# $NetBSD: tar-test.sh,v 1.1 2007/09/09 08:01:45 rillig Exp $
# $NetBSD: tar.test,v 1.1 2020/05/02 07:24:32 rillig Exp $
#
set -e

View file

@ -0,0 +1,14 @@
# $NetBSD: tests.subr,v 1.1 2020/05/02 07:24:32 rillig Exp $
#
# usage: testcase_start <testname>
testcase_start() {
printf " Running testcase %s\\n" "$1"
}
# usage: assert_equal <testname> <expected> <got>
assert_equal() {
[ "x$2" = "x$3" ] && return 0
printf "error: assert_equal failed for \"%s\":\nexpected: %s\nbut got: %s\n" "$1" "$2" "$3" 1>&2
return 1
}

View file

@ -1,5 +1,5 @@
#! /bin/sh
# $NetBSD: tr-test.sh,v 1.2 2005/11/24 19:46:45 rillig Exp $
# $NetBSD: tr.test,v 1.1 2020/05/02 07:24:32 rillig Exp $
#
set -e
@ -38,9 +38,8 @@ tr_test "eat-newlines" \
"foo${nl}bar${nl}" "foobar" -d "\\n"
tr_test "eat-minus" \
"describe-function" "describefunction" -d "-"
# The following test does not work on NetBSD 1.6.2.
#tr_test "eat-minus-d" \
# "describe-function" "escribefunction" -d "-d"
tr_test "eat-minus-d" \
"describe-function" "escribefunction" -d -- "-d"
tr_test "eat-d-minus" \
"describe-function" "escribefunction" -d "d-"

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.15 2019/03/24 11:29:19 rillig Exp $
# $NetBSD: Makefile,v 1.16 2020/05/02 07:24:31 rillig Exp $
#
DISTNAME= # not applicable
@ -15,8 +15,6 @@ WRKSRC= ${WRKDIR}
NO_CHECKSUM= yes
PLIST_SRC= # none
REGRESS_TESTS+= logging shquote
REGRESS_TESTS+= awk sed sh sort tar tr
USE_TOOLS+= awk sed sh sort tar tr
TOOLS_CREATE+= script-dquot
TOOLS_SCRIPT.script-dquot= \

View file

@ -1,44 +0,0 @@
#! /bin/sh
# $NetBSD: sh-test.sh,v 1.3 2018/12/05 19:01:40 rillig Exp $
#
set -e
mydir=`dirname "$0"`
. "${mydir}/tests.subr"
#
# Functions specific for the sh testsuite.
#
# usage: sh_test <testname> <input> <expected-output> <args...>
sh_test() {
testname=$1; input=$2; expected=$3; shift 3;
testcase_start "${testname}"
output=`sh ${1+"$@"} <<EOF
$input
EOF
`
assert_equal "${testname}" "${expected}" "${output}"
}
# usage: sh_assert_equals "testname" "expected" "got"
sh_assert_equals() {
testcase_start "$1"
assert_equal "$1" "$2" "$3"
}
#
# The actual test.
#
nl="
"
# If this test fails because the result is "#define bindir \"", the
# tested shell may be from NetBSD 7.0, which is known to have this bug.
# Since NetBSD 8, this bug is fixed. See https://gnats.netbsd.org/43469.
line="#define bindir \"/usr/bin\" /* bar */"
sh_assert_equals "removing C comments" "#define bindir \"/usr/bin\" " "${line%%/\**}"