X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fforeign.test.sh;h=2d7865f86b0bbf437ef450379a04f631006e29ff;hb=16a6592367eec7c5e9da668ec42fd260e7705b0c;hp=89f98d701b1070f841685b11170c80c6a835d97f;hpb=b6194ba1e9e25a4bf6fd13e82d917648edc2ff50;p=sbcl.git diff --git a/tests/foreign.test.sh b/tests/foreign.test.sh index 89f98d7..2d7865f 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,45 +16,202 @@ 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-$$ -# Make a little shared object file to test with. +## Make a little shared object files to test with. + +build_so() { + echo building $1.so + if [ $(uname -m) = x86_64 ]; 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 +} + echo 'int summish(int x, int y) { return 1 + x + y; }' > $testfilestem.c -cc -c $testfilestem.c -o $testfilestem.o -ld -shared -o $testfilestem.so $testfilestem.o +echo 'int numberish = 42;' >> $testfilestem.c +echo 'int nummish(int x) { return numberish + x; }' >> $testfilestem.c +echo 'short negative_short() { return -1; }' >> $testfilestem.c +echo 'int negative_int() { return -2; }' >> $testfilestem.c +echo 'long negative_long() { return -3; }' >> $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 -# Test interaction with the shared object file. -${SBCL:-sbcl} < $testfilestem.def.lisp < $testfilestem.test.lisp <