[pypy-svn] r63631 - in pypy/branch/pyjitpl5-simplify/pypy/jit/backend: test x86/test

fijal at codespeak.net fijal at codespeak.net
Sat Apr 4 22:56:25 CEST 2009


Author: fijal
Date: Sat Apr  4 22:56:23 2009
New Revision: 63631

Added:
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/test/
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/test/runner.py   (contents, props changed)
Modified:
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py
Log:
factor out the common backend infrastructure for running tests


Added: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/test/runner.py
==============================================================================
--- (empty file)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/test/runner.py	Sat Apr  4 22:56:23 2009
@@ -0,0 +1,42 @@
+
+from pypy.jit.metainterp.history import BoxInt, Box, BoxPtr, TreeLoop, ConstInt
+from pypy.jit.metainterp.resoperation import ResOperation, rop
+
+class BaseBackendTest(object):
+    
+    def execute_operation(self, opname, valueboxes, result_type, descr=0):
+        loop = self.get_compiled_single_operation(opname, result_type,
+                                                  valueboxes, descr)
+        boxes = [box for box in valueboxes if isinstance(box, Box)]
+        res = self.cpu.execute_operations(loop, boxes)
+        if result_type != 'void':
+            return res.args[0]
+
+    def get_compiled_single_operation(self, opnum, result_type, valueboxes,
+                                      descr):
+        if result_type == 'void':
+            result = None
+        elif result_type == 'int':
+            result = BoxInt()
+        elif result_type == 'ptr':
+            result = BoxPtr()
+        else:
+            raise ValueError(result_type)
+        if result is None:
+            results = []
+        else:
+            results = [result]
+        operations = [ResOperation(opnum, valueboxes, result),
+                      ResOperation(rop.FAIL, results, None)]
+        operations[0].descr = descr
+        operations[-1].ovf = False
+        operations[-1].exc = False
+        if operations[0].is_guard():
+            operations[0].suboperations = [ResOperation(rop.FAIL,
+                                                        [ConstInt(-13)], None)]
+        loop = TreeLoop('single op')
+        loop.operations = operations
+        loop.inputargs = [box for box in valueboxes if isinstance(box, Box)]
+        self.cpu.compile_operations(loop)
+        return loop
+

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py	Sat Apr  4 22:56:23 2009
@@ -8,6 +8,7 @@
 from pypy.jit.backend.x86 import symbolic
 from pypy.jit.metainterp.resoperation import rop
 from pypy.jit.metainterp.executor import execute
+from pypy.jit.backend.test.runner import BaseBackendTest
 import ctypes
 import sys
 
@@ -31,47 +32,11 @@
 
 # ____________________________________________________________
 
-class TestX86(object):
+class TestX86(BaseBackendTest):
     def setup_class(cls):
         cls.cpu = CPU(rtyper=None, stats=FakeStats())
         cls.cpu.set_meta_interp(FakeMetaInterp())
 
-    def execute_operation(self, opname, valueboxes, result_type, descr=0):
-        loop = self.get_compiled_single_operation(opname, result_type,
-                                                  valueboxes, descr)
-        boxes = [box for box in valueboxes if isinstance(box, Box)]
-        res = self.cpu.execute_operations(loop, boxes)
-        if result_type != 'void':
-            return res.args[0]
-
-    def get_compiled_single_operation(self, opnum, result_type, valueboxes,
-                                      descr):
-        if result_type == 'void':
-            result = None
-        elif result_type == 'int':
-            result = BoxInt()
-        elif result_type == 'ptr':
-            result = BoxPtr()
-        else:
-            raise ValueError(result_type)
-        if result is None:
-            results = []
-        else:
-            results = [result]
-        operations = [ResOperation(opnum, valueboxes, result),
-                      ResOperation(rop.FAIL, results, None)]
-        operations[0].descr = descr
-        operations[-1].ovf = False
-        operations[-1].exc = False
-        if operations[0].is_guard():
-            operations[0].suboperations = [ResOperation(rop.FAIL,
-                                                        [ConstInt(-13)], None)]
-        loop = TreeLoop('single op')
-        loop.operations = operations
-        loop.inputargs = [box for box in valueboxes if isinstance(box, Box)]
-        self.cpu.compile_operations(loop)
-        return loop
-
     def test_int_binary_ops(self):
         for op, args, res in [
             (rop.INT_SUB, [BoxInt(42), BoxInt(40)], 2),



More information about the Pypy-commit mailing list