# and non-linkage-table platforms fail this
PUNT=104
-testfilestem=${TMPDIR:-/tmp}/sbcl-foreign-test-$$
+testfiledir=sbcl-foreign-test-$$
+testfilestem=`pwd`/$testfiledir/sbcl-foreign-test
+mkdir $testfiledir
## Make some shared object files to test with.
build_so() {
echo building $1.so
- if [ "`uname -m`" = x86_64 ]; then
+ if [ "`uname -m`" = x86_64 -o "`uname -m`" = amd64 -o \
+ "`uname -m`" = mips -o "`uname -m`" = mips64 ]; then
CFLAGS="$CFLAGS -fPIC"
fi
if [ "`uname`" = Darwin ]; then
## Foreign definitions & load
-cat > $testfilestem.def.lisp <<EOF
+cat > $testfilestem.base.lisp <<EOF
(define-alien-variable environ (* c-string))
(defvar *environ* environ)
(eval-when (:compile-toplevel :load-toplevel :execute)
(assert (= (sb-sys:sap-int (alien-sap *environ*))
(sb-sys:sap-int (alien-sap environ))))
- (enable-debugger)
;; automagic restarts
- (setf *debugger-hook*
+ (setf *invoke-debugger-hook*
(lambda (condition hook)
- (print (list :debugger-hook condition))
+ (princ condition)
(let ((cont (find-restart 'continue condition)))
(when cont
(invoke-restart cont)))
(invoke-debugger condition)))
EOF
+echo "(declaim (optimize speed))" > $testfilestem.fast.lisp
+cat $testfilestem.base.lisp >> $testfilestem.fast.lisp
+
+echo "(declaim (optimize space))" > $testfilestem.small.lisp
+cat $testfilestem.base.lisp >> $testfilestem.small.lisp
+
# Test code
cat > $testfilestem.test.lisp <<EOF
- (assert (= (summish 10 20) 31))
+ ;; FIXME: currently the start/small case fails on x86/Darwin. Moving
+ ;; this NOTE definition to the base.lisp file fixes that, but obviously
+ ;; it is better fo figure out what is going on instead of doing that...
+ ;;
+ ;; Other trivialish changes that mask the error include:
+ ;; * loading the .lisp file instead of the .fasl at the save test
+ ;; * --eval 'nil' before loading the .fasl at the save test
+ ;;
+ ;; HATE.
+ (defun note (x)
+ (write-line x *standard-output*)
+ (force-output *standard-output*))
+ (note "/initial assertions")
+ (assert (= 31 (summish 10 20)))
(assert (= 42 numberish))
(setf numberish 13)
(assert (= 13 numberish))
(assert (= 1 (long-test2 1 2 3 4 5 6 7 8 9 (+ 1 (ash 1 37)) 15)))
(assert (= (ash 1 33) (return-long-long)))
- (print :stage-1)
+ (note "/initial assertions ok")
;; test reloading object file with new definitions
(assert (= 13 foo))
(assert (= 42 (bar)))
+ (note "/original definitions ok")
(rename-file "$testfilestem-b.so" "$testfilestem-b.bak")
(rename-file "$testfilestem-b2.so" "$testfilestem-b.so")
(load-shared-object "$testfilestem-b.so")
+ (note "/reloading ok")
(assert (= 42 foo))
(assert (= 13 (bar)))
+ (note "/redefined versions ok")
(rename-file "$testfilestem-b.so" "$testfilestem-b2.so")
(rename-file "$testfilestem-b.bak" "$testfilestem-b.so")
-
- (print :stage-2)
+ (note "/renamed back to originals")
;; test late resolution
#+linkage-table
(progn
+ (note "/starting linkage table tests")
(define-alien-variable late-foo int)
(define-alien-routine late-bar int)
(multiple-value-bind (val err) (ignore-errors late-foo)
(assert (typep err 'undefined-alien-error)))
(load-shared-object "$testfilestem-c.so")
(assert (= 43 late-foo))
- (assert (= 14 (late-bar))))
-
- (print :stage-3)
+ (assert (= 14 (late-bar)))
+ (note "/linkage table ok"))
(sb-ext:quit :unix-status 52) ; success convention for Lisp program
EOF
-${SBCL:-sbcl} --eval "(progn (load (compile-file #p\"$testfilestem.def.lisp\")) (sb-ext:quit :unix-status 52))"
-if [ $? = 52 ]; then
- true # nop
-else
- # we can't compile the test file. something's wrong.
- # rm $testfilestem.*
- echo test failed: $?
- exit 1
-fi
-
-echo compile ok
+test_compile() {
+ ${SBCL:-sbcl} --eval "(progn (load (compile-file #p\"$testfilestem.$1.lisp\")) (sb-ext:quit :unix-status 52))"
+ if [ $? = 52 ]; then
+ echo test compile $1 ok
+ else
+ # we can't compile the test file. something's wrong.
+ # rm $testfilestem.*
+ echo test compile $1 failed: $?
+ exit 1
+ fi
+}
-${SBCL:-sbcl} --load $testfilestem.def.fasl --load $testfilestem.test.lisp
-RET=$?
-if [ $RET = 22 ]; then
- rm $testfilestem.*
- exit $PUNT # success -- load-shared-object not supported
-elif [ $RET != 52 ]; then
- rm $testfilestem.*
- echo test failed: $?
- exit 1
-fi
+test_compile fast
+test_compile small
+
+test_use() {
+ ${SBCL:-sbcl} --load $testfilestem.$1.fasl --load $testfilestem.test.lisp
+ RET=$?
+ if [ $RET = 22 ]; then
+ rm $testfilestem.*
+ exit $PUNT # success -- load-shared-object not supported
+ elif [ $RET != 52 ]; then
+ rm $testfilestem.*
+ echo test use $1 failed: $?
+ exit 1
+ else
+ echo test use $1 ok
+ fi
+}
-echo load ok
+test_use small
+test_use fast
-${SBCL:-sbcl} --load $testfilestem.def.fasl --eval "(when (member :linkage-table *features*) (save-lisp-and-die \"$testfilestem.core\"))" <<EOF
+test_save() {
+ echo testing save $1
+ ${SBCL:-sbcl} --load $testfilestem.$1.fasl --eval "#+linkage-table (save-lisp-and-die \"$testfilestem.$1.core\") #-linkage-table nil" <<EOF
(sb-ext:quit :unix-status 22) ; catch this
EOF
-if [ $? = 22 ]; then
- rm $testfilestem.*
- exit $PUNT # success -- linkage-table not available
-fi
-
-echo table ok
+ if [ $? = 22 ]; then
+ rm $testfilestem.*
+ exit $PUNT # success -- linkage-table not available
+ else
+ echo save $1 ok
+ fi
+}
-${SBCL_ALLOWING_CORE:-sbcl} --core $testfilestem.core --sysinit /dev/null --userinit /dev/null --load $testfilestem.test.lisp
-if [ $? != 52 ]; then
- rm $testfilestem.*
- echo test failed: $?
- exit 1 # Failure
-fi
+test_save small
+test_save fast
+
+test_start() {
+ echo testing start $1
+ ${SBCL_ALLOWING_CORE:-sbcl} --core $testfilestem.$1.core --sysinit /dev/null --userinit /dev/null --load $testfilestem.test.lisp
+ if [ $? != 52 ]; then
+ rm $testfilestem.*
+ echo test failed: $?
+ exit 1 # Failure
+ else
+ echo test start $1 ok
+ fi
+}
-echo start ok
+test_start fast
+test_start small
# missing object file
rm $testfilestem-b.so $testfilestem-b2.so
-${SBCL_ALLOWING_CORE:-sbcl} --core $testfilestem.core --sysinit /dev/null --userinit /dev/null <<EOF
+${SBCL_ALLOWING_CORE:-sbcl} --core $testfilestem.fast.core --sysinit /dev/null --userinit /dev/null <<EOF
(assert (= 22 (summish 10 11)))
(multiple-value-bind (val err) (ignore-errors (eval 'foo))
(assert (not val))
exit 1 # Failure
fi
-echo missing ok
+echo missing .so ok
-rm -f $testfilestem.* $testfilestem-*
+rm -r $testfiledir
# success convention for script
exit 104