2017-10-28 15:31:37 +03:00
|
|
|
#include "config.h"
|
|
|
|
|
2013-10-31 15:44:48 +04:00
|
|
|
#define LIBSSH_STATIC
|
|
|
|
#include <libssh/priv.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include "torture.h"
|
|
|
|
#include "channels.c"
|
|
|
|
|
|
|
|
static void torture_channel_select(void **state)
|
|
|
|
{
|
2018-08-20 17:17:33 +03:00
|
|
|
fd_set readfds;
|
2013-10-31 15:44:48 +04:00
|
|
|
int fd;
|
|
|
|
int rc;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
(void)state; /* unused */
|
|
|
|
|
2018-08-20 17:17:33 +03:00
|
|
|
ZERO_STRUCT(readfds);
|
|
|
|
|
2013-10-31 15:44:48 +04:00
|
|
|
fd = open("/dev/null", 0);
|
|
|
|
assert_true(fd > 2);
|
|
|
|
|
2013-11-27 20:55:48 +04:00
|
|
|
FD_ZERO(&readfds);
|
2013-10-31 15:44:48 +04:00
|
|
|
FD_SET(fd, &readfds);
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
ssh_channel cin[1] = { NULL, };
|
|
|
|
ssh_channel cout[1] = { NULL, };
|
|
|
|
struct timeval tv = { .tv_sec = 0, .tv_usec = 1000 };
|
|
|
|
|
|
|
|
rc = ssh_select(cin, cout, fd + 1, &readfds, &tv);
|
|
|
|
assert_int_equal(rc, SSH_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
int torture_run_tests(void) {
|
|
|
|
int rc;
|
2015-09-07 11:39:51 +03:00
|
|
|
struct CMUnitTest tests[] = {
|
|
|
|
cmocka_unit_test(torture_channel_select),
|
2013-10-31 15:44:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
ssh_init();
|
2014-09-02 11:07:17 +04:00
|
|
|
torture_filter_tests(tests);
|
2015-09-07 11:39:51 +03:00
|
|
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
2013-10-31 15:44:48 +04:00
|
|
|
ssh_finalize();
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|