From ba25b75dc2a4f37cb65b5e2ff1bf41bd1707770b Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Mon, 13 Jan 2014 19:39:52 +0000 Subject: 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. --- init.cfg | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'init.cfg') diff --git a/init.cfg b/init.cfg index af3963c72..6a9b004ff 100644 --- 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_() -- cgit v1.2.3-54-g00ecf