Debian Codegraph @

tests/unittests/torture_channel.c

raw
1 #include "config.h"
2
3 #define LIBSSH_STATIC
4 #include <libssh/priv.h>
5
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9
10 #include "torture.h"
11 #include "channels.c"
12
13 static void torture_channel_select(void **state)
14 {
15 fd_set readfds;
16 int fd;
17 int rc;
18 int i;
19
20 (void)state; /* unused */
21
22 ZERO_STRUCT(readfds);
23
24 fd = open("/dev/null", 0);
25 assert_true(fd > 2);
26
27 FD_ZERO(&readfds);
28 FD_SET(fd, &readfds);
29
30 for (i = 0; i < 10; i++) {
31 ssh_channel cin[1] = { NULL, };
32 ssh_channel cout[1] = { NULL, };
33 struct timeval tv = { .tv_sec = 0, .tv_usec = 1000 };
34
35 rc = ssh_select(cin, cout, fd + 1, &readfds, &tv);
36 assert_int_equal(rc, SSH_OK);
37 }
38
39 close(fd);
40 }
41
42 int torture_run_tests(void) {
43 int rc;
44 struct CMUnitTest tests[] = {
45 cmocka_unit_test(torture_channel_select),
46 };
47
48 ssh_init();
49 torture_filter_tests(tests);
50 rc = cmocka_run_group_tests(tests, NULL, NULL);
51 ssh_finalize();
52
53 return rc;
54 }