[test] Correctly check bootable ISOs

ISO image without MBR and GPT can still be bootable if it has an El
Torito boot catalog. The test phase must accept such images.

This slightly defeats the point of the check: to verify the ISO is
hybrid. However, based on the metadata we have no way to actually tell
if the image is supposed to be hybrid.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-07-22 13:58:29 +02:00
parent f0dca7687e
commit 22e94caf3c
2 changed files with 26 additions and 7 deletions

View File

@ -127,13 +127,15 @@ def check(compose, variant, arch, image):
deliverable = getattr(image, 'deliverable')
with failable(compose, variant, arch, deliverable, subvariant=image.subvariant):
with open(path) as f:
if image.format == 'iso' and not is_iso(f):
iso = is_iso(f)
if image.format == 'iso' and not iso:
result = False
raise RuntimeError('%s does not look like an ISO file' % path)
if image.bootable and not has_mbr(f) and not has_gpt(f):
if image.bootable and not has_mbr(f) and not has_gpt(f) and not (iso and has_eltorito(f)):
result = False
raise RuntimeError(
'%s is supposed to be bootable, but does not have MBR nor GPT' % path)
'%s is supposed to be bootable, but does not have MBR nor '
'GPT nor is it a bootable ISO' % path)
# If exception is raised above, failable may catch it
return result
@ -154,3 +156,7 @@ def has_mbr(f):
def has_gpt(f):
return _check_magic(f, 0x200, 'EFI PART')
def has_eltorito(f):
return _check_magic(f, 0x8801, 'CD001\1EL TORITO SPECIFICATION')

View File

@ -23,10 +23,12 @@ FAILABLE_CONFIG = {
]
}
UNBOOTABLE_ISO = ('\0' * 0x8001) + 'CD001' + ('\0' * 100)
ISO_WITH_MBR = ('\0' * 0x1fe) + '\x55\xAA' + ('\0' * 0x7e01) + 'CD001' + ('\0' * 100)
ISO_WITH_GPT = ('\0' * 0x200) + 'EFI PART' + ('\0' * 0x7df9) + 'CD001' + ('\0' * 100)
ISO_WITH_MBR_AND_GPT = ('\0' * 0x1fe) + '\x55\xAAEFI PART' + ('\0' * 0x7df9) + 'CD001' + ('\0' * 100)
PAD = '\0' * 100
UNBOOTABLE_ISO = ('\0' * 0x8001) + 'CD001' + PAD
ISO_WITH_MBR = ('\0' * 0x1fe) + '\x55\xAA' + ('\0' * 0x7e01) + 'CD001' + PAD
ISO_WITH_GPT = ('\0' * 0x200) + 'EFI PART' + ('\0' * 0x7df9) + 'CD001' + PAD
ISO_WITH_MBR_AND_GPT = ('\0' * 0x1fe) + '\x55\xAAEFI PART' + ('\0' * 0x7df9) + 'CD001' + PAD
ISO_WITH_TORITO = ('\0' * 0x8001) + 'CD001' + ('\0' * 0x7fa) + '\0CD001\1EL TORITO SPECIFICATION' + PAD
class TestCheckImageSanity(PungiTestCase):
@ -125,6 +127,17 @@ class TestCheckImageSanity(PungiTestCase):
except:
self.fail('Bootable image with MBR and GPT must not raise')
def test_bootable_iso_with_el_torito_does_not_raise(self):
compose = DummyCompose(self.topdir, {})
compose.image.format = 'iso'
compose.image.bootable = True
touch(os.path.join(self.topdir, 'compose', compose.image.path), ISO_WITH_TORITO)
try:
test_phase.check_image_sanity(compose)
except:
self.fail('Bootable image with El Torito must not raise')
def test_checks_with_optional_variant(self):
compose = DummyCompose(self.topdir, {})
compose.variants['Server'].variants = {