diff options
author | Pádraig Brady <P@draigBrady.com> | 2014-01-13 19:39:52 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2014-01-13 23:11:17 +0000 |
commit | ba25b75dc2a4f37cb65b5e2ff1bf41bd1707770b (patch) | |
tree | 7a5dbdc9cbdb81d1b05631deb0fe251071a22088 | |
parent | 243128dbf0293be7b170dd47c8dbf3ed1834c093 (diff) | |
download | coreutils-ba25b75dc2a4f37cb65b5e2ff1bf41bd1707770b.tar.xz |
maint: tests: refactor gcc commands for building shared lib
* 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.
-rw-r--r-- | init.cfg | 15 | ||||
-rwxr-xr-x | tests/cp/nfs-removal-race.sh | 2 | ||||
-rwxr-xr-x | tests/df/no-mtab-status.sh | 2 | ||||
-rwxr-xr-x | tests/df/skip-duplicates.sh | 2 | ||||
-rwxr-xr-x | tests/ls/getxattr-speedup.sh | 2 | ||||
-rwxr-xr-x | tests/rm/r-root.sh | 2 |
6 files changed, 19 insertions, 6 deletions
@@ -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_() diff --git a/tests/cp/nfs-removal-race.sh b/tests/cp/nfs-removal-race.sh index 0638db1ee..6969e8bd3 100755 --- a/tests/cp/nfs-removal-race.sh +++ b/tests/cp/nfs-removal-race.sh @@ -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_ diff --git a/tests/df/no-mtab-status.sh b/tests/df/no-mtab-status.sh index 58f1b46f9..f2fda5e65 100755 --- a/tests/df/no-mtab-status.sh +++ b/tests/df/no-mtab-status.sh @@ -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: diff --git a/tests/df/skip-duplicates.sh b/tests/df/skip-duplicates.sh index 69182d2b3..266520aa6 100755 --- a/tests/df/skip-duplicates.sh +++ b/tests/df/skip-duplicates.sh @@ -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: diff --git a/tests/ls/getxattr-speedup.sh b/tests/ls/getxattr-speedup.sh index 5725fa54b..0144571eb 100755 --- a/tests/ls/getxattr-speedup.sh +++ b/tests/ls/getxattr-speedup.sh @@ -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: diff --git a/tests/rm/r-root.sh b/tests/rm/r-root.sh index 06e57696c..04a88eb27 100755 --- a/tests/rm/r-root.sh +++ b/tests/rm/r-root.sh @@ -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' #------------------------------------------------------------------------------- |