[pypy-svn] r31121 - in pypy/dist/pypy/jit/codegen: . i386 i386/test

arigo at codespeak.net arigo at codespeak.net
Mon Aug 7 17:17:18 CEST 2006


Author: arigo
Date: Mon Aug  7 17:17:14 2006
New Revision: 31121

Added:
   pypy/dist/pypy/jit/codegen/detect_cpu.py   (contents, props changed)
   pypy/dist/pypy/jit/codegen/i386/__init__.py   (contents, props changed)
   pypy/dist/pypy/jit/codegen/i386/conftest.py   (contents, props changed)
   pypy/dist/pypy/jit/codegen/i386/test/   (props changed)
   pypy/dist/pypy/jit/codegen/i386/test/__init__.py   (contents, props changed)
   pypy/dist/pypy/jit/codegen/i386/test/test_assembler.py
      - copied, changed from r31119, pypy/dist/pypy/jit/codegen/i386/test_assembler.py
   pypy/dist/pypy/jit/codegen/i386/test/test_i386.py
      - copied, changed from r31119, pypy/dist/pypy/jit/codegen/i386/test_i386.py
   pypy/dist/pypy/jit/codegen/i386/test/test_ri386.py
      - copied, changed from r31119, pypy/dist/pypy/jit/codegen/i386/test_ri386.py
   pypy/dist/pypy/jit/codegen/i386/test/test_ri386genop.py
      - copied, changed from r31119, pypy/dist/pypy/jit/codegen/i386/test_ri386genop.py
Removed:
   pypy/dist/pypy/jit/codegen/i386/test_assembler.py
   pypy/dist/pypy/jit/codegen/i386/test_i386.py
   pypy/dist/pypy/jit/codegen/i386/test_ri386.py
   pypy/dist/pypy/jit/codegen/i386/test_ri386genop.py
Modified:
   pypy/dist/pypy/jit/codegen/i386/autotest.py
Log:
* Copied simple CPU detection code from Psyco's setup.py.
* Skip tests on non-386 processors.
* Added __init__s, moved the tests in a test/ subdirectory.


Added: pypy/dist/pypy/jit/codegen/detect_cpu.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/jit/codegen/detect_cpu.py	Mon Aug  7 17:17:14 2006
@@ -0,0 +1,27 @@
+"""
+Processor auto-detection
+"""
+import sys, os
+
+
+class ProcessorAutodetectError(Exception):
+    pass
+
+def autodetect():
+    platform = sys.platform.lower()
+    if platform.startswith('win'):   # assume an Intel Windows
+        return 'i386'
+    # assume we have 'uname'
+    mach = os.popen('uname -m', 'r').read().strip()
+    if not mach:
+        raise ProcessorAutodetectError, "cannot run 'uname -m'"
+    try:
+        return {'i386': 'i386',
+                'i486': 'i386',
+                'i586': 'i386',
+                'i686': 'i386',
+                'i86pc': 'i386',    # Solaris/Intel
+                'x86':   'i386',    # Apple
+                }[mach]
+    except KeyError:
+        raise ProcessorAutodetectError, "unsupported processor '%s'" % mach

Added: pypy/dist/pypy/jit/codegen/i386/__init__.py
==============================================================================

Modified: pypy/dist/pypy/jit/codegen/i386/autotest.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/autotest.py	(original)
+++ pypy/dist/pypy/jit/codegen/i386/autotest.py	Mon Aug  7 17:17:14 2006
@@ -2,8 +2,8 @@
 import i386
 
 FILENAME = 'checkfile.tmp'
-BEGIN_TAG = '<<<psyco-test-begin>>>'
-END_TAG =   '<<<psyco-test-end>>>'
+BEGIN_TAG = '<<<ri386-test-begin>>>'
+END_TAG =   '<<<ri386-test-end>>>'
 
 COUNT1 = 15
 COUNT2 = 25

Added: pypy/dist/pypy/jit/codegen/i386/conftest.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/jit/codegen/i386/conftest.py	Mon Aug  7 17:17:14 2006
@@ -0,0 +1,16 @@
+import py
+from pypy.jit.codegen import detect_cpu
+
+
+class Directory(py.test.collect.Directory):
+
+    def run(self):
+        try:
+            processor = detect_cpu.autodetect()
+        except detect_cpu.ProcessorAutodetectError, e:
+            py.test.skip(str(e))
+        else:
+            if processor != 'i386':
+                py.test.skip('detected a %r CPU' % (processor,))
+
+        return super(Directory, self).run()

Added: pypy/dist/pypy/jit/codegen/i386/test/__init__.py
==============================================================================



More information about the Pypy-commit mailing list