예제 #1
0
def test_virtualprobe_memory():
    """Test of virtual Debug Probe - Memory access tests."""
    virtual_probe = DebugProbeVirtual("ID", None)
    with pytest.raises(SPSDKDebugProbeNotOpenError):
        virtual_probe.mem_reg_read(0)

    with pytest.raises(SPSDKDebugProbeNotOpenError):
        virtual_probe.mem_reg_write(0, 0)

    virtual_probe.open()
    with pytest.raises(SPSDKDebugProbeMemoryInterfaceNotEnabled):
        virtual_probe.mem_reg_read(0)
    with pytest.raises(SPSDKDebugProbeMemoryInterfaceNotEnabled):
        virtual_probe.mem_reg_write(0, 0)

    virtual_probe.enable_memory_interface()

    assert virtual_probe.mem_reg_read(0) == 0
    virtual_probe.mem_reg_write(0, 1)
    assert virtual_probe.mem_reg_read(0) == 1

    virtual_probe.mem_reg_write(0, 1)
    assert virtual_probe.mem_reg_read(0) == 1

    virtual_probe.set_virtual_memory_substitute_data(
        {0: [2, 3, "Exception", "Invalid"]})
    assert virtual_probe.mem_reg_read(0) == 2
    assert virtual_probe.mem_reg_read(0) == 3
    with pytest.raises(SPSDKDebugProbeError):
        assert virtual_probe.mem_reg_read(0) == 3
    assert virtual_probe.mem_reg_read(0) == 1
    assert virtual_probe.mem_reg_read(0) == 1
예제 #2
0
def test_virtualprobe_memory():
    vp = DebugProbeVirtual("ID", None)
    with pytest.raises(DebugProbeNotOpenError):
        vp.mem_reg_read(0)

    with pytest.raises(DebugProbeNotOpenError):
        vp.mem_reg_write(0, 0)

    vp.open()
    with pytest.raises(DebugProbeMemoryInterfaceNotEnabled):
        vp.mem_reg_read(0)
    with pytest.raises(DebugProbeMemoryInterfaceNotEnabled):
        vp.mem_reg_write(0, 0)

    vp.enable_memory_interface()

    assert vp.mem_reg_read(0) == 0
    vp.mem_reg_write(0, 1)
    assert vp.mem_reg_read(0) == 1

    vp.mem_reg_write(0, 1)
    assert vp.mem_reg_read(0) == 1

    vp.set_virtual_memory_substitute_data({0: [2, 3, "Exception", "Invalid"]})
    assert vp.mem_reg_read(0) == 2
    assert vp.mem_reg_read(0) == 3
    with pytest.raises(DebugProbeError):
        assert vp.mem_reg_read(0) == 3
    assert vp.mem_reg_read(0) == 1
    assert vp.mem_reg_read(0) == 1
예제 #3
0
def get_probe():
    probe = DebugProbeVirtual(DebugProbeVirtual.UNIQUE_SERIAL)
    probe.open()
    probe.enable_memory_interface()
    return probe
예제 #4
0
def get_probe():
    """Help function to get Probe - used in tests."""
    probe = DebugProbeVirtual(DebugProbeVirtual.UNIQUE_SERIAL)
    probe.open()
    probe.enable_memory_interface()
    return probe