Maciej Fijalkowski avatar Maciej Fijalkowski committed 7ef29ce

try to make those tests actually test anything

Comments (0)

Files changed (2)

rpython/jit/backend/x86/test/test_zrpy_gc.py

 """
 
 import weakref
-import py, os
-from rpython.annotator import policy as annpolicy
+import os
 from rpython.rlib import rgc
-from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
+from rpython.rtyper.lltypesystem import lltype
 from rpython.rlib.jit import JitDriver, dont_look_inside
 from rpython.rlib.jit import elidable, unroll_safe
 from rpython.jit.backend.llsupport.gc import GcLLDescr_framework

rpython/jit/backend/x86/test/test_zrpy_releasegil.py

 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
 from rpython.rlib.jit import dont_look_inside
+from rpython.rlib.objectmodel import invoke_around_extcall
 from rpython.jit.metainterp.optimizeopt import ALL_OPTS_NAMES
 
-from rpython.rlib.libffi import CDLL, types, ArgChain, clibffi
-from rpython.rtyper.lltypesystem.ll2ctypes import libc_name
 from rpython.rtyper.annlowlevel import llhelper
 
 from rpython.jit.backend.x86.test.test_zrpy_gc import BaseFrameworkTests
 from rpython.jit.backend.x86.test.test_zrpy_gc import check
+from rpython.tool.udir import udir
 
 
 class ReleaseGILTests(BaseFrameworkTests):
 
     def define_simple(self):
         class Glob:
-            pass
+            def __init__(self):
+                self.events = []
         glob = Glob()
         #
-        def f42(n):
-            c_strchr = glob.c_strchr
-            raw = rffi.str2charp("foobar" + chr((n & 63) + 32))
-            argchain = ArgChain()
-            argchain = argchain.arg(rffi.cast(lltype.Signed, raw))
-            argchain = argchain.arg(rffi.cast(rffi.INT, ord('b')))
-            res = c_strchr.call(argchain, rffi.CCHARP)
-            check(rffi.charp2str(res) == "bar" + chr((n & 63) + 32))
-            rffi.free_charp(raw)
-        #
+
+        c_strchr = rffi.llexternal('strchr', [rffi.CCHARP, lltype.Signed],
+                                   rffi.CCHARP)
+
+        def func():
+            glob.events.append("x")
+
         def before(n, x):
-            libc = CDLL(libc_name)
-            c_strchr = libc.getpointer('strchr', [types.pointer, types.sint],
-                                       types.pointer)
-            glob.c_strchr = c_strchr
+            invoke_around_extcall(func, func)
             return (n, None, None, None, None, None,
                     None, None, None, None, None, None)
         #
         def f(n, x, *args):
-            f42(n)
+            a = rffi.str2charp(str(n))
+            c_strchr(a, ord('0'))
+            lltype.free(a, flavor='raw')
             n -= 1
             return (n, x) + args
         return before, f, None
 
     def test_simple(self):
         self.run('simple')
+        assert 'call_release_gil' in udir.join('test_zrpy_gc.log').read()
 
     def define_close_stack(self):
         #
         @dont_look_inside
         def free1(p):
             llmemory.raw_free(p)
+
+        c_qsort = rffi.llexternal('qsort', [rffi.VOIDP, rffi.SIZE_T,
+                                            rffi.SIZE_T, CALLBACK], lltype.Void)
         #
         def f42():
             length = len(glob.lst)
-            c_qsort = glob.c_qsort
             raw = alloc1()
             fn = llhelper(CALLBACK, rffi._make_wrapper_for(CALLBACK, callback))
-            argchain = ArgChain()
-            argchain = argchain.arg(rffi.cast(lltype.Signed, raw))
-            argchain = argchain.arg(rffi.cast(rffi.SIZE_T, 2))
-            argchain = argchain.arg(rffi.cast(rffi.SIZE_T, 8))
-            argchain = argchain.arg(rffi.cast(lltype.Signed, fn))
-            c_qsort.call(argchain, lltype.Void)
+            c_qsort(rffi.cast(rffi.VOIDP, raw), rffi.cast(rffi.SIZE_T, 2),
+                    rffi.cast(rffi.SIZE_T, 8), fn)
             free1(raw)
             check(len(glob.lst) > length)
             del glob.lst[:]
         #
         def before(n, x):
-            libc = CDLL(libc_name)
-            types_size_t = clibffi.cast_type_to_ffitype(rffi.SIZE_T)
-            c_qsort = libc.getpointer('qsort', [types.pointer, types_size_t,
-                                                types_size_t, types.pointer],
-                                      types.void)
-            glob.c_qsort = c_qsort
             glob.lst = []
+            
             return (n, None, None, None, None, None,
                     None, None, None, None, None, None)
         #
 
     def test_close_stack(self):
         self.run('close_stack')
+        assert 'call_release_gil' in udir.join('test_zrpy_gc.log').read()
 
 
 class TestShadowStack(ReleaseGILTests):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.