0.pre7.63:
[sbcl.git] / tests / foreign.test.sh
1 #!/bin/sh
2
3 # tests related to foreign function interface and LOAD-FOREIGN
4
5 # This software is part of the SBCL system. See the README file for
6 # more information.
7 #
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
10 # from CMU CL.
11
12 # This software is in the public domain and is provided with
13 # absolutely no warranty. See the COPYING and CREDITS files for
14 # more information.
15
16 testfilestem=${TMPDIR:-/tmp}/sbcl-foreign-test-$$
17
18 echo 'int summish(int x, int y) { return 1 + x + y; }' > $testfilestem.c
19 make $testfilestem.o
20 ld -shared -o $testfilestem.so $testfilestem.o
21
22 ${SBCL:-sbcl} <<EOF
23   (unless (fboundp 'load-foreign) ; not necessarily supported on all OSes..
24     (sb-ext:quit :unix-status 52)) ; successfully unsupported:-|
25   (load-foreign '("$testfilestem.so"))
26   (def-alien-routine summish int (x int) (y int))
27   (assert (= (summish 10 20) 31))
28   (sb-ext:quit :unix-status 52) ; success convention for Lisp program
29 EOF
30 if [ $? != 52 ]; then
31     echo test failed: $?
32     exit 1
33 fi
34
35 # FIXME: I rewrote the handling of ENV/ENVIRONMENT arguments for
36 # LOAD-FOREIGN, but I can't think of a nice way to test it. (Kent Beck
37 # would cry. If he didn't keel over on the spot and then commence
38 # rolling over in his grave.:-) It would be good to make a test case
39 # for it..
40
41 rm $testfilestem.*
42
43 # success convention for script
44 exit 104