Adapt tests/tail-2/ to use test-lib.sh.
authorJim Meyering <jim@meyering.net>
Thu, 13 Sep 2007 06:44:26 +0000 (08:44 +0200)
committerJim Meyering <jim@meyering.net>
Sat, 15 Sep 2007 06:40:39 +0000 (08:40 +0200)
tests/tail-2/Makefile.am
tests/tail-2/append-only
tests/tail-2/assert
tests/tail-2/assert-2
tests/tail-2/big-4gb
tests/tail-2/fflush
tests/tail-2/infloop-1
tests/tail-2/proc-ksyms
tests/tail-2/start-middle
tests/tail-2/tail-n0f

index a1ff003..abd603d 100644 (file)
@@ -30,3 +30,5 @@ TESTS = \
   append-only \
   tail-n0f \
   big-4gb proc-ksyms start-middle assert assert-2
+
+include $(top_srcdir)/tests/check.mk
index 30cd2c1..94adba5 100755 (executable)
@@ -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
index a2b5a6d..72ee9c9 100755 (executable)
@@ -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'
 
index c13397f..090bf0f 100755 (executable)
@@ -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'
 
index cd56be7..5494e3d 100755 (executable)
@@ -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
 # 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
index 6711818..020601f 100755 (executable)
@@ -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 &
index c60a13a..9b2701f 100755 (executable)
@@ -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=$!
index 1e58559..4a1a176 100755 (executable)
@@ -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
 
index 6e7cda0..7e62a40 100755 (executable)
@@ -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
index 3a94bc5..de5786e 100755 (executable)
@@ -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