Skip to content

Commit

Permalink
Fix and add tests for the preexec changes
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirSlavik committed Jul 12, 2023
1 parent 0fd50ca commit d2868fc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions tests/unit_tests/pyanaconda_tests/core/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,31 @@ def test_still_running():
with pytest.raises(ExitError):
WatchProcesses.watch_process(proc, "test2")

@patch("pyanaconda.core.util.startProgram")
def test_do_preexec(self, mock_start_program):
"""Test the do_preexec option of exec*** functions."""
mock_start_program.return_value.communicate.return_value = (b"", b"")

util.execWithRedirect("ls", [])
mock_start_program.assert_called_once()
assert mock_start_program.call_args.kwargs["do_preexec"] is True
mock_start_program.reset_mock()

util.execWithRedirect("ls", [], do_preexec=False)
mock_start_program.assert_called_once()
assert mock_start_program.call_args.kwargs["do_preexec"] is False
mock_start_program.reset_mock()

util.execWithCapture("ls", [], do_preexec=False)
mock_start_program.assert_called_once()
assert mock_start_program.call_args.kwargs["do_preexec"] is False
mock_start_program.reset_mock()

util.execWithCapture("ls", [], do_preexec=False)
mock_start_program.assert_called_once()
assert mock_start_program.call_args.kwargs["do_preexec"] is False
mock_start_program.reset_mock()


class MiscTests(unittest.TestCase):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ def test_mount_filesystems(self, core_run_program, blivet_run_program, makedirs,
core_run_program.assert_any_call(
['mount', '--rbind', '/mnt/sysimage', '/mnt/sysroot'],
stdin=None, stdout=None, root='/', env_prune=None,
log_output=True, binary_output=False)
log_output=True, binary_output=False, do_preexec=True)

@patch_dbus_get_proxy
@patch("pyanaconda.modules.storage.installation.conf")
Expand Down

0 comments on commit d2868fc

Please sign in to comment.