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()
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)
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)])
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)])
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)
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)
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
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
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.