fixed unmounting of ESP on error
This commit is contained in:
parent
41398abdcf
commit
d622c8064c
11
ekernel.py
11
ekernel.py
@ -173,11 +173,12 @@ def efi (f):
|
||||
if f"already mounted on {Kernel.esp}" not in msg:
|
||||
raise RuntimeError(e.stderr.decode().splitlines()[0])
|
||||
assert Kernel.boot.exists()
|
||||
r = f(*args, **kwargs)
|
||||
# umount esp
|
||||
if mounted:
|
||||
subprocess.run(["umount", str(Kernel.esp)], check=True)
|
||||
return r
|
||||
try:
|
||||
return f(*args, **kwargs)
|
||||
finally:
|
||||
# umount esp
|
||||
if mounted:
|
||||
subprocess.run(["umount", str(Kernel.esp)], check=True)
|
||||
return locator
|
||||
|
||||
@cli
|
||||
|
@ -100,6 +100,15 @@ class Tests (unittest.TestCase):
|
||||
self.assertEqual(run("-q", "-k", "10"), 0)
|
||||
self.check_clean(10)
|
||||
|
||||
@capture_stdout
|
||||
def test_clean_umount_on_error (self):
|
||||
with self.assertRaises(SystemExit):
|
||||
self.assertEqual(run("-h"), 0)
|
||||
tracer, (args, kwargs) = self.interceptor.trace[-1]
|
||||
self.assertEqual(tracer.name, "subprocess.run")
|
||||
self.assertEqual(args, (["umount", "/tmp"],))
|
||||
self.assertEqual(kwargs, {"check": True})
|
||||
|
||||
@colorless
|
||||
@capture_stdout
|
||||
def test_clean_dry_run (self):
|
||||
|
@ -82,3 +82,7 @@ class Tests (unittest.TestCase):
|
||||
with self.assertRaises(SystemExit):
|
||||
self.assertEqual(run("-s", str(data.latest)), 1)
|
||||
self.assertRegex(sys.stderr.getvalue(), r"missing.*bzImage")
|
||||
tracer, (args, kwargs) = self.interceptor.trace[-1]
|
||||
self.assertEqual(tracer.name, "subprocess.run")
|
||||
self.assertEqual(args, (["umount", "/tmp"],))
|
||||
self.assertEqual(kwargs, {"check": True})
|
||||
|
Loading…
Reference in New Issue
Block a user