sbcl.sbcl/tests/map-refs.pure.lisp
Douglas Katzman 559f9e0049 Enforce fewer side-effects of "pure" regression tests
- Capture before/after state of globaldb and global symbols for comparison.
- Do a better job clobbering remants of defining forms after each test file.
- Allow DEFSTRUCT and DEFTYPE in pure tests.

The intent of this change is to  get a larger set of tests that don't fork
a new child, which will provide more metrics on the effectiveness of GC
during the regression run.

Contrary to the comments, DEFUN and DEFMACRO do not render a test impure,
because DELETE-PACKAGE undoes those. Apparently thread creation is treated
as pure, evidenced by the mere existence of 'threads.pure.lisp'.
Also, creating a file is not impure, because state change outside the process
is usually irrelevant. A failing pure test may have side-effects by accident,
which isn't great, but we can live with it.
2022-01-10 00:54:05 -05:00

15 lines
852 B
Common Lisp

;;; Make sure MAP-REFERENCING-OBJECTS doesn't spuriously treat raw bits as
;;; potential pointers. Also make sure it sees the SYMBOL-INFO slot.
(defstruct afoo (slot nil :type sb-ext:word))
(defvar *afoo* (make-afoo :slot (sb-kernel:get-lisp-obj-address '*posix-argv*)))
(with-test (:name :map-referencing-objs)
(sb-vm::map-referencing-objects (lambda (x) (assert (not (typep x 'afoo))))
:dynamic '*posix-argv*)
(let ((v (sb-kernel:symbol-%info 'satisfies)) referers)
(sb-vm::map-referencing-objects (lambda (referer) (push referer referers))
#+gencgc :dynamic #-gencgc :static v)
#+immobile-space
(sb-vm::map-referencing-objects (lambda (referer) (push referer referers))
:immobile v)
(assert (member 'satisfies referers))))