Ejemplo n.º 1
0
    def setUp(self):
        """setUp()
            Set up a test fixture for the BootEntryTests class.

            Defines standard OsProfile, BootParams, and BootEntry
            objects for use in these tests.
        """
        reset_sandbox()

        # Sandbox paths
        boot_sandbox = join(SANDBOX_PATH, "boot")
        boom_sandbox = join(SANDBOX_PATH, "boot/boom")
        loader_sandbox = join(SANDBOX_PATH, "boot/loader")

        # Initialise sandbox from master
        makedirs(boot_sandbox)
        shutil.copytree(self.boom_path, boom_sandbox)
        shutil.copytree(self.loader_path, loader_sandbox)

        # Set boom paths
        boom.set_boot_path(boot_sandbox)

        # Load test OsProfile and BootEntry data
        load_profiles()
        load_entries()
Ejemplo n.º 2
0
 def setUp(self):
     rm_sandbox()
     if not self.bootloader_config:
         raise ValueError("bootloader_config is undefined")
     config_path = join(self.configs, self.bootloader_config)
     shutil.copytree(config_path, join(SANDBOX_PATH))
     boom.set_boot_path(join(BOOT_ROOT_TEST, "sandbox/boot"))
Ejemplo n.º 3
0
    def setUp(self):
        """Set up a test fixture for the BootEntryTests class.

            Defines standard OsProfile, BootParams, and BootEntry
            objects for use in these tests.
        """
        reset_sandbox()

        # Sandbox paths
        boot_sandbox = join(SANDBOX_PATH, "boot")
        boom_sandbox = join(SANDBOX_PATH, "boot/boom")
        loader_sandbox = join(SANDBOX_PATH, "boot/loader")

        # Initialise sandbox from master
        makedirs(boot_sandbox)
        shutil.copytree(self.boom_path, boom_sandbox)
        shutil.copytree(self.loader_path, loader_sandbox)

        # Set boom paths
        boom.set_boot_path(boot_sandbox)

        # Load test OsProfile and BootEntry data
        load_profiles()
        load_entries()

        # Define a new, test OsProfile that is never included in the
        # standard set distributed with boom. To be used only for
        # formatting BootEntry objects for testing.
        osp = OsProfile(name="Distribution",
                        short_name="distro",
                        version="1 (Workstation Edition)",
                        version_id="1")
        osp.uname_pattern = "di1"
        osp.kernel_pattern = "/vmlinuz-%{version}"
        osp.initramfs_pattern = "/initramfs-%{version}.img"
        osp.root_opts_lvm2 = "rd.lvm.lv=%{lvm_root_lv}"
        osp.root_opts_btrfs = "rootflags=%{btrfs_subvolume}"
        osp.options = "root=%{root_device} %{root_opts} rhgb quiet"
        self.test_osp = osp

        # Define a standard set of test BootParams
        bp = BootParams("1.1.1.fc24",
                        root_device="/dev/vg/lv",
                        lvm_root_lv="vg/lv")
        self.test_bp = bp

        # Define a synthetic BootEntry for testing
        be = BootEntry(title="title",
                       machine_id="ffffffff",
                       boot_params=bp,
                       osprofile=osp,
                       allow_no_dev=True)
        self.test_be = be
Ejemplo n.º 4
0
    def setUp(self):
        reset_sandbox()

        # Sandbox paths
        boot_sandbox = join(SANDBOX_PATH, "boot")
        boom_sandbox = join(SANDBOX_PATH, "boot/boom")
        loader_sandbox = join(SANDBOX_PATH, "boot/loader")

        # Initialise sandbox from master
        makedirs(boot_sandbox)
        shutil.copytree(self.boom_path, boom_sandbox)
        shutil.copytree(self.loader_path, loader_sandbox)

        # Set boom paths
        boom.set_boot_path(boot_sandbox)

        # Reset profiles, entries, and host profiles to known state.
        load_profiles()
        load_entries()
        load_host_profiles()
Ejemplo n.º 5
0
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import unittest
import logging
from sys import stdout
from os import listdir
from os.path import exists, join, abspath

log = logging.getLogger()
log.level = logging.DEBUG
log.addHandler(logging.FileHandler("test.log"))

# Override default BOOM_ROOT and BOOT_ROOT
import boom
BOOT_ROOT_TEST = abspath("./tests")
boom.set_boot_path(BOOT_ROOT_TEST)

from boom.bootloader import *
from boom.osprofile import OsProfile
from boom import Selection


class BootParamsTests(unittest.TestCase):
    def test_BootParams_no_version_raises(self):
        with self.assertRaises(ValueError) as cm:
            # A version string is required
            bp = BootParams(None)

    def test_BootParams_conflicting_btrfs_raises(self):
        with self.assertRaises(ValueError) as cm:
            # Only one of subvol_id or subvol_path is allowed
Ejemplo n.º 6
0
def reset_boom_paths():
    """Reset configurable boom module paths to the default test values.
    """
    boom.set_boot_path(BOOT_ROOT_TEST)
Ejemplo n.º 7
0
 def test_set_boom_path_no_profiles(self):
     boom.set_boot_path(BOOT_ROOT_TEST)
     with self.assertRaises(ValueError) as cm:
         boom.set_boom_path("loader")
Ejemplo n.º 8
0
 def test_set_boot_path_non_abs(self):
     with self.assertRaises(ValueError) as cm:
         boom.set_boot_path("absolutely/the/wrong/path")
Ejemplo n.º 9
0
 def test_set_boom_path_non_abs_bad(self):
     boom.set_boot_path(BOOT_ROOT_TEST + "/boom")
     with self.assertRaises(ValueError) as cm:
         boom.set_boom_path("absolutely/the/wrong/path")
Ejemplo n.º 10
0
 def test_set_boom_path_non_abs(self):
     boom.set_boot_path(BOOT_ROOT_TEST)
     boom.set_boom_path("boom/")
Ejemplo n.º 11
0
 def test_set_boot_path_bad_path(self):
     with self.assertRaises(ValueError) as cm:
         boom.set_boot_path("/the/wrong/path")
Ejemplo n.º 12
0
 def test_set_boot_path(self):
     boom.set_boot_path(BOOT_ROOT_TEST)