1
1

torture_session: Test delayed close

The test for delayed close asks for the execution of a command that
generates big output (larger than the default window) to make data to
remain in buffers while the close message arrives, triggering the
delayed channel closure.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Этот коммит содержится в:
Anderson Toshiyuki Sasaki 2020-09-24 13:26:09 +02:00
родитель a4b8045fb8
Коммит cdac4fca5f

Просмотреть файл

@ -218,6 +218,46 @@ static void torture_max_sessions(void **state)
#undef MAX_CHANNELS
}
static void torture_channel_delayed_close(void **state)
{
struct torture_state *s = *state;
ssh_session session = s->ssh.session;
ssh_channel channel;
char request[256];
char buff[256] = {0};
int rc;
int fd;
snprintf(request, 256,
"dd if=/dev/urandom of=/tmp/file bs=64000 count=2; hexdump -C /tmp/file");
channel = ssh_channel_new(session);
assert_non_null(channel);
rc = ssh_channel_open_session(channel);
assert_ssh_return_code(session, rc);
fd = ssh_get_fd(session);
assert_true(fd > 2);
/* Make the request, read parts with close */
rc = ssh_channel_request_exec(channel, request);
assert_ssh_return_code(session, rc);
do {
rc = ssh_channel_read(channel, buff, 256, 0);
} while(rc > 0);
assert_ssh_return_code(session, rc);
rc = ssh_channel_poll_timeout(channel, 500, 0);
assert_int_equal(rc, SSH_EOF);
ssh_channel_free(channel);
}
int torture_run_tests(void) {
int rc;
struct CMUnitTest tests[] = {
@ -233,6 +273,9 @@ int torture_run_tests(void) {
cmocka_unit_test_setup_teardown(torture_max_sessions,
session_setup,
session_teardown),
cmocka_unit_test_setup_teardown(torture_channel_delayed_close,
session_setup,
session_teardown),
};
ssh_init();