X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fforeign.test.sh;h=177d170089b833904ce44eaf1ae71f474609e26a;hb=1cba0af01f5107ab384d0d8b94b1f6330b3d0ef4;hp=aac8a705dbba82c1e400bf613266dd4abaf1fa6d;hpb=4919f9971429d18fab618b9b49e164c6b57bea6f;p=sbcl.git diff --git a/tests/foreign.test.sh b/tests/foreign.test.sh index aac8a70..177d170 100644 --- a/tests/foreign.test.sh +++ b/tests/foreign.test.sh @@ -9,127 +9,379 @@ # 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. +. ./expect.sh +. ./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 + /bin/sh ../run-compiler.sh -sbcl-pic -sbcl-shared "$1.c" -o "$1.so" +) + +# 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 +long long powish(unsigned int x, unsigned int y) { + long long acc = 1; + long long xx = (long long) x; + for(; y != 1; y /= 2) { + if (y & 1) { + acc *= xx; + y -= 1; + } + xx *= xx; + } + return xx*acc; +} -echo 'int foo = 13;' > $testfilestem-foobar.c -echo 'int bar() { return 42; }' >> $testfilestem-foobar.c -cc -c $testfilestem-foobar.c -o $testfilestem-foobar.o -ld -shared -o $testfilestem-foobar.so $testfilestem-foobar.o +float return9th(float f1, float f2, float f3, float f4, float f5, + float f6, float f7, float f8, float f9, float f10, + float f11, float f12) { + return f9; +} -echo 'int foo = 42;' > $testfilestem-foobar2.c -echo 'int bar() { return 13; }' >> $testfilestem-foobar2.c -cc -c $testfilestem-foobar2.c -o $testfilestem-foobar2.o -ld -shared -o $testfilestem-foobar2.so $testfilestem-foobar2.o +double return9thd(double f1, double f2, double f3, double f4, double f5, + double f6, double f7, double f8, double f9, double f10, + double f11, double f12) { + return f9; +} + +int long_test8(int a1, int a2, int a3, int a4, int a5, + int a6, int a7, long long l1) { + return (l1 == powish(2,34)); +} + +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)); +} + +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))); +} + +int long_sap_test1(int *p1, long long l1) { + return (l1 == (3 + powish(2,*p1))); +} + +int long_sap_test2(int *p1, int i1, long long l1) { + return (l1 == (3 + powish(2,*p1))); +} + +long long return_long_long() { + return powish(2,33); +} +EOF + +build_so $TEST_FILESTEM + +echo 'int foo = 13;' > $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 > $testfilestem.def.lisp < $TEST_FILESTEM.base.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 < $TEST_FILESTEM.alien.enum.lisp <