tests: Migrated torture_proxycommand to cmockery.
Этот коммит содержится в:
родитель
e6329c72d1
Коммит
df55918a41
@ -3,4 +3,4 @@ project(clienttests C)
|
|||||||
add_cmockery_test(torture_algorithms torture_algorithms.c ${TORTURE_LIBRARY})
|
add_cmockery_test(torture_algorithms torture_algorithms.c ${TORTURE_LIBRARY})
|
||||||
add_cmockery_test(torture_auth torture_auth.c ${TORTURE_LIBRARY})
|
add_cmockery_test(torture_auth torture_auth.c ${TORTURE_LIBRARY})
|
||||||
add_cmockery_test(torture_knownhosts torture_knownhosts.c ${TORTURE_LIBRARY})
|
add_cmockery_test(torture_knownhosts torture_knownhosts.c ${TORTURE_LIBRARY})
|
||||||
#add_check_test(torture_proxycommand torture_proxycommand.c ${TORTURE_LIBRARY})
|
add_cmockery_test(torture_proxycommand torture_proxycommand.c ${TORTURE_LIBRARY})
|
||||||
|
@ -3,52 +3,48 @@
|
|||||||
#include "torture.h"
|
#include "torture.h"
|
||||||
#include <libssh/libssh.h>
|
#include <libssh/libssh.h>
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
ssh_session session;
|
|
||||||
|
|
||||||
static void setup(void) {
|
static void setup(void **state) {
|
||||||
session = ssh_new();
|
ssh_session session = ssh_new();
|
||||||
|
|
||||||
|
*state = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void) {
|
static void teardown(void **state) {
|
||||||
ssh_free(session);
|
ssh_free(*state);
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST (torture_options_set_proxycommand)
|
static void torture_options_set_proxycommand(void **state) {
|
||||||
{
|
ssh_session session = *state;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
|
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
|
||||||
ck_assert(rc == 0);
|
assert_true(rc == 0);
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, "nc localhost 22");
|
rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, "nc localhost 22");
|
||||||
ck_assert(rc == 0);
|
assert_true(rc == 0);
|
||||||
rc = ssh_connect(session);
|
rc = ssh_connect(session);
|
||||||
ck_assert_msg(rc== SSH_OK,ssh_get_error(session));
|
assert_true(rc == SSH_OK);
|
||||||
}
|
}
|
||||||
END_TEST
|
|
||||||
|
|
||||||
START_TEST (torture_options_set_proxycommand_notexist)
|
static void torture_options_set_proxycommand_notexist(void **state) {
|
||||||
{
|
ssh_session session = *state;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
|
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
|
||||||
ck_assert(rc == 0);
|
assert_true(rc == 0);
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, "this_command_does_not_exist");
|
rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, "this_command_does_not_exist");
|
||||||
ck_assert(rc == SSH_OK);
|
assert_true(rc == SSH_OK);
|
||||||
rc = ssh_connect(session);
|
rc = ssh_connect(session);
|
||||||
ck_assert_msg(rc== SSH_ERROR);
|
assert_true(rc == SSH_ERROR);
|
||||||
}
|
}
|
||||||
END_TEST
|
|
||||||
|
|
||||||
Suite *torture_make_suite(void) {
|
int torture_run_tests(void) {
|
||||||
Suite *s = suite_create("libssh_proxycommand");
|
const UnitTest tests[] = {
|
||||||
|
unit_test_setup_teardown(torture_options_set_proxycommand, setup, teardown),
|
||||||
|
unit_test_setup_teardown(torture_options_set_proxycommand_notexist, setup, teardown),
|
||||||
|
};
|
||||||
|
|
||||||
torture_create_case_fixture(s, "torture_options_set_proxycommand",
|
return run_tests(tests);
|
||||||
torture_options_set_proxycommand, setup, teardown);
|
|
||||||
torture_create_case_fixture(s, "torture_options_set_proxycommand_notexist",
|
|
||||||
torture_options_set_proxycommand_notexist, setup, teardown);
|
|
||||||
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user