예제 #1
0
def test_checkdata_export_parse():
    cmd = CmdCheckData(ops=EnumCheckOps.ANY_CLEAR,
                       address=0,
                       mask=0x00000001,
                       count=5)
    data = cmd.export()
    assert len(data) == 16
    assert cmd == CmdCheckData.parse(data)
예제 #2
0
파일: test_csf.py 프로젝트: vhamersky/spsdk
def test_SegCSF_append():
    csf_seg = SegCSF()
    csf_seg.append_command(
        CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                     address=0x307900C4,
                     mask=0x00000001))
    assert len(csf_seg) == 1
    csf_seg.append_command(
        CmdCheckData(ops=EnumCheckOps.ANY_SET,
                     address=0x307900C4,
                     mask=0x00000001))
    assert len(csf_seg) == 2
예제 #3
0
def dcd_in_python() -> SegDCD:
    """Create DCD in python code."""
    dcd = SegDCD(enabled=True)
    dcd.append(
        CmdWriteData(
            ops=EnumWriteOps.WRITE_VALUE,
            data=(
                (0x30340004, 0x4F400005),
                (0x30340004, 0x4F400005),
                (0x30340004, 0x4F400005),
                (0x30340004, 0x4F400005),
            ),
        ))
    dcd.append(
        CmdWriteData(ops=EnumWriteOps.CLEAR_BITMASK,
                     data=((0x307900C4, 0x00000001), )))
    dcd.append(
        CmdWriteData(ops=EnumWriteOps.SET_BITMASK,
                     data=((0x307900C4, 0x00000001), )))
    dcd.append(
        CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                     address=0x307900C4,
                     mask=0x00000001))
    dcd.append(
        CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                     address=0x307900C4,
                     mask=0x00000001,
                     count=5))
    dcd.append(
        CmdCheckData(ops=EnumCheckOps.ANY_CLEAR,
                     address=0x307900C4,
                     mask=0x00000001))
    dcd.append(
        CmdCheckData(ops=EnumCheckOps.ANY_CLEAR,
                     address=0x307900C4,
                     mask=0x00000001,
                     count=5))
    dcd.append(
        CmdCheckData(ops=EnumCheckOps.ALL_SET,
                     address=0x307900C4,
                     mask=0x00000001))
    dcd.append(
        CmdCheckData(ops=EnumCheckOps.ALL_SET,
                     address=0x307900C4,
                     mask=0x00000001,
                     count=5))
    dcd.append(
        CmdCheckData(ops=EnumCheckOps.ANY_SET,
                     address=0x307900C4,
                     mask=0x00000001))
    dcd.append(
        CmdCheckData(ops=EnumCheckOps.ANY_SET,
                     address=0x307900C4,
                     mask=0x00000001,
                     count=5))
    dcd.append(CmdNop())
    return dcd
예제 #4
0
def ref_csf_obj():
    # Prepare reference CSF object
    obj = SegCSF(enabled=True)
    obj.append_command(CmdWriteData(ops=EnumWriteOps.WRITE_VALUE, data=((0x30340004, 0x4F400005),)))
    obj.append_command(
        CmdCheckData(ops=EnumCheckOps.ALL_CLEAR, address=0x307900C4, mask=0x00000001, count=10)
    )
    return obj
예제 #5
0
def test_checkdata_invalid():
    cmd = CmdCheckData()
    with pytest.raises(SPSDKError):
        cmd.num_bytes = 6
    with pytest.raises(SPSDKError):
        cmd.ops = 99
    with pytest.raises(SPSDKError):
        cmd = CmdCheckData(numbytes=8)
    with pytest.raises(SPSDKError):
        cmd = CmdCheckData(ops=80)
예제 #6
0
파일: test_dcd.py 프로젝트: vhamersky/spsdk
def test_segDCD_set_get_iter():
    dcd_seg = SegDCD(0x40)
    dcd_seg.append(
        CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                     address=0x307900C4,
                     mask=0x00000001))
    dcd_seg.append(CmdNop())
    dcd_seg[1] = CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                              address=0x307900C4,
                              mask=0x00000001)
    assert dcd_seg[1] == CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                                      address=0x307900C4,
                                      mask=0x00000001)
    dcd_seg.append(
        CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                     address=0x307900C4,
                     mask=0x00000001))
    my_iter = iter(dcd_seg)
    assert next(my_iter) == CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                                         address=0x307900C4,
                                         mask=0x00000001)
    assert next(my_iter) == CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                                         address=0x307900C4,
                                         mask=0x00000001)
    assert next(my_iter) == CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                                         address=0x307900C4,
                                         mask=0x00000001)
    with pytest.raises(StopIteration):
        next(my_iter)
예제 #7
0
def test_checkdata_cmd_basic():
    cmd = CmdCheckData(ops=EnumCheckOps.ANY_CLEAR,
                       address=0,
                       mask=0x00000001,
                       count=5)
    assert cmd.num_bytes == 4
    assert cmd.ops == EnumCheckOps.ANY_CLEAR
    assert cmd.address == 0
    assert cmd.mask == 0x00000001
    assert cmd.count == 5

    assert cmd._header.param == 20
    cmd.num_bytes = 1
    assert cmd._header.param == 17

    cmd.ops = EnumCheckOps.ALL_CLEAR
    assert cmd._header.param == 1

    assert "CmdCheckData " in repr(cmd)
예제 #8
0
파일: test_csf.py 프로젝트: vhamersky/spsdk
def test_segCSF_clear():
    csf_seg = SegCSF(0x40)
    csf_seg.append_command(
        CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                     address=0x307900C4,
                     mask=0x00000001))
    assert csf_seg._header.length == 16
    assert csf_seg._header.size == 4
    csf_seg.clear_commands()
    assert csf_seg._header.length == 4
    assert csf_seg._header.size == 4
예제 #9
0
파일: test_dcd.py 프로젝트: vhamersky/spsdk
def test_segDCD_pop_append():
    dcd_seg = SegDCD(0x40)
    dcd_seg.append(
        CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                     address=0x307900C4,
                     mask=0x00000001))
    dcd_seg.append(CmdNop())
    output = dcd_seg.pop(1)
    assert "Command \"No Operation" in output.info()
    output = dcd_seg.pop(0)
    assert "Command \"Check Data" in output.info()
예제 #10
0
def ref_dcd_obj():
    # Prepare reference DCD object
    obj = SegDCD(enabled=True)
    obj.append(
        CmdWriteData(
            ops=EnumWriteOps.WRITE_VALUE,
            data=[(0x400FC010, 0x4F400005), (0x400FC010, 0x4F463645), (0x400FC010, 0xA54EF14A)],
        )
    )
    obj.append(
        CmdWriteData(
            ops=EnumWriteOps.WRITE_CLEAR_BITS,
            data=[(0x402F0008, 0x00000001), (0x402F0008, 0x00000002), (0x402F0008, 0x00000003)],
        )
    )
    obj.append(
        CmdWriteData(
            ops=EnumWriteOps.SET_BITMASK,
            data=[(0x400D8158, 0x00000009), (0x400D8158, 0x0000000A), (0x400D8158, 0x000000B4)],
        )
    )
    obj.append(
        CmdCheckData(ops=EnumCheckOps.ALL_CLEAR, address=0x401F83F4, mask=0x000000AF, count=5)
    )
    obj.append(CmdCheckData(ops=EnumCheckOps.ALL_CLEAR, address=0x401F83F4, mask=0x000000A1))
    obj.append(
        CmdCheckData(ops=EnumCheckOps.ANY_CLEAR, address=0x400D8150, mask=0x000000FF, count=3)
    )
    obj.append(CmdCheckData(ops=EnumCheckOps.ANY_CLEAR, address=0x400D8150, mask=0x00000004))
    obj.append(CmdCheckData(ops=EnumCheckOps.ALL_SET, address=0x402F0008, mask=0x00000006))
    obj.append(CmdCheckData(ops=EnumCheckOps.ALL_SET, address=0x402F0008, mask=0x00000AF3, count=2))
    obj.append(CmdCheckData(ops=EnumCheckOps.ANY_SET, address=0x400D8158, mask=0x00000009))
    obj.append(CmdCheckData(ops=EnumCheckOps.ANY_SET, address=0x400D8158, mask=0xB00E60E1))
    obj.append(CmdCheckData(ops=EnumCheckOps.ANY_CLEAR, address=0x400D8158, mask=0x000F00A2))
    obj.append(CmdCheckData(ops=EnumCheckOps.ANY_CLEAR, address=0x400D8158, mask=0xA00F60C1))
    obj.append(CmdWriteData(ops=EnumWriteOps.WRITE_CLEAR_BITS, data=[(0x401F8400, 0x00000001)]))
    obj.append(CmdWriteData(ops=EnumWriteOps.SET_BITMASK, data=[(0x401F8400, 0x00000000)]))
    obj.append(CmdWriteData(ops=EnumWriteOps.WRITE_CLEAR_BITS, data=[(0x401F8400, 0x00000000)]))
    obj.append(CmdWriteData(ops=EnumWriteOps.SET_BITMASK, data=[(0x401F8400, 0x00000001)]))
    obj.append(CmdNop())
    return obj
예제 #11
0
파일: test_dcd.py 프로젝트: vhamersky/spsdk
def test_segDCD_clear():
    dcd_seg = SegDCD(0x40)
    dcd_seg.append(
        CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                     address=0x307900C4,
                     mask=0x00000001))
    assert len(dcd_seg) == len(dcd_seg._commands)
    assert dcd_seg._header.length == 16
    assert dcd_seg._header.size == 4
    dcd_seg.clear()
    assert dcd_seg._header.length == 4
    assert dcd_seg._header.size == 4
예제 #12
0
파일: test_csf.py 프로젝트: vhamersky/spsdk
def test_SegCSF_get_set_iter():
    csf_seg = SegCSF()
    csf_seg.append_command(
        CmdCheckData(ops=EnumCheckOps.ALL_CLEAR,
                     address=0x307900C4,
                     mask=0x00000001))
    csf_seg.append_command(
        CmdCheckData(ops=EnumCheckOps.ANY_SET,
                     address=0x307900C4,
                     mask=0x00000001))
    csf_seg[0] = CmdCheckData(ops=EnumCheckOps.ALL_SET,
                              address=0x307900C4,
                              mask=0x00000001)
    assert csf_seg[0] == CmdCheckData(ops=EnumCheckOps.ALL_SET,
                                      address=0x307900C4,
                                      mask=0x00000001)
    my_iter = iter(csf_seg)
    assert next(my_iter) == CmdCheckData(ops=EnumCheckOps.ALL_SET,
                                         address=0x307900C4,
                                         mask=0x00000001)
    assert next(my_iter) == CmdCheckData(ops=EnumCheckOps.ANY_SET,
                                         address=0x307900C4,
                                         mask=0x00000001)
    with pytest.raises(StopIteration):
        next(my_iter)
예제 #13
0
def test_checkdata_info():
    cmd = CmdCheckData(count=1)
    assert "Count: " in cmd.info()