def test_ivt2_export_parse(): ivt2 = SegIVT2(0x41) ivt2.ivt_address = 0x877FF400 ivt2.bdt_address = 0x877FF420 ivt2.dcd_address = 0x877FF42C ivt2.app_address = 0x87800000 ivt2.csf_address = 0 data = ivt2.export() ivt2_parsed = SegIVT2.parse(data) assert ivt2 == ivt2_parsed # with padding data = ivt2.export() ivt2_parsed = SegIVT2.parse(data) assert ivt2 == ivt2_parsed
def test_bdt_eq_repr(): bdt = SegBDT() bdt_other = SegBDT(0x555) ivt2 = SegIVT2(0x41) output = repr(bdt) repr_strings = ["BDT", "LEN", "Plugin:"] for req_string in repr_strings: assert req_string in output, f'string {req_string} is not in the output: {output}' assert bdt != bdt_other assert bdt != ivt2
def test_ivt2_validate(): ivt2 = SegIVT2(0x41) # set incorrect values ivt2.ivt_address = 0x877FF42C ivt2.dcd_address = 0x877FF400 ivt2.bdt_address = 0x877FF42E with pytest.raises(ValueError): ivt2.validate() ivt2.csf_address = 0x877FF000 ivt2.dcd_address = 0x877FF500 with pytest.raises(ValueError): ivt2.validate() ivt2.padding = 1 ivt2.csf_address = 0x877FF600 with pytest.raises(ValueError): ivt2.validate()
def test_ivt2_segment_api(): ivt2 = SegIVT2(0x41) assert ivt2.version == 0x41 assert ivt2.ivt_address == 0 assert ivt2.bdt_address == 0 assert ivt2.dcd_address == 0 assert ivt2.app_address == 0 assert ivt2.csf_address == 0 with pytest.raises(ValueError): _ = ivt2.export() # set correct values ivt2.ivt_address = 0x877FF400 ivt2.bdt_address = 0x877FF420 ivt2.dcd_address = 0x877FF42C ivt2.app_address = 0x87800000 ivt2.csf_address = 0 ivt2.version = 0x44 assert ivt2._header.param == 0x44
def test_ivt2_equality(): ivt2 = SegIVT2(0x41) ivt2_other = SegIVT2(0x40) ivt3a = SegIVT3a(0x41) assert ivt2 != ivt3a assert ivt2 != ivt2_other
def test_ivt2_repr(): ivt2 = SegIVT2(0x41) output = repr(ivt2) repr_strings = ["BDT", "IVT2", "DCD", "APP", "CSF"] for req_string in repr_strings: assert req_string in output, f'string {req_string} is not in the output: {output}'
def test_ivt2_invalid_version(): ivt2 = SegIVT2(0x41) with pytest.raises(SPSDKError, match="Invalid version of IVT and image format"): ivt2.version = 0x39