2017-10-28 15:31:37 +03:00
|
|
|
#include "config.h"
|
2011-01-11 19:48:48 +03:00
|
|
|
|
2018-04-12 18:03:06 +03:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2010-03-02 15:47:14 +03:00
|
|
|
#include <sys/types.h>
|
2010-12-29 22:35:55 +03:00
|
|
|
#ifndef _WIN32
|
2011-01-11 19:48:48 +03:00
|
|
|
|
|
|
|
#define _POSIX_PTHREAD_SEMANTICS
|
2010-03-02 15:47:14 +03:00
|
|
|
#include <pwd.h>
|
2010-12-29 22:35:55 +03:00
|
|
|
#endif
|
2010-03-03 01:48:45 +03:00
|
|
|
|
|
|
|
#define LIBSSH_STATIC
|
2010-03-02 15:47:14 +03:00
|
|
|
#include <libssh/priv.h>
|
|
|
|
|
|
|
|
#include "torture.h"
|
|
|
|
#include "misc.c"
|
2011-02-13 13:55:31 +03:00
|
|
|
#include "error.c"
|
|
|
|
|
2010-12-28 16:57:42 +03:00
|
|
|
#define TORTURE_TEST_DIR "/usr/local/bin/truc/much/.."
|
2010-03-02 15:47:14 +03:00
|
|
|
|
2010-05-11 03:12:08 +04:00
|
|
|
|
2015-09-07 11:39:51 +03:00
|
|
|
static int setup(void **state)
|
|
|
|
{
|
2010-12-28 16:57:42 +03:00
|
|
|
ssh_session session = ssh_new();
|
|
|
|
*state = session;
|
2015-09-07 11:39:51 +03:00
|
|
|
|
|
|
|
return 0;
|
2010-05-11 03:12:08 +04:00
|
|
|
}
|
|
|
|
|
2015-09-07 11:39:51 +03:00
|
|
|
static int teardown(void **state)
|
|
|
|
{
|
2010-12-28 16:57:42 +03:00
|
|
|
ssh_free(*state);
|
2015-09-07 11:39:51 +03:00
|
|
|
|
|
|
|
return 0;
|
2010-05-11 03:12:08 +04:00
|
|
|
}
|
|
|
|
|
2010-12-28 16:57:42 +03:00
|
|
|
static void torture_get_user_home_dir(void **state) {
|
2010-12-29 22:35:55 +03:00
|
|
|
#ifndef _WIN32
|
|
|
|
struct passwd *pwd = getpwuid(getuid());
|
|
|
|
#endif /* _WIN32 */
|
2010-03-02 15:47:14 +03:00
|
|
|
char *user;
|
|
|
|
|
2010-12-28 16:57:42 +03:00
|
|
|
(void) state;
|
|
|
|
|
2010-03-02 15:47:14 +03:00
|
|
|
user = ssh_get_user_home_dir();
|
2019-01-15 15:45:10 +03:00
|
|
|
assert_non_null(user);
|
2010-12-29 22:35:55 +03:00
|
|
|
#ifndef _WIN32
|
2010-12-28 16:57:42 +03:00
|
|
|
assert_string_equal(user, pwd->pw_dir);
|
2010-12-29 22:35:55 +03:00
|
|
|
#endif /* _WIN32 */
|
2010-03-13 18:59:26 +03:00
|
|
|
|
|
|
|
SAFE_FREE(user);
|
2010-03-02 15:47:14 +03:00
|
|
|
}
|
|
|
|
|
2010-12-28 16:57:42 +03:00
|
|
|
static void torture_basename(void **state) {
|
2010-05-09 00:13:35 +04:00
|
|
|
char *path;
|
2010-12-28 16:57:42 +03:00
|
|
|
|
|
|
|
(void) state;
|
|
|
|
|
|
|
|
path=ssh_basename(TORTURE_TEST_DIR "/test");
|
2019-01-15 13:19:49 +03:00
|
|
|
assert_non_null(path);
|
2010-12-28 16:57:42 +03:00
|
|
|
assert_string_equal(path, "test");
|
2010-05-09 00:13:35 +04:00
|
|
|
SAFE_FREE(path);
|
2010-12-28 16:57:42 +03:00
|
|
|
path=ssh_basename(TORTURE_TEST_DIR "/test/");
|
2019-01-15 13:19:49 +03:00
|
|
|
assert_non_null(path);
|
2010-12-28 16:57:42 +03:00
|
|
|
assert_string_equal(path, "test");
|
2010-05-09 00:13:35 +04:00
|
|
|
SAFE_FREE(path);
|
|
|
|
}
|
|
|
|
|
2010-12-28 16:57:42 +03:00
|
|
|
static void torture_dirname(void **state) {
|
2010-05-09 00:13:35 +04:00
|
|
|
char *path;
|
2010-12-28 16:57:42 +03:00
|
|
|
|
|
|
|
(void) state;
|
|
|
|
|
|
|
|
path=ssh_dirname(TORTURE_TEST_DIR "/test");
|
2019-01-15 13:19:49 +03:00
|
|
|
assert_non_null(path);
|
2010-12-28 16:57:42 +03:00
|
|
|
assert_string_equal(path, TORTURE_TEST_DIR );
|
2010-05-09 00:13:35 +04:00
|
|
|
SAFE_FREE(path);
|
2010-12-28 16:57:42 +03:00
|
|
|
path=ssh_dirname(TORTURE_TEST_DIR "/test/");
|
2019-01-15 13:19:49 +03:00
|
|
|
assert_non_null(path);
|
2010-12-28 16:57:42 +03:00
|
|
|
assert_string_equal(path, TORTURE_TEST_DIR);
|
2010-05-09 00:13:35 +04:00
|
|
|
SAFE_FREE(path);
|
|
|
|
}
|
|
|
|
|
2010-12-28 16:57:42 +03:00
|
|
|
static void torture_ntohll(void **state) {
|
2010-05-09 00:23:05 +04:00
|
|
|
uint64_t value = 0x0123456789abcdef;
|
2010-12-28 16:57:42 +03:00
|
|
|
uint32_t sample = 1;
|
|
|
|
unsigned char *ptr = (unsigned char *) &sample;
|
2010-05-09 00:23:05 +04:00
|
|
|
uint64_t check;
|
2010-12-28 16:57:42 +03:00
|
|
|
|
|
|
|
(void) state;
|
|
|
|
|
|
|
|
if (ptr[0] == 1){
|
2017-07-12 00:10:26 +03:00
|
|
|
/* we're in little endian */
|
|
|
|
check = 0xefcdab8967452301;
|
2010-05-09 00:22:06 +04:00
|
|
|
} else {
|
2017-07-12 00:10:26 +03:00
|
|
|
/* big endian */
|
|
|
|
check = value;
|
2010-05-09 00:22:06 +04:00
|
|
|
}
|
2010-12-28 16:57:42 +03:00
|
|
|
value = ntohll(value);
|
|
|
|
assert_true(value == check);
|
2010-05-09 00:22:06 +04:00
|
|
|
}
|
|
|
|
|
2011-01-01 21:23:38 +03:00
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
static void torture_path_expand_tilde_win(void **state) {
|
|
|
|
char *d;
|
|
|
|
|
|
|
|
(void) state;
|
|
|
|
|
|
|
|
d = ssh_path_expand_tilde("~\\.ssh");
|
2019-01-15 15:45:10 +03:00
|
|
|
assert_non_null(d);
|
2011-01-01 21:23:38 +03:00
|
|
|
print_message("Expanded path: %s\n", d);
|
|
|
|
free(d);
|
|
|
|
|
|
|
|
d = ssh_path_expand_tilde("/guru/meditation");
|
|
|
|
assert_string_equal(d, "/guru/meditation");
|
|
|
|
free(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* _WIN32 */
|
|
|
|
|
|
|
|
static void torture_path_expand_tilde_unix(void **state) {
|
2010-05-11 00:47:21 +04:00
|
|
|
char h[256];
|
|
|
|
char *d;
|
2015-02-12 13:26:50 +03:00
|
|
|
char *user;
|
|
|
|
char *home;
|
2010-05-11 00:47:21 +04:00
|
|
|
|
2010-12-28 16:57:42 +03:00
|
|
|
(void) state;
|
|
|
|
|
2015-02-12 13:26:50 +03:00
|
|
|
user = getenv("USER");
|
|
|
|
if (user == NULL){
|
|
|
|
user = getenv("LOGNAME");
|
|
|
|
}
|
2018-04-12 18:03:06 +03:00
|
|
|
/* in certain CIs there no such variables */
|
|
|
|
if (!user){
|
|
|
|
struct passwd *pw = getpwuid(getuid());
|
|
|
|
if (pw){
|
|
|
|
user = pw->pw_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-12 13:26:50 +03:00
|
|
|
home = getenv("HOME");
|
|
|
|
assert_non_null(home);
|
|
|
|
snprintf(h, 256 - 1, "%s/.ssh", home);
|
2010-05-11 00:47:21 +04:00
|
|
|
|
|
|
|
d = ssh_path_expand_tilde("~/.ssh");
|
2015-02-12 13:26:50 +03:00
|
|
|
assert_non_null(d);
|
2010-12-28 16:57:42 +03:00
|
|
|
assert_string_equal(d, h);
|
2010-05-11 00:47:21 +04:00
|
|
|
free(d);
|
|
|
|
|
|
|
|
d = ssh_path_expand_tilde("/guru/meditation");
|
2015-02-12 13:26:50 +03:00
|
|
|
assert_non_null(d);
|
2010-12-28 16:57:42 +03:00
|
|
|
assert_string_equal(d, "/guru/meditation");
|
2010-05-11 00:47:21 +04:00
|
|
|
free(d);
|
|
|
|
|
2015-02-12 13:26:50 +03:00
|
|
|
snprintf(h, 256 - 1, "~%s/.ssh", user);
|
2010-05-11 00:47:21 +04:00
|
|
|
d = ssh_path_expand_tilde(h);
|
2015-02-12 13:26:50 +03:00
|
|
|
assert_non_null(d);
|
2010-05-11 00:47:21 +04:00
|
|
|
|
2015-02-12 13:26:50 +03:00
|
|
|
snprintf(h, 256 - 1, "%s/.ssh", home);
|
2010-12-28 16:57:42 +03:00
|
|
|
assert_string_equal(d, h);
|
2010-05-11 00:47:21 +04:00
|
|
|
free(d);
|
|
|
|
}
|
|
|
|
|
2011-01-01 21:23:38 +03:00
|
|
|
#endif /* _WIN32 */
|
|
|
|
|
2010-12-28 16:57:42 +03:00
|
|
|
static void torture_path_expand_escape(void **state) {
|
|
|
|
ssh_session session = *state;
|
2010-05-11 03:12:08 +04:00
|
|
|
const char *s = "%d/%h/by/%r";
|
|
|
|
char *e;
|
|
|
|
|
2012-02-05 14:50:49 +04:00
|
|
|
session->opts.sshdir = strdup("guru");
|
|
|
|
session->opts.host = strdup("meditation");
|
|
|
|
session->opts.username = strdup("root");
|
2010-05-11 03:12:08 +04:00
|
|
|
|
|
|
|
e = ssh_path_expand_escape(session, s);
|
2015-02-12 13:26:50 +03:00
|
|
|
assert_non_null(e);
|
2010-12-28 16:57:42 +03:00
|
|
|
assert_string_equal(e, "guru/meditation/by/root");
|
2010-05-11 03:12:08 +04:00
|
|
|
free(e);
|
|
|
|
}
|
|
|
|
|
2010-12-28 16:57:42 +03:00
|
|
|
static void torture_path_expand_known_hosts(void **state) {
|
|
|
|
ssh_session session = *state;
|
2010-05-31 11:17:54 +04:00
|
|
|
char *tmp;
|
|
|
|
|
2012-02-05 14:50:49 +04:00
|
|
|
session->opts.sshdir = strdup("/home/guru/.ssh");
|
2010-05-31 11:17:54 +04:00
|
|
|
|
|
|
|
tmp = ssh_path_expand_escape(session, "%d/known_hosts");
|
2015-02-12 13:26:50 +03:00
|
|
|
assert_non_null(tmp);
|
2010-12-28 16:57:42 +03:00
|
|
|
assert_string_equal(tmp, "/home/guru/.ssh/known_hosts");
|
2010-05-31 11:17:54 +04:00
|
|
|
free(tmp);
|
|
|
|
}
|
2010-03-02 15:47:14 +03:00
|
|
|
|
2019-07-30 17:02:46 +03:00
|
|
|
static void torture_path_expand_percent(void **state) {
|
|
|
|
ssh_session session = *state;
|
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
session->opts.sshdir = strdup("/home/guru/.ssh");
|
|
|
|
|
|
|
|
tmp = ssh_path_expand_escape(session, "%d/config%%1");
|
|
|
|
assert_non_null(tmp);
|
|
|
|
assert_string_equal(tmp, "/home/guru/.ssh/config%1");
|
|
|
|
free(tmp);
|
|
|
|
}
|
|
|
|
|
2011-05-25 01:26:18 +04:00
|
|
|
static void torture_timeout_elapsed(void **state){
|
|
|
|
struct ssh_timestamp ts;
|
|
|
|
(void) state;
|
|
|
|
ssh_timestamp_init(&ts);
|
|
|
|
usleep(50000);
|
|
|
|
assert_true(ssh_timeout_elapsed(&ts,25));
|
|
|
|
assert_false(ssh_timeout_elapsed(&ts,30000));
|
|
|
|
assert_false(ssh_timeout_elapsed(&ts,75));
|
|
|
|
assert_true(ssh_timeout_elapsed(&ts,0));
|
|
|
|
assert_false(ssh_timeout_elapsed(&ts,-1));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void torture_timeout_update(void **state){
|
|
|
|
struct ssh_timestamp ts;
|
|
|
|
(void) state;
|
|
|
|
ssh_timestamp_init(&ts);
|
|
|
|
usleep(50000);
|
|
|
|
assert_int_equal(ssh_timeout_update(&ts,25), 0);
|
|
|
|
assert_in_range(ssh_timeout_update(&ts,30000),29000,29960);
|
|
|
|
assert_in_range(ssh_timeout_update(&ts,75),1,40);
|
|
|
|
assert_int_equal(ssh_timeout_update(&ts,0),0);
|
|
|
|
assert_int_equal(ssh_timeout_update(&ts,-1),-1);
|
|
|
|
}
|
|
|
|
|
2017-07-12 01:46:54 +03:00
|
|
|
static void torture_ssh_analyze_banner(void **state) {
|
|
|
|
int rc = 0;
|
|
|
|
ssh_session session = NULL;
|
|
|
|
(void) state;
|
|
|
|
|
|
|
|
#define reset_banner_test() \
|
|
|
|
do { \
|
|
|
|
rc = 0; \
|
|
|
|
ssh_free(session); \
|
|
|
|
session = ssh_new(); \
|
|
|
|
assert_non_null(session); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define assert_banner_rejected(is_server) \
|
|
|
|
do { \
|
2018-06-28 18:52:58 +03:00
|
|
|
rc = ssh_analyze_banner(session, is_server); \
|
2017-07-12 01:46:54 +03:00
|
|
|
assert_int_not_equal(0, rc); \
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
#define assert_client_banner_rejected(banner) \
|
|
|
|
do { \
|
|
|
|
reset_banner_test(); \
|
|
|
|
session->clientbanner = strdup(banner); \
|
|
|
|
assert_non_null(session->clientbanner); \
|
|
|
|
assert_banner_rejected(1 /*server*/); \
|
|
|
|
SAFE_FREE(session->clientbanner); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define assert_server_banner_rejected(banner) \
|
|
|
|
do { \
|
|
|
|
reset_banner_test(); \
|
|
|
|
session->serverbanner = strdup(banner); \
|
|
|
|
assert_non_null(session->serverbanner); \
|
|
|
|
assert_banner_rejected(0 /*client*/); \
|
|
|
|
SAFE_FREE(session->serverbanner); \
|
|
|
|
} while (0)
|
|
|
|
|
2018-06-28 18:52:58 +03:00
|
|
|
#define assert_banner_accepted(is_server) \
|
2017-07-12 01:46:54 +03:00
|
|
|
do { \
|
2018-06-28 18:52:58 +03:00
|
|
|
rc = ssh_analyze_banner(session, is_server); \
|
2017-07-12 01:46:54 +03:00
|
|
|
assert_int_equal(0, rc); \
|
|
|
|
} while (0)
|
|
|
|
|
2018-06-28 18:52:58 +03:00
|
|
|
#define assert_client_banner_accepted(banner) \
|
2017-07-12 01:46:54 +03:00
|
|
|
do { \
|
|
|
|
reset_banner_test(); \
|
|
|
|
session->clientbanner = strdup(banner); \
|
|
|
|
assert_non_null(session->clientbanner); \
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_banner_accepted(1 /*server*/); \
|
2017-07-12 01:46:54 +03:00
|
|
|
SAFE_FREE(session->clientbanner); \
|
|
|
|
} while (0)
|
|
|
|
|
2018-06-28 18:52:58 +03:00
|
|
|
#define assert_server_banner_accepted(banner) \
|
2017-07-12 01:46:54 +03:00
|
|
|
do { \
|
|
|
|
reset_banner_test(); \
|
|
|
|
session->serverbanner = strdup(banner); \
|
|
|
|
assert_non_null(session->serverbanner); \
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_banner_accepted(0 /*client*/); \
|
2017-07-12 01:46:54 +03:00
|
|
|
SAFE_FREE(session->serverbanner); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/* no banner is set */
|
|
|
|
reset_banner_test();
|
|
|
|
assert_banner_rejected(0 /*client*/);
|
|
|
|
reset_banner_test();
|
|
|
|
assert_banner_rejected(1 /*server*/);
|
|
|
|
|
|
|
|
/* banner is too short */
|
|
|
|
assert_client_banner_rejected("abc");
|
|
|
|
assert_server_banner_rejected("abc");
|
|
|
|
|
|
|
|
/* banner doesn't start "SSH-" */
|
|
|
|
assert_client_banner_rejected("abc-2.0");
|
|
|
|
assert_server_banner_rejected("abc-2.0");
|
|
|
|
|
|
|
|
/* SSH v1 */
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_client_banner_rejected("SSH-1.0");
|
|
|
|
assert_server_banner_rejected("SSH-1.0");
|
2017-07-12 01:46:54 +03:00
|
|
|
|
|
|
|
/* SSH v1.9 gets counted as both v1 and v2 */
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_client_banner_accepted("SSH-1.9");
|
|
|
|
assert_server_banner_accepted("SSH-1.9");
|
2017-07-12 01:46:54 +03:00
|
|
|
|
|
|
|
/* SSH v2 */
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_client_banner_accepted("SSH-2.0");
|
|
|
|
assert_server_banner_accepted("SSH-2.0");
|
2017-07-12 01:46:54 +03:00
|
|
|
|
|
|
|
/* OpenSSH banners: too short to extract major and minor versions */
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_client_banner_accepted("SSH-2.0-OpenSSH");
|
2017-07-12 01:46:54 +03:00
|
|
|
assert_int_equal(0, session->openssh);
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_server_banner_accepted("SSH-2.0-OpenSSH");
|
2017-07-12 01:46:54 +03:00
|
|
|
assert_int_equal(0, session->openssh);
|
|
|
|
|
|
|
|
/* OpenSSH banners: big enough to extract major and minor versions */
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_client_banner_accepted("SSH-2.0-OpenSSH_5.9p1");
|
2017-07-12 01:46:54 +03:00
|
|
|
assert_int_equal(SSH_VERSION_INT(5, 9, 0), session->openssh);
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_server_banner_accepted("SSH-2.0-OpenSSH_5.9p1");
|
2017-07-12 01:46:54 +03:00
|
|
|
assert_int_equal(SSH_VERSION_INT(5, 9, 0), session->openssh);
|
|
|
|
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_client_banner_accepted("SSH-2.0-OpenSSH_1.99");
|
2017-07-12 01:46:54 +03:00
|
|
|
assert_int_equal(SSH_VERSION_INT(1, 99, 0), session->openssh);
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_server_banner_accepted("SSH-2.0-OpenSSH_1.99");
|
2017-07-12 01:46:54 +03:00
|
|
|
assert_int_equal(SSH_VERSION_INT(1, 99, 0), session->openssh);
|
|
|
|
|
2017-07-12 02:34:18 +03:00
|
|
|
/* OpenSSH banners: major, minor version limits result in zero */
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_client_banner_accepted("SSH-2.0-OpenSSH_0.99p1");
|
2017-07-12 02:34:18 +03:00
|
|
|
assert_int_equal(0, session->openssh);
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_server_banner_accepted("SSH-2.0-OpenSSH_0.99p1");
|
2017-07-12 02:34:18 +03:00
|
|
|
assert_int_equal(0, session->openssh);
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_client_banner_accepted("SSH-2.0-OpenSSH_1.101p1");
|
2017-07-12 02:34:18 +03:00
|
|
|
assert_int_equal(0, session->openssh);
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_server_banner_accepted("SSH-2.0-OpenSSH_1.101p1");
|
2017-07-12 02:34:18 +03:00
|
|
|
assert_int_equal(0, session->openssh);
|
2017-07-12 01:46:54 +03:00
|
|
|
|
2017-07-12 02:34:18 +03:00
|
|
|
/* OpenSSH banners: bogus major results in zero */
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_client_banner_accepted("SSH-2.0-OpenSSH_X.9p1");
|
2017-07-12 02:34:18 +03:00
|
|
|
assert_int_equal(0, session->openssh);
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_server_banner_accepted("SSH-2.0-OpenSSH_X.9p1");
|
2017-07-12 02:34:18 +03:00
|
|
|
assert_int_equal(0, session->openssh);
|
2017-07-12 01:46:54 +03:00
|
|
|
|
2017-07-12 02:34:18 +03:00
|
|
|
/* OpenSSH banners: bogus minor results in zero */
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_server_banner_accepted("SSH-2.0-OpenSSH_5.Yp1");
|
2017-07-12 02:34:18 +03:00
|
|
|
assert_int_equal(0, session->openssh);
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_client_banner_accepted("SSH-2.0-OpenSSH_5.Yp1");
|
2017-07-12 02:34:18 +03:00
|
|
|
assert_int_equal(0, session->openssh);
|
2017-07-12 01:46:54 +03:00
|
|
|
|
|
|
|
/* OpenSSH banners: ssh-keyscan(1) */
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_client_banner_accepted("SSH-2.0-OpenSSH-keyscan");
|
2017-07-12 01:46:54 +03:00
|
|
|
assert_int_equal(0, session->openssh);
|
2018-06-28 18:52:58 +03:00
|
|
|
assert_server_banner_accepted("SSH-2.0-OpenSSH-keyscan");
|
2017-07-12 01:46:54 +03:00
|
|
|
assert_int_equal(0, session->openssh);
|
|
|
|
|
|
|
|
ssh_free(session);
|
|
|
|
}
|
|
|
|
|
2010-12-28 16:57:42 +03:00
|
|
|
int torture_run_tests(void) {
|
2011-01-02 19:25:51 +03:00
|
|
|
int rc;
|
2015-09-07 11:39:51 +03:00
|
|
|
struct CMUnitTest tests[] = {
|
|
|
|
cmocka_unit_test(torture_get_user_home_dir),
|
|
|
|
cmocka_unit_test(torture_basename),
|
|
|
|
cmocka_unit_test(torture_dirname),
|
|
|
|
cmocka_unit_test(torture_ntohll),
|
2011-01-01 21:23:38 +03:00
|
|
|
#ifdef _WIN32
|
2015-09-07 11:39:51 +03:00
|
|
|
cmocka_unit_test(torture_path_expand_tilde_win),
|
2011-01-01 21:23:38 +03:00
|
|
|
#else
|
2015-09-07 11:39:51 +03:00
|
|
|
cmocka_unit_test(torture_path_expand_tilde_unix),
|
2011-01-01 21:23:38 +03:00
|
|
|
#endif
|
2015-09-07 11:39:51 +03:00
|
|
|
cmocka_unit_test_setup_teardown(torture_path_expand_escape, setup, teardown),
|
|
|
|
cmocka_unit_test_setup_teardown(torture_path_expand_known_hosts, setup, teardown),
|
2019-07-30 17:02:46 +03:00
|
|
|
cmocka_unit_test_setup_teardown(torture_path_expand_percent, setup, teardown),
|
2015-09-07 11:39:51 +03:00
|
|
|
cmocka_unit_test(torture_timeout_elapsed),
|
|
|
|
cmocka_unit_test(torture_timeout_update),
|
2017-07-12 01:46:54 +03:00
|
|
|
cmocka_unit_test(torture_ssh_analyze_banner),
|
2010-12-28 16:57:42 +03:00
|
|
|
};
|
|
|
|
|
2011-01-02 19:25:51 +03: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);
|
2011-01-02 19:25:51 +03:00
|
|
|
ssh_finalize();
|
|
|
|
return rc;
|
2010-12-28 16:57:42 +03:00
|
|
|
}
|