test_som.py 2.87 KB
Newer Older
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1
# Copyright 2017 The Australian National University
John Zhang's avatar
John Zhang committed
2
#
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
3 4 5
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
John Zhang's avatar
John Zhang committed
6
#
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
7
#     http://www.apache.org/licenses/LICENSE-2.0
John Zhang's avatar
John Zhang committed
8
#
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
9 10 11 12 13 14
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

qinsoon's avatar
qinsoon committed
15 16 17
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rlib.rmu import zebu as rmu
from rpython.translator.platform import platform
John Zhang's avatar
John Zhang committed
18
from util import fncptr_from_rpy_func, fncptr_from_py_script, may_spawn_proc, bin_dir
qinsoon's avatar
qinsoon committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
import ctypes, py, stat, os
import pytest

from test_rpython import run_boot_image

@may_spawn_proc
def test_RPySOM():
    from som.vm.universe import main, Exit

    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')))

John Zhang's avatar
John Zhang committed
40
    res = run_boot_image(entry_point, str(bin_dir.join('RPySOM-no-jit-mu')),
qinsoon's avatar
qinsoon committed
41 42 43 44
                         args=['-cp', '%(RPYSOM)s/Smalltalk' % locals(),
                               '%(RPYSOM)s/TestSuite/TestHarness.som' % locals()])
    assert res.returncode == 0, res.err
    expected_out = \
Yi Lin's avatar
Yi Lin committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
"""\
Testing...
Running test EmptyTest
Running test SystemTest
Running test ArrayTest
Running test ClassLoadingTest
Running test ClosureTest
Running test CoercionTest
Running test CompilerReturnTest
Running test DoubleTest
Running test HashTest
Running test IntegerTest
Warning: Test instance of IntegerTest failed: Identity failed. Expected: true, but Actual: false
Warning: Test instance of IntegerTest failed: Identity failed. Expected: true, but Actual: false
Running test ObjectSizeTest
Warning: Test instance of ObjectSizeTest failed: Plain object does not have size 1.
Warning: Test instance of ObjectSizeTest failed: Integer object does not have size 1.
Warning: Test instance of ObjectSizeTest failed: hello String object does not have size 1.
Warning: Test instance of ObjectSizeTest failed: Empty array object does not have size 1.
Warning: Test instance of ObjectSizeTest failed: Array object (length 4) does not have size 5.
Running test PreliminaryTest
Running test ReflectionTest
Running test SelfBlockTest
Running test SuperTest
Running test SymbolTest
Running test VectorTest
Running test BlockTest
Running test StringTest
Running test ClassStructureTest
Definition of Class changed. Testcase needs to be updated.
Running test DoesNotUnderstandTest
...done
"""
qinsoon's avatar
qinsoon committed
78
    assert res.out == expected_out