Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/regress regress: move tests for platform tools to tool...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/601e42d86793
branches:  trunk
changeset: 430588:601e42d86793
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat May 02 07:24:31 2020 +0000

description:
regress: move tests for platform tools to tools-platform

diffstat:

 regress/tools-platform/awk.test   |  65 +++++++++++++++++++++++++++++++++++++++
 regress/tools-platform/sed.test   |  39 +++++++++++++++++++++++
 regress/tools-platform/sh.test    |  14 +++++++-
 regress/tools-platform/sort.test  |  38 ++++++++++++++++++++++
 regress/tools-platform/spec       |  14 +++++++-
 regress/tools-platform/tar.test   |  24 ++++++++++++++
 regress/tools-platform/tests.subr |  14 ++++++++
 regress/tools-platform/tr.test    |  55 +++++++++++++++++++++++++++++++++
 regress/tools/Makefile            |   4 +-
 regress/tools/files/awk-test.sh   |  65 ---------------------------------------
 regress/tools/files/sed-test.sh   |  39 -----------------------
 regress/tools/files/sh-test.sh    |  44 --------------------------
 regress/tools/files/sort-test.sh  |  38 ----------------------
 regress/tools/files/tar-test.sh   |  24 --------------
 regress/tools/files/tr-test.sh    |  56 ---------------------------------
 15 files changed, 261 insertions(+), 272 deletions(-)

diffs (truncated from 631 to 300 lines):

diff -r 24af957f7f4f -r 601e42d86793 regress/tools-platform/awk.test
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/tools-platform/awk.test   Sat May 02 07:24:31 2020 +0000
@@ -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
diff -r 24af957f7f4f -r 601e42d86793 regress/tools-platform/sed.test
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/tools-platform/sed.test   Sat May 02 07:24:31 2020 +0000
@@ -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"
diff -r 24af957f7f4f -r 601e42d86793 regress/tools-platform/sh.test
--- a/regress/tools-platform/sh.test    Sat May 02 06:54:48 2020 +0000
+++ b/regress/tools-platform/sh.test    Sat May 02 07:24:31 2020 +0000
@@ -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 @@
 # 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
diff -r 24af957f7f4f -r 601e42d86793 regress/tools-platform/sort.test
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/tools-platform/sort.test  Sat May 02 07:24:31 2020 +0000
@@ -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"
diff -r 24af957f7f4f -r 601e42d86793 regress/tools-platform/spec
--- a/regress/tools-platform/spec       Sat May 02 06:54:48 2020 +0000
+++ b/regress/tools-platform/spec       Sat May 02 07:24:31 2020 +0000
@@ -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 @@
                        -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"
diff -r 24af957f7f4f -r 601e42d86793 regress/tools-platform/tar.test
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/tools-platform/tar.test   Sat May 02 07:24:31 2020 +0000
@@ -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
diff -r 24af957f7f4f -r 601e42d86793 regress/tools-platform/tests.subr
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/tools-platform/tests.subr Sat May 02 07:24:31 2020 +0000
@@ -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
+}
diff -r 24af957f7f4f -r 601e42d86793 regress/tools-platform/tr.test
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/tools-platform/tr.test    Sat May 02 07:24:31 2020 +0000
@@ -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="
+"
+



Home | Main Index | Thread Index | Old Index