curtin-dev team mailing list archive
-
curtin-dev team
-
Mailing list archive
-
Message #03198
Re: [Merge] ~ogayot/curtin:efibootmgr into curtin:master
Review: Approve
I still wonder if we could just set it unconditionally but well probably better to be like this. A couple of flakes to fix before landing.
Diff comments:
> diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
> index e2c4caf..6bbe151 100644
> --- a/tests/unittests/test_util.py
> +++ b/tests/unittests/test_util.py
> @@ -1195,4 +1196,48 @@ class TestNotExclusiveRetry(CiTestCase):
> util.not_exclusive_retry(f, 1, 2, 3)
> sleep.assert_called_once()
>
> +
> +class TestEFIVarFSBug(CiTestCase):
> + def test_is_system_affected__unaffected(self):
> + # os.statvfs succeeds
> + with mock.patch("os.statvfs", return_value=None):
> + self.assertFalse(util.EFIVarFSBug.is_system_affected())
> +
> + # os.statvfs fails with PermissionError (e.g., EPERM)
> + with mock.patch("os.statvfs", side_effect=PermissionError):
> + self.assertFalse(util.EFIVarFSBug.is_system_affected())
> +
> + # os.statvfs fails with FileNotFoundError (e.g., ENOENT)
> + with mock.patch("os.statvfs", side_effect=FileNotFoundError):
> + self.assertFalse(util.EFIVarFSBug.is_system_affected())
> +
> + # os.statvfs fails with OSError (but not EINVAL)
> + ose = OSError(errno.EBADFD, "Bad file descriptor")
> + with mock.patch("os.statvfs", side_effect=ose):
> + self.assertFalse(util.EFIVarFSBug.is_system_affected())
> +
> + def test_is_system_affected__affected(self):
> + ose = OSError(errno.EINVAL, "Invalid argument")
> + with mock.patch("os.statvfs", side_effect=ose):
> + self.assertTrue(util.EFIVarFSBug.is_system_affected())
> +
> + def test_apply_workaround(self):
> + with mock.patch.dict(os.environ, clear=True):
TIL mock.patch.dict
> + util.EFIVarFSBug.apply_workaround()
> + self.assertEqual(os.environ["LIBEFIVAR_OPS"], "efivarfs")
> +
> + def test_apply_workaround_if_affected(self):
> + with mock.patch.object(util.EFIVarFSBug,
> + "apply_workaround") as apply_wa:
> + with mock.patch.object(util.EFIVarFSBug, "is_system_affected",
> + return_value=True):
flake8 doesn't like this
> + util.EFIVarFSBug.apply_workaround_if_affected()
> + apply_wa.assert_called_once()
> +
> + apply_wa.reset_mock()
> + with mock.patch.object(util.EFIVarFSBug, "is_system_affected",
> + return_value=False):
or this
> + util.EFIVarFSBug.apply_workaround_if_affected()
> + apply_wa.assert_not_called()
> +
> # vi: ts=4 expandtab syntax=python
--
https://code.launchpad.net/~ogayot/curtin/+git/curtin/+merge/454608
Your team curtin developers is subscribed to branch curtin:master.
References