コード例 #1
0
ファイル: test_commands_api.py プロジェクト: mstarecek/spsdk
def test_load_cmd_preexisting():
    data = (b"\x1c\x02\x00\x00\n\x00\x00\x00\x10\x00\x00\x00_3<\xd8"
            b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\xbb\xffT\x0f+r")
    cmd = parse_command(data)
    assert isinstance(cmd, CmdLoad)
    assert cmd.address == 10
    assert cmd.data[:10] == bytes(range(10))
コード例 #2
0
ファイル: test_commands_api.py プロジェクト: mstarecek/spsdk
def test_tag_cmd():
    cmd = CmdTag()
    assert cmd.info()

    data = cmd.export()
    assert len(data) == 16
    assert len(data) == cmd.raw_size

    cmd_parsed = parse_command(data)
    assert cmd == cmd_parsed
コード例 #3
0
ファイル: test_commands_api.py プロジェクト: mstarecek/spsdk
def test_fill_cmd_length_not_defined():
    cmd = CmdFill(address=100, pattern=16909060)
    assert cmd.address == 100
    assert cmd.pattern == b"\x01\x02\x03\x04"

    data = cmd.export()
    assert len(data) == 16
    assert len(data) == cmd.raw_size

    cmd_parsed = parse_command(data)
    assert cmd == cmd_parsed
コード例 #4
0
ファイル: test_commands_api.py プロジェクト: mstarecek/spsdk
def test_fill_cmd_half_word():
    cmd = CmdFill(address=100, pattern=258, length=12)
    assert cmd.address == 100
    assert cmd.pattern == b"\x01\x02\x01\x02"

    data = cmd.export()
    assert len(data) == 16
    assert len(data) == cmd.raw_size

    cmd_parsed = parse_command(data)
    assert cmd == cmd_parsed
コード例 #5
0
ファイル: test_commands_api.py プロジェクト: mstarecek/spsdk
def test_call_cmd():
    cmd = CmdCall(address=100, argument=10)
    assert cmd.address == 100
    assert cmd.argument == 10
    assert cmd.info()

    data = cmd.export()
    assert len(data) == 16
    assert len(data) == cmd.raw_size

    cmd_parsed = parse_command(data)
    assert cmd == cmd_parsed
コード例 #6
0
ファイル: test_commands_api.py プロジェクト: mstarecek/spsdk
def test_mem_enable_cmd():
    cmd = CmdMemEnable(address=100, size=10, mem_type=ExtMemId.MMC_CARD)
    assert cmd.address == 100
    assert cmd.size == 10
    assert cmd.mem_type == ExtMemId.MMC_CARD
    assert cmd.info()

    data = cmd.export()
    assert len(data) == 16
    assert len(data) == cmd.raw_size

    cmd_parsed = parse_command(data)
    assert cmd == cmd_parsed
コード例 #7
0
ファイル: test_commands_api.py プロジェクト: mstarecek/spsdk
def test_erase_cmd():
    cmd = CmdErase(address=100, length=10, flags=0)
    assert cmd.address == 100
    assert cmd.length == 10
    assert cmd.flags == 0
    assert cmd.info()

    data = cmd.export()
    assert len(data) == 16
    assert len(data) == cmd.raw_size

    cmd_parsed = parse_command(data)
    assert cmd == cmd_parsed
コード例 #8
0
ファイル: test_commands_api.py プロジェクト: mstarecek/spsdk
def test_jump_cmd():
    cmd = CmdJump(address=100, argument=10, spreg=None)
    assert cmd.address == 100
    assert cmd.argument == 10
    assert cmd.spreg is None
    assert cmd.info()

    data = cmd.export()
    assert len(data) == 16
    assert len(data) == cmd.raw_size

    cmd_parsed = parse_command(data)
    assert cmd == cmd_parsed
コード例 #9
0
ファイル: test_commands_api.py プロジェクト: mstarecek/spsdk
def test_keystore_restore():
    """Test SB command `CmdKeyStoreRestore`"""
    cmd = CmdKeyStoreRestore(1000, 1)
    assert cmd.info()

    data = cmd.export()
    assert len(data) == 16
    assert len(data) == cmd.raw_size

    cmd_parsed = parse_command(data)
    assert cmd == cmd_parsed

    assert cmd.address == 1000
    assert cmd.controller_id == 1
コード例 #10
0
ファイル: test_commands_api.py プロジェクト: mstarecek/spsdk
def test_version_check():
    """Test SB command `CmdVersionCheck`"""
    cmd = CmdVersionCheck(VersionCheckType.NON_SECURE_VERSION, 0x16)
    assert cmd.info()

    data = cmd.export()
    assert len(data) == 16
    assert len(data) == cmd.raw_size

    cmd_parsed = parse_command(data)
    assert cmd == cmd_parsed

    assert cmd.version == 0x16
    assert cmd.type == VersionCheckType.NON_SECURE_VERSION
コード例 #11
0
ファイル: test_commands_api.py プロジェクト: mstarecek/spsdk
def test_load_cmd():
    cmd = CmdLoad(address=100, data=b"\x00" * 100)
    assert cmd.address == 100
    assert cmd.data == bytearray([0] * 100)
    assert cmd.info()

    cmd.data = cmd.data + b"\x10"
    assert len(cmd.data) == 101

    data = cmd.export()
    assert len(data) == 128
    assert len(data) == cmd.raw_size

    cmd_parsed = parse_command(data)
    assert cmd == cmd_parsed
コード例 #12
0
ファイル: test_commands_api.py プロジェクト: mstarecek/spsdk
def test_parse_invalid_command_tag():
    with pytest.raises(SPSDKError):
        parse_command(b"\xEE" * 16)