Author: Tim Felgentreff <[email protected]>
Branch: 
Changeset: r300:15149caf13f0
Date: 2013-04-19 14:17 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/15149caf13f0/

Log:    fix tests that segfaultet

diff --git a/spyvm/test/test_model.py b/spyvm/test/test_model.py
--- a/spyvm/test/test_model.py
+++ b/spyvm/test/test_model.py
@@ -2,7 +2,7 @@
 import math
 from spyvm import model, shadow
 from spyvm.shadow import MethodNotFound
-from spyvm import objspace, error
+from spyvm import objspace, error, display
 from rpython.rlib.rarithmetic import intmask, r_uint
 
 mockclass = objspace.bootstrap_class
@@ -288,7 +288,16 @@
     assert hex(r_uint(target.value)) == hex(r_uint(source.value))
 
 def test_display_bitmap():
-    target = model.W_DisplayBitmap.create(space, space.w_Array, 100, 1, None)
+    # XXX: Patch SDLDisplay -> get_pixelbuffer() to circumvent
+    # double-free bug
+    def get_pixelbuffer(self):
+        from rpython.rtyper.lltypesystem import lltype, rffi
+        return lltype.malloc(rffi.ULONGP.TO, self.width * self.height * 32, 
flavor='raw')
+    display.SDLDisplay.get_pixelbuffer = get_pixelbuffer
+    d = display.SDLDisplay("test")
+    d.set_video_mode(10, 10, 1)
+
+    target = model.W_DisplayBitmap.create(space, space.w_Array, 100, 1, d)
     target.setword(0, 0xFF00)
     assert bin(target.getword(0)) == bin(0xFF00)
     target.setword(0, 0x00FF00FF)
diff --git a/spyvm/test/test_primitives.py b/spyvm/test/test_primitives.py
--- a/spyvm/test/test_primitives.py
+++ b/spyvm/test/test_primitives.py
@@ -637,7 +637,13 @@
     assert w_1 is not w_2
 
 def test_primitive_be_display():
-    py.test.fail("This test leads to a Segfault.")
+    # XXX: Patch SDLDisplay -> get_pixelbuffer() to circumvent
+    # double-free bug
+    def get_pixelbuffer(self):
+        from rpython.rtyper.lltypesystem import lltype, rffi
+        return lltype.malloc(rffi.ULONGP.TO, self.width * self.height * 32, 
flavor='raw')
+    display.SDLDisplay.get_pixelbuffer = get_pixelbuffer
+
     assert space.objtable["w_display"] is None
     mock_display = model.W_PointersObject(space, space.w_Point, 4)
     w_wordbmp = model.W_WordsObject(space, space.w_Array, 100)
@@ -671,7 +677,13 @@
     assert mock_display.fetch(space, 0) is w_bitmap
 
 def test_primitive_force_display_update(monkeypatch):
-    py.test.fail("This test leads to a Segfault.")
+    # XXX: Patch SDLDisplay -> get_pixelbuffer() to circumvent
+    # double-free bug
+    def get_pixelbuffer(self):
+        from rpython.rtyper.lltypesystem import lltype, rffi
+        return lltype.malloc(rffi.ULONGP.TO, self.width * self.height * 32, 
flavor='raw')
+    display.SDLDisplay.get_pixelbuffer = get_pixelbuffer
+
     mock_display = model.W_PointersObject(space, space.w_Point, 4)
     w_wordbmp = model.W_WordsObject(space, space.w_Array, 100)
     mock_display.store(space, 0, w_wordbmp) # bitmap
@@ -701,6 +713,7 @@
             self.w_simulateCopyBits = "simulateCopyBits"
 
     mock_bitblt = model.W_PointersObject(space, space.w_Point, 15)
+    mock_bitblt.store(space, 3, space.wrap_int(15)) # combination rule
 
     def perform_mock(w_selector, argcount, interp):
         if w_selector == "simulateCopyBits" or w_selector.as_string() == 
"simulateCopyBits":
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to