diff options
Diffstat (limited to 'tests/misc')
38 files changed, 152 insertions, 609 deletions
diff --git a/tests/misc/arch b/tests/misc/arch index 7ad48521a..942fa933d 100755 --- a/tests/misc/arch +++ b/tests/misc/arch @@ -27,26 +27,14 @@ if test "$VERBOSE" = yes; then arch --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 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh + fail=0 arch > out || fail=1 uname -m > exp || fail=1 -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/misc/cat-proc b/tests/misc/cat-proc index 975188b9e..84265e18e 100755 --- a/tests/misc/cat-proc +++ b/tests/misc/cat-proc @@ -22,19 +22,8 @@ if test "$VERBOSE" = yes; then cat --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 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh + f=/proc/cpuinfo test -f $f \ @@ -52,7 +41,6 @@ fail=0 cat -E $f | sed 's/[0-9][0-9]*/D/g' | tr -d '$' > out || fail=1 cat $f | sed 's/[0-9][0-9]*/D/g' | tr -d '$' > exp || fail=1 -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/misc/chcon b/tests/misc/chcon index 88c009baf..46aaf87e3 100755 --- a/tests/misc/chcon +++ b/tests/misc/chcon @@ -8,22 +8,9 @@ fi . $srcdir/../lang-default PRIV_CHECK_ARG=require-root . $srcdir/../priv-check - -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 -mkdir -p d/sub/s2 || framework_failure=1 -touch f g d/sub/1 d/sub/2 || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh +mkdir -p d/sub/s2 || framework_failure +touch f g d/sub/1 d/sub/2 || framework_failure fail=0 @@ -67,7 +54,6 @@ f|-robject_r|root:object_r:file_t:SystemLow-SystemHigh f|-ttmp_t|root:object_r:tmp_t:SystemLow-SystemHigh 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/misc/chcon-fail b/tests/misc/chcon-fail index d639e86b5..865b1b996 100755 --- a/tests/misc/chcon-fail +++ b/tests/misc/chcon-fail @@ -8,20 +8,7 @@ if test "$VERBOSE" = yes; then fi . $srcdir/../lang-default - -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 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 diff --git a/tests/misc/close-stdout b/tests/misc/close-stdout index 0f8c2eaab..301c8ecb5 100755 --- a/tests/misc/close-stdout +++ b/tests/misc/close-stdout @@ -2,7 +2,7 @@ # Ensure that several programs work fine, even with stdout initially closed. # This is effectively a test of closeout.c's close_stdout function. -# Copyright (C) 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 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,22 +22,9 @@ if test "$VERBOSE" = yes; then rm --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 +. $srcdir/../test-lib.sh -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi - -PATH="$pwd/../..:$PATH" -export PATH +p="$abs_top_builddir" fail=0 @@ -54,21 +41,21 @@ mv d e >&- || fail=1 rmdir e >&- || fail=1 touch e >&- || fail=1 sleep 0 >&- || fail=1 -"$pwd/../../src/true" >&- || fail=1 -"$pwd/../../src/printf" '' >&- || fail=1 +"$p/src/true" >&- || fail=1 +"$p/src/printf" '' >&- || fail=1 # If >&- works, ensure these fail, because stdout is closed and they # *do* generate output. >&- apparently does not work in HP-UX 11.23. # This test is ineffective unless /dev/stdout also works. -if "$pwd/../../src/test" -w /dev/stdout >/dev/null && - "$pwd/../../src/test" ! -w /dev/stdout >&-; then - "$pwd/../../src/printf" 'foo' >&- 2>/dev/null && fail=1 +if "$p/src/test" -w /dev/stdout >/dev/null && + "$p/src/test" ! -w /dev/stdout >&-; then + "$p/src/printf" 'foo' >&- 2>/dev/null && fail=1 cp --verbose a b >&- 2>/dev/null && fail=1 fi # Likewise for /dev/full, if /dev/full works. if test -w /dev/full && test -c /dev/full; then - "$pwd/../../src/printf" 'foo' >/dev/full 2>/dev/null && fail=1 + "$p/src/printf" 'foo' >/dev/full 2>/dev/null && fail=1 cp --verbose a b >/dev/full 2>/dev/null && fail=1 fi diff --git a/tests/misc/csplit b/tests/misc/csplit index 65a9cca51..defff67d7 100755 --- a/tests/misc/csplit +++ b/tests/misc/csplit @@ -1,8 +1,7 @@ #!/bin/sh # various csplit tests -# Copyright (C) 2001, 2002, 2003, 2004, 2005 2006 Free Software -# Foundation, Inc. +# Copyright (C) 2001-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,20 +22,7 @@ if test "$VERBOSE" = yes; then fi . $srcdir/../lang-default - -pwd=`pwd` -tmp=csplit.$$ -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 "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 @@ -48,16 +34,14 @@ cat <<EOF > exp 0 2 EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 rm -f in out exp # Ensure that xx02 contains just two newlines. # This would fail due to reading from freed buffer with coreutils-5.0.91. printf '\n\n' > exp cp xx02 out || fail=1 -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 rm -f in out exp # csplit would infloop @@ -67,8 +51,7 @@ cat <<EOF > exp 0 3 EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 rm -f in out exp # `echo |csplit - 1 1' used to abort. @@ -79,13 +62,11 @@ cat <<EOF > exp 0 1 EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 cat <<\EOF > experr csplit: warning: line number `1' is the same as preceding line number EOF -cmp err experr || fail=1 -test $fail = 1 && diff err experr 2> /dev/null +compare err experr || fail=1 rm -f in out exp err experr # make sure `csplit FILE 0' fails. @@ -99,8 +80,7 @@ csplit: line number `1' is smaller than preceding line number, 2 csplit: warning: line number `3' is the same as preceding line number csplit: `3': line number out of range EOF -cmp err experr || fail=1 -test $fail = 1 && diff err experr 2> /dev/null +compare err experr || fail=1 # Ensure that lines longer than the initial buffer length don't cause # trouble (e.g. reading from freed memory, resulting in corrupt output). @@ -109,6 +89,6 @@ test $fail = 1 && diff err experr 2> /dev/null rm -f in out exp err experr xx?? printf 'x%8199s\nx\n%8199s\nx\n' x x > in csplit in '/x\{1\}/' '{*}' > /dev/null || fail=1 -cat xx?? | cmp - in || fail=1 +cat xx?? | compare - in || fail=1 (exit $fail); exit $fail diff --git a/tests/misc/date-sec b/tests/misc/date-sec index d389e7272..445326dc5 100755 --- a/tests/misc/date-sec +++ b/tests/misc/date-sec @@ -23,19 +23,8 @@ if test "$VERBOSE" = yes; then date --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 +. $srcdir/../test-lib.sh -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi fail=0 diff --git a/tests/misc/df b/tests/misc/df index 6138beaab..84050f375 100755 --- a/tests/misc/df +++ b/tests/misc/df @@ -21,6 +21,8 @@ if test "$VERBOSE" = yes; then df --version fi +. $srcdir/../test-lib.sh + case `df .` in *' '*) diff --git a/tests/misc/df-P b/tests/misc/df-P index 4fffd499b..a27abf0b9 100755 --- a/tests/misc/df-P +++ b/tests/misc/df-P @@ -21,22 +21,8 @@ if test "$VERBOSE" = yes; then df --version fi -. $srcdir/../envvar-check . $srcdir/../lang-default - -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 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 @@ -52,7 +38,6 @@ BLOCK_SIZE=1M df -P . > t2 || fail=1 head -n1 t1 > exp || fail=1 head -n1 t2 > out || fail=1 -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/misc/false-status b/tests/misc/false-status index f5b158a6a..b6b22a6ac 100755 --- a/tests/misc/false-status +++ b/tests/misc/false-status @@ -1,7 +1,7 @@ #!/bin/sh # ensure that false exits nonzero even with --help or --version -# 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 @@ -21,22 +21,9 @@ if test "$VERBOSE" = yes; then false --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 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 - false --version > /dev/null && fail=1 false --help > /dev/null && fail=1 diff --git a/tests/misc/fmt-long-line b/tests/misc/fmt-long-line index 547b02f3c..aae1fa8be 100755 --- a/tests/misc/fmt-long-line +++ b/tests/misc/fmt-long-line @@ -1,7 +1,7 @@ #!/bin/sh # make sure fmt -s works even on long lines -# Copyright (C) 2002, 2006 Free Software Foundation, Inc. +# Copyright (C) 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,17 +21,11 @@ if test "$VERBOSE" = yes; then fmt --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 +. $srcdir/../test-lib.sh -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -(echo ' '; yes) | head -n1000 | tr '\n' ' ' > in || framework_failure=1 +(echo ' '; yes) | head -n1000 | tr '\n' ' ' > in || framework_failure -cat <<\EOF > exp || framework_failure=1 +cat <<\EOF > exp || framework_failure y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y y @@ -64,16 +58,10 @@ cat <<\EOF > exp || framework_failure=1 y y EOF -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi - fail=0 fmt -s in > out || fail=1 -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/misc/groups-version b/tests/misc/groups-version index 407a25174..15327be32 100755 --- a/tests/misc/groups-version +++ b/tests/misc/groups-version @@ -22,27 +22,12 @@ if test "$VERBOSE" = yes; then fi . $srcdir/../lang-default - -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 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 - groups --version | sed 's/^groups/id/; /^$/q' > out || fail=1 id --version | sed '/^$/q' > exp || fail=1 -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/misc/head-c b/tests/misc/head-c index c75b0541c..1520ea610 100755 --- a/tests/misc/head-c +++ b/tests/misc/head-c @@ -1,7 +1,7 @@ #!/bin/sh # exercise the fix of 2001-08-18, based on test case from Ian Bruce -# 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,23 +21,11 @@ if test "$VERBOSE" = yes; then head --version fi -pwd=`pwd` -tmp=head-c.$$ -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 abc > in || framework_failure=1 - -if test $framework_failure = 1; then - echo 'failure in testing framework' 1>&2 - (exit 1); exit 1 -fi +echo abc > in || framework_failure fail=0 - (head -c1; head -c1) < in > out || fail=1 case "`cat out`" in ab) ;; diff --git a/tests/misc/head-pos b/tests/misc/head-pos index 3a27d3e8e..b78a42d43 100755 --- a/tests/misc/head-pos +++ b/tests/misc/head-pos @@ -2,7 +2,7 @@ # When reading a specified number of lines, ensure that the output # file pointer is positioned just after those lines. -# Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 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,20 +22,9 @@ if test "$VERBOSE" = yes; then head --version fi -pwd=`pwd` -tmp=head-pos.$$ -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 a; echo b) > in || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +(echo a; echo b) > in || framework_failure fail=0 (head -n 1 >/dev/null; cat) < in > out || fail=1 @@ -43,7 +32,6 @@ cat <<EOF > exp b 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/misc/ls-time b/tests/misc/ls-time index 9456411bd..4099e6b99 100755 --- a/tests/misc/ls-time +++ b/tests/misc/ls-time @@ -22,33 +22,13 @@ if test "$VERBOSE" = yes; then ls --version fi -. $srcdir/../envvar-check - -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 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh # Avoid any possible glitches due to daylight-saving changes near the # time stamps used during the test. TZ=UTC0 export TZ -tmp=t-ls.$$ - -framework_failure=0 -mkdir $tmp || framework_failure=1 -cd $tmp || framework_failure=1 - t1='1998-01-15 21:00' t2='1998-01-15 22:00' t3='1998-01-15 23:00' @@ -57,15 +37,15 @@ u1='1998-01-14 11:00' u2='1998-01-14 12:00' u3='1998-01-14 13:00' -touch -m -d "$t3" a || framework_failure=1 -touch -m -d "$t2" b || framework_failure=1 -touch -m -d "$t1" c || framework_failure=1 +touch -m -d "$t3" a || framework_failure +touch -m -d "$t2" b || framework_failure +touch -m -d "$t1" c || framework_failure -touch -a -d "$u3" c || framework_failure=1 -touch -a -d "$u2" b || framework_failure=1 +touch -a -d "$u3" c || framework_failure +touch -a -d "$u2" b || framework_failure # Make sure A has ctime at least 1 second more recent than C's. sleep 2 -touch -a -d "$u1" a || framework_failure=1 +touch -a -d "$u1" a || framework_failure fail=0 @@ -78,7 +58,7 @@ test "$*" = 'a c' || fail=1 sleep 2 # Create a link, updating c's ctime. -ln c d || framework_failure=1 +ln c d || framework_failure # Before we go any further, verify that touch's -m option works. set -- `ls --full -l a` @@ -95,7 +75,7 @@ have been $t3. EOF #` ls --full -l a - framework_failure=1 + framework_failure ;; esac @@ -117,11 +97,6 @@ EOF ;; esac -if test $framework_failure = 1; then - echo 'failure in testing framework' - exit 1 -fi - set `ls -ut a b c` test "$*" = 'c b a' && : || fail=1 test $fail = 1 && ls -l --full-time --time=access a b c diff --git a/tests/misc/mknod b/tests/misc/mknod index c9311113a..37b33d18d 100755 --- a/tests/misc/mknod +++ b/tests/misc/mknod @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that mknod, mkfifo, mkdir -m MODE work with a restrictive umask -# Copyright (C) 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 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,19 +21,7 @@ if test "$VERBOSE" = yes; then mknod --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 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 diff --git a/tests/misc/nice b/tests/misc/nice index ba6ce1c00..6b063daa2 100755 --- a/tests/misc/nice +++ b/tests/misc/nice @@ -1,7 +1,7 @@ #! /bin/sh # Test "nice". -# Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2005-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 @@ -16,13 +16,13 @@ # 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 script takes no arguments. - -if test -n "$DJDIR"; then - echo "$0: cannot test nice on DJGPP" >&2 - exit 77 +if test "$VERBOSE" = yes; then + set -x + nice --version fi +. $srcdir/../test-lib.sh + tests=' 0 empty 10 1 -1 1 diff --git a/tests/misc/nl b/tests/misc/nl index 77db3c9a1..13855fbca 100755 --- a/tests/misc/nl +++ b/tests/misc/nl @@ -1,7 +1,7 @@ #!/bin/sh # exercise nl functionality -# 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 @@ -21,19 +21,7 @@ if test "$VERBOSE" = yes; then nl --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 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 @@ -55,7 +43,6 @@ cat <<\EOF > exp $ 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/misc/nohup b/tests/misc/nohup index c4f971ff5..ac9e5e561 100755 --- a/tests/misc/nohup +++ b/tests/misc/nohup @@ -1,7 +1,7 @@ #!/bin/sh # test nohup -# 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 @@ -21,22 +21,8 @@ if test "$VERBOSE" = yes; then nohup --version fi -. $srcdir/../envvar-check . $srcdir/../lang-default - -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 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 @@ -62,8 +48,7 @@ else fi echo 'stderr' >> exp || fail=1 -cmp exp err || fail=1 -test $fail = 1 && diff exp err 2> /dev/null +compare exp err || fail=1 rm -f nohup.out err exp # ---------------------- @@ -95,8 +80,7 @@ nohup: appending output to `nohup.out' nohup: cannot run command `no-such-command': No such file or directory EOF # Disable these comparisons. Too much variation in 2nd line. -# cmp exp err || fail=1 -# test $fail = 1 && diff exp err 2> /dev/null +# compare exp err || fail=1 rm -f nohup.out err exp # ---------------------- @@ -116,8 +100,7 @@ nohup: appending output to `nohup.out' nohup: cannot run command `./k': Permission denied EOF # Disable these comparisons. Too much variation in 2nd line. -# cmp exp err || fail=1 -# test $fail = 1 && diff exp err 2> /dev/null +# compare exp err || fail=1 # Make sure it fails with exit status of 127 when given too few arguments. nohup >/dev/null 2>&1 diff --git a/tests/misc/pathchk1 b/tests/misc/pathchk1 index a2dc8c067..ffe917910 100755 --- a/tests/misc/pathchk1 +++ b/tests/misc/pathchk1 @@ -1,7 +1,7 @@ #!/bin/sh # pathchk tests -# Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2002, 2004, 2005, 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 fi PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check +. $srcdir/../test-lib.sh -pwd=`pwd` -t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ -trap 'status=$?; cd "$pwd" && 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 file || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +touch file || framework_failure fail=0 diff --git a/tests/misc/pr b/tests/misc/pr index 37ccad0f8..76c32d6b0 100755 --- a/tests/misc/pr +++ b/tests/misc/pr @@ -20,7 +20,6 @@ : ${PERL=perl} : ${srcdir=.} -. $srcdir/../envvar-check $PERL -e 1 > /dev/null 2>&1 || { echo 1>&2 "$0: configure didn't find a usable version of Perl," \ diff --git a/tests/misc/printf b/tests/misc/printf index 6fea4b0bc..5637d25f2 100755 --- a/tests/misc/printf +++ b/tests/misc/printf @@ -1,7 +1,7 @@ #!/bin/sh # basic tests for printf -# Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 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 @@ -16,26 +16,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -prog=`pwd`/../../src/printf +prog="$abs_top_builddir/src/printf" if test "$VERBOSE" = yes; then set -x "$prog" --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 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 @@ -46,8 +34,7 @@ cat <<\EOF > exp foo EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 rm -f out exp # Until coreutils-4.5.10, this would elicit a segfault. @@ -106,7 +93,6 @@ cat <<\EOF > exp 11 x EOF -cmp out exp || fail=1 -test $fail = 1 && diff -au out exp 2> /dev/null +compare out exp || fail=1 (exit $fail); exit $fail diff --git a/tests/misc/printf-hex b/tests/misc/printf-hex index 525d90beb..4ece0ac29 100755 --- a/tests/misc/printf-hex +++ b/tests/misc/printf-hex @@ -1,7 +1,7 @@ #!/bin/sh # make sure that only two hex. digits are consumed in a \xHHH sequence -# Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 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 @@ -16,26 +16,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -prog=`pwd`/../../src/printf +prog="$abs_top_builddir/src/printf" if test "$VERBOSE" = yes; then set -x "$prog" --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 +. $srcdir/../test-lib.sh -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi fail=0 @@ -44,7 +33,6 @@ cat <<\EOF > exp ~3 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/misc/pwd-long b/tests/misc/pwd-long index 920c25842..42a092c24 100755 --- a/tests/misc/pwd-long +++ b/tests/misc/pwd-long @@ -24,26 +24,13 @@ $PERL -e 1 > /dev/null 2>&1 || { exit 77 } -framework_failure=0 -pwd=`"${BUILD_SRC_DIR?}"/pwd` || framework_failure=1 -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 - -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh ARGV_0=$0 export ARGV_0 -CWD=$pwd/$tmp -export CWD - +# Don't use CuTmpdir here, since File::Temp's use of rmtree can't +# remove the deep tree we create. $PERL -Tw -- - <<\EOF # Show that pwd works even when the length of the resulting diff --git a/tests/misc/pwd-unreadable-parent b/tests/misc/pwd-unreadable-parent index b79d53d37..57557c673 100755 --- a/tests/misc/pwd-unreadable-parent +++ b/tests/misc/pwd-unreadable-parent @@ -24,6 +24,8 @@ if test "$VERBOSE" = yes; then readlink --version fi +. $srcdir/../test-lib.sh + test $host_os != linux-gnu && { echo 1>&2 "$0: vendor getcwd may be inadequate; skipping this test" @@ -38,31 +40,16 @@ test $REPLACE_GETCWD = 1 && (exit 77); exit 77 } -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 - -mkdir -p a/b || framework_failure=1 -cd a/b || framework_failure=1 -chmod a=x .. || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +mkdir -p a/b || framework_failure +cd a/b || framework_failure +chmod a=x .. || framework_failure -pwd_exe=$pwd/../../src/pwd +pwd_exe="$abs_top_builddir/src/pwd" fail=0 $pwd_exe > exp || fail=1 readlink -ev . > out || fail=1 -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/misc/runcon-no-reorder b/tests/misc/runcon-no-reorder index 42828852c..0fda3b442 100755 --- a/tests/misc/runcon-no-reorder +++ b/tests/misc/runcon-no-reorder @@ -22,25 +22,12 @@ if test "$VERBOSE" = yes; then fi . $srcdir/../lang-default +. $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 - -cat <<\EOF > exp || framework_failure=1 +cat <<\EOF > exp || framework_failure runcon: runcon may be used only on a SELinux kernel EOF -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi - fail=0 # This test works even on systems without SELinux. @@ -49,7 +36,6 @@ fail=0 # about -j being an invalid option. runcon -t unconfined_t true -j 2> out && : > exp -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/misc/selinux b/tests/misc/selinux index 3e2aae5e2..90ab2d6c4 100755 --- a/tests/misc/selinux +++ b/tests/misc/selinux @@ -10,29 +10,15 @@ if test "$VERBOSE" = yes; then stat --version fi -. $srcdir/../envvar-check . $srcdir/../lang-default . $srcdir/../selinux PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check - -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/../test-lib.sh # Create a regular file, dir, fifo. -touch f || framework_failure=1 -mkdir d s1 s2 || framework_failure=1 -mkfifo p || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +touch f || framework_failure +mkdir d s1 s2 || framework_failure +mkfifo p || framework_failure fail=0 diff --git a/tests/misc/shuf b/tests/misc/shuf index fdbedee61..ac59c55ff 100755 --- a/tests/misc/shuf +++ b/tests/misc/shuf @@ -21,39 +21,27 @@ if test "$VERBOSE" = yes; then shuf --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 +. $srcdir/../test-lib.sh -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -seq 100 > in || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +seq 100 > in || framework_failure fail=0 - shuf in >out || fail=1 # Fail if the input is the same as the output. # This is a probabilistic test :-) # However, the odds of failure are very low: 1 in 100! (~ 1 in 10^158) -cmp in out > /dev/null && { fail=1; echo "not random?" 1>&2; } +compare in out > /dev/null && { fail=1; echo "not random?" 1>&2; } # Fail if the sorted output is not the same as the input. sort -n out > out1 -cmp in out1 || { fail=1; echo "not a permutation" 1>&2; } +compare in out1 || { fail=1; echo "not a permutation" 1>&2; } # Exercise shuf's -i option. shuf -i 1-100 > out || fail=1 -cmp in out > /dev/null && { fail=1; echo "not random?" 1>&2; } +compare in out > /dev/null && { fail=1; echo "not random?" 1>&2; } sort -n out > out1 -cmp in out1 || { fail=1; echo "not a permutation" 1>&2; } +compare in out1 || { fail=1; echo "not a permutation" 1>&2; } # Exercise shuf's -e option. t=`shuf -e a b c d e | sort | fmt` diff --git a/tests/misc/sort-compress b/tests/misc/sort-compress index 568bfa762..00aae25c5 100755 --- a/tests/misc/sort-compress +++ b/tests/misc/sort-compress @@ -21,22 +21,11 @@ if test "$VERBOSE" = yes; then sort --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 -seq -w 2000 > exp || framework_failure=1 -tac exp > in || framework_failure=1 -SORT=$abs_top_builddir/src/sort - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh + +seq -w 2000 > exp || framework_failure +tac exp > in || framework_failure +SORT="$abs_top_builddir/src/sort" # Ensure that $TMPDIR is valid. TMPDIR=.; export TMPDIR @@ -45,8 +34,7 @@ fail=0 # This should force the use of temp files compressed with the default gzip sort -S 1k in > out || fail=1 -cmp exp out || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare exp out || fail=1 # Create our own gzip program that will be used as the default cat <<\EOF > gzip || fail=1 @@ -59,35 +47,30 @@ chmod +x gzip # This will find our new gzip in PATH PATH=.:$PATH sort -S 1k --compress-program=gzip in > out || fail=1 -cmp exp out || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare exp out || fail=1 test -f ok || fail=1 rm -f ok # This is to make sure it works with no compression. PATH=.:$PATH sort -S 1k in > out || fail=1 -cmp exp out || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare exp out || fail=1 test -f ok && fail=1 # This is to make sure we can use something other than gzip mv gzip dzip || fail=1 sort --compress-program=./dzip -S 1k in > out || fail=1 -cmp exp out || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare exp out || fail=1 test -f ok || fail=1 rm -f ok # Make sure it can find other programs in PATH correctly PATH=.:$PATH sort --compress-program=dzip -S 1k in > out || fail=1 -cmp exp out || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare exp out || fail=1 test -f ok || fail=1 rm -f dzip ok # This is to make sure sort functions if it can't find the default gzip PATH=. "$SORT" -S 1k in > out || fail=1 -cmp exp out || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare exp out || fail=1 (exit $fail); exit $fail diff --git a/tests/misc/sort-rand b/tests/misc/sort-rand index c6dd597e3..8b9fb2df0 100755 --- a/tests/misc/sort-rand +++ b/tests/misc/sort-rand @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that sort --sort-random doesn't sort. -# Copyright (C) 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2005-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,20 +21,9 @@ if test "$VERBOSE" = yes; then sort --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 +. $srcdir/../test-lib.sh -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -seq 100 > in || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +seq 100 > in || framework_failure fail=0 @@ -43,11 +32,11 @@ sort --random-sort in > out || fail=1 # Fail if the input is the same as the output. # This is a probabilistic test :-) # However, the odds of failure are very low: 1 in 100! (~ 1 in 10^158) -cmp in out > /dev/null && { fail=1; echo "not random?" 1>&2; } +compare in out > /dev/null && { fail=1; echo "not random?" 1>&2; } # Fail if the sorted output is not the same as the input. sort -n out > out1 -cmp in out1 || { fail=1; echo "not a permutation" 1>&2; } +compare in out1 || { fail=1; echo "not a permutation" 1>&2; } # If locale is available then use it to find a random non-C locale. if (locale --version) > /dev/null 2>&1; then @@ -56,11 +45,11 @@ if (locale --version) > /dev/null 2>&1; then LC_ALL=$locale sort --random-sort in > out2 || fail=1 # Fail if the output "randomly" is the same twice in a row. - cmp out1 out2 > /dev/null && { fail=1; echo "not random with LC_ALL=$locale" 1>&2; } + compare out1 out2 > /dev/null && { fail=1; echo "not random with LC_ALL=$locale" 1>&2; } # Fail if the sorted output is not the same as the input. sort -n out > out1 - cmp in out1 || { fail=1; echo "not a permutation with LC_ALL=$locale" 1>&2; } + compare in out1 || { fail=1; echo "not a permutation with LC_ALL=$locale" 1>&2; } fi (exit $fail); exit $fail diff --git a/tests/misc/split-a b/tests/misc/split-a index 3f13b9db0..794115f5c 100755 --- a/tests/misc/split-a +++ b/tests/misc/split-a @@ -1,7 +1,7 @@ #!/bin/sh # Show that split -a works. -# Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 2002-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,20 +22,7 @@ if test "$VERBOSE" = yes; then fi . $srcdir/../lang-default - -pwd=`pwd` -tmp=split-a.$$ -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 "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh fail=0 @@ -88,7 +75,6 @@ creating file `xaz' creating file `xba' EOF -cmp err exp || fail=1 -test $fail = 1 && diff err exp 2> /dev/null +compare err exp || fail=1 (exit $fail); exit $fail diff --git a/tests/misc/split-fail b/tests/misc/split-fail index 84491e1e8..5cc6d73ef 100755 --- a/tests/misc/split-fail +++ b/tests/misc/split-fail @@ -22,21 +22,9 @@ if test "$VERBOSE" = yes; then fi . $srcdir/../lang-default +. $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 -touch in || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +touch in || framework_failure fail=0 @@ -85,8 +73,7 @@ mv -f out-t out cat <<\EOF > exp split: line count option -99*... is too large 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/misc/split-l b/tests/misc/split-l index 0a9d80069..2460289b8 100755 --- a/tests/misc/split-l +++ b/tests/misc/split-l @@ -1,7 +1,7 @@ #!/bin/sh # show that `split --lines=2' works. -# Copyright (C) 2002, 2006 Free Software Foundation, Inc. +# Copyright (C) 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,23 +21,11 @@ if test "$VERBOSE" = yes; then ln --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 +. $srcdir/../test-lib.sh -framework_failure=0 -mkdir -p $tmp || framework_failure=1 -cd $tmp || framework_failure=1 -printf '1\n2\n3\n4\n5\n' > in || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +printf '1\n2\n3\n4\n5\n' > in || framework_failure fail=0 - split --lines=2 in > out || fail=1 cat <<\EOF > exp-1 1 @@ -51,12 +39,9 @@ cat <<\EOF > exp-3 5 EOF -cmp xaa exp-1 || fail=1 -test $fail = 1 && diff xaa exp 2> /dev/null -cmp xab exp-2 || fail=1 -test $fail = 2 && diff xab exp 2> /dev/null -cmp xac exp-3 || fail=1 -test $fail = 3 && diff xac exp 2> /dev/null +compare xaa exp-1 || fail=1 +compare xab exp-2 || fail=1 +compare xac exp-3 || fail=1 test -f xad && fail=1 (exit $fail); exit $fail diff --git a/tests/misc/stat-fmt b/tests/misc/stat-fmt index 3fbaefe4d..ebc3b880c 100755 --- a/tests/misc/stat-fmt +++ b/tests/misc/stat-fmt @@ -21,19 +21,8 @@ if test "$VERBOSE" = yes; then stat --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 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +. $srcdir/../test-lib.sh + fail=0 diff --git a/tests/misc/tac-continue b/tests/misc/tac-continue index 47b7d3e89..aa8f69d1e 100755 --- a/tests/misc/tac-continue +++ b/tests/misc/tac-continue @@ -3,7 +3,7 @@ # when it encounters an error with say the first one. # With coreutils-5.2.1 and earlier, this test would fail. -# Copyright (C) 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 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 @@ -24,6 +24,7 @@ if test "$VERBOSE" = yes; then fi . $srcdir/../lang-default +. $srcdir/../test-lib.sh # See if the envvar is defined. if test x = "x$FULL_PARTITION_TMPDIR"; then @@ -37,17 +38,8 @@ if ! test -d "$FULL_PARTITION_TMPDIR"; then (exit 1); exit 1 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 fp_tmp="$FULL_PARTITION_TMPDIR/tac-cont-$$" -t0="$t0 $fp_tmp" # Make sure we can create an empty file there (i.e. no shortage of inodes). if ! touch $fp_tmp; then echo "$0: $fp_tmp: cannot create empty file" 1>&2 @@ -63,11 +55,6 @@ fi seq 5 > in -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi - fail=0 # Give tac a fifo command line argument. @@ -84,7 +71,6 @@ cat <<\EOF > exp || fail=1 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/misc/wc-files0 b/tests/misc/wc-files0 index 35da2f45f..44bf84ffe 100755 --- a/tests/misc/wc-files0 +++ b/tests/misc/wc-files0 @@ -1,7 +1,7 @@ #!/bin/sh # Show that wc's new --files0-from option works. -# 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 @@ -22,24 +22,11 @@ if test "$VERBOSE" = yes; then fi . $srcdir/../lang-default +. $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 - -echo 2 > 2b || framework_failure=1 -echo 2 words > 2w || framework_failure=1 -printf '2b\n2w\n' |tr '\n' '\0' > names || framework_failure=1 - -if test $framework_failure = 1; then - echo "$0: failure in testing framework" 1>&2 - (exit 1); exit 1 -fi +echo 2 > 2b || framework_failure +echo 2 words > 2w || framework_failure +printf '2b\n2w\n' |tr '\n' '\0' > names || framework_failure fail=0 @@ -50,15 +37,13 @@ cat <<\EOF > exp || fail=1 2 3 10 total EOF -cmp out exp || fail=1 -test $fail = 1 && diff out exp 2> /dev/null +compare out exp || fail=1 if test "$fail" = ''; then # Repeat the above test, but read the file name list from stdin. rm -f out wc --files0-from=- < names > out || fail=1 - cmp out exp || fail=1 - test $fail = 1 && diff out exp 2> /dev/null + compare out exp || fail=1 fi (exit $fail); exit $fail diff --git a/tests/misc/wc-files0-from b/tests/misc/wc-files0-from index 53511c84a..1d46b2a34 100755 --- a/tests/misc/wc-files0-from +++ b/tests/misc/wc-files0-from @@ -21,7 +21,6 @@ : ${PERL=perl} : ${srcdir=.} -. $srcdir/../envvar-check PROG=`echo $0|sed 's,.*/,,'`; export PROG diff --git a/tests/misc/xstrtol b/tests/misc/xstrtol index 4d26ef6ca..aa2b8a7b5 100755 --- a/tests/misc/xstrtol +++ b/tests/misc/xstrtol @@ -21,8 +21,6 @@ if test "$VERBOSE" = yes; then pr --version fi -. $srcdir/../envvar-check - : ${PERL=perl} : ${srcdir=.} |