X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fforeign.test.sh;h=039d1210f576fc49d74d437b78c2fc4dbc0a0d5a;hb=6a0601ab48635465ad3400c290e5cfbca28e5367;hp=47f434482c98258f7bfa77fe34abeb82232091c3;hpb=7cec182a00d4143dc7cfd43fc55c6691e356e609;p=sbcl.git diff --git a/tests/foreign.test.sh b/tests/foreign.test.sh index 47f4344..039d121 100644 --- a/tests/foreign.test.sh +++ b/tests/foreign.test.sh @@ -1,6 +1,7 @@ #!/bin/sh -# tests related to foreign function interface and LOAD-FOREIGN +# tests related to foreign function interface and loading of shared +# libraries # This software is part of the SBCL system. See the README file for # more information. @@ -8,41 +9,327 @@ # While most of SBCL is derived from the CMU CL system, the test # files (like this one) were written from scratch after the fork # from CMU CL. -# +# # This software is in the public domain and is provided with # absolutely no warranty. See the COPYING and CREDITS files for # more information. -testfilestem=${TMPDIR:-/tmp}/sbcl-foreign-test-$$ +echo //entering foreign.test.sh + +# simple way to make sure we're not punting by accident: +# setting PUNT to anything other than 104 will make non-dlopen +# and non-linkage-table platforms fail this +PUNT=104 + +testfiledir=sbcl-foreign-test-$$ +testfilestem=`pwd`/$testfiledir/sbcl-foreign-test + +mkdir $testfiledir +## Make some shared object files to test with. + +build_so() { + echo building $1.so + if [ "`uname -m`" = x86_64 -o "`uname -m`" = amd64 -o \ + "`uname -m`" = mips -o "`uname -m`" = mips64 ]; then + CFLAGS="$CFLAGS -fPIC" + fi + if [ "`uname`" = Darwin ]; then + SO_FLAGS="-bundle" + else + SO_FLAGS="-shared" + fi + cc -c $1.c -o $1.o $CFLAGS + ld $SO_FLAGS -o $1.so $1.o +} + +cat > $testfilestem.c < $testfilestem.c -make $testfilestem.o -ld -shared -o $testfilestem.so $testfilestem.o +int long_test9(int a1, int a2, int a3, int a4, int a5, + int a6, int a7, long long l1, int a8) { + return (l1 == powish(2,35)); +} -${SBCL:-sbcl} < $testfilestem-b.c +echo 'int bar() { return 42; }' >> $testfilestem-b.c +build_so $testfilestem-b + +echo 'int foo = 42;' > $testfilestem-b2.c +echo 'int bar() { return 13; }' >> $testfilestem-b2.c +build_so $testfilestem-b2 + +echo 'int late_foo = 43;' > $testfilestem-c.c +echo 'int late_bar() { return 14; }' >> $testfilestem-c.c +build_so $testfilestem-c + +## Foreign definitions & load + +cat > $testfilestem.base.lisp < $testfilestem.fast.lisp +cat $testfilestem.base.lisp >> $testfilestem.fast.lisp + +echo "(declaim (optimize space))" > $testfilestem.small.lisp +cat $testfilestem.base.lisp >> $testfilestem.small.lisp + +# Test code +cat > $testfilestem.test.lisp <