def test_BootEntry_write(self): # Use a real OsProfile here: the entry will be written to disk, and # may be seen during entry loading (to avoid the entry being moved # to the Null profile). osp = find_profiles(Selection(os_id="d4439b7"))[0] bp = BootParams("1.1.1-1.fc26", root_device="/dev/vg00/lvol0", lvm_root_lv="vg00/lvol0") be = BootEntry(title="title", machine_id="ffffffff", boot_params=bp, osprofile=osp, allow_no_dev=True) boot_id = be.boot_id be.write_entry() load_entries() be2 = find_entries(Selection(boot_id=boot_id))[0] self.assertEqual(be.title, be2.title) self.assertEqual(be.boot_id, be2.boot_id) self.assertEqual(be.version, be2.version) ## Create on-disk entry and add to list of known entries #be.write_entry() # Profile and entry are non-persistent be2.delete_entry()
def test_find_entries_by_version(self): version = "4.10.17-100.fc24.x86_64" boom.bootloader._entries = None bes = boom.bootloader.find_entries(Selection(version=version)) path = boom_entries_path() nr = len([p for p in listdir(path) if version in p]) self.assertEqual(len(bes), nr)
def test_osprofile_find_profiles_by_name(self): os_name = "Fedora" os_short_name = "fedora" osp_list = find_profiles(selection=Selection(os_name=os_name)) nr_profiles = 0 for f in listdir(boom_profiles_path()): if os_short_name in f: nr_profiles += 1 self.assertTrue(len(osp_list), nr_profiles)
def test_find_boot_entries(self): boom.bootloader.load_entries() find_entries = boom.bootloader.find_entries entries = find_entries() self.assertEqual(len(entries), len(boom.bootloader._entries)) entries = find_entries(Selection(machine_id="ffffffff")) self.assertEqual(len(entries), self._nr_machine_id("ffffffff"))
def test_find_entries_by_lvm_root_lv(self): entries_path = boom_entries_path() boom.bootloader._entries = None lvm_root_lv = "vg_root/root" bes = boom.bootloader.find_entries(Selection(lvm_root_lv=lvm_root_lv)) xentries = 0 for e in listdir(entries_path): if e.endswith(".conf"): with open(join(entries_path, e)) as f: for l in f.readlines(): if "rd.lvm.lv=" + lvm_root_lv in l: xentries += 1 self.assertEqual(len(bes), xentries)
def test_find_entries_by_root_device(self): entries_path = boom_entries_path() root_device = "/dev/vg_root/root" boom.bootloader._entries = None bes = boom.bootloader.find_entries(Selection(root_device=root_device)) xentries = 0 for e in listdir(entries_path): if e.endswith(".conf"): with open(join(entries_path, e)) as f: for l in f.readlines(): if root_device in l: xentries += 1 self.assertEqual(len(bes), xentries)
def test_find_entries_by_btrfs_subvol_path(self): entries_path = boom_entries_path() btrfs_subvol_path = "/snapshot/today" boom.bootloader._entries = None bes = boom.bootloader.find_entries( Selection(btrfs_subvol_path=btrfs_subvol_path)) nr = 0 # count entries for p in listdir(entries_path): with open(join(entries_path, p), "r") as f: for l in f.readlines(): if "/snapshot/today" in l: nr += 1 self.assertEqual(len(bes), nr)
def test_find_entries_by_btrfs_subvol_id(self): entries_path = boom_entries_path() boom.bootloader._entries = None btrfs_subvol_id = "23" nr = 0 # count entries for p in listdir(entries_path): with open(join(entries_path, p), "r") as f: for l in f.readlines(): if "subvolid=23" in l: nr += 1 bes = boom.bootloader.find_entries( Selection(btrfs_subvol_id=btrfs_subvol_id)) self.assertEqual(len(bes), nr)
def test_BootEntry_write(self): osp = self._get_test_OsProfile() bp = BootParams("1.1.1-1.di1", root_device="/dev/vg00/lvol0", lvm_root_lv="vg00/lvol0") be = BootEntry(title="title", machine_id="ffffffff", boot_params=bp, osprofile=osp, allow_no_dev=True) boot_id = be.boot_id be.write_entry() load_entries() be2 = find_entries(Selection(boot_id=boot_id))[0] self.assertEqual(be.title, be2.title) self.assertEqual(be.boot_id, be2.boot_id) self.assertEqual(be.version, be2.version) be.delete_entry()
def test_find_entries_by_title(self): title = "Red Hat Enterprise Linux 7.2 (Maipo) 3.10-23.el7" boom.bootloader._entries = None bes = boom.bootloader.find_entries(Selection(title=title)) self.assertEqual(len(bes), 1)
def test_find_entries_by_boot_id(self): boot_id = "12a2696bf85cc33f42f0449fab5da64dac7aa10a" boom.bootloader._entries = None bes = boom.bootloader.find_entries(Selection(boot_id=boot_id)) self.assertEqual(len(bes), 1)
def test_osprofile_find_profiles_by_id(self): rhel72_os_id = "9736c347ccb724368be04e51bb25687a361e535c" osp_list = find_profiles(selection=Selection(os_id=rhel72_os_id)) self.assertEqual(len(osp_list), 1) self.assertEqual(osp_list[0].os_id, rhel72_os_id)
def test_Selection_no_osp_match(self): s = Selection(os_id="12345") self.assertFalse(find_entries(s))