summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-10-28 09:39:52 +0000
committerJim Meyering <jim@meyering.net>2001-10-28 09:39:52 +0000
commit1c7b8f6e85a1cca05757b18541726202436f9e8f (patch)
tree9efa960b54a19e84d490de54e891919d387b273c /tests
parentaf6ce0f12c24b23fa018a02128d77a85acda2e40 (diff)
downloadcoreutils-1c7b8f6e85a1cca05757b18541726202436f9e8f.tar.xz
test Paul's fix
Diffstat (limited to 'tests')
-rwxr-xr-xtests/sum/sysv54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/sum/sysv b/tests/sum/sysv
new file mode 100755
index 000000000..cab25b153
--- /dev/null
+++ b/tests/sum/sysv
@@ -0,0 +1,54 @@
+#!/bin/sh
+# make sure `sum -s' works for input whose sum of bytes is larger than 2^32
+
+if test "$VERBOSE" = yes; then
+ set -x
+ sum --version
+fi
+
+case "$PERL" in
+ *'missing perl')
+ echo 1>&2 "$0: configure didn't find a usable version of Perl, so can't run this test"
+ exit 77
+ ;;
+esac
+
+pwd=`pwd`
+tmp=sum-s.$$
+trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
+trap '(exit $?); exit' 1 2 13 15
+
+framework_failure=0
+mkdir $tmp || framework_failure=1
+cd $tmp || framework_failure=1
+
+if test $framework_failure = 1; then
+ echo 'failure in testing framework' 1>&2
+ (exit 1); exit
+fi
+
+fail=0
+
+# FYI, 16843009 is floor (2^32 / 255).
+
+# aka: perl -e 'print chr(255) x 16843009'
+$PERL -e '$s = chr(255) x 65537; foreach (1..257) {print $s}' \
+ | sum -s > out || fail=1
+cat > exp <<\EOF
+65535 32897
+EOF
+cmp out exp || fail=1
+test $fail = 1 && diff out exp 2> /dev/null
+
+rm -f out exp
+
+# aka: perl -e 'print chr(255) x 16843010'
+$PERL -e '$s = chr(255) x 65537; foreach (1..257) {print $s}; print chr(255)' \
+ | sum -s > out || fail=1
+cat > exp <<\EOF
+254 32897
+EOF
+cmp out exp || fail=1
+test $fail = 1 && diff out exp 2> /dev/null
+
+(exit $fail); exit