def test_plain_xip_crc_default_tz(data_dir, input_img, expected_mbi): """Test plain image with CRC and default TZ-M :param data_dir: absolute path, where test data are located :param input_img: file name of input image (binary) :param expected_mbi: file name of MBI image file with expected data """ with open(os.path.join(data_dir, input_img), "rb") as f: org_data = f.read() mbi = MasterBootImage(app=org_data, load_addr=0, image_type=MasterBootImageType.CRC_XIP_IMAGE, trust_zone=TrustZone.enabled()) assert _compare_image(mbi, data_dir, expected_mbi)
def test_plain_xip_crc_default_tz(data_dir, input_img, expected_mbi): """Test plain image with CRC and default TZ-M :param data_dir: absolute path, where test data are located :param input_img: file name of input image (binary) :param expected_mbi: file name of MBI image file with expected data """ with open(os.path.join(data_dir, input_img), "rb") as f: org_data = f.read() mbi = Mbi_CrcXip( app=org_data, trust_zone=TrustZone.enabled(), ) assert _compare_image(mbi, data_dir, expected_mbi)
def test_tz_types(sample_tz_data): # TZ is enabled by default tz = TrustZone() assert tz.type == TrustZoneType.ENABLED tz = TrustZone.enabled() assert tz.type == TrustZoneType.ENABLED tz = TrustZone.disabled() assert tz.type == TrustZoneType.DISABLED tz = TrustZone(family="lpc55xx", customizations=sample_tz_data) assert tz.type == TrustZoneType.CUSTOM tz = TrustZone(family="lpc55xx", customizations=sample_tz_data, tz_type=TrustZoneType.CUSTOM) assert tz.type == TrustZoneType.CUSTOM tz = TrustZone(family="lpc55xx", customizations=sample_tz_data, tz_type=TrustZoneType.ENABLED) assert tz.type == TrustZoneType.CUSTOM tz = TrustZone.custom(family="lpc55xx", customizations=sample_tz_data) assert tz.type == TrustZoneType.CUSTOM assert "TrustZone" in str(tz)
def test_simplified_export(): assert TrustZone().export() == b"" assert TrustZone.enabled().export() == b"" assert TrustZone.disabled().export() == b""