]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: don't let a fail=1 env. setting induce unwarranted test failure
authorJim Meyering <meyering@redhat.com>
Thu, 29 Oct 2009 13:40:40 +0000 (14:40 +0100)
committerJim Meyering <meyering@redhat.com>
Thu, 29 Oct 2009 15:51:07 +0000 (16:51 +0100)
* cfg.mk (sc_fail_is_initialized): New rule.
Fix the offenders:
* tests/cp/acl: Set fail=0
* tests/cp/backup-is-src: Likewise.
* tests/cp/file-perm-race: Likewise.
* tests/cp/reflink-auto: Likewise.
* tests/cp/same-file: Likewise.
* tests/ln/backup-1: Likewise.
* tests/misc/su-fail: Likewise.
* tests/misc/truncate-owned-by-other: Likewise.
* tests/mkdir/p-3: Likewise.
* tests/mkdir/selinux: Likewise.
* tests/mkdir/special-1: Likewise.
* tests/mv/acl: Likewise.
* tests/mv/backup-is-src: Likewise.
* tests/mv/diag: Likewise.
* tests/mv/force: Likewise.
* tests/mv/hard-link-1: Likewise.
* tests/mv/into-self-3: Likewise.
* tests/mv/sticky-to-xpart: Likewise.
* tests/touch/now-owned-by-other: Likewise.

20 files changed:
cfg.mk
tests/cp/acl
tests/cp/backup-is-src
tests/cp/file-perm-race
tests/cp/reflink-auto
tests/cp/same-file
tests/ln/backup-1
tests/misc/su-fail
tests/misc/truncate-owned-by-other
tests/mkdir/p-3
tests/mkdir/selinux
tests/mkdir/special-1
tests/mv/acl
tests/mv/backup-is-src
tests/mv/diag
tests/mv/force
tests/mv/hard-link-1
tests/mv/into-self-3
tests/mv/sticky-to-xpart
tests/touch/now-owned-by-other

diff --git a/cfg.mk b/cfg.mk
index 1e5108b2d4ceabefa6ee3f657bde33b6a3a9e075..c3a7afe5e35980d21ece7a5a1f91153b9476b696 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -230,4 +230,15 @@ sc_prohibit_emacs__indent_tabs_mode__setting:
        msg='use of emacs indent-tabs-mode: setting'                    \
          $(_prohibit_regexp)
 
+# Ensure that each file that contains fail=1 also contains fail=0.
+# Otherwise, setting file=1 in the environment would make tests fail unexpectedly.
+sc_fail_is_initialized:
+       @files=$$(grep -l -E '\<fail=1$$' $$($(VC_LIST_EXCEPT)));       \
+       if test "$$?" = 0; then                                         \
+         grep -LE '\<fail=0$$' $$files | grep . &&                     \
+           { echo '$(ME): the above files do not set fail=0'           \
+               1>&2; exit 1; } || :;                                   \
+       else :;                                                         \
+       fi
+
 include $(srcdir)/dist-check.mk
index 2f8742880a1a052f00b32d1e9877d72f7f58593d..059a1e10c4b8b6919cf474d8f215ce2fb5635201 100755 (executable)
@@ -45,6 +45,7 @@ acl1=`cd a && getfacl file | grep -v ':bin:' | grep -v 'mask::'` \
 test $skip = yes &&
   skip_test_ "'.' is not on a suitable file system for this test"
 
+fail=0
 # copy a file without preserving permissions
 cp a/file b/ || fail=1
 
index bf03e590aa3a6483c4f809269d98a56f659bd874..f226382d0977f22e999f50b0d80dd0749be35868 100755 (executable)
@@ -26,6 +26,7 @@ fi
 echo a > a || framework_failure
 echo a-tilde > a~ || framework_failure
 
+fail=0
 # This cp command should exit nonzero.
 cp --b=simple a~ a > out 2>&1 && fail=1
 
index 1ff2746c2c4a76cc854e058b7d5e1ec50f979dac..8ae7cb04e85ecc8fd7592bee2eecea2da2e486d7 100755 (executable)
@@ -23,6 +23,7 @@ fi
 
 . $srcdir/test-lib.sh
 
+fail=0
 umask 022
 mkfifo fifo ||
   skip_test_ "fifos not supported"
index d1f6b2bca9eb0396ae670fcc718698d7e4e0f1f8..5e39b72652240d8b90ddc4bed1c023c2c661c402 100755 (executable)
@@ -28,8 +28,9 @@ cleanup_() { rm -rf "$other_partition_tmpdir"; }
 a_other="$other_partition_tmpdir/a"
 rm -f "$a_other" || framework_failure
 
-echo non_zero_size > "$a_other"
+echo non_zero_size > "$a_other" || framework_failure
 
+fail=0
 # we shouldn't be able to reflink() files on separate partitions
 cp --reflink      "$a_other" b && fail=1
 
index 6d57ebd6aa1f364356595032c850f6447a1df59b..d5deb6857043af20ca55f082d384423ba6fac159 100755 (executable)
@@ -220,7 +220,7 @@ cat <<\EOF | sed "$remove_these_sed" > $expected
 
 EOF
 
-fail=0;
+fail=0
 
 compare $expected $actual 1>&2 || fail=1
 
index cc3e10e0cb3016ced72fd40f5f152af64c630d1f..68c9ca22f2fdbc468e91ffe5f939972048cd0b8d 100755 (executable)
@@ -28,6 +28,7 @@ fi
 
 touch a b || framework_failure
 
+fail=0
 ln b b~ || fail=1
 ln -f --b=simple a b || fail=1
 
index bba7d1f0153fa19c4066039e92f9f6293c8135c1..f00edc95b61f8fc42a4ebc55e4aacb7885a83f52 100755 (executable)
@@ -24,6 +24,8 @@ if test "$VERBOSE" = yes; then
   su --version
 fi
 
+fail=0
+
 # Very little that we can test without a root password
 su --- / true # unknown option
 test $? = 125 || fail=1
index c7bdf61c247805cfea82244058e33175399bd4ff..61cbe8b50f239a18dc0decafb196a0a2834f38c5 100755 (executable)
@@ -35,6 +35,7 @@ chmod g+w root-owned
 # Ensure that the current directory is searchable by $NON_ROOT_USERNAME.
 chmod g+x .
 
+fail=0
 setuidgid $NON_ROOT_USERNAME env PATH="$PATH" truncate -s0 root-owned || fail=1
 
 Exit $fail
index df1c56d3272970996c175bc9c00d45fb53fe8a60..06207b2698f57bb983b3dcc8715341300b9462d7 100755 (executable)
@@ -30,6 +30,7 @@ mkdir no-access || framework_failure
 mkdir no-acce2s || framework_failure
 mkdir -p no-acce3s/d || framework_failure
 
+fail=0
 p=`pwd`
 (cd no-access && chmod 0 . && mkdir -p "$p/a/b" u/v) 2> /dev/null && fail=1
 test -d "$p/a/b" || fail=1
index ddd237cdb0ae157f2ce28658c6902afbb9057803..d872cb6d1bc023ab845c7d91e8dffdf15d5027f7 100755 (executable)
@@ -33,6 +33,7 @@ require_selinux_enforcing_
 c=invalid-selinux-context
 msg="failed to set default file creation context to \`$c':"
 
+fail=0
 # Test each of mkdir, mknod, mkfifo with "-Z invalid-context".
 
 for cmd_w_arg in 'mkdir dir' 'mknod b p' 'mkfifo f'; do
index 4956c20e9784d995b713dc0f489165c3f405aca3..d1af121da2e68a90ee36b3a05abe8afdcefa438d 100755 (executable)
@@ -26,6 +26,7 @@ fi
 set_mode_string=u=rwx,g=rx,o=w,-s,+t
 output_mode_string=drwxr-x-wT
 
+fail=0
 tmp=t
 mkdir -m$set_mode_string $tmp || fail=1
 
index 5ad8de05210d6b4e1966a2c0c547e373610bfc5c..e9fb626798270c9555a44ac2f4b9edfb73985280 100755 (executable)
@@ -48,6 +48,7 @@ acl1=`getfacl file` || skip_partition=.
 test $skip_partition != none &&
   skip_test_ "'$skip' is not on a suitable file system for this test"
 
+fail=0
 # move the access acl of a file
 mv file "$other_partition_tmpdir" || fail=1
 acl2=`cd "$other_partition_tmpdir" && getfacl file` || framework_failure
index df6561bafa8ec2395ba0136f45178e3b35ab3c12..7d80078f2f27d3dfbf45d91f329a26eb0a63ff4c 100755 (executable)
@@ -32,6 +32,7 @@ rm -f "$a" "$a2" || framework_failure
 echo a > "$a" || framework_failure
 echo a2 > "$a2" || framework_failure
 
+fail=0
 # This mv command should exit nonzero.
 mv --b=simple "$a2" "$a" > out 2>&1 && fail=1
 
index 6e28fa463672f7ae03f5dbbc4e7d0bd390723689..75904d626154bc6d518c7345a26d88f299f31f41 100755 (executable)
@@ -28,6 +28,7 @@ touch f1 || framework_failure
 touch f2 || framework_failure
 touch d || framework_failure
 
+fail=0
 # These mv commands should all exit nonzero.
 
 # Too few args.  This first one did fail, but with an incorrect diagnostic
index 88851ac59c61e8415045be4daa391050a90c414a..df43970503e738db6b78c2b5dc5543a9161c52cd 100755 (executable)
@@ -29,6 +29,7 @@ ff2=mvforce2
 echo force-contents > $ff || framework_failure
 ln $ff $ff2 || framework_failure
 
+fail=0
 # This mv command should exit nonzero.
 mv $ff $ff > out 2>&1 && fail=1
 
index 2df2cf3ff9de051ca8a0fd0264b13f1bdf91d8b0..d626f3cc05e5def552f669f2ce2ca91a75e74493 100755 (executable)
@@ -32,6 +32,7 @@ mkdir $dir || framework_failure
 > $dir/a || framework_failure
 ln $dir/a $dir/b || framework_failure
 
+fail=0
 mv $dir "$other_partition_tmpdir" || fail=1
 
 # Display inode numbers, one per line.
index b9fa41af4c89c93d050ca8f1faad2a85a9ffaeeb..e5a4f8d30874de3594131a16650329b34ef4dc7e 100755 (executable)
@@ -28,6 +28,7 @@ dir2=is3-dir2
 
 mkdir $dir1 $dir2 || framework_failure
 
+fail=0
 # This mv command should exit nonzero.
 mv $dir1 $dir2 $dir2 > out 2>&1 && fail=1
 
index f0f9f95e34e0aa373af5d4bcd2cd381a7237cb46..f8855a21fd13997c926e7757442d22209ef783bc 100755 (executable)
@@ -43,6 +43,8 @@ chown "$NON_ROOT_USERNAME" "$other_partition_tmpdir" || framework_failure
 # We have to allow $NON_ROOT_USERNAME access to ".".
 chmod go+x . || framework_failure
 
+fail=0
+
 # Ensure that $NON_ROOT_USERNAME can access the required version of mv.
 version=`setuidgid $NON_ROOT_USERNAME env PATH="$PATH" mv --version|sed -n '1s/.* //p'`
 case $version in
index e124a2e4a46693bf79c449e227239a39792c1466..4ce4ec6defb262bf13f317097c257bca834b8d43 100755 (executable)
@@ -34,6 +34,7 @@ chmod g+w root-owned
 # Ensure that the current directory is searchable by $NON_ROOT_USERNAME.
 chmod g+x .
 
+fail=0
 setuidgid $NON_ROOT_USERNAME env PATH="$PATH" touch -d now root-owned || fail=1
 
 Exit $fail