def test_PyPy(): pypy_dir = py.path.local( os.environ.get( 'PYPY_MU', str(py.path.local(__file__).join('..', 'mu-client-pypy')))) python = os.environ.get('PYTHON', 'pypy') # by default use pypy target = bin_dir.join('pypy-zebu') cmd = [pypy_dir.join('rpython/bin/rpython')] flags = [ '-O3', '--no-shared', '--backend=mu', '--mu-impl=zebu', '--mu-vmargs', '--gc-immixspace-size=10737418240', '--mu-suplibdir=%(bin_dir)s' % globals() ] # flags = ['-O3', '--no-shared', '--backend=c', '--no-profopt'] args = ['--no-allworkingmodules'] cmd.extend(flags) cmd.extend(['--output=%s' % target]) cmd.append(pypy_dir.join('pypy', 'goal', 'targetpypystandalone.py')) cmd.extend(args) cmd = map(str, cmd) log_platform.execute(' '.join([python] + cmd)) res = platform.execute(python, map(str, cmd)) assert res.returncode == 0, res.err fib_py = bin_dir.join('fib.py') with fib_py.open('w') as fp: fp.write(""" def fib(n): if n in (0, 1): return n return fib(n - 1) + fib(n - 2) def main(argv): print fib(int(argv[1])) if __name__ == "__main__": import sys main(sys.argv) """) log_platform.execute(' '.join([str(target), str(fib_py), '10'])) res = platform.execute(str(target), [str(fib_py), '10']) assert res.returncode == 0, res.err assert res.out == "55\n"
def test_rpython_list_addr_check_length100(): Int64Ptr = lltype.Ptr(lltype.Array(rffi.LONGLONG, hints={'nolength': True})) def check(actual, expect): if actual != expect: c_exit(rffi.cast(rffi.INT, actual)) def main(argv): a = [] for i in range(0, 100): a.append(i) from rpython.rtyper.lltypesystem.llmemory import cast_ptr_to_adr from rpython.rlib.objectmodel import keepalive_until_here addr = cast_ptr_to_adr(a) mem = rffi.cast(Int64Ptr, addr) # ignore mem[0] check(mem[1], 100) keepalive_until_here(a) return 0 res = run_boot_image( main, str(bin_dir.join('test_rpython_list_addr_check_length2'))) assert res.returncode == 0, 'returncode = %d\n%s' % (res.returncode, res.err)
def test_rpython_image_list_append(): def main(argv): a = [] for i in range(0, 10): a.append(i) c_exit(rffi.cast(rffi.INT, len(a))) return 0 res = run_boot_image(main, str(bin_dir.join('test_rpython_image_list_append'))) assert res.returncode == 10, 'returncode = %d\n%s' % (res.returncode, res.err)
def test_rpython_list_iter(): def main(argv): a = [] for i in range(0, 10): a.append(i) sum = 0 for n in a: sum += n c_exit(rffi.cast(rffi.INT, sum)) return 0 res = run_boot_image(main, str(bin_dir.join('test_rpython_list_iter'))) assert res.returncode == 45, 'returncode = %d\n%s' % (res.returncode, res.err)
def entry_point(argv): try: main(argv) except Exit, e: return e.code except Exception, e: os.write(2, "ERROR: %s thrown during execution.\n" % e) return 1 return 1 RPYSOM = os.environ.get('RPYSOM', str(py.path.local(__file__).join('..', 'RPySOM'))) res = run_boot_image(entry_point, str(bin_dir.join('RPySOM-no-jit-mu')), args=[ '-cp', '%(RPYSOM)s/Smalltalk' % locals(), '%(RPYSOM)s/TestSuite/TestHarness.som' % locals() ]) assert res.returncode == 0, res.err expected_out = \ """\ Testing... Running test EmptyTest Running test SystemTest Running test ArrayTest Running test ClassLoadingTest Running test ClosureTest Running test CoercionTest