]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: tests: refactor gcc commands for building shared lib
authorPádraig Brady <P@draigBrady.com>
Mon, 13 Jan 2014 19:39:52 +0000 (19:39 +0000)
committerPádraig Brady <P@draigBrady.com>
Mon, 13 Jan 2014 23:11:17 +0000 (23:11 +0000)
* init.cfg (gcc_shared_): A new function refactored from tests.
(require_gcc_shared_): Adjust to call gcc_shared_() to build the
test library, and remove that library before the function returns.
* tests/cp/nfs-removal-race.sh: Call the new gcc_shared_().
* 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.

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

index af3963c7257a7768e794e61762a4672e9e2f2948..6a9b004ff22776783db316853bc4818c70c16a36 100644 (file)
--- a/init.cfg
+++ b/init.cfg
@@ -500,13 +500,26 @@ require_sparse_support_()
   fi
 }
 
+# Compile a shared lib using the GCC options for doing so.
+# Pass input and output file as parameters respectively.
+# Any other optional parmeters are passed to $CC.
+gcc_shared_()
+{
+  local in=$1
+  local out=$2
+  shift 2 || return 1
+
+  $CC -Wall -shared --std=gnu99 -fPIC -ldl -O2 $* "$in" -o "$out"
+}
+
 # There are a myriad of ways to build shared libs,
 # so we only consider running tests requiring shared libs,
 # on platforms that support building them as follows.
 require_gcc_shared_()
 {
-  $CC -shared -fPIC -O2 -xc -o d.so -ldl - < /dev/null 2>&1 \
+  gcc_shared_ '-' 'd.so' -xc < /dev/null 2>&1 \
     || skip_ '$CC -shared ... failed to build a shared lib'
+  rm -f d.so
 }
 
 mkfifo_or_skip_()
index 0638db1ee1d466227f5b5659d9af400af0e045f8..6969e8bd3566e27e3def49d741a194aa0344e9d0 100755 (executable)
@@ -58,7 +58,7 @@ __xstat (int ver, const char *path, struct stat *st)
 EOF
 
 # Then compile/link it:
-$CC -shared -fPIC -O2 k.c -o k.so -ldl \
+gcc_shared_ k.c k.so \
   || framework_failure_ 'failed to build shared library'
 
 touch d2 || framework_failure_
index 58f1b46f9e8ab680326726473aea0d6f1a0e80ca..f2fda5e656df32a7e2ac2e56c1be63fc035cfde8 100755 (executable)
@@ -45,7 +45,7 @@ struct mntent *getmntent (FILE *fp)
 EOF
 
 # Then compile/link it:
-$CC -shared -fPIC -ldl -O2 k.c -o k.so \
+gcc_shared_ k.c k.so \
   || framework_failure_ 'failed to build shared library'
 
 # Test if LD_PRELOAD works:
index 69182d2b3189c293c94eaa070fd36fdfbe0c8502..266520aa657f13da3e47221c7c0dd840680d135a 100755 (executable)
@@ -60,7 +60,7 @@ struct mntent *getmntent (FILE *fp)
 EOF
 
 # Then compile/link it:
-gcc --std=gnu99 -shared -fPIC -ldl -O2 k.c -o k.so \
+gcc_shared_ k.c k.so \
   || framework_failure_ 'failed to build shared library'
 
 # Test if LD_PRELOAD works:
index 5725fa54ba9b3e40c67a40d791c2c61959899203..0144571ebdf9333a136c459c5533a7ddaa2cb0df 100755 (executable)
@@ -48,7 +48,7 @@ ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
 EOF
 
 # Then compile/link it:
-$CC -shared -fPIC -O2 k.c -o k.so \
+gcc_shared_ k.c k.so \
   || framework_failure_ 'failed to build shared library'
 
 # Create a few files:
index 06e57696ce24ab488c0268cee5b895ce46b06a39..04a88eb27c5af59b5d9685c14bddb60b0fa29a10 100755 (executable)
@@ -60,7 +60,7 @@ int unlinkat (int dirfd, const char *pathname, int flags)
 EOF
 
 # Then compile/link it:
-gcc -Wall --std=gnu99 -shared -fPIC -ldl -O2 k.c -o k.so \
+gcc_shared_ k.c k.so \
   || framework_failure_ 'failed to build shared library'
 
 #-------------------------------------------------------------------------------