Skip to content

Commit

Permalink
tests: Adjusted reproducer for #57
Browse files Browse the repository at this point in the history
Removes the failed marker as it works now, as well as the forked fixture
as it makes it hard to debug possible issues.

Signed-off-by: Jakub Jelen <[email protected]>
  • Loading branch information
Jakuje committed Nov 20, 2024
1 parent d40b52a commit c8236e9
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/unit/channel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,24 @@ def ssh_channel(ssh_client_session):
chan.close()


@pytest.mark.xfail(
reason='This test causes SEGFAULT, flakily. '
'Ref: https://github.com/ansible/pylibssh/issues/57',
strict=False,
)
@pytest.mark.forked
def exec_second_command(ssh_channel):
"""Call ``exec_command()`` and checks the output."""
u_cmd_out = ssh_channel.exec_command('echo -n Hello Again').stdout.decode()
assert u_cmd_out == u'Hello Again' # noqa: WPS302


def test_exec_command(ssh_channel):
"""Test getting the output of a remotely executed command."""
u_cmd_out = ssh_channel.exec_command('echo -n Hello World').stdout.decode()
assert u_cmd_out == u'Hello World' # noqa: WPS302
# Test that repeated calls to exec_command do not segfault.
u_cmd_out = ssh_channel.exec_command('echo -n Hello Again').stdout.decode()
assert u_cmd_out == u'Hello Again' # noqa: WPS302

# NOTE: Call `exec_command()` once again from another function to
# NOTE: force it to happen in another place of the call stack,
# NOTE: making sure that the context is different from one in this
# NOTE: this test function. The resulting call stack will end up
# NOTE: being more random.
exec_second_command(ssh_channel)


def test_double_close(ssh_channel):
Expand Down

0 comments on commit c8236e9

Please sign in to comment.