Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions test/anacondalib.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@

class VirtInstallMachineCase(MachineCase):
# The boot modes in which the test should run
boot_modes = ["bios"]
is_efi = os.environ.get("TEST_FIRMWARE", "bios") == "efi"
boot_modes = ["efi"]
is_bios = os.environ.get("TEST_FIRMWARE", "efi") == "bios"
report_to_wiki = os.path.exists(os.path.join(TEST_DIR, "report.json"))
MachineCase.machine_class = VirtInstallMachine
report_file = os.path.join(TEST_DIR, "report.json")
Expand Down Expand Up @@ -74,13 +74,13 @@ def setUpClass(cls):

def setUp(self):
method = getattr(self, self._testMethodName)
boot_modes = getattr(method, "boot_modes", ["bios"])
boot_modes = getattr(method, "boot_modes", ["efi"])
self.disk_images = getattr(method, "disk_images", [("", 15)])

if self.is_efi and "efi" not in boot_modes:
self.skipTest("Skipping for EFI boot mode")
elif not self.is_efi and "bios" not in boot_modes:
if self.is_bios and "bios" not in boot_modes:
self.skipTest("Skipping for BIOS boot mode")
elif not self.is_bios and "efi" not in boot_modes:
self.skipTest("Skipping for EFI boot mode")
Comment on lines +80 to +83
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This logic for skipping tests based on the boot mode can be simplified to be more concise and avoid repetition. By determining the current firmware mode first, you can use a single if statement to check if it's in the allowed boot_modes.

Suggested change
if self.is_bios and "bios" not in boot_modes:
self.skipTest("Skipping for BIOS boot mode")
elif not self.is_bios and "efi" not in boot_modes:
self.skipTest("Skipping for EFI boot mode")
firmware = "bios" if self.is_bios else "efi"
if firmware not in boot_modes:
self.skipTest(f"Skipping for {firmware.upper()} boot mode")


if "TestPayloadDNF" in self.__class__.__name__:
if os.environ.get("TEST_PAYLOAD", None) != "dnf":
Expand Down Expand Up @@ -291,7 +291,7 @@ def install(self, needs_confirmation, button_text="Install"):

# FIXME: https://bugzilla.redhat.com/show_bug.cgi?id=2325707
# This should be removed from the test
if self.is_efi:
if not self.is_bios:
# Add efibootmgr entry for the second OS
distro_name = self.disk_images[0][0].split("-")[0]
m.execute(f"efibootmgr -c -d /dev/vda -p 15 -L {distro_name} -l '/EFI/{distro_name}/shimx64.efi'")
Expand All @@ -303,7 +303,7 @@ def install(self, needs_confirmation, button_text="Install"):
def appendResultsToReport(self):
with open(self.report_file, "r+") as f:
test_name = f"{self.__class__.__name__}.{self._testMethodName}"
firmware = "UEFI" if self.is_efi else "BIOS"
firmware = "BIOS" if self.is_bios else "UEFI"
arch = "x86_64"
error = super().getError()
status = "fail" if error else "pass"
Expand Down Expand Up @@ -334,10 +334,10 @@ def tearDown(self):
def run_boot(*modes):
"""
Decorator to run tests only on specific boot modes ('bios', 'efi').
The VirtMachine has self.is_efi = True/False set.
We need to skip the test if self.is_efi is True but 'efi' is not in the modes list.
The VirtMachine has self.is_bios = True/False set.
We need to skip the test if self.is_bios is True but 'bios' is not in the modes list.

The absence of the decorator is equivalent to run_boot("bios").
The absence of the decorator is equivalent to run_boot("efi").

:param modes: Boot modes in which the test should run (e.g., "bios", "efi").
"""
Expand Down
1 change: 0 additions & 1 deletion test/check-storage-cockpit
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ class TestStorageCockpitIntegration(VirtInstallMachineCase, StorageCase):
i.check_next_disabled()

@nondestructive
@run_boot("efi")
def testBtrfsTopLevelVolume(self):
"""
Description:
Expand Down
3 changes: 1 addition & 2 deletions test/check-storage-home-reuse
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import os

from anacondalib import VirtInstallMachineCase, disk_images, run_boot
from anacondalib import VirtInstallMachineCase, disk_images
from installer import Installer
from review import Review
from storage import BOOT_PARTITION_DEFAULT_SIZE, BOOT_PARTITION_DEFAULT_SIZE_GB, Storage
Expand Down Expand Up @@ -385,7 +385,6 @@ class TestStorageHomeReuse(VirtInstallMachineCase):
move_standard_fedora_disk_to_win_disk(storage, self.machine, "vda", "vdb")
self._remove_unknown_mountpoints("vdb")

@run_boot("efi")
@disk_images([("", 35), ("fedora-rawhide", 15)])
def testWindowsSingleDisk(self):
"""
Expand Down
6 changes: 1 addition & 5 deletions test/check-storage-mountpoints
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import os

from anacondalib import VirtInstallMachineCase, disk_images, pixel_tests_ignore, run_boot
from anacondalib import VirtInstallMachineCase, disk_images, pixel_tests_ignore
from installer import Installer
from review import Review
from storage import Storage
Expand All @@ -33,7 +33,6 @@ BOTS_DIR = f'{ROOT_DIR}/bots'
class TestStorageMountPoints(VirtInstallMachineCase, StorageCase):
# FIXME: Re-enable bios test, it's currently failing in CI to detect the BIOS boot partition
# @run_boot("bios", "efi")
@run_boot("efi")
@disk_images([("", 15), ("fedora-42", "15")])
@skipImage("btrfs support missing on fedora-eln image", "fedora-eln-boot")
@nondestructive
Expand Down Expand Up @@ -722,7 +721,6 @@ class TestStorageMountPoints(VirtInstallMachineCase, StorageCase):
umount /mnt
""")

@run_boot("efi")
@nondestructive
def testExtendedPartition(self):
"""
Expand Down Expand Up @@ -754,7 +752,6 @@ class TestStorageMountPoints(VirtInstallMachineCase, StorageCase):
storage = Storage(self.browser, self.machine)
move_standard_fedora_disk_to_win_disk(storage, self.machine, "vda", "vdb")

@run_boot("efi")
@disk_images([("", 35), ("fedora-rawhide", 15)])
def testWindowsSingleDiskHomeReuse(self):
"""
Expand Down Expand Up @@ -814,7 +811,6 @@ class TestStorageMountPoints(VirtInstallMachineCase, StorageCase):
m.execute(f"wipefs -a {disk2}")
s.create_luks_partition(disk2, "homepass", "encrypted-home", "xfs")

@run_boot("efi")
@disk_images([("", 15), ("", 10)])
@nondestructive
def testEncryptedHomeSecondDisk(self):
Expand Down
3 changes: 1 addition & 2 deletions test/check-storage-mountpoints-btrfs-e2e
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# 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/>.

from anacondalib import VirtInstallMachineCase, run_boot
from anacondalib import VirtInstallMachineCase
from installer import Installer
from review import Review
from storage import Storage
Expand Down Expand Up @@ -52,7 +52,6 @@ class TestStorageMountPointsBtrfs_E2E(VirtInstallMachineCase):
rmdir {tmp_mount}
""")

@run_boot("efi")
def testPreserveHome(self):
"""
Description:
Expand Down
4 changes: 2 additions & 2 deletions test/machine_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _write_interactive_defaults_ks(self, updates_image, updates_image_edited):
os.system(f"cd {tmp_dir} && find . | cpio -c -o | gzip -9cv > {updates_image_edited}")

def start(self):
self.is_efi = os.environ.get("TEST_FIRMWARE", "bios") == "efi"
self.is_bios = os.environ.get("TEST_FIRMWARE", "efi") == "bios"
self.os = os.environ.get("TEST_OS", "fedora-rawhide-boot").split("-boot")[0]

self.payload_path = os.path.join(ROOT_DIR, f"tmp/{self.os}-anaconda-payload")
Expand Down Expand Up @@ -141,7 +141,7 @@ def start(self):
# FIXME: Disable SELinux on DNF installation as it needs relabelling other wise ssh logins are prevented
selinux = "inst.noselinux " if os.environ.get("TEST_PAYLOAD", "liveimg").lower() == "dnf" else ""

boot_arg = "--boot uefi " if self.is_efi else ""
boot_arg = "--boot uefi " if not self.is_bios else ""
try:
self._execute(
"virt-install "
Expand Down
3 changes: 2 additions & 1 deletion test/run
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ BASIC_TESTS="$(echo "$ALL_TESTS" | grep -vE "$RE_EXPENSIVE" | grep -vE "$RE_DNF_

# every known case needs to set RUN_OPTS to something non-empty, so that we can check if we hit any branch
case "${TEST_SCENARIO:=}" in
*efi*) export TEST_FIRMWARE="efi";;&
# FIXME: Inverted logic - EFI is now the default, so the "efi" scenario runs BIOS tests till we flip that in bots
*efi*) export TEST_FIRMWARE="bios";;&

*compose-*)
# Supported values are: compose-<compose-id> or compose-<compose-id>-staging
Expand Down
Loading