Improve upon change 6ea0a4fb ("make notes make sense")
[sbcl.git] / tests / swap-lispobjs.impure.lisp
blob8e8c1ca7d4c7d218a421af37f0464088a6cd1a2e
1 ;;;; Testing swap_lispobjs.
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
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
8 ;;;; from CMU CL.
9 ;;;;
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)
16 #-(or x86 x86-64)
17 (sb-ext:exit :code 104)
19 (defun run (program &rest arguments)
20 (let* ((proc nil)
21 (output
22 (with-output-to-string (s)
23 (setf proc (run-program program arguments
24 :output s)))))
25 (unless (zerop (process-exit-code proc))
26 (error "Bad exit code: ~S~%Output:~% ~S"
27 (process-exit-code proc)
28 output))
29 output))
31 (with-test (:name :swap-lispobjs/prepare :broken-on :win32)
32 (run "/bin/sh" "run-compiler.sh"
33 "-sbcl-pic" "-sbcl-shared"
34 "-O3" "-I" "../src/runtime/"
35 "swap-lispobjs.c" "-o" "swap-lispobjs.so")
37 (load-shared-object (truename "swap-lispobjs.so"))
39 (define-alien-routine try-to-zero-with-swap-lispobjs int
40 (lispobj-adress unsigned-long)))
42 (with-test (:name :swap-lispobjs :fails-on :win32)
43 (let ((x (cons 13 27)))
44 (try-to-zero-with-swap-lispobjs
45 (logandc2 (sb-kernel:get-lisp-obj-address x)
46 sb-vm:lowtag-mask))
47 (assert (equal x (cons 0 27)))))
49 (when (probe-file "swap-lispobjs.so")
50 (delete-file "swap-lispobjs.so"))