Since all the bootloader stuff has been rewritten, it seems easier to write new bootloader tests from scratch instead of adapting what we've got. --- tests/Makefile.am | 2 +- tests/booty_test/Makefile.am | 29 --- tests/booty_test/checkbootloader_test.py | 118 ------------ tests/booty_test/lilo_test.py | 295 ------------------------------ tests/booty_test/x86_test.py | 108 ----------- 5 files changed, 1 insertions(+), 551 deletions(-) delete mode 100644 tests/booty_test/Makefile.am delete mode 100644 tests/booty_test/checkbootloader_test.py delete mode 100644 tests/booty_test/lilo_test.py delete mode 100644 tests/booty_test/x86_test.py diff --git a/tests/Makefile.am b/tests/Makefile.am index 6dad25b..df244c9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,6 +17,6 @@ # # Author: David Cantrell <dcantrell@xxxxxxxxxx> -SUBDIRS = mock kickstart_test storage_test regex pyanaconda_test pylint booty_test logpicker_test +SUBDIRS = mock kickstart_test storage_test regex pyanaconda_test pylint logpicker_test MAINTAINERCLEANFILES = Makefile.in diff --git a/tests/booty_test/Makefile.am b/tests/booty_test/Makefile.am deleted file mode 100644 index fe824b7..0000000 --- a/tests/booty_test/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# tests/booty_test/Makefile.am for anaconda -# -# Copyright (C) 2010 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# Author: Tomas Mlcoch <tmlcoch@xxxxxxxxxx> - -EXTRA_DIST = *.py - -MAINTAINERCLEANFILES = Makefile.in - -ANACDIR = $(top_builddir)/pyanaconda -TESTS_ENVIRONMENT = PYTHONPATH=$(top_builddir)/tests:$(ANACDIR)/isys/.libs:$(ANACDIR):$(top_builddir) - -TESTS = checkbootloader_test.py \ - lilo_test.py \ - x86_test.py diff --git a/tests/booty_test/checkbootloader_test.py b/tests/booty_test/checkbootloader_test.py deleted file mode 100644 index 2fd2407..0000000 --- a/tests/booty_test/checkbootloader_test.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/python - -import mock - -class CheckBootLoaderTest(mock.TestCase): - - def setUp(self): - self.setupModules(['_isys', 'block', 'storage', 'parted', - 'pyanaconda.storage.formats', 'logging', - 'ConfigParser', 'pyanaconda.storage.storage_log']) - - self.fs = mock.DiskIO() - - import pyanaconda - pyanaconda.anaconda_log = mock.Mock() - - import pyanaconda.booty.checkbootloader - pyanaconda.booty.checkbootloader.iutil = mock.Mock() - pyanaconda.booty.checkbootloader.os = mock.Mock() - pyanaconda.booty.checkbootloader.log = mock.Mock() - pyanaconda.booty.checkbootloader.open = self.fs.open - - self.INSTROOT = '' - self.STORAGE = mock.Mock() - - def tearDown(self): - self.tearDownModules() - - def get_boot_dev_string_test(self): - import pyanaconda.booty.checkbootloader - LINE = "#boot=/dev/sda" - ret = pyanaconda.booty.checkbootloader.getBootDevString(LINE) - self.assertEqual(ret, '/dev/sda') - - def get_boot_dev_list_test(self): - import pyanaconda.booty.checkbootloader - LINE = "boot=/dev/sda" - ret = pyanaconda.booty.checkbootloader.getBootDevList(LINE) - self.assertEqual(ret, '/dev/sda') - - def get_bootloader_type_and_boot_grub_1_test(self): - import pyanaconda.booty.checkbootloader - - def fake_f(path, _): - return True if 'grub.conf' in path else False - - pyanaconda.booty.checkbootloader.os.access = fake_f - self.fs.open('/etc/sysconfig/grub', 'w').write('boot=/dev/sda\n') - pyanaconda.booty.checkbootloader.iutil.isEfi = mock.Mock(return_value=True) - - ret = pyanaconda.booty.checkbootloader.getBootloaderTypeAndBoot(self.INSTROOT, self.STORAGE) - self.assertEqual(ret, ('GRUB', '/dev/sda')) - - def get_bootloader_type_and_boot_grub_2_test(self): - import pyanaconda.booty.checkbootloader - - def fake_f(path, _): - return True if 'grub.conf' in path else False - - pyanaconda.booty.checkbootloader.os.access = fake_f - self.fs.open('/etc/sysconfig/grub', 'w').write('boot=/dev/sda\n') - pyanaconda.booty.checkbootloader.iutil.isEfi = mock.Mock(return_value=False) - pyanaconda.booty.checkbootloader.getBootBlock = mock.Mock(return_value=\ - 'asdfGRUBasdf') - - ret = pyanaconda.booty.checkbootloader.getBootloaderTypeAndBoot(self.INSTROOT, self.STORAGE) - self.assertEqual(ret, ('GRUB', '/dev/sda')) - - def get_bootloader_type_and_boot_lilo_1_test(self): - import pyanaconda.booty.checkbootloader - - def fake_f(path, _): - return True if 'lilo.conf' in path else False - - pyanaconda.booty.checkbootloader.os.access = fake_f - self.fs.open('/etc/lilo.conf', 'w').write('boot=/dev/sda\n') - pyanaconda.booty.checkbootloader.getBootBlock = mock.Mock(return_value=\ - 'asdfokLILOasdf') - - ret = pyanaconda.booty.checkbootloader.getBootloaderTypeAndBoot(self.INSTROOT, self.STORAGE) - self.assertEqual(ret, ('LILO', '/dev/sda')) - - def get_bootloader_type_and_boot_yaboot_1_test(self): - import pyanaconda.booty.checkbootloader - - def fake_f(path, _): - return True if 'yaboot.conf' in path else False - - pyanaconda.booty.checkbootloader.os.access = fake_f - self.fs.open('/etc/yaboot.conf', 'w').write('boot=/dev/sda\n') - - ret = pyanaconda.booty.checkbootloader.getBootloaderTypeAndBoot(self.INSTROOT, self.STORAGE) - self.assertEqual(ret, ('YABOOT', '/dev/sda')) - - def get_bootloader_type_and_boot_silo_1_test(self): - import pyanaconda.booty.checkbootloader - - def fake_f(path, _): - return True if 'silo.conf' in path else False - - pyanaconda.booty.checkbootloader.os.access = fake_f - self.fs.open('/etc/sysconfig/silo', 'w').write('boot=/dev/sda\n') - pyanaconda.booty.checkbootloader.getBootBlock = mock.Mock(return_value=\ - 'asdfokasdfghjlasdfghjklaSILOasdf') - - ret = pyanaconda.booty.checkbootloader.getBootloaderTypeAndBoot(self.INSTROOT, self.STORAGE) - self.assertEqual(ret, ('SILO', '/dev/sda')) - - def get_bootloader_type_and_boot_none_test(self): - import pyanaconda.booty.checkbootloader - - def fake_f(path, _): - return False - - pyanaconda.booty.checkbootloader.os.access = fake_f - - ret = pyanaconda.booty.checkbootloader.getBootloaderTypeAndBoot(self.INSTROOT, self.STORAGE) - self.assertEqual(ret, (None, None)) diff --git a/tests/booty_test/lilo_test.py b/tests/booty_test/lilo_test.py deleted file mode 100644 index ac8ef2e..0000000 --- a/tests/booty_test/lilo_test.py +++ /dev/null @@ -1,295 +0,0 @@ -#!/usr/bin/python - -import mock - -class LiloTest(mock.TestCase): - only = True - def setUp(self): - self.setupModules(['_isys', 'block', 'parted', 'storage', - 'pyanaconda.storage.formats', 'logging', - 'ConfigParser', 'pyanaconda.storage.storage_log']) - - self.fs = mock.DiskIO() - - import pyanaconda - pyanaconda.anaconda_log = mock.Mock() - - import pyanaconda.booty.lilo - pyanaconda.booty.lilo.open = self.fs.open - - self.LFILE = '/tmp/lilo.conf' - self.LILO_CFG = ( - "boot=/dev/hda\n" - "map=/boot/map\n" - "install=/boot/boot.b\n" - "compact\n" - "prompt\n" - "timeout=50\n" - "\n" - "image=/boot/vmlinuz-2.0.36\n" - "\tlabel=linux\n" - "\talias=foo\n" - "\troot=/dev/hda2\n" - "\tread-only\n" - "\n" - "other=/dev/hda1\n" - "\tlabel=win\n") - - self.LFILE_OTHER = '/tmp/lilo.conf_other' - self.LILO_CFG_OTHER = ( - "boot=/dev/hda\n" - "map=/boot/map\n" - "install=/boot/boot.b\n" - "compact\n" - "prompt\n" - "timeout=50\n" - "\n" - "other=/dev/hda1\n" - "\tlabel=win\n") - - self.LFILE_DO = '/tmp/lilo.conf_do' - self.LILO_CFG_DO = ( - "boot=/dev/hda\n" - "map=/boot/map\n" - "default=win\n" - "install=/boot/boot.b\n" - "compact\n" - "prompt\n" - "timeout=50\n" - "\n" - "image=/boot/vmlinuz-2.0.36\n" - "\tlabel=linux\n" - "\talias=foo\n" - "\troot=/dev/hda2\n" - "\tread-only\n" - "\n" - "other=/dev/hda1\n" - "\tlabel=win\n") - - self.fs.open(self.LFILE, 'w').write(self.LILO_CFG) - self.fs.open(self.LFILE_OTHER, 'w').write(self.LILO_CFG_OTHER) - self.fs.open(self.LFILE_DO, 'w').write(self.LILO_CFG_DO) - - def tearDown(self): - self.tearDownModules() - - def add_entry_1_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - conf.addEntry('fooentry', '55') - ret = conf.getEntry('fooentry') - self.assertEqual(ret, '55') - - def add_entry_2_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - conf.addEntry('fooentry', '55') - conf.addEntry('fooentry', '22', replace=0) - ret = conf.getEntry('fooentry') - self.assertEqual(ret, '55') - - def get_entry_1_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - ret = conf.getEntry('timeout') - self.assertEqual(ret, '50') - - def get_entry_2_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - ret = conf.getEntry('foofoofoo') - self.assertEqual(ret, None) - - def del_entry_key_exists_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - conf.delEntry('timeout') - ret = conf.getEntry('timeout') - self.assertEqual(ret, None) - - def del_entry_key_does_not_exist_test(self): - # This test fails - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - self.assertRaises(KeyError, conf.delEntry, 'foofoofoo') - - def list_entries_1_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - ret = conf.listEntries() - self.assertEqual(ret, {'compact': None, 'map': '/boot/map', - 'prompt': None, 'install': '/boot/boot.b', 'boot': '/dev/hda', - 'timeout': '50'}) - - def test_entry_1_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - ret = conf.testEntry('timeout') - self.assertTrue(ret) - - def test_entry_2_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - ret = conf.testEntry('entryentryentry') - self.assertFalse(ret) - - def get_image_by_label_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - ret = conf.getImage('linux') - self.assertEqual(repr(ret), - "('image', label=linux\nalias=foo\nroot=/dev/hda2\nread-only\n, " - "'/boot/vmlinuz-2.0.36', None)" - ) - - def get_image_by_alias_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - ret = conf.getImage('foo') - self.assertEqual(repr(ret), - "('image', label=linux\nalias=foo\nroot=/dev/hda2\nread-only\n, " - "'/boot/vmlinuz-2.0.36', None)" - ) - - def get_image_raise_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - self.assertRaises(IndexError, conf.getImage, ('foobar')) - - def add_image_1_test(self): - import pyanaconda.booty.lilo - img = mock.Mock() - img.path='foopath' - img.imageType='footype' - img.getEntry.return_value = 'foo' - img.imageType = 'image' - img.path = '/boot/foo' - img.other = None - - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.addImage(img) - - ret = conf.getImage('foo') - self.assertEqual(ret[0], 'image') - # ret[1] is mock object instance - self.assertEqual(ret[2], '/boot/foo') - self.assertEqual(ret[3], None) - - def add_image_raise_test(self): - import pyanaconda.booty.lilo - image = pyanaconda.booty.lilo.LiloConfigFile() - conf = pyanaconda.booty.lilo.LiloConfigFile() - self.assertRaises(ValueError, conf.addImage, (image)) - - def del_image_1_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - conf.delImage('linux') - conf.delImage('win') - self.assertEqual(repr(conf), - 'boot=/dev/hda\nmap=/boot/map\ninstall=/boot/boot.b\ncompact\nprompt\ntimeout=50\n') - - def del_image_raise_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - self.assertRaises(IndexError, conf.delImage, ('barfoo')) - - def get_default_1_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - ret = conf.getDefault() - self.assertEqual(repr(ret), "label=linux\nalias=foo\nroot=/dev/hda2\nread-only\n") - - def get_default_2_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE_OTHER) - ret = conf.getDefault() - self.assertEqual(repr(ret), "label=win\n") - - def get_default_2_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE_DO) - ret = conf.getDefault() - self.assertEqual(repr(ret), "label=win\n") - - def get_default_linux_1_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - ret = conf.getDefaultLinux() - self.assertEqual(repr(ret), "label=linux\nalias=foo\nroot=/dev/hda2\nread-only\n") - - def get_default_linux_2_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE_OTHER) - ret = conf.getDefaultLinux() - self.assertEqual(ret, None) - - def get_default_linux_3_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE_DO) - ret = conf.getDefaultLinux() - self.assertEqual(repr(ret), "label=linux\nalias=foo\nroot=/dev/hda2\nread-only\n") - - def list_images_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - ret = conf.listImages() - self.assertEqual(ret, ['linux', 'win']) - - def list_aliases_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - ret = conf.listAliases() - self.assertEqual(ret, ['foo']) - - def get_path_test(self): - import pyanaconda.booty.lilo - PATH = '/tmp/path' - conf = pyanaconda.booty.lilo.LiloConfigFile(path=PATH) - ret = conf.path - self.assertEqual(ret, PATH) - - def write_test(self): - import pyanaconda.booty.lilo - pyanaconda.booty.lilo.os = mock.Mock() - pyanaconda.booty.lilo.os.chmod = mock.Mock() - WFILE = '/tmp/lilo.conf_out' - - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - conf.write(WFILE) - self.assertEqual(self.fs[WFILE], self.LILO_CFG) - - def read_1_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE) - self.assertEqual(repr(conf), self.LILO_CFG) - - def read_2_test(self): - import pyanaconda.booty.lilo - conf = pyanaconda.booty.lilo.LiloConfigFile() - conf.read(self.LFILE_OTHER) - self.assertEqual(repr(conf), self.LILO_CFG_OTHER) - diff --git a/tests/booty_test/x86_test.py b/tests/booty_test/x86_test.py deleted file mode 100644 index b5e6917..0000000 --- a/tests/booty_test/x86_test.py +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/python - -import mock -import sys - -class writeGrubConfTest(mock.TestCase): - def setUp(self): - self.setupModules(['_isys', 'block', 'parted', 'storage', - 'pyanaconda.storage.formats', 'logging', - 'ConfigParser', 'pyanaconda.storage.storage_log']) - - self.fs = mock.DiskIO() - - import pyanaconda - pyanaconda.anaconda_log = mock.Mock() - - import pyanaconda.booty.x86 as x86 - x86.open = self.fs.open - x86.os = mock.Mock() - x86.os.access.return_value=False - x86.bootloaderInfo = mock.Mock() - x86.x86BootloaderInfo.getPhysicalDevices = mock.Mock(return_value=['']) - x86.x86BootloaderInfo.grubbyPartitionName = mock.Mock(return_value='(hd0,0)') - x86.x86BootloaderInfo.serial = 0 - x86.x86BootloaderInfo.timeout = 0 - x86.x86BootloaderInfo.args = mock.Mock(return_value='') - x86.x86BootloaderInfo.args.get.return_value='' - x86.x86BootloaderInfo.makeInitrd = mock.Mock( - return_value = 'initramfs-2.6.33.3-85.fc13.x86_64.img') - - # Params for writeGrubConf function - self.instRoot = '' - self.bootDev = mock.Mock() - self.rootDev = mock.Mock() - self.rootDev.path = '/dev/sda' - self.rootDev.name = 'linux' - self.rootDev.fstabSpec = '/dev/sda' - self.defaultDev = mock.Mock() - self.defaultDev.name = 'linux' - self.kernelList = [('Fedora', 'Fedora', '2.6.33.5-124.fc13.x86_64')] - self.chainList = [] - self.grubTarget = 'sda1' - self.grubPath = '/grub' - self.cfPath = '/' - - def tearDown(self): - self.tearDownModules() - - def writegrubconf_1_test(self): - """Simulate writing GRUB.conf""" - import pyanaconda.booty.x86 - - bl = pyanaconda.booty.x86.x86BootloaderInfo(mock.Mock()) - bl.writeGrubConf(self.instRoot, self.bootDev, self.rootDev, \ - self.defaultDev, self.kernelList, self.chainList, \ - self.grubTarget, self.grubPath, self.cfPath) - - self.assertEqual(self.fs['/boot/grub/grub.conf'], - "# grub.conf generated by anaconda\n" - "#\n" - "# Note that you do not have to rerun grub after making changes to this file\n" - "# NOTICE: You have a /boot partition. This means that\n" - "# all kernel and initrd paths are relative to /boot/, eg.\n" - "# root (hd0,0)\n" - "# kernel /vmlinuz-version ro root=/dev/sda\n" - "# initrd /initrd-[generic-]version.img\n" - "#boot=/dev/sda1\n" - "default=0\n" - "timeout=0\n" - "title Fedora (2.6.33.5-124.fc13.x86_64)\n" - " root (hd0,0)\n" - " kernel /vmlinuz-2.6.33.5-124.fc13.x86_64 ro root=/dev/sda\n" - " initrd /initramfs-2.6.33.3-85.fc13.x86_64.img\n" - ) - - def writegrubconf_2_test(self): - """Simulate writing GRUB.conf""" - import pyanaconda.booty.x86 - - # make EFI - pyanaconda.booty.x86.x86BootloaderInfo.configfile = '/boot/efi/EFI/redhat/grub.conf' - pyanaconda.booty.x86.iutil = mock.Mock() - pyanaconda.booty.x86.iutil.isEfi.return_value=True - - bl = pyanaconda.booty.x86.x86BootloaderInfo(mock.Mock()) - bl.getEfiProductPath = mock.Mock(return_value=None) - bl.writeGrubConf(self.instRoot, self.bootDev, self.rootDev, \ - self.defaultDev, self.kernelList, self.chainList, \ - self.grubTarget, self.grubPath, self.cfPath) - - self.assertTrue(bl.getEfiProductPath.called) - self.assertEqual(self.fs['/boot/efi/EFI/redhat/grub.conf'], - "# grub.conf generated by anaconda\n" - "#\n" - "# Note that you do not have to rerun grub after making changes to this file\n" - "# NOTICE: You have a /boot partition. This means that\n" - "# all kernel and initrd paths are relative to /boot/, eg.\n" - "# root (hd0,0)\n" - "# kernel /vmlinuz-version ro root=/dev/sda\n" - "# initrd /initrd-[generic-]version.img\n" - "#boot=/dev/sda1\n" - "default=0\n" - "timeout=0\n" - "title Fedora (2.6.33.5-124.fc13.x86_64)\n" - " root (hd0,0)\n" - " kernel /vmlinuz-2.6.33.5-124.fc13.x86_64 ro root=/dev/sda\n" - " initrd /initramfs-2.6.33.3-85.fc13.x86_64.img\n" - ) -- 1.7.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list