1 ;;;; Testing swap_lispobjs.
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; While most of SBCL is derived from the CMU CL system, the test
7 ;;;; files (like this one) were written from scratch after the fork
10 ;;;; This software is in the public domain and is provided with
11 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
12 ;;;; more information.
14 (use-package :sb-alien)
17 (sb-ext:exit :code 104)
19 (defun run (program &rest arguments)
22 (with-output-to-string (s)
23 (setf proc (run-program program arguments
24 :environment (test-util::test-env)
26 (unless (zerop (process-exit-code proc))
27 (error "Bad exit code: ~S~%Output:~% ~S"
28 (process-exit-code proc)
32 (with-test (:name :swap-lispobjs/prepare :broken-on :win32)
33 (run "/bin/sh" "run-compiler.sh"
34 "-sbcl-pic" "-sbcl-shared"
35 "-O3" "-I" "../src/runtime/"
36 "swap-lispobjs.c" "-o" "swap-lispobjs.so")
38 (load-shared-object (truename "swap-lispobjs.so"))
40 (define-alien-routine try-to-zero-with-swap-lispobjs int
41 (lispobj-adress unsigned-long)))
43 (with-test (:name :swap-lispobjs :fails-on :win32)
44 (let ((x (cons 13 27)))
45 (try-to-zero-with-swap-lispobjs
46 (logandc2 (sb-kernel:get-lisp-obj-address x)
48 (assert (equal x (cons 0 27)))))
50 (when (probe-file "swap-lispobjs.so")
51 (delete-file "swap-lispobjs.so"))