]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: avoid false failures with LD_PRELOAD=libasan.so.2
authorPádraig Brady <P@draigBrady.com>
Thu, 25 Jun 2015 12:21:28 +0000 (13:21 +0100)
committerPádraig Brady <P@draigBrady.com>
Thu, 25 Jun 2015 12:41:24 +0000 (13:41 +0100)
The LD_PRELOAD checks by -fsanitize=address are overly strict:
https://groups.google.com/forum/#!topic/address-sanitizer/jEvOJgkDqQk
A workaround is to first export LD_PRELOAD=libasan.so.2
The tests below are adjusted so that workaround is not discarded.

* tests/cp/no-ctx.sh: Append to $LD_PRELOAD.
* tests/df/no-mtab-status.sh: Likewise.
* tests/df/skip-duplicates.sh: Likewise.
* tests/ls/getxattr-speedup.sh: Likewise.
* tests/rm/r-root.sh: Likewise.
* tests/cp/nfs-removal-race.sh: Likewise.  Also check that
LD_PRELOAD is effective to aid future maintainability
and avoid false failure if libasan.so.2 is not preloaded.

tests/cp/nfs-removal-race.sh
tests/cp/no-ctx.sh
tests/df/no-mtab-status.sh
tests/df/skip-duplicates.sh
tests/ls/getxattr-speedup.sh
tests/rm/r-root.sh

index 70276a384b797ceada46cc901f220c1128ec8699..fdac03f7de073ca682b7ac574d88c8feff44a363 100755 (executable)
@@ -35,6 +35,7 @@ require_gcc_shared_
 # Replace each stat call with a call to this wrapper.
 cat > k.c <<'EOF' || framework_failure_
 #define _GNU_SOURCE
+#include <stdio.h>
 #include <sys/types.h>
 #include <dlfcn.h>
 
@@ -49,6 +50,7 @@ int
 __xstat (int ver, const char *path, struct stat *st)
 {
   static int (*real_stat)(int ver, const char *path, struct stat *st) = NULL;
+  fclose(fopen("preloaded", "w"));
   if (!real_stat)
     real_stat = dlsym (RTLD_NEXT, "__xstat");
   /* When asked to stat nonexistent "d",
@@ -65,7 +67,9 @@ touch d2 || framework_failure_
 echo xyz > src || framework_failure_
 
 # Finally, run the test:
-LD_PRELOAD=./k.so cp src d || fail=1
+LD_PRELOAD=$LD_PRELOAD:./k.so cp src d || fail=1
+
+test -f preloaded || skip_ 'LD_PRELOAD was ineffective?'
 
 compare src d || fail=1
 Exit $fail
index 377d203b0b8c92741aeacff1a5fd6947aa5b5d8c..852b8e641ae9b41fd4fbf417c96cb92ccea12d12 100755 (executable)
@@ -50,14 +50,14 @@ gcc_shared_ k.c k.so \
 touch file_src
 
 # New file with SELinux context optionally included
-LD_PRELOAD=./k.so cp -a file_src file_dst || fail=1
+LD_PRELOAD=$LD_PRELOAD:./k.so cp -a file_src file_dst || fail=1
 
 # Existing file with SELinux context optionally included
-LD_PRELOAD=./k.so cp -a file_src file_dst || fail=1
+LD_PRELOAD=$LD_PRELOAD:./k.so cp -a file_src file_dst || fail=1
 
 # ENODATA should give an immediate error when required to preserve ctx
 # This is debatable, and maybe we should not fail when no context available?
-( export LD_PRELOAD=./k.so
+( export LD_PRELOAD=$LD_PRELOAD:./k.so
   returns_ 1 cp --preserve=context file_src file_dst ) || fail=1
 
 test -e preloaded || skip_ 'LD_PRELOAD interception failed'
index 41d1b521b95afc63c6d45e17535781911cdc757b..c35da6b8c1b3b250c576dd4f071488f47046a086 100755 (executable)
@@ -90,7 +90,7 @@ gcc_shared_ k.c k.so \
 
 cleanup_() { unset LD_PRELOAD; }
 
-export LD_PRELOAD=./k.so
+export LD_PRELOAD=$LD_PRELOAD:./k.so
 
 # Test if LD_PRELOAD works:
 df 2>/dev/null
index c13787665c4309055a9066743f426a101da3e23c..40696047304a336a4ee980f7dd1e801d67014fff 100755 (executable)
@@ -146,23 +146,23 @@ gcc_shared_ k.c k.so \
   || framework_failure_ 'failed to build shared library'
 
 # Test if LD_PRELOAD works:
-LD_PRELOAD=./k.so df
+LD_PRELOAD=$LD_PRELOAD:./k.so df
 test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?"
 
 # The fake mtab file should only contain entries
 # having the same device number; thus the output should
 # consist of a header and unique entries.
-LD_PRELOAD=./k.so df -T >out || fail=1
+LD_PRELOAD=$LD_PRELOAD:./k.so df -T >out || fail=1
 test $(wc -l <out) -eq $(expr 1 + $unique_entries) || { fail=1; cat out; }
 
 # With --total we should suppress the duplicate but separate remote file system
-LD_PRELOAD=./k.so df --total >out || fail=1
+LD_PRELOAD=$LD_PRELOAD:./k.so df --total >out || fail=1
 test "$CU_REMOTE_FS" && elide_remote=1 || elide_remote=0
 test $(wc -l <out) -eq $(expr 2 + $unique_entries - $elide_remote) ||
   { fail=1; cat out; }
 
 # Ensure we don't fail when unable to stat (currently) unavailable entries
-LD_PRELOAD=./k.so CU_TEST_DUPE_INVALID=1 df -T >out || fail=1
+LD_PRELOAD=$LD_PRELOAD:./k.so CU_TEST_DUPE_INVALID=1 df -T >out || fail=1
 test $(wc -l <out) -eq $(expr 1 + $unique_entries) || { fail=1; cat out; }
 
 # df should also prefer "/fsname" over "fsname"
@@ -176,7 +176,7 @@ fi
 test $(grep -c 'virtfs2.*t2' <out) -eq 1 || { fail=1; cat out; }
 
 # Ensure that filtering duplicates does not affect -a processing.
-LD_PRELOAD=./k.so df -a >out || fail=1
+LD_PRELOAD=$LD_PRELOAD:./k.so df -a >out || fail=1
 total_fs=6; test "$CU_REMOTE_FS" && total_fs=$(expr $total_fs + 3)
 test $(wc -l <out) -eq $total_fs || { fail=1; cat out; }
 # Ensure placeholder "-" values used for the eclipsed "virtfs"
index f84c9da61fc5f69cd6f505433e8ecefc078e5ce2..be43c50e4de86e68f906b0a4c312208597ffa871 100755 (executable)
@@ -55,7 +55,7 @@ gcc_shared_ k.c k.so \
 seq 20 | xargs touch || framework_failure_
 
 # Finally, run the test:
-LD_PRELOAD=./k.so ls --color=always -l . || fail=1
+LD_PRELOAD=$LD_PRELOAD:./k.so ls --color=always -l . || fail=1
 
 test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?"
 
index 74d1a2a62ac7a2a756a42bb7c010081fd4f84850..c06332ae262e9c66327d9789b4f25c0ccf118215 100755 (executable)
@@ -89,7 +89,7 @@ exercise_rm_r_root ()
   fi
 
   timeout --signal=KILL 2 \
-    env LD_PRELOAD=./k.so $skip_exit \
+    env LD_PRELOAD=$LD_PRELOAD:./k.so $skip_exit \
       rm -rv --one-file-system "$@" > out 2> err
 
   return $?