Tests fail when using libssh master
adelton opened this issue · 4 comments
Hello,
when I build ssh-python against libssh master, test test_channel_exec fails.
In the https://github.com/ParallelSSH/ssh-python checkout directory I do
rm -rf libssh && git clone git://git.libssh.org/projects/libssh.git --depth 1python3 setup.py build_ext --inplacepython3 setup.py test --test-suite tests.test_channel.ChannelTest
The output ends with
WARNING: 'UsePAM no' is not supported in Fedora and may cause several problems.
/root/ssh-python/tests/embedded_server/openssh.py:68: ResourceWarning: unclosed <socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 59326), raddr=('127.0.0.1', 2222)>
del sock
ResourceWarning: Enable tracemalloc to get the object allocation traceback
test_channel_exec (tests.test_channel.ChannelTest) ... ERROR
test_close (tests.test_channel.ChannelTest) ... ok
test_exit_code (tests.test_channel.ChannelTest) ... ok
test_long_running_execute (tests.test_channel.ChannelTest) ... ok
test_pty (tests.test_channel.ChannelTest) ... ok
test_read_stderr (tests.test_channel.ChannelTest) ... ok
======================================================================
ERROR: test_channel_exec (tests.test_channel.ChannelTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/root/ssh-python/tests/test_channel.py", line 57, in test_channel_exec
size, data = chan.read()
File "ssh/channel.pyx", line 166, in ssh.channel.Channel.read
return handle_ok_error_codes(rc), buf
File "ssh/utils.pyx", line 74, in ssh.utils.handle_ok_error_codes
raise SSHError
ssh.exceptions.SSHError
----------------------------------------------------------------------
Ran 6 tests in 3.834s
FAILED (errors=1)
Test failed: <unittest.runner.TextTestResult run=6 errors=1 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=6 errors=1 failures=0>
All other tests pass.
This is on Fedora 29 with gcc-8.3.1-2.fc29.x86_64.
I tried to debug the failure a bit and it seems that the
rc = c_ssh.ssh_channel_read(self._channel, cbuf, size, is_stderr)
in ssh/channel.pyx returns -1 the second time it is called from tests/test_channel.py's test_channel_exec.
With the libssh/ content as shipped with ssh-python, the call returns 0 the second time it is called.
However, in my C-code which uses libssh, I still see 0 returned when I run ssh_channel_read after there is no more output -- so it seems like ssh-python sets something about the session or channel which causes the return to be -1.
I see the same test failure when I use the packaged libssh-0.8.7-1.fc29.x86_64 using
rm -rf libssh# to make sure we are not using the embedded codeSYSTEM_LIBSSH=1 python3 setup.py build_ext --inplaceSYSTEM_LIBSSH=1 python3 setup.py test --test-suite tests.test_channel.ChannelTest
Hi there,
Thanks for the interest.
Hm, that is interesting. -1 is SSH_ERROR, so the code is correct as far as I can see. Channel.read only returns code from ssh_channel_read so there is nothing else happening in bindings code. Will need to take a look at debug output.
Doesn't error with 0.9.4.