[pypy-svn] r61615 - pypy/trunk/pypy/translator/sandbox/test

arigo at codespeak.net arigo at codespeak.net
Sat Feb 7 17:34:13 CET 2009


Author: arigo
Date: Sat Feb  7 17:34:12 2009
New Revision: 61615

Modified:
   pypy/trunk/pypy/translator/sandbox/test/test_sandbox.py
   pypy/trunk/pypy/translator/sandbox/test/test_sandlib.py
Log:
Fix the tests to use gc='ref' instead of the now-default gc='hybrid'.
This avoids the initial calls to os.getenv() done by the generation GC.


Modified: pypy/trunk/pypy/translator/sandbox/test/test_sandbox.py
==============================================================================
--- pypy/trunk/pypy/translator/sandbox/test/test_sandbox.py	(original)
+++ pypy/trunk/pypy/translator/sandbox/test/test_sandbox.py	Sat Feb  7 17:34:12 2009
@@ -19,6 +19,10 @@
         write_message(g, result, resulttype)
         g.flush()
 
+def compile(f):
+    t = Translation(f, backend='c', standalone=True, sandbox=True, gc='ref')
+    return str(t.compile())
+
 
 def test_open_dup():
     def entry_point(argv):
@@ -28,8 +32,7 @@
         assert fd2 == 78
         return 0
 
-    t = Translation(entry_point, backend='c', standalone=True, sandbox=True)
-    exe = str(t.compile())
+    exe = compile(entry_point)
     g, f = os.popen2(exe, "t", 0)
     expect(f, g, "ll_os.ll_os_open", ("/tmp/foobar", os.O_RDONLY, 0777), 77)
     expect(f, g, "ll_os.ll_os_dup",  (77,), 78)
@@ -49,8 +52,7 @@
         os.close(fd)
         return 0
 
-    t = Translation(entry_point, backend='c', standalone=True, sandbox=True)
-    exe = str(t.compile())
+    exe = compile(entry_point)
     g, f = os.popen2(exe, "t", 0)
     expect(f, g, "ll_os.ll_os_open",  ("/tmp/foobar", os.O_RDONLY, 0777), 77)
     expect(f, g, "ll_os.ll_os_read",  (77, 123), "he\x00llo")
@@ -67,8 +69,7 @@
         y = os.access("spam", 77)
         return 1 - y
 
-    t = Translation(entry_point, backend='c', standalone=True, sandbox=True)
-    exe = str(t.compile())
+    exe = compile(entry_point)
     g, f = os.popen2(exe, "t", 0)
     expect(f, g, "ll_os.ll_os_dup2",   (34, 56), None)
     expect(f, g, "ll_os.ll_os_access", ("spam", 77), True)
@@ -87,8 +88,7 @@
         os.ftruncate(st.st_mode, st.st_size)  # nonsense, just to see outside
         return 0
 
-    t = Translation(entry_point, backend='c', standalone=True, sandbox=True)
-    exe = str(t.compile())
+    exe = compile(entry_point)
     g, f = os.popen2(exe, "t", 0)
     st = os.stat_result((55, 0, 0, 0, 0, 0, 0x12380000007, 0, 0, 0))
     expect(f, g, "ll_os.ll_os_stat", ("somewhere",), st,
@@ -105,8 +105,7 @@
         os.dup(int(t*1000))
         return 0
 
-    t = Translation(entry_point, backend='c', standalone=True, sandbox=True)
-    exe = str(t.compile())
+    exe = compile(entry_point)
     g, f = os.popen2(exe, "t", 0)
     expect(f, g, "ll_time.ll_time_time", (), 3.141592)
     expect(f, g, "ll_os.ll_os_dup", (3141,), 3)
@@ -123,8 +122,7 @@
             os.close(e.errno)    # nonsense, just to see outside
         return 0
 
-    t = Translation(entry_point, backend='c', standalone=True, sandbox=True)
-    exe = str(t.compile())
+    exe = compile(entry_point)
     g, f = os.popen2(exe, "t", 0)
     expect(f, g, "ll_os.ll_os_stat", ("somewhere",), OSError(6321, "egg"))
     expect(f, g, "ll_os.ll_os_close", (6321,), None)
@@ -136,9 +134,7 @@
 class TestPrintedResults:
 
     def run(self, entry_point, args, expected):
-        t = Translation(entry_point, backend='c', standalone=True,
-                        sandbox=True)
-        exe = str(t.compile())
+        exe = compile(entry_point)
         from pypy.translator.sandbox.sandlib import SimpleIOSandboxedProc
         proc = SimpleIOSandboxedProc([exe] + args)
         output, error = proc.communicate()

Modified: pypy/trunk/pypy/translator/sandbox/test/test_sandlib.py
==============================================================================
--- pypy/trunk/pypy/translator/sandbox/test/test_sandlib.py	(original)
+++ pypy/trunk/pypy/translator/sandbox/test/test_sandlib.py	Sat Feb  7 17:34:12 2009
@@ -5,7 +5,7 @@
 from pypy.translator.sandbox.sandlib import SandboxedProc
 from pypy.translator.sandbox.sandlib import SimpleIOSandboxedProc
 from pypy.translator.sandbox.sandlib import VirtualizedSocketProc
-from pypy.translator.interactive import Translation
+from pypy.translator.sandbox.test.test_sandbox import compile
 
 
 class MySandboxedProc(SandboxedProc):
@@ -46,8 +46,7 @@
             assert count == 61
         os.close(fd)
         return 0
-    t = Translation(entry_point, backend='c', standalone=True, sandbox=True)
-    exe = str(t.compile())
+    exe = compile(entry_point)
 
     proc = MySandboxedProc([exe, 'x1', 'y2'], expected = [
         ("open", ("/tmp/foobar", os.O_RDONLY, 0777), 77),
@@ -68,8 +67,7 @@
         s = rffi.str2charp(argv[1]); n = foobar(s); rffi.free_charp(s)
         s = rffi.str2charp(argv[n]); n = foobar(s); rffi.free_charp(s)
         return n
-    t = Translation(entry_point, backend='c', standalone=True, sandbox=True)
-    exe = str(t.compile())
+    exe = compile(entry_point)
 
     proc = MySandboxedProc([exe, 'spam', 'egg'], expected = [
         ("foobar", ("spam",), 2),
@@ -92,8 +90,7 @@
         num = int(buf)
         print "The double is:", num * 2
         return 0
-    t = Translation(entry_point, backend='c', standalone=True, sandbox=True)
-    exe = str(t.compile())
+    exe = compile(entry_point)
 
     proc = SimpleIOSandboxedProc([exe, 'x1', 'y2'])
     output, error = proc.communicate("21\n")
@@ -110,8 +107,7 @@
         os.write(fd, 'GET /\n')
         print os.read(fd, 30)
         return 0
-    t = Translation(entry_point, backend='c', standalone=True, sandbox=True)
-    exe = str(t.compile())
+    exe = compile(entry_point)
 
     proc = SocketProc([exe])
     output, error = proc.communicate("")
@@ -124,8 +120,7 @@
         except OSError, e:
             os.close(e.errno)    # nonsense, just to see outside
         return 0
-    t = Translation(entry_point, backend='c', standalone=True, sandbox=True)
-    exe = str(t.compile())
+    exe = compile(entry_point)
 
     proc = MySandboxedProc([exe], expected = [
         ("open", ("/tmp/foobar", os.O_RDONLY, 0777), OSError(-42, "baz")),



More information about the Pypy-commit mailing list