X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fforeign.test.sh;h=8c8a79c15857481d618f4aca32c60797f2cb0c16;hb=00ca0f6bd2e4e4e4c6214466c83b2f5e7c063c65;hp=9ae8a484f7b4efb8e84ea7879dedeef0cb5e280b;hpb=6198ab492260b440a551e29b274bdd4ac5534dbb;p=sbcl.git diff --git a/tests/foreign.test.sh b/tests/foreign.test.sh index 9ae8a48..8c8a79c 100644 --- a/tests/foreign.test.sh +++ b/tests/foreign.test.sh @@ -9,34 +9,126 @@ # 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. +. ./subr.sh +use_test_subdirectory + 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 +PUNT=$EXIT_TEST_WIN + +## Make some shared object files to test with. + +build_so() ( + echo building $1.so + set +u + case "`uname -m`" in + x86_64|amd64|mips|mips64) + CFLAGS="$CFLAGS -fPIC" + ;; + esac + if [ "`uname`" = Darwin ]; then + SO_FLAGS="-bundle" + if run_sbcl --eval '(sb-ext:quit :unix-status #+x86-64 0 #-x86-64 1)'; then + CFLAGS="$CFLAGS -arch x86_64" + fi + else + SO_FLAGS="-shared" + fi + cc -c $1.c -o $1.o $CFLAGS + ld $SO_FLAGS -o $1.so $1.o +) + +# We want to bail out in case any of these Unix programs fails. +set -e + +cat > $TEST_FILESTEM.c < $testfilestem.c -echo 'int numberish = 42;' >> $testfilestem.c -echo 'int nummish(int x) { return numberish + x; }' >> $testfilestem.c -cc -c $testfilestem.c -o $testfilestem.o -ld -shared -o $testfilestem.so $testfilestem.o +int long_test2(int i1, int i2, int i3, int i4, int i5, int i6, + int i7, int i8, int i9, long long l1, long long l2) { + return (l1 == (1 + powish(2,37))); +} -# Foreign definitions & load -cat > $testfilestem.def.lisp < $TEST_FILESTEM-b.c +echo 'int bar() { return 42; }' >> $TEST_FILESTEM-b.c +build_so $TEST_FILESTEM-b + +echo 'int foo = 42;' > $TEST_FILESTEM-b2.c +echo 'int bar() { return 13; }' >> $TEST_FILESTEM-b2.c +build_so $TEST_FILESTEM-b2 + +echo 'int late_foo = 43;' > $TEST_FILESTEM-c.c +echo 'int late_bar() { return 14; }' >> $TEST_FILESTEM-c.c +build_so $TEST_FILESTEM-c + +## Foreign definitions & load + +cat > $TEST_FILESTEM.base.lisp < $testfilestem.def.lisp < $TEST_FILESTEM.fast.lisp +cat $TEST_FILESTEM.base.lisp >> $TEST_FILESTEM.fast.lisp + +echo "(declaim (optimize space))" > $TEST_FILESTEM.small.lisp +cat $TEST_FILESTEM.base.lisp >> $TEST_FILESTEM.small.lisp + # Test code -cat > $testfilestem.test.lisp < $TEST_FILESTEM.test.lisp < $TEST_FILESTEM.addr.heap.c <