util/chroot: use subprocess.run() for all commands

For consistency, use subprocess.run() with check=True for the calls that
were previously using subprocess.check_call().

Update the affected tests to match.
This commit is contained in:
Achilleas Koutsou 2024-08-27 12:55:07 +02:00 committed by Brian C. Lane
parent 73464ff119
commit 1093b5eeb2
3 changed files with 24 additions and 26 deletions

View file

@ -22,11 +22,9 @@ def test_dracut_with_initoverlayfs(mocked_run, tmp_path, stage_module, with_init
stage_module.main(str(tmp_path), options)
# subprocess.run() gets called 4 times:
# - once for the 'dracut' or 'initoverlayfs-install' call
# - three times for the 'umount' calls to unmount /proc, /dev, and /sys
assert len(mocked_run.call_args_list) == 4
args, kwargs = mocked_run.call_args_list[0]
# We expect 7 calls to run(): 3 mount + chroot + 3 umount
assert len(mocked_run.call_args_list) == 7
args, kwargs = mocked_run.call_args_list[3] # chroot is the 4th call
assert kwargs.get("check") is True
run_argv = args[0]
assert run_argv[0] == "/usr/sbin/chroot"