X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fforeign.test.sh;h=7d207b432e32102d51a14629e02f1ce6825c810c;hb=dfe6138af5c38d92568b6dac48e852c01be0ec8e;hp=eaa3b4b8d7d1de0410184b9575e5701b6e55b063;hpb=2481b0d0f223640c43032f75b689608f8fa332db;p=sbcl.git diff --git a/tests/foreign.test.sh b/tests/foreign.test.sh index eaa3b4b..7d207b4 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. @@ -15,46 +16,183 @@ 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 + testfilestem=${TMPDIR:-/tmp}/sbcl-foreign-test-$$ -# FIXME: At least on OpenBSD, the "make $testfilestem.o" puts the -# output file into the current directory, instead of the -# target directory. E.g. "make /tmp/foo.o" causes "./foo.o" to be -# created (!). Since OpenBSD doesn't support LOAD-FOREIGN, this -# doesn't matter much, since it punts with UNSUPPORTED-OPERATOR -# instead of not finding the file. But it'd be nice to straighten -# this out, if only so that sbcl-foreign-test-*.o clutter -# doesn't pile up in this directory. Maybe some time when I have -# several test machines at hand to check the behavior of different -# versions of "make"... +## Make a little shared object files to test with. + +build_so() { + echo building $1.so + cc -c $1.c -o $1.o + ld -shared -o $1.so $1.o +} + echo 'int summish(int x, int y) { return 1 + x + y; }' > $testfilestem.c -make $testfilestem.o -ld -shared -o $testfilestem.so $testfilestem.o - -${SBCL:-sbcl} <> $testfilestem.c +echo 'int nummish(int x) { return numberish + x; }' >> $testfilestem.c +build_so $testfilestem + +echo 'int foo = 13;' > $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.def.lisp < $testfilestem.test.lisp <