* maint.mk (sc_require_test_exit_idiom): New rule to enforce policy.
* tests/cp/acl: Adhere to the new policy.
* tests/cp/preserve-gid: Likewise.
* tests/dd/misc:
* tests/install/create-leading:
* tests/ln/sf-1:
* tests/ls/symlink-slash:
* tests/misc/help-version:
* tests/misc/ls-time:
* tests/misc/nice:
* tests/misc/shred-remove:
* tests/misc/stty:
* tests/misc/stty-row-col:
* tests/mkdir/p-1:
* tests/mkdir/p-2:
* tests/mkdir/p-3:
* tests/mkdir/p-v:
* tests/mkdir/special-1:
* tests/mkdir/writable-under-readonly:
* tests/mv/acl:
* tests/mv/backup-is-src:
* tests/mv/diag:
* tests/mv/dir-file:
* tests/mv/force:
* tests/mv/hard-link-1:
* tests/mv/i-2:
* tests/mv/i-4:
* tests/mv/into-self:
* tests/mv/into-self-2:
* tests/mv/into-self-3:
* tests/mv/partition-perm:
* tests/mv/to-symlink:
* tests/rmdir/ignore:
* tests/tail-2/assert:
* tests/tail-2/assert-2:
* tests/touch/dangling-symlink:
* tests/touch/dir-1:
* tests/touch/empty-file:
* tests/touch/fifo:
* tests/touch/no-rights: Likewise.
Signed-off-by: Jim Meyering <meyering@redhat.com>
# -*-Makefile-*-
-# This Makefile fragment is shared between the coreutils,
-# CPPI, Bison, and Autoconf.
+# This Makefile fragment tries to be general-purpose enough to be
+# used by at least coreutils, idutils, CPPI, Bison, and Autoconf.
## Copyright (C) 2001-2008 Free Software Foundation, Inc.
##
1>&2; exit 1; } || :; \
fi
+# Require that the final line of each test-lib.sh-using test be this one:
+# (exit $fail); exit $fail
+# Note: this test requires GNU grep's --label= option.
+sc_require_test_exit_idiom:
+ @if test -f $(srcdir)/tests/test-lib.sh; then \
+ die=0; \
+ for i in $$(grep -l -F /../test-lib.sh $$($(VC_LIST) tests)); do \
+ tail -n1 $$i | grep '^(exit \$$fail); exit \$$fail$$' > /dev/null \
+ && : || { die=1; echo $$i; } \
+ done; \
+ test $$die = 1 && \
+ { echo 1>&2 '$(ME): the final line in each of the above is not:'; \
+ echo 1>&2 '(exit $$fail); exit $$fail'; \
+ exit 1; } || :; \
+ fi
+
sc_sun_os_names:
@grep -nEi \
'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
acl2=`cd b && getfacl file` || framework_failure
test "$acl1" = "$acl2" || fail=1
-exit $fail
+(exit $fail); exit $fail
t1 c0 "$nameless_uid" "$nameless_gid1" cp -p
t1 c1 "$nameless_uid" "$nameless_gid2" cp -p
-(exit 0); exit 0
+fail=0
+(exit $fail); exit $fail
# Ensure dd treats `--' properly.
# Also test some flag values.
-# Copyright (C) 1999, 2004-2007 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2004-2008 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
test "$outbytes" -eq 3 || fail=1
test $fail -eq 0 && fail=$warn
-exit $fail
+
+(exit $fail); exit $fail
#! /bin/sh
# Test -D option.
-# Copyright (C) 2000, 2001, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2000-2001, 2006-2008 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
test -d no-dir1/no-dir2 || fail=1
test -r no-dir1/no-dir2/dest || fail=1
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# Test "ln -sf".
-# Copyright (C) 1997-2000, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1997-2000, 2007-2008 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
*) fail=1 ;;
esac
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# Do dereference a symlink arg if its name is written with a trailing slash.
-# Copyright (C) 1999, 2000, 2004, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1999-2000, 2004, 2007-2008 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
# Prior to fileutils-4.0k, the following would have output `... symlink -> dir'.
test "$*" = 'total 0' && : || fail=1
-exit $fail
+(exit $fail); exit $fail
# Make sure all these programs work properly
# when invoked with --help or --version.
-# Copyright (C) 2000-2007 Free Software Foundation, Inc.
+# Copyright (C) 2000-2008 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
rm -rf $tmp_in $tmp_in2 $tmp_out $tmp_dir
done
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# Test some of ls's sorting options.
-# Copyright (C) 1998, 1999, 2000, 2001, 2004, 2007 Free Software Foundation,
-# Inc.
+# Copyright (C) 1998-2001, 2004, 2007-2008 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
fail=1
fi
-exit $fail
+(exit $fail); exit $fail
#! /bin/sh
# Test "nice".
-# Copyright (C) 2002, 2003, 2005-2007 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2005-2008 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
shift; shift; shift
done
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# Exercise a bug that was fixed in shred-4.0l
-# Copyright (C) 1999, 2000, 2003, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1999-2000, 2003, 2006-2008 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
# When the command completes, expect it to fail.
shred -u $file > /dev/null 2>&1 && fail=1 || :
-exit $fail
+(exit $fail); exit $fail
#! /bin/sh
# Make sure stty can parse most of its options.
-# Copyright (C) 1998-2004, 2006-2007 Free Software Foundation, Inc.
+# Copyright (C) 1998-2004, 2006-2008 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
stty `cat $saved_state`
-exit $fail
+(exit $fail); exit $fail
#! /bin/sh
# Test "stty" with rows and columns.
-# Copyright (C) 1998-2001, 2003-2007 Free Software Foundation, Inc.
+# Copyright (C) 1998-2001, 2003-2008 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
set x $saved_size
stty rows $2 columns $3 || exit 1
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# Test "mkdir -p".
-# Copyright (C) 1997, 2000, 2002, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1997, 2000, 2002, 2006-2008 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
mkdir --parents "`pwd`/t" || fail=1
test -d t || fail=1
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# Just like p-1, but with an absolute path.
-# Copyright (C) 1997, 2000, 2002, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1997, 2000, 2002, 2006-2008 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
mkdir --parents "`pwd`/t/u" || fail=1
test -d t/u || fail=1
-exit $fail
+(exit $fail); exit $fail
# causes immediate failure. Also, ensure that we don't create
# subsequent, relative command-line arguments in the wrong place.
-# Copyright (C) 2005-2007 Free Software Foundation, Inc.
+# Copyright (C) 2005-2008 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
# With coreutils-5.3.0, this would fail with $b=bu.
test "x$b" = xb || fail=1
-exit $fail
+(exit $fail); exit $fail
. $srcdir/../lang-default
. $srcdir/../test-lib.sh
-mkdir -pv foo/a/b/c/d >out || exit
+fail=0
+mkdir -pv foo/a/b/c/d >out || fail=1
diff - out <<\EOF
mkdir: created directory `foo'
mkdir: created directory `foo/a/b/c'
mkdir: created directory `foo/a/b/c/d'
EOF
+
+(exit $fail); exit $fail
#!/bin/sh
# verify that mkdir honors special bits in MODE
-# Copyright (C) 2000, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2006-2008 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
*) fail=1 ;;
esac
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# FIXME: convert this to a root-only test.
-# Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2005, 2007-2008 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
# FIXME: define cleanup_ to do the umount
+fail=0
# FIXME: use mktemp
cd /tmp \
&& dd if=/dev/zero of=1 bs=8192 count=50 \
# To clean up
umount /tmp/2
umount /tmp/1
+
+(exit $fail); exit $fail
acl2=`cd $other_partition_tmpdir && getfacl dir2` || framework_failure
test "$acl1" = "$acl2" || fail=1
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# Force mv to use the copying code.
-# Copyright (C) 1998, 1999, 2000, 2004, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1998-2000, 2004, 2007-2008 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
compare out2 exp || fail=1
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# make sure we get proper diagnostics: e.g., with --target-dir=d but no args
-# Copyright (C) 2000, 2004, 2006-2007 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2004, 2006-2008 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
compare out exp || fail=1
-(exit $fail)
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# mv must fail when src and dest are mismatched directory/non-directory.
-# Copyright (C) 2000, 2006-2007 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2006-2008 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
mv dir file > /dev/null 2>&1 && fail=1
mv file dir > /dev/null 2>&1 && fail=1
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# move a file onto itself
-# Copyright (C) 1999, 2000, 2002, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2002, 2007-2008 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
# device and inodes are the same.
mv $ff $ff2 || fail=1
-exit $fail
+(exit $fail); exit $fail
# move a directory containing hard-linked files and
# make sure the links are preserved
-# Copyright (C) 1998, 1999, 2000, 2004, 2006-2007 Free Software Foundation, Inc.
+# Copyright (C) 1998, 1999, 2000, 2004, 2006-2008 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
b=`sed -n 's/ b$//p' out`
test "$a" = "$b" || fail=1
-exit $fail
+(exit $fail); exit $fail
# Test both cp and mv for their behavior with -if and -fi
# The standards (POSIX and SuS) dictate annoyingly inconsistent behavior.
-# Copyright (C) 2000, 2001, 2006-2007 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2006-2008 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
test -f h || fail=1
compare g h || fail=1
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# make sure `mv -i a b' does its job with a positive response
-# Copyright (C) 2001, 2005-2007 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2005-2008 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
test -r a && fail=1
test -r b || fail=1
-exit $fail
+(exit $fail); exit $fail
#! /bin/sh
# Demonstrate how mv fails when it tries to move a directory into itself.
-# Copyright (C) 1998, 1999, 2000, 2002, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1998-2000, 2002, 2007-2008 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
# Make sure the file has been moved to the right place.
test -f $dir/$file || fail=1
-exit $fail
+(exit $fail); exit $fail
compare out2 exp || fail=1
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# move a directory into itself, with a twist
-# Copyright (C) 1998, 1999, 2000, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1998, 1999, 2000, 2007-2008 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
compare out2 exp || fail=1
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# Make sure permissions are preserved when moving from one partition to another.
-# Copyright (C) 1999, 2000, 2001, 2006-2007 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2001, 2006-2008 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
mode=`ls -l $other_partition_tmpdir/file|cut -b-10`
test "$mode" = "-rwxrwxrwx" || fail=1
-exit $fail
+(exit $fail); exit $fail
# Make sure that the copying code used in an inter-partition
# move unlinks a destination symlink before opening it.
-# Copyright (C) 1999, 2000, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2007-2008 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
# Make sure $rem_file is unmodified.
test `cat $rem_file` = remote || fail=1
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# make sure rmdir's --ignore-fail-on-non-empty option works
-# Copyright (C) 1999, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2007-2008 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
test -d "$cwd/a/b" && fail=1
test -d "$cwd/a/b/c" && fail=1
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# Test for assertion failure in "test".
-# Copyright (C) 1999, 2000, 2004, 2006-2007 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2004, 2006-2008 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
test $fail = 1 && cat err
-exit $fail
+(exit $fail); exit $fail
# 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-2007 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2006-2008 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
test $fail = 1 && cat err
-exit $fail
+(exit $fail); exit $fail
# Make sure touch can create a file through a dangling symlink.
# This was broken in the 4.0[e-i] test releases.
-# Copyright (C) 1999, 2000, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2007-2008 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
esac
fi
-exit $fail
+(exit $fail); exit $fail
fail=0
touch . || fail=1
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# Make sure touch can set the mtime on an empty file.
-# Copyright (C) 1998, 1999, 2000, 2005-2007 Free Software Foundation, Inc.
+# Copyright (C) 1998, 1999, 2000, 2005-2008 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
EOF
fi
-exit $fail
+(exit $fail); exit $fail
#!/bin/sh
# Make sure touch works on fifos without hanging.
-# Copyright (C) 2000, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2007-2008 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
touch fifo || fail=1
-exit $fail
+(exit $fail); exit $fail
# Make sure touch can update the times on a file that is neither
# readable nor writable.
-# Copyright (C) 1999, 2000, 2002, 2006-2007 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2002, 2006-2008 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
# Also test the combination of --no-create and -a.
touch -a --no-create t1 || fail=1
-exit $fail
+(exit $fail); exit $fail