Example #1
0
def test_virtualprobe_ap():
    """Test of virtual Debug Probe - Access port control."""
    virtual_probe = DebugProbeVirtual("ID", None)
    with pytest.raises(SPSDKDebugProbeNotOpenError):
        virtual_probe.coresight_reg_read(True, 0)

    with pytest.raises(SPSDKDebugProbeNotOpenError):
        virtual_probe.coresight_reg_write(True, 0, 0)

    virtual_probe.open()

    assert virtual_probe.coresight_reg_read(True, 0) == 0
    virtual_probe.coresight_reg_write(True, 0, 1)
    assert virtual_probe.coresight_reg_read(True, 0) == 1

    virtual_probe.coresight_reg_write(True, 0, 1)
    assert virtual_probe.coresight_reg_read(True, 0) == 1

    virtual_probe.set_coresight_ap_substitute_data(
        {0: [2, 3, "Exception", "Invalid"]})
    assert virtual_probe.coresight_reg_read(True, 0) == 2
    assert virtual_probe.coresight_reg_read(True, 0) == 3
    with pytest.raises(SPSDKDebugProbeError):
        assert virtual_probe.coresight_reg_read(True, 0) == 3
    assert virtual_probe.coresight_reg_read(True, 0) == 1
    assert virtual_probe.coresight_reg_read(True, 0) == 1
Example #2
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
Example #3
0
def test_virtualprobe_dp():
    """Test of virtual Debug Probe - Debug port access."""
    virtual_probe = DebugProbeVirtual("ID", None)
    with pytest.raises(SPSDKDebugProbeNotOpenError):
        virtual_probe.coresight_reg_read(False, 0)
    with pytest.raises(SPSDKDebugProbeNotOpenError):
        virtual_probe.coresight_reg_write(False, 0, 0)
    virtual_probe.open()

    assert virtual_probe.coresight_reg_read(False, 0) == 0
    virtual_probe.coresight_reg_write(False, 0, 1)
    assert virtual_probe.coresight_reg_read(False, 0) == 1

    virtual_probe.coresight_reg_write(False, 0, 1)
    assert virtual_probe.coresight_reg_read(False, 0) == 1

    virtual_probe.set_coresight_dp_substitute_data(
        {0: [2, 3, "Exception", "Invalid"]})
    assert virtual_probe.coresight_reg_read(False, 0) == 2
    assert virtual_probe.coresight_reg_read(False, 0) == 3
    with pytest.raises(SPSDKDebugProbeError):
        assert virtual_probe.coresight_reg_read(False, 0) == 3

    assert virtual_probe.coresight_reg_read(False, 0) == 1
    assert virtual_probe.coresight_reg_read(False, 0) == 1

    virtual_probe.dp_write_cause_exception()

    with pytest.raises(SPSDKDebugProbeTransferError):
        virtual_probe.coresight_reg_write(False, 0, 0)
Example #4
0
def test_virtualprobe_reset():
    """Test of virtual Debug Probe - Reset API."""
    virtual_probe = DebugProbeVirtual("ID", None)
    with pytest.raises(SPSDKDebugProbeNotOpenError):
        virtual_probe.reset()
    virtual_probe.open()
    virtual_probe.reset()
Example #5
0
def test_virtualprobe_dp():
    vp = DebugProbeVirtual("ID", None)
    with pytest.raises(DebugProbeNotOpenError):
        vp.coresight_reg_read(False, 0)
    with pytest.raises(DebugProbeNotOpenError):
        vp.coresight_reg_write(False, 0, 0)
    vp.open()

    assert vp.coresight_reg_read(False, 0) == 0
    vp.coresight_reg_write(False, 0, 1)
    assert vp.coresight_reg_read(False, 0) == 1

    vp.coresight_reg_write(False, 0, 1)
    assert vp.coresight_reg_read(False, 0) == 1

    vp.set_coresight_dp_substitute_data({0: [2, 3, "Exception", "Invalid"]})
    assert vp.coresight_reg_read(False, 0) == 2
    assert vp.coresight_reg_read(False, 0) == 3
    with pytest.raises(DebugProbeError):
        assert vp.coresight_reg_read(False, 0) == 3

    assert vp.coresight_reg_read(False, 0) == 1
    assert vp.coresight_reg_read(False, 0) == 1

    vp.dp_write_cause_exception()

    with pytest.raises(DebugProbeTransferError):
        vp.coresight_reg_write(False, 0, 0)
Example #6
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
Example #7
0
def test_virtualprobe_basic():
    vp = DebugProbeVirtual("ID", None)
    assert vp is not None
    assert vp.hardware_id == "ID"

    assert not vp.opened
    vp.open()
    assert vp.opened
    vp.close()
    assert not vp.opened
Example #8
0
def test_virtualprobe_basic():
    """Test of virtual Debug Probe - Basic Test."""
    virtual_probe = DebugProbeVirtual("ID", None)
    assert virtual_probe is not None
    assert virtual_probe.hardware_id == "ID"

    assert not virtual_probe.opened
    virtual_probe.open()
    assert virtual_probe.opened
    virtual_probe.close()
    assert not virtual_probe.opened
Example #9
0
def test_virtualprobe_debugmbox():
    vp = DebugProbeVirtual("ID", None)
    with pytest.raises(DebugProbeNotOpenError):
        vp.dbgmlbx_reg_read(0)
    with pytest.raises(DebugProbeNotOpenError):
        vp.dbgmlbx_reg_write(0, 0)

    vp.open()

    assert vp.dbgmlbx_reg_read(0) == 0
    vp.dbgmlbx_reg_write(0, 1)
    assert vp.dbgmlbx_reg_read(0) == 1

    vp.dbgmlbx_reg_write(0, 1)
    assert vp.dbgmlbx_reg_read(0) == 1

    vp.set_coresight_ap_substitute_data({0x02000000: [2, 3]})
    assert vp.dbgmlbx_reg_read(0) == 2
    assert vp.dbgmlbx_reg_read(0) == 3
    assert vp.dbgmlbx_reg_read(0) == 1
Example #10
0
def test_virtualprobe_debugmbox():
    """Test of virtual Debug Probe - Debug mailbox API."""
    virtual_probe = DebugProbeVirtual("ID", None)
    with pytest.raises(SPSDKDebugProbeNotOpenError):
        virtual_probe.dbgmlbx_reg_read(0)
    with pytest.raises(SPSDKDebugProbeNotOpenError):
        virtual_probe.dbgmlbx_reg_write(0, 0)

    virtual_probe.open()

    assert virtual_probe.dbgmlbx_reg_read(0) == 0
    virtual_probe.dbgmlbx_reg_write(0, 1)
    assert virtual_probe.dbgmlbx_reg_read(0) == 1

    virtual_probe.dbgmlbx_reg_write(0, 1)
    assert virtual_probe.dbgmlbx_reg_read(0) == 1

    virtual_probe.set_coresight_ap_substitute_data({0x02000000: [2, 3]})
    assert virtual_probe.dbgmlbx_reg_read(0) == 2
    assert virtual_probe.dbgmlbx_reg_read(0) == 3
    assert virtual_probe.dbgmlbx_reg_read(0) == 1
Example #11
0
def get_probe():
    probe = DebugProbeVirtual(DebugProbeVirtual.UNIQUE_SERIAL)
    probe.open()
    probe.enable_memory_interface()
    return probe
Example #12
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
Example #13
0
def test_virtualprobe_reset():
    vp = DebugProbeVirtual("ID", None)
    with pytest.raises(DebugProbeNotOpenError):
        vp.reset()
    vp.open()
    vp.reset()