pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/regress
Module Name: pkgsrc
Committed By: rillig
Date: Sat May 2 07:24:32 UTC 2020
Modified Files:
pkgsrc/regress/tools: Makefile
pkgsrc/regress/tools-platform: sh.test spec
Added Files:
pkgsrc/regress/tools-platform: awk.test sed.test sort.test tar.test
tests.subr tr.test
Removed Files:
pkgsrc/regress/tools/files: awk-test.sh sed-test.sh sh-test.sh
sort-test.sh tar-test.sh tr-test.sh
Log Message:
regress: move tests for platform tools to tools-platform
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 pkgsrc/regress/tools/Makefile
cvs rdiff -u -r0 -r1.1 pkgsrc/regress/tools-platform/awk.test \
pkgsrc/regress/tools-platform/sed.test \
pkgsrc/regress/tools-platform/sort.test \
pkgsrc/regress/tools-platform/tar.test \
pkgsrc/regress/tools-platform/tests.subr \
pkgsrc/regress/tools-platform/tr.test
cvs rdiff -u -r1.1 -r1.2 pkgsrc/regress/tools-platform/sh.test \
pkgsrc/regress/tools-platform/spec
cvs rdiff -u -r1.8 -r0 pkgsrc/regress/tools/files/awk-test.sh
cvs rdiff -u -r1.1 -r0 pkgsrc/regress/tools/files/sed-test.sh \
pkgsrc/regress/tools/files/sort-test.sh \
pkgsrc/regress/tools/files/tar-test.sh
cvs rdiff -u -r1.3 -r0 pkgsrc/regress/tools/files/sh-test.sh
cvs rdiff -u -r1.2 -r0 pkgsrc/regress/tools/files/tr-test.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/regress/tools/Makefile
diff -u pkgsrc/regress/tools/Makefile:1.15 pkgsrc/regress/tools/Makefile:1.16
--- pkgsrc/regress/tools/Makefile:1.15 Sun Mar 24 11:29:19 2019
+++ pkgsrc/regress/tools/Makefile Sat May 2 07:24:31 2020
@@ -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= \
Index: pkgsrc/regress/tools-platform/sh.test
diff -u pkgsrc/regress/tools-platform/sh.test:1.1 pkgsrc/regress/tools-platform/sh.test:1.2
--- pkgsrc/regress/tools-platform/sh.test:1.1 Fri May 1 18:37:59 2020
+++ pkgsrc/regress/tools-platform/sh.test Sat May 2 07:24:32 2020
@@ -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%/*}" --equal
# 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
Index: pkgsrc/regress/tools-platform/spec
diff -u pkgsrc/regress/tools-platform/spec:1.1 pkgsrc/regress/tools-platform/spec:1.2
--- pkgsrc/regress/tools-platform/spec:1.1 Fri May 1 18:37:59 2020
+++ pkgsrc/regress/tools-platform/spec Sat May 2 07:24:32 2020
@@ -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"
Added files:
Index: pkgsrc/regress/tools-platform/awk.test
diff -u /dev/null pkgsrc/regress/tools-platform/awk.test:1.1
--- /dev/null Sat May 2 07:24:32 2020
+++ pkgsrc/regress/tools-platform/awk.test Sat May 2 07:24:32 2020
@@ -0,0 +1,65 @@
+#! /bin/sh
+# $NetBSD: awk.test,v 1.1 2020/05/02 07:24:32 rillig Exp $
+#
+
+set -e
+
+mydir=`dirname "$0"`
+. "${mydir}/tests.subr"
+
+#
+# Functions specific for the awk testsuite.
+#
+
+# usage: test_assignment <testname> <input> <expected-output>
+test_assignment() {
+ testcase_start "$1"
+ o=`echo "" | awk '{print var}' var="$2"`
+ assert_equal "$1" "$3" "${o}"
+}
+
+# usage: test_passline <testname> <input>
+test_passline() {
+ testcase_start "$1"
+ o=`awk '{print}' <<EOF
+$2
+EOF
+`
+ assert_equal "$1" "$2" "${o}"
+}
+
+#
+# The actual test.
+#
+
+#
+# Assignment of variables from the command line. The Solaris
+# /usr/bin/awk does not conform to the POSIX specification, but passes
+# the right hand side of the assignment uninterpreted. It fails the
+# cmd.3 test case. The "for" loop makes sure that awk can handle strings
+# of 4096 bytes length.
+#
+test_assignment "cmd.1" \
+ "foo" "foo"
+test_assignment "cmd.2" \
+ "foo bar baz" "foo bar baz"
+test_assignment "cmd.3" \
+ "CPPFLAGS=\\\"-Dfoo=bar\\\"" "CPPFLAGS=\"-Dfoo=bar\""
+line="a"
+for i in 0 1 2 3 4 5 6 7 8 9 10 11 12; do
+ test_assignment "cmd.2^${i}" "${line}" "${line}"
+ line="${line}${line}"
+done
+
+#
+# Passing strings from stdin to stdout. awk should be able to handle at
+# least 2^12 characters per line.
+#
+# Solaris 9 /usr/bin/awk: 2559 bytes
+# Solaris 9 /usr/bin/nawk: 6144 bytes
+#
+line="a"
+for i in 0 1 2 3 4 5 6 7 8 9 10 11 12; do
+ test_passline "line.2^${i}" "${line}"
+ line="${line}${line}"
+done
Index: pkgsrc/regress/tools-platform/sed.test
diff -u /dev/null pkgsrc/regress/tools-platform/sed.test:1.1
--- /dev/null Sat May 2 07:24:32 2020
+++ pkgsrc/regress/tools-platform/sed.test Sat May 2 07:24:32 2020
@@ -0,0 +1,39 @@
+#! /bin/sh
+# $NetBSD: sed.test,v 1.1 2020/05/02 07:24:32 rillig Exp $
+#
+
+set -e
+
+mydir=`dirname "$0"`
+. "${mydir}/tests.subr"
+
+#
+# Functions specific for the "sed" testsuite.
+#
+
+# usage: sed_test <testname> <input> <expected-output> <args...>
+sed_test() {
+ testname=$1; input=$2; expected=$3; shift 3;
+
+ testcase_start "${testname}"
+ output=`sed "$@" <<EOF
+$input
+EOF
+`
+ assert_equal "${testname}" "${expected}" "${output}"
+}
+
+#
+# The actual test.
+#
+
+nl="
+"
+
+#
+# Make sure that sed(1) can handle character classes.
+#
+sed_test "[[:character classes:]]" \
+ "hello${nl}foo bar" \
+ "hello" \
+ -e "/[[:space:]]/d"
Index: pkgsrc/regress/tools-platform/sort.test
diff -u /dev/null pkgsrc/regress/tools-platform/sort.test:1.1
--- /dev/null Sat May 2 07:24:32 2020
+++ pkgsrc/regress/tools-platform/sort.test Sat May 2 07:24:32 2020
@@ -0,0 +1,38 @@
+#! /bin/sh
+# $NetBSD: sort.test,v 1.1 2020/05/02 07:24:32 rillig Exp $
+#
+
+set -e
+
+mydir=`dirname "$0"`
+. "${mydir}/tests.subr"
+
+#
+# Functions specific for the "sort" testsuite.
+#
+
+# usage: sort_test <testname> <input> <expected-output> <args...>
+sort_test() {
+ testname=$1; input=$2; expected=$3; shift 3;
+
+ testcase_start "${testname}"
+ output=`sort "$@" <<EOF
+$input
+EOF
+`
+ assert_equal "${testname}" "${expected}" "${output}"
+}
+
+#
+# The actual test.
+#
+
+nl="
+"
+
+sort_test "one line" \
+ "text line 1" "text line 1"
+sort_test "uppercase letters" \
+ "A${nl}B${nl}C" "A${nl}B${nl}C"
+sort_test "A < C < b" \
+ "A${nl}b${nl}C" "A${nl}C${nl}b"
Index: pkgsrc/regress/tools-platform/tar.test
diff -u /dev/null pkgsrc/regress/tools-platform/tar.test:1.1
--- /dev/null Sat May 2 07:24:32 2020
+++ pkgsrc/regress/tools-platform/tar.test Sat May 2 07:24:32 2020
@@ -0,0 +1,24 @@
+#! /bin/sh
+# $NetBSD: tar.test,v 1.1 2020/05/02 07:24:32 rillig Exp $
+#
+
+set -e
+
+mydir=`dirname "$0"`
+. "${mydir}/tests.subr"
+
+#
+# Functions specific for the tar testsuite.
+#
+
+# none.
+
+#
+# The actual test.
+#
+
+# tar must support the -z option.
+#
+testcase_start "-z"
+echo "data" > file
+tar cfz archive.tar.gz file
Index: pkgsrc/regress/tools-platform/tests.subr
diff -u /dev/null pkgsrc/regress/tools-platform/tests.subr:1.1
--- /dev/null Sat May 2 07:24:32 2020
+++ pkgsrc/regress/tools-platform/tests.subr Sat May 2 07:24:32 2020
@@ -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
+}
Index: pkgsrc/regress/tools-platform/tr.test
diff -u /dev/null pkgsrc/regress/tools-platform/tr.test:1.1
--- /dev/null Sat May 2 07:24:32 2020
+++ pkgsrc/regress/tools-platform/tr.test Sat May 2 07:24:32 2020
@@ -0,0 +1,55 @@
+#! /bin/sh
+# $NetBSD: tr.test,v 1.1 2020/05/02 07:24:32 rillig Exp $
+#
+
+set -e
+
+mydir=`dirname "$0"`
+. "${mydir}/tests.subr"
+
+#
+# Functions specific for the tr testsuite.
+#
+
+# usage: tr_test <testname> <input> <expected-output> <args...>
+tr_test() {
+ testname=$1; input=$2; expected=$3; shift 3;
+
+ testcase_start "${testname}"
+ output=`tr "$@" <<EOF
+$input
+EOF
+`
+ assert_equal "${testname}" "${expected}" "${output}"
+}
+
+#
+# The actual test.
+#
+
+nl="
+"
+
+tr_test "simple" \
+ "foo" "baa" "fo" "ba"
+tr_test "tolower" \
+ "The Great Green Fox" "the great green fox" "A-Z" "a-z"
+tr_test "eat-newlines" \
+ "foo${nl}bar${nl}" "foobar" -d "\\n"
+tr_test "eat-minus" \
+ "describe-function" "describefunction" -d "-"
+tr_test "eat-minus-d" \
+ "describe-function" "escribefunction" -d -- "-d"
+tr_test "eat-d-minus" \
+ "describe-function" "escribefunction" -d "d-"
+
+s="0123456789abcdef"
+s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
+s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
+s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
+f="ffffffffffffffff"
+f="$f$f$f$f$f$f$f$f$f$f$f$f$f$f$f$f"
+f="$f$f$f$f$f$f$f$f$f$f$f$f$f$f$f$f"
+
+tr_test "65536" \
+ "$s" "$f" -d "0-9a-e"
Home |
Main Index |
Thread Index |
Old Index