1 2os=$(uname) 3 4case $os in 5 FreeBSD) libdl=;; 6 Linux) libdl=-ldl;; 7 Haiku) libdl=;; 8 *) echo "Unsupported OS: $os"; exit 1;; 9esac 10 11testdir=${testdir-testdir}/$(basename $0) 12 13rm -rf $testdir 14mkdir -p $testdir 15cd $testdir 16 17# test_run_ok <program> <expected return value> 18test_run_ok() 19{ 20 # exists? 21 if [ ! -f $1 ]; then 22 exit 1 23 fi 24 25 # run 26 $1 27 retval=$? 28 if [ $retval != $2 ]; then 29 echo "test_run_ok: $1: return value: $retval, expected: $2" 30 exit 1 31 fi 32} 33 34compile_lib() 35{ 36 gcc -shared $@ -D_GNU_SOURCE -fPIC 37} 38 39compile_lib_dl() 40{ 41 compile_lib $@ $libdl 42} 43 44compile_program() 45{ 46 gcc $@ -D_GNU_SOURCE -Wl,-rpath,.,--export-dynamic 47} 48 49compile_program_dl() 50{ 51 compile_program $@ $libdl 52} 53