Example #1
0
def test_unimpl():
    """Check that the unimpl instruction throws a NotImplementedError.
    """
    elf_filename = os.path.join(elf_dir, 'unimpl.elf')
    with pytest.raises(NotImplementedError):
        epiphany = Epiphany()
        with open(elf_filename, 'rb') as elf:
            epiphany.init_state(elf, elf_filename, '', [], False, is_test=True)
            epiphany.run()
Example #2
0
def test_elf(elf, expected):
    """Test ELF files that deal in unsigned integers (rather than floats).
    """
    elf_filename = os.path.join(elf_dir, elf)
    epiphany = Epiphany()
    with open(elf_filename, 'rb') as elf:
        epiphany.init_state(elf, elf_filename, '', [], False, is_test=True)
        epiphany.max_insts = 10000
        epiphany.run()
        expected.check(epiphany.state)
Example #3
0
def test_store(elf, expected):
    """Test ELF files that transfer data from registers to memory.
    """
    elf_filename = os.path.join(elf_dir, elf)
    epiphany = Epiphany()
    with open(elf_filename, 'rb') as elf:
        epiphany.init_state(elf, elf_filename, '', [], False, is_test=True)
        epiphany.max_insts = 10000
        epiphany.run()
        expected.check(epiphany.state, memory=[(0x00100004, 4, 0xFFFFFFFF)])
Example #4
0
def test_testset32():
    elf_filename = os.path.join(elf_dir, 'testset.elf')
    epiphany = Epiphany()
    with open(elf_filename, 'rb') as elf:
        if elf == 'movts.elf': print 'MOVTS'
        epiphany.init_state(elf, elf_filename, '', [], False, is_test=True)
        epiphany.state.mem.write(0x100004, 4, 0x0)
        epiphany.max_insts = 100000
        epiphany.run()
        expected = StateChecker(AZ=1, rf0=0, rf1=0x100000, rf2=0x4)
        expected.check(epiphany.state, memory=[(0x100004, 4, 0xFFFF)])
Example #5
0
def test_load(elf, expected):
    """Test ELF files that load values from memory into a register.
    """
    elf_filename = os.path.join(elf_dir, elf)
    epiphany = Epiphany()
    with open(elf_filename, 'rb') as elf:
        epiphany.init_state(elf, elf_filename, '', [], False, is_test=True)
        epiphany.state.mem.write(0x00100004, 4, 0xFFFFFFFF)
        epiphany.max_insts = 10000
        epiphany.run()
        expected.check(epiphany.state)
Example #6
0
def test_fp_elf(elf, expected):
    """Check that floating point instructions operate correctly.
    These ELF files are tested separately using the fp_check method.
    This means that test failures will be reported so that the contents of
    registers are printed as floats, rather than as unsigned integers.
    """
    elf_filename = os.path.join(elf_dir, elf)
    epiphany = Epiphany()
    with open(elf_filename, 'rb') as elf:
        epiphany.init_state(elf, elf_filename, '', [], False, is_test=True)
        epiphany.max_insts = 10000
        epiphany.run()
        expected.fp_check(epiphany.state)
Example #7
0
def test_compiled_c(elf_file, expected, capsys):
    """Test an ELF file that has been compiled from a C function.
    This test checks that the correct number of instructions have been executed.
    """
    elf_filename = os.path.join(elf_dir, elf_file)
    epiphany = Epiphany()
    with open(elf_filename, 'rb') as elf:
        epiphany.init_state(elf, elf_filename, '', [], False, is_test=True)
        epiphany.max_insts = 10000
        epiphany.run()
        out, err = capsys.readouterr()
        expected_text = 'Instructions Executed = ' + str(expected)
        assert expected_text in out
        assert err == ''
        assert not epiphany.state.running
Example #8
0
def test_testset32_fail():
    """Check that the testset32 instruction fails if the memory address it
    is given is too low..
    """
    elf_filename = os.path.join(elf_dir, 'testset_fail.elf')
    expected_text = """testset32 has failed to write to address %s.
The absolute address used for the test and set instruction must be located
within the on-chip local memory and must be greater than 0x00100000 (2^20).
""" % str(hex(0x4))
    with pytest.raises(ValueError) as expected_exn:
        epiphany = Epiphany()
        with open(elf_filename, 'rb') as elf:
            epiphany.init_state(elf, elf_filename, '', [], False, is_test=True)
            epiphany.max_insts = 100000
            epiphany.run()
    assert expected_text == expected_exn.value.message
Example #9
0
def test_execute_idle16(capsys):
    """Check that the idle16 prints out the correct warning on STDOUT.
    """
    elf_filename = os.path.join(elf_dir, 'idle.elf')
    epiphany = Epiphany()
    with open(elf_filename, 'rb') as elf:
        epiphany.init_state(elf, elf_filename, '', [], False, is_test=True)
        epiphany.state.rfSTATUS = 1
        epiphany.max_insts = 10000
        epiphany.run()
        out, err = capsys.readouterr()
        expected_state = StateChecker(rfSTATUS=0)
        expected_text = ('IDLE16 does not wait in this simulator. ' +
                         'Moving to next instruction.')
        expected_state.check(epiphany.state)
        assert expected_text in out
        assert err == ''
        assert not epiphany.state.running  # Set by bkpt16 instruction.
Example #10
0
 def __init__(self):
     Epiphany.__init__(self)
     self.debug = Debug()
     Debug.global_enabled = True