summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2007-09-13 08:44:26 +0200
committerJim Meyering <jim@meyering.net>2007-09-15 08:40:39 +0200
commit53d36aaf9a856f523bd52de479a88f14338edda3 (patch)
treed43c74c6219ab7e0f8d294c131189034b15bea47
parent10d190b8b6289f8a4b4818bd03b8f3a5dc87fd14 (diff)
downloadcoreutils-53d36aaf9a856f523bd52de479a88f14338edda3.tar.xz
Adapt tests/tail-2/ to use test-lib.sh.
-rw-r--r--tests/tail-2/Makefile.am2
-rwxr-xr-xtests/tail-2/append-only21
-rwxr-xr-xtests/tail-2/assert16
-rwxr-xr-xtests/tail-2/assert-216
-rwxr-xr-xtests/tail-2/big-4gb26
-rwxr-xr-xtests/tail-2/fflush15
-rwxr-xr-xtests/tail-2/infloop-115
-rwxr-xr-xtests/tail-2/proc-ksyms7
-rwxr-xr-xtests/tail-2/start-middle21
-rwxr-xr-xtests/tail-2/tail-n0f22
10 files changed, 34 insertions, 127 deletions
diff --git a/tests/tail-2/Makefile.am b/tests/tail-2/Makefile.am
index a1ff0037a..abd603dcd 100644
--- a/tests/tail-2/Makefile.am
+++ b/tests/tail-2/Makefile.am
@@ -30,3 +30,5 @@ TESTS = \
append-only \
tail-n0f \
big-4gb proc-ksyms start-middle assert assert-2
+
+include $(top_srcdir)/tests/check.mk
diff --git a/tests/tail-2/append-only b/tests/tail-2/append-only
index 30cd2c134..94adba558 100755
--- a/tests/tail-2/append-only
+++ b/tests/tail-2/append-only
@@ -2,7 +2,7 @@
# Ensure that tail -f works on an append-only file
# Requires root access to do chattr +a, as well as an ext[23] or xfs file system
-# Copyright (C) 2006 Free Software Foundation, Inc.
+# Copyright (C) 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -23,22 +23,15 @@ if test "$VERBOSE" = yes; then
fi
PRIV_CHECK_ARG=require-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
+chattr_a_works=1
touch f
-chattr +a f 2>/dev/null || framework_failure=1
-( echo x > f ) 2>/dev/null && framework_failure=1
-echo x >> f || framework_failure=1
+chattr +a f 2>/dev/null || chattr_a_works=0
+( echo x > f ) 2>/dev/null && chattr_a_works=0
+echo x >> f || chattr_a_works=0
-if test $framework_failure = 1; then
+if test $chattr_a_works = 0; then
echo "$0: chattr +a doesn't work on this file system; skipping this test " 1>&2
(exit 77); exit 77
fi
diff --git a/tests/tail-2/assert b/tests/tail-2/assert
index a2b5a6df7..72ee9c933 100755
--- a/tests/tail-2/assert
+++ b/tests/tail-2/assert
@@ -1,7 +1,7 @@
#!/bin/sh
# Test for assertion failure in "test".
-# Copyright (C) 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2004, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -30,19 +30,7 @@ fi
# Not "expensive" per se, but sleeping for so long is annoying.
. $srcdir/../very-expensive
-
-tmp=tail-assert.$$
-pwd=`pwd`
-trap 'cd "$pwd" && rm -rf $tmp' 0 1 2 3 15
-
-test_failure=0
-mkdir $tmp || test_failure=1
-cd $tmp || test_failure=1
-
-if test $test_failure = 1; then
- echo 'failure in testing framework'
- exit 1
-fi
+. $srcdir/../test-lib.sh
ok='ok ok ok'
diff --git a/tests/tail-2/assert-2 b/tests/tail-2/assert-2
index c13397f48..090bf0ff9 100755
--- a/tests/tail-2/assert-2
+++ b/tests/tail-2/assert-2
@@ -3,7 +3,7 @@
# Due to a race condition in the test, the `assert' script would get
# the UMR on Solaris only some of the time, and not at all on Linux/GNU.
-# Copyright (C) 2000, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -25,19 +25,7 @@ fi
# Not "expensive" per se, but sleeping for so long is annoying.
. $srcdir/../very-expensive
-
-tmp=tail-as2.$$
-pwd=`pwd`
-trap 'cd "$pwd" && rm -rf $tmp' 0 1 2 3 15
-
-test_failure=0
-mkdir $tmp || test_failure=1
-cd $tmp || test_failure=1
-
-if test $test_failure = 1; then
- echo 'failure in testing framework'
- exit 1
-fi
+. $srcdir/../test-lib.sh
ok='ok ok ok'
diff --git a/tests/tail-2/big-4gb b/tests/tail-2/big-4gb
index cd56be71b..5494e3dc4 100755
--- a/tests/tail-2/big-4gb
+++ b/tests/tail-2/big-4gb
@@ -2,7 +2,7 @@
# Demonstrate a bug in `tail -cN' when operating on files of size 4G and larger
# Fixed in coreutils-4.5.2.
-# Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,28 +17,20 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-. $srcdir/../expensive
-
if test "$VERBOSE" = yes; then
set -x
tail --version
fi
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+. $srcdir/../expensive
+. $srcdir/../test-lib.sh
# Create a file of size exactly 4GB (2^32) with 8 bytes
# at the beginning and another set of 8 bytes at the end.
# The rest will be NUL bytes. On most modern systems, the following
# creates a file that takes up only a few KB. Here, du -sh says 16K.
-echo abcdefgh | tr -d '\n' > big || framework_failure=1
-echo 87654321 | tr -d '\n' > tmp || framework_failure=1
+echo abcdefgh | tr -d '\n' > big || framework_failure
+echo 87654321 | tr -d '\n' > tmp || framework_failure
# Seek 4GB - 8
dd bs=1 seek=4294967288 if=tmp of=big 2> err || dd_failed=1
if test "$dd_failed" = 1; then
@@ -49,11 +41,6 @@ if test "$dd_failed" = 1; then
(exit 77); exit 77
fi
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
-
fail=0
tail -c1 big > out || fail=1
@@ -63,7 +50,6 @@ cat <<\EOF > exp
1
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/tail-2/fflush b/tests/tail-2/fflush
index 6711818e9..020601f17 100755
--- a/tests/tail-2/fflush
+++ b/tests/tail-2/fflush
@@ -3,7 +3,7 @@
# The problem was that using the solaris5.7 setvbuf function to turn off
# buffering doesn't flush stdout.
-# Copyright (C) 1999, 2000, 2003, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2003, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -29,18 +29,7 @@ if test "$VERBOSE" = yes; then
tail --version
fi
-tmp=tail-flush.$$
-pwd=`pwd`
-trap 'cd "$pwd" && rm -rf $tmp' 0 1 2 3 15
-
-test_failure=0
-mkdir $tmp || test_failure=1
-cd $tmp || test_failure=1
-
-if test $test_failure = 1; then
- echo 'failure in testing framework'
- exit 1
-fi
+. $srcdir/../test-lib.sh
echo fubar > in
tail -f in | cat > out &
diff --git a/tests/tail-2/infloop-1 b/tests/tail-2/infloop-1
index c60a13a0d..9b2701f9f 100755
--- a/tests/tail-2/infloop-1
+++ b/tests/tail-2/infloop-1
@@ -1,7 +1,7 @@
#!/bin/sh
# This test would fail with tail from pre-1.22i textutils.
-# Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,18 +21,7 @@ if test "$VERBOSE" = yes; then
tail --version
fi
-tmp=tail-inf1.$$
-pwd=`pwd`
-trap 'cd "$pwd" && rm -rf $tmp' 0 1 2 3 15
-
-test_failure=0
-mkdir $tmp || test_failure=1
-cd $tmp || test_failure=1
-
-if test $test_failure = 1; then
- echo 'failure in testing framework'
- exit 1
-fi
+. $srcdir/../test-lib.sh
yes > t &
yes_pid=$!
diff --git a/tests/tail-2/proc-ksyms b/tests/tail-2/proc-ksyms
index 1e5855962..4a1a17662 100755
--- a/tests/tail-2/proc-ksyms
+++ b/tests/tail-2/proc-ksyms
@@ -1,7 +1,7 @@
#!/bin/sh
# Prior to textutils-2.0.17, `tail /proc/ksyms' would segfault on Linux.
-# Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2004, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,10 +21,7 @@ if test "$VERBOSE" = yes; then
tail --version
fi
-pwd=`pwd`
-tmp=proc-ksyms.$$
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
+. $srcdir/../test-lib.sh
fail=0
diff --git a/tests/tail-2/start-middle b/tests/tail-2/start-middle
index 6e7cda0de..7e62a4073 100755
--- a/tests/tail-2/start-middle
+++ b/tests/tail-2/start-middle
@@ -2,7 +2,7 @@
# Verify that tail works even when it's reading from a file
# that is not at its beginning. Based on a report from John Roll.
-# Copyright (C) 2001, 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2004, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,21 +22,9 @@ if test "$VERBOSE" = yes; then
tail --version
fi
-pwd=`pwd`
-tmp=tail-mid.$$
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
+. $srcdir/../test-lib.sh
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-(echo 1; echo 2) > k || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+(echo 1; echo 2) > k || framework_failure
fail=0
@@ -45,7 +33,6 @@ cat <<EOF > exp
2
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/tail-2/tail-n0f b/tests/tail-2/tail-n0f
index 3a94bc5f3..de5786e91 100755
--- a/tests/tail-2/tail-n0f
+++ b/tests/tail-2/tail-n0f
@@ -2,7 +2,7 @@
# Make sure that `tail -n0 -f' and `tail -c0 -f' sleep
# rather than doing what amounted to a busy-wait.
-# Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,7 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
# This bug was fixed for 5.0.91
# It skips the test if your system lacks a /proc/$pid/status
# file, or if its contents don't look right.
@@ -27,6 +26,8 @@ if test "$VERBOSE" = yes; then
tail --version
fi
+. $srcdir/../test-lib.sh
+
sleep 2 &
pid=$!
sleep .5
@@ -37,21 +38,8 @@ grep '^State:[ ]*[S]' /proc/$pid/status > /dev/null 2>&1 || \
}
kill $pid
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-touch empty || framework_failure=1
-echo anything > nonempty || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+touch empty || framework_failure
+echo anything > nonempty || framework_failure
fail=0