3 # tests related to foreign function interface and LOAD-FOREIGN
5 # This software is part of the SBCL system. See the README file for
8 # While most of SBCL is derived from the CMU CL system, the test
9 # files (like this one) were written from scratch after the fork
12 # This software is in the public domain and is provided with
13 # absolutely no warranty. See the COPYING and CREDITS files for
16 echo //entering foreign.
test.sh
18 testfilestem
=${TMPDIR:-/tmp}/sbcl-foreign-test-$$
20 # Make a little shared object file to test with.
21 echo 'int summish(int x, int y) { return 1 + x + y; }' > $testfilestem.c
22 cc
-c $testfilestem.c
-o $testfilestem.o
23 ld
-shared -o $testfilestem.so
$testfilestem.o
25 # Test interaction with the shared object file.
28 (load-foreign '("$testfilestem.so"))
29 (sb-int:unsupported-operator ()
30 ;; At least as of sbcl-0.7.0.5, LOAD-FOREIGN isn't supported
31 ;; on every OS. In that case, there's nothing to test, and we
32 ;; can just fall through to success.
33 (sb-ext:quit :unix-status 52))) ; success convention for Lisp program
34 (define-alien-routine summish int (x int) (y int))
35 (assert (= (summish 10 20) 31))
36 (sb-ext:quit :unix-status 52) ; success convention for Lisp program
43 # FIXME: I rewrote the handling of ENV/ENVIRONMENT arguments for
44 # LOAD-FOREIGN, but I can't think of a nice way to test it. (Kent Beck
45 # would cry. If he didn't keel over on the spot and then commence
46 # rolling over in his grave.:-) It would be good to make a test case
49 echo //cleanup
: removing
$testfilestem.
*
52 # success convention for script