2016-04-04 13:49:30 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import mock
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
|
|
|
|
|
|
|
from tests import helpers
|
|
|
|
from pungi import createiso
|
|
|
|
|
|
|
|
|
2016-04-28 21:27:19 +00:00
|
|
|
class CreateIsoScriptTest(helpers.PungiTestCase):
|
2016-04-04 13:49:30 +00:00
|
|
|
|
|
|
|
def assertEqualCalls(self, actual, expected):
|
|
|
|
self.assertEqual(len(actual), len(expected))
|
|
|
|
for x, y in zip(actual, expected):
|
|
|
|
self.assertEqual(x, y)
|
|
|
|
|
2016-04-14 08:14:51 +00:00
|
|
|
def setUp(self):
|
2016-04-28 21:27:19 +00:00
|
|
|
super(CreateIsoScriptTest, self).setUp()
|
2016-04-14 08:14:51 +00:00
|
|
|
self.outdir = os.path.join(self.topdir, 'isos')
|
|
|
|
|
2016-04-04 13:49:30 +00:00
|
|
|
@mock.patch('kobo.shortcuts.run')
|
|
|
|
def test_minimal_run(self, run):
|
|
|
|
createiso.main([
|
2016-05-25 11:37:39 +00:00
|
|
|
'--output-dir=%s' % self.outdir,
|
2016-04-04 13:49:30 +00:00
|
|
|
'--iso-name=DP-1.0-20160405.t.3-x86_64.iso',
|
|
|
|
'--volid=DP-1.0-20160405.t.3',
|
|
|
|
'--graft-points=graft-list',
|
|
|
|
'--arch=x86_64',
|
|
|
|
])
|
|
|
|
self.maxDiff = None
|
|
|
|
self.assertEqual(
|
|
|
|
run.call_args_list,
|
|
|
|
[mock.call(['/usr/bin/genisoimage', '-untranslated-filenames',
|
|
|
|
'-volid', 'DP-1.0-20160405.t.3', '-J', '-joliet-long',
|
|
|
|
'-rational-rock', '-translation-table',
|
|
|
|
'-input-charset', 'utf-8', '-x', './lost+found',
|
|
|
|
'-o', 'DP-1.0-20160405.t.3-x86_64.iso',
|
|
|
|
'-graft-points', '-path-list', 'graft-list'],
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
2016-04-04 13:49:30 +00:00
|
|
|
mock.call(['/usr/bin/implantisomd5', 'DP-1.0-20160405.t.3-x86_64.iso'],
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
2016-04-04 13:49:30 +00:00
|
|
|
mock.call('isoinfo -R -f -i DP-1.0-20160405.t.3-x86_64.iso | grep -v \'/TRANS.TBL$\' | sort >> DP-1.0-20160405.t.3-x86_64.iso.manifest',
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir)]
|
2016-04-04 13:49:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
@mock.patch('kobo.shortcuts.run')
|
|
|
|
def test_bootable_run(self, run):
|
|
|
|
run.return_value = (0, '/usr/share/lorax')
|
|
|
|
|
|
|
|
createiso.main([
|
2016-05-25 11:37:39 +00:00
|
|
|
'--output-dir=%s' % self.outdir,
|
2016-04-04 13:49:30 +00:00
|
|
|
'--iso-name=DP-1.0-20160405.t.3-x86_64.iso',
|
|
|
|
'--volid=DP-1.0-20160405.t.3',
|
|
|
|
'--graft-points=graft-list',
|
|
|
|
'--arch=x86_64',
|
|
|
|
'--buildinstall-method=lorax',
|
|
|
|
])
|
|
|
|
|
|
|
|
self.maxDiff = None
|
|
|
|
self.assertItemsEqual(
|
|
|
|
run.call_args_list,
|
|
|
|
[mock.call(['/usr/bin/genisoimage', '-untranslated-filenames',
|
|
|
|
'-volid', 'DP-1.0-20160405.t.3', '-J', '-joliet-long',
|
|
|
|
'-rational-rock', '-translation-table',
|
|
|
|
'-input-charset', 'utf-8', '-x', './lost+found',
|
|
|
|
'-b', 'isolinux/isolinux.bin', '-c', 'isolinux/boot.cat',
|
|
|
|
'-no-emul-boot',
|
|
|
|
'-boot-load-size', '4', '-boot-info-table',
|
|
|
|
'-eltorito-alt-boot', '-e', 'images/efiboot.img',
|
|
|
|
'-no-emul-boot',
|
|
|
|
'-o', 'DP-1.0-20160405.t.3-x86_64.iso',
|
|
|
|
'-graft-points', '-path-list', 'graft-list'],
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
2016-04-04 13:49:30 +00:00
|
|
|
mock.call(['pungi-pylorax-find-templates', '/usr/share/lorax'],
|
|
|
|
show_cmd=True, stdout=True),
|
2016-04-28 21:27:19 +00:00
|
|
|
mock.call(['/usr/bin/isohybrid', '--uefi', 'DP-1.0-20160405.t.3-x86_64.iso'],
|
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
2016-04-04 13:49:30 +00:00
|
|
|
mock.call(['/usr/bin/implantisomd5', 'DP-1.0-20160405.t.3-x86_64.iso'],
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
2016-04-04 13:49:30 +00:00
|
|
|
mock.call('isoinfo -R -f -i DP-1.0-20160405.t.3-x86_64.iso | grep -v \'/TRANS.TBL$\' | sort >> DP-1.0-20160405.t.3-x86_64.iso.manifest',
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir)]
|
2016-04-04 13:49:30 +00:00
|
|
|
)
|
|
|
|
|
2016-04-28 21:27:19 +00:00
|
|
|
@mock.patch('kobo.shortcuts.run')
|
|
|
|
def test_bootable_run_on_i386(self, run):
|
|
|
|
# This will call isohybrid, but not with --uefi switch
|
|
|
|
run.return_value = (0, '/usr/share/lorax')
|
|
|
|
|
|
|
|
createiso.main([
|
2016-05-25 11:37:39 +00:00
|
|
|
'--output-dir=%s' % self.outdir,
|
2016-04-28 21:27:19 +00:00
|
|
|
'--iso-name=DP-1.0-20160405.t.3-i386.iso',
|
|
|
|
'--volid=DP-1.0-20160405.t.3',
|
|
|
|
'--graft-points=graft-list',
|
|
|
|
'--arch=i386',
|
|
|
|
'--buildinstall-method=lorax',
|
|
|
|
])
|
|
|
|
|
|
|
|
self.maxDiff = None
|
|
|
|
self.assertItemsEqual(
|
|
|
|
run.call_args_list,
|
|
|
|
[mock.call(['/usr/bin/genisoimage', '-untranslated-filenames',
|
|
|
|
'-volid', 'DP-1.0-20160405.t.3', '-J', '-joliet-long',
|
|
|
|
'-rational-rock', '-translation-table',
|
|
|
|
'-input-charset', 'utf-8', '-x', './lost+found',
|
|
|
|
'-b', 'isolinux/isolinux.bin', '-c', 'isolinux/boot.cat',
|
|
|
|
'-no-emul-boot',
|
|
|
|
'-boot-load-size', '4', '-boot-info-table',
|
|
|
|
'-o', 'DP-1.0-20160405.t.3-i386.iso',
|
|
|
|
'-graft-points', '-path-list', 'graft-list'],
|
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
|
|
|
mock.call(['pungi-pylorax-find-templates', '/usr/share/lorax'],
|
|
|
|
show_cmd=True, stdout=True),
|
|
|
|
mock.call(['/usr/bin/isohybrid', 'DP-1.0-20160405.t.3-i386.iso'],
|
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
|
|
|
mock.call(['/usr/bin/implantisomd5', 'DP-1.0-20160405.t.3-i386.iso'],
|
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
|
|
|
mock.call('isoinfo -R -f -i DP-1.0-20160405.t.3-i386.iso | grep -v \'/TRANS.TBL$\' | sort >> DP-1.0-20160405.t.3-i386.iso.manifest',
|
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir)]
|
|
|
|
)
|
|
|
|
|
2016-04-04 13:49:30 +00:00
|
|
|
@mock.patch('kobo.shortcuts.run')
|
|
|
|
def test_bootable_run_ppc64(self, run):
|
|
|
|
run.return_value = (0, '/usr/share/lorax')
|
|
|
|
|
|
|
|
createiso.main([
|
2016-05-25 11:37:39 +00:00
|
|
|
'--output-dir=%s' % self.outdir,
|
2016-04-04 13:49:30 +00:00
|
|
|
'--iso-name=DP-1.0-20160405.t.3-ppc64.iso',
|
|
|
|
'--volid=DP-1.0-20160405.t.3',
|
|
|
|
'--graft-points=graft-list',
|
|
|
|
'--arch=ppc64',
|
|
|
|
'--buildinstall-method=lorax',
|
|
|
|
])
|
|
|
|
|
|
|
|
self.maxDiff = None
|
|
|
|
self.assertItemsEqual(
|
|
|
|
run.call_args_list,
|
|
|
|
[mock.call(['/usr/bin/genisoimage', '-untranslated-filenames',
|
|
|
|
'-volid', 'DP-1.0-20160405.t.3', '-J', '-joliet-long',
|
|
|
|
'-rational-rock', '-translation-table',
|
|
|
|
'-x', './lost+found',
|
|
|
|
'-part', '-hfs', '-r', '-l', '-sysid', 'PPC', '-no-desktop',
|
|
|
|
'-allow-multidot', '-chrp-boot', '-map', '/usr/share/lorax/config_files/ppc/mapping',
|
|
|
|
'-hfs-bless', '/ppc/mac',
|
|
|
|
'-o', 'DP-1.0-20160405.t.3-ppc64.iso',
|
|
|
|
'-graft-points', '-path-list', 'graft-list'],
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
2016-04-04 13:49:30 +00:00
|
|
|
mock.call(['pungi-pylorax-find-templates', '/usr/share/lorax'],
|
|
|
|
show_cmd=True, stdout=True),
|
|
|
|
mock.call(['/usr/bin/implantisomd5', 'DP-1.0-20160405.t.3-ppc64.iso'],
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
2016-04-04 13:49:30 +00:00
|
|
|
mock.call('isoinfo -R -f -i DP-1.0-20160405.t.3-ppc64.iso | grep -v \'/TRANS.TBL$\' | sort >> DP-1.0-20160405.t.3-ppc64.iso.manifest',
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir)]
|
2016-04-04 13:49:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
@mock.patch('kobo.shortcuts.run')
|
|
|
|
def test_bootable_run_buildinstall(self, run):
|
|
|
|
createiso.main([
|
2016-05-25 11:37:39 +00:00
|
|
|
'--output-dir=%s' % self.outdir,
|
2016-04-04 13:49:30 +00:00
|
|
|
'--iso-name=DP-1.0-20160405.t.3-ppc64.iso',
|
|
|
|
'--volid=DP-1.0-20160405.t.3',
|
|
|
|
'--graft-points=graft-list',
|
|
|
|
'--arch=ppc64',
|
|
|
|
'--buildinstall-method=buildinstall',
|
|
|
|
])
|
|
|
|
|
|
|
|
self.maxDiff = None
|
|
|
|
self.assertItemsEqual(
|
|
|
|
run.call_args_list,
|
|
|
|
[mock.call(['/usr/bin/genisoimage', '-untranslated-filenames',
|
|
|
|
'-volid', 'DP-1.0-20160405.t.3', '-J', '-joliet-long',
|
|
|
|
'-rational-rock', '-translation-table',
|
|
|
|
'-x', './lost+found',
|
|
|
|
'-part', '-hfs', '-r', '-l', '-sysid', 'PPC', '-no-desktop',
|
|
|
|
'-allow-multidot', '-chrp-boot',
|
|
|
|
'-map', '/usr/lib/anaconda-runtime/boot/mapping',
|
|
|
|
'-hfs-bless', '/ppc/mac',
|
|
|
|
'-o', 'DP-1.0-20160405.t.3-ppc64.iso',
|
|
|
|
'-graft-points', '-path-list', 'graft-list'],
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
2016-04-04 13:49:30 +00:00
|
|
|
mock.call(['/usr/bin/implantisomd5', 'DP-1.0-20160405.t.3-ppc64.iso'],
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
2016-04-04 13:49:30 +00:00
|
|
|
mock.call('isoinfo -R -f -i DP-1.0-20160405.t.3-ppc64.iso | grep -v \'/TRANS.TBL$\' | sort >> DP-1.0-20160405.t.3-ppc64.iso.manifest',
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir)]
|
2016-04-04 13:49:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
@mock.patch('sys.stderr')
|
|
|
|
@mock.patch('kobo.shortcuts.run')
|
|
|
|
def test_run_with_jigdo_bad_args(self, run, stderr):
|
|
|
|
with self.assertRaises(SystemExit):
|
|
|
|
createiso.main([
|
2016-05-25 11:37:39 +00:00
|
|
|
'--output-dir=%s' % self.outdir,
|
2016-04-04 13:49:30 +00:00
|
|
|
'--iso-name=DP-1.0-20160405.t.3-x86_64.iso',
|
|
|
|
'--volid=DP-1.0-20160405.t.3',
|
|
|
|
'--graft-points=graft-list',
|
|
|
|
'--arch=x86_64',
|
2016-05-25 11:37:39 +00:00
|
|
|
'--jigdo-dir=%s/jigdo' % self.topdir,
|
2016-04-04 13:49:30 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
@mock.patch('kobo.shortcuts.run')
|
|
|
|
def test_run_with_jigdo(self, run):
|
|
|
|
createiso.main([
|
2016-05-25 11:37:39 +00:00
|
|
|
'--output-dir=%s' % self.outdir,
|
2016-04-04 13:49:30 +00:00
|
|
|
'--iso-name=DP-1.0-20160405.t.3-x86_64.iso',
|
|
|
|
'--volid=DP-1.0-20160405.t.3',
|
|
|
|
'--graft-points=graft-list',
|
|
|
|
'--arch=x86_64',
|
2016-05-25 11:37:39 +00:00
|
|
|
'--jigdo-dir=%s/jigdo' % self.topdir,
|
|
|
|
'--os-tree=%s/os' % self.topdir,
|
2016-04-04 13:49:30 +00:00
|
|
|
])
|
|
|
|
self.maxDiff = None
|
|
|
|
self.assertItemsEqual(
|
|
|
|
run.call_args_list,
|
|
|
|
[mock.call(['/usr/bin/genisoimage', '-untranslated-filenames',
|
|
|
|
'-volid', 'DP-1.0-20160405.t.3', '-J', '-joliet-long',
|
|
|
|
'-rational-rock', '-translation-table',
|
|
|
|
'-input-charset', 'utf-8', '-x', './lost+found',
|
|
|
|
'-o', 'DP-1.0-20160405.t.3-x86_64.iso',
|
|
|
|
'-graft-points', '-path-list', 'graft-list'],
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
2016-04-04 13:49:30 +00:00
|
|
|
mock.call(['/usr/bin/implantisomd5', 'DP-1.0-20160405.t.3-x86_64.iso'],
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
2016-04-04 13:49:30 +00:00
|
|
|
mock.call('isoinfo -R -f -i DP-1.0-20160405.t.3-x86_64.iso | grep -v \'/TRANS.TBL$\' | sort >> DP-1.0-20160405.t.3-x86_64.iso.manifest',
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir),
|
2016-04-04 13:49:30 +00:00
|
|
|
mock.call(['jigdo-file', 'make-template', '--force',
|
2016-05-25 11:37:39 +00:00
|
|
|
'--image=%s/isos/DP-1.0-20160405.t.3-x86_64.iso' % self.topdir,
|
|
|
|
'--jigdo=%s/jigdo/DP-1.0-20160405.t.3-x86_64.iso.jigdo' % self.topdir,
|
|
|
|
'--template=%s/jigdo/DP-1.0-20160405.t.3-x86_64.iso.template' % self.topdir,
|
2016-04-04 13:49:30 +00:00
|
|
|
'--no-servers-section', '--report=noprogress', self.topdir + '/os//'],
|
2016-04-14 08:14:51 +00:00
|
|
|
show_cmd=True, stdout=True, workdir=self.outdir)]
|
2016-04-04 13:49:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|