tests: Migrate to new cmocka API
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
родитель
5b586fdfec
Коммит
82a80b205b
@ -26,15 +26,19 @@
|
|||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state) {
|
||||||
int verbosity=torture_libssh_verbosity();
|
int verbosity=torture_libssh_verbosity();
|
||||||
ssh_session session = ssh_new();
|
ssh_session session = ssh_new();
|
||||||
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
|
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
|
||||||
*state = session;
|
*state = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state) {
|
||||||
ssh_free(*state);
|
ssh_free(*state);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_algorithm(ssh_session session, const char *algo, const char *hmac) {
|
static void test_algorithm(ssh_session session, const char *algo, const char *hmac) {
|
||||||
@ -289,42 +293,42 @@ static void torture_algorithms_dh_group1(void **state) {
|
|||||||
}
|
}
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha1, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_256, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_256, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_512, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_512, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha1, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_256, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_256, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_512, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_512, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha1, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_256, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_256, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_512, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_512, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha1, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_256, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_256, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_512, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_512, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha1, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_256, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_256, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_512, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_512, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha1, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_256, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_256, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_512, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_512, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha1, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_256, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_256, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_512, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_512, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha1, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_256, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_256, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_512, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_512, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_zlib, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_zlib, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_zlib_openssh, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_zlib_openssh, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_algorithms_dh_group1,setup,teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_dh_group1,setup,teardown),
|
||||||
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_ECC)
|
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_ECC)
|
||||||
unit_test_setup_teardown(torture_algorithms_ecdh_sha2_nistp256,setup,teardown)
|
cmocka_unit_test_setup_teardown(torture_algorithms_ecdh_sha2_nistp256,setup,teardown)
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc = run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "libssh/session.h"
|
#include "libssh/session.h"
|
||||||
#include "agent.c"
|
#include "agent.c"
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state) {
|
||||||
int verbosity = torture_libssh_verbosity();
|
int verbosity = torture_libssh_verbosity();
|
||||||
ssh_session session = ssh_new();
|
ssh_session session = ssh_new();
|
||||||
|
|
||||||
@ -35,11 +35,15 @@ static void setup(void **state) {
|
|||||||
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
|
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
|
||||||
|
|
||||||
*state = session;
|
*state = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state) {
|
||||||
ssh_disconnect(*state);
|
ssh_disconnect(*state);
|
||||||
ssh_free(*state);
|
ssh_free(*state);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_auth_autopubkey(void **state) {
|
static void torture_auth_autopubkey(void **state) {
|
||||||
@ -421,22 +425,22 @@ static void torture_auth_none_nonblocking(void **state) {
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_auth_kbdint, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_auth_kbdint, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_auth_kbdint_nonblocking, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_auth_kbdint_nonblocking, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_auth_password, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_auth_password, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_auth_password_nonblocking, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_auth_password_nonblocking, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_auth_autopubkey, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_auth_autopubkey, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_auth_autopubkey_nonblocking, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_auth_autopubkey_nonblocking, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_auth_agent, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_auth_agent, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_auth_agent_nonblocking, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_auth_agent_nonblocking, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_auth_none, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_auth_none, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_auth_none_nonblocking, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_auth_none_nonblocking, setup, teardown),
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc = run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -32,19 +32,23 @@
|
|||||||
/* Should work until Apnic decides to assign it :) */
|
/* Should work until Apnic decides to assign it :) */
|
||||||
#define BLACKHOLE "1.1.1.1"
|
#define BLACKHOLE "1.1.1.1"
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state) {
|
||||||
int verbosity=torture_libssh_verbosity();
|
int verbosity=torture_libssh_verbosity();
|
||||||
ssh_session session = ssh_new();
|
ssh_session session = ssh_new();
|
||||||
|
|
||||||
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
|
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
|
||||||
|
|
||||||
*state = session;
|
*state = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state) {
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
ssh_free(session);
|
ssh_free(session);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_connect_nonblocking(void **state) {
|
static void torture_connect_nonblocking(void **state) {
|
||||||
@ -141,18 +145,18 @@ static void torture_connect_socket(void **state) {
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_connect_nonblocking, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_connect_nonblocking, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_connect_double, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_connect_double, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_connect_failure, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_connect_failure, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_connect_timeout, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_connect_timeout, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_connect_socket, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_connect_socket, setup, teardown),
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
|
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc = run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
|
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "torture.h"
|
#include "torture.h"
|
||||||
#include <libssh/libssh.h>
|
#include <libssh/libssh.h>
|
||||||
|
|
||||||
static void setup(void **state)
|
static int setup(void **state)
|
||||||
{
|
{
|
||||||
ssh_session session;
|
ssh_session session;
|
||||||
const char *host;
|
const char *host;
|
||||||
@ -43,9 +43,11 @@ static void setup(void **state)
|
|||||||
|
|
||||||
assert_non_null(session);
|
assert_non_null(session);
|
||||||
*state = session;
|
*state = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state)
|
static int teardown(void **state)
|
||||||
{
|
{
|
||||||
ssh_session session = (ssh_session) *state;
|
ssh_session session = (ssh_session) *state;
|
||||||
|
|
||||||
@ -55,6 +57,8 @@ static void teardown(void **state)
|
|||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
}
|
}
|
||||||
ssh_free(session);
|
ssh_free(session);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_ssh_forward(void **state)
|
static void torture_ssh_forward(void **state)
|
||||||
@ -81,14 +85,14 @@ static void torture_ssh_forward(void **state)
|
|||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_ssh_forward, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_ssh_forward, setup, teardown),
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
|
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc = run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
|
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -44,22 +44,26 @@
|
|||||||
"h0dSi8VJXI1wes5HTyLsv9VBmU1uCXUUvufoQKfF/OcSH0ufcCpnd62g1/adZcy2" \
|
"h0dSi8VJXI1wes5HTyLsv9VBmU1uCXUUvufoQKfF/OcSH0ufcCpnd62g1/adZcy2" \
|
||||||
"WJg=="
|
"WJg=="
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state) {
|
||||||
int verbosity=torture_libssh_verbosity();
|
int verbosity=torture_libssh_verbosity();
|
||||||
ssh_session session = ssh_new();
|
ssh_session session = ssh_new();
|
||||||
|
|
||||||
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
|
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
|
||||||
|
|
||||||
*state = session;
|
*state = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state) {
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
|
|
||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
ssh_free(session);
|
ssh_free(session);
|
||||||
|
|
||||||
unlink(KNOWNHOSTFILES);
|
unlink(KNOWNHOSTFILES);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_knownhosts_port(void **state) {
|
static void torture_knownhosts_port(void **state) {
|
||||||
@ -282,19 +286,19 @@ static void torture_knownhosts_precheck(void **state) {
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_knownhosts_port, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_knownhosts_port, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_knownhosts_fail, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_knownhosts_fail, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_knownhosts_other, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_knownhosts_other, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_knownhosts_other_auto, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_knownhosts_other_auto, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_knownhosts_conflict, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_knownhosts_conflict, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_knownhosts_precheck, setup, teardown)
|
cmocka_unit_test_setup_teardown(torture_knownhosts_precheck, setup, teardown)
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
|
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc = run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
|
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -4,14 +4,18 @@
|
|||||||
#include <libssh/libssh.h>
|
#include <libssh/libssh.h>
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state) {
|
||||||
ssh_session session = ssh_new();
|
ssh_session session = ssh_new();
|
||||||
|
|
||||||
*state = session;
|
*state = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state) {
|
||||||
ssh_free(*state);
|
ssh_free(*state);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_set_proxycommand(void **state) {
|
static void torture_options_set_proxycommand(void **state) {
|
||||||
@ -42,16 +46,16 @@ static void torture_options_set_proxycommand_notexist(void **state) {
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_options_set_proxycommand, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_proxycommand, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_options_set_proxycommand_notexist, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_proxycommand_notexist, setup, teardown),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
|
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc = run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "torture.h"
|
#include "torture.h"
|
||||||
#include <libssh/libssh.h>
|
#include <libssh/libssh.h>
|
||||||
|
|
||||||
static void setup(void **state)
|
static int setup(void **state)
|
||||||
{
|
{
|
||||||
ssh_session session;
|
ssh_session session;
|
||||||
const char *host;
|
const char *host;
|
||||||
@ -43,9 +43,11 @@ static void setup(void **state)
|
|||||||
|
|
||||||
assert_false(session == NULL);
|
assert_false(session == NULL);
|
||||||
*state = session;
|
*state = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state)
|
static int teardown(void **state)
|
||||||
{
|
{
|
||||||
ssh_session session = *state;
|
ssh_session session = *state;
|
||||||
|
|
||||||
@ -55,6 +57,8 @@ static void teardown(void **state)
|
|||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
}
|
}
|
||||||
ssh_free(session);
|
ssh_free(session);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_request_env(void **state)
|
static void torture_request_env(void **state)
|
||||||
@ -100,14 +104,14 @@ static void torture_request_env(void **state)
|
|||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_request_env, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_request_env, setup, teardown),
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
|
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc = run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
|
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#define BUFLEN 4096
|
#define BUFLEN 4096
|
||||||
static char buffer[BUFLEN];
|
static char buffer[BUFLEN];
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state) {
|
||||||
int verbosity = torture_libssh_verbosity();
|
int verbosity = torture_libssh_verbosity();
|
||||||
ssh_session session = ssh_new();
|
ssh_session session = ssh_new();
|
||||||
|
|
||||||
@ -37,10 +37,14 @@ static void setup(void **state) {
|
|||||||
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
|
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
|
||||||
|
|
||||||
*state = session;
|
*state = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state) {
|
||||||
ssh_disconnect(*state);
|
ssh_disconnect(*state);
|
||||||
|
|
||||||
|
return 0;
|
||||||
ssh_free(*state);
|
ssh_free(*state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,14 +103,14 @@ static void torture_channel_read_error(void **state) {
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_channel_read_error, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_channel_read_error, setup, teardown),
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
|
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc = run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "torture.h"
|
#include "torture.h"
|
||||||
#include "sftp.c"
|
#include "sftp.c"
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state) {
|
||||||
ssh_session session;
|
ssh_session session;
|
||||||
struct torture_sftp *t;
|
struct torture_sftp *t;
|
||||||
const char *host;
|
const char *host;
|
||||||
@ -24,15 +24,19 @@ static void setup(void **state) {
|
|||||||
assert_false(t == NULL);
|
assert_false(t == NULL);
|
||||||
|
|
||||||
*state = t;
|
*state = t;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state) {
|
||||||
struct torture_sftp *t = *state;
|
struct torture_sftp *t = *state;
|
||||||
|
|
||||||
assert_false(t == NULL);
|
assert_false(t == NULL);
|
||||||
|
|
||||||
torture_rmdirs(t->testdir);
|
torture_rmdirs(t->testdir);
|
||||||
torture_sftp_close(t);
|
torture_sftp_close(t);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_sftp_mkdir(void **state) {
|
static void torture_sftp_mkdir(void **state) {
|
||||||
@ -61,14 +65,14 @@ static void torture_sftp_mkdir(void **state) {
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_sftp_mkdir, setup, teardown)
|
cmocka_unit_test_setup_teardown(torture_sftp_mkdir, setup, teardown)
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
|
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc = run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
#define MAX_XFER_BUF_SIZE 16384
|
#define MAX_XFER_BUF_SIZE 16384
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state)
|
||||||
|
{
|
||||||
ssh_session session;
|
ssh_session session;
|
||||||
struct torture_sftp *t;
|
struct torture_sftp *t;
|
||||||
const char *host;
|
const char *host;
|
||||||
@ -26,15 +27,20 @@ static void setup(void **state) {
|
|||||||
assert_false(t == NULL);
|
assert_false(t == NULL);
|
||||||
|
|
||||||
*state = t;
|
*state = t;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state)
|
||||||
|
{
|
||||||
struct torture_sftp *t = (struct torture_sftp*) *state;
|
struct torture_sftp *t = (struct torture_sftp*) *state;
|
||||||
|
|
||||||
assert_false(t == NULL);
|
assert_false(t == NULL);
|
||||||
|
|
||||||
torture_rmdirs(t->testdir);
|
torture_rmdirs(t->testdir);
|
||||||
torture_sftp_close(t);
|
torture_sftp_close(t);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_sftp_read_blocking(void **state) {
|
static void torture_sftp_read_blocking(void **state) {
|
||||||
@ -72,14 +78,14 @@ static void torture_sftp_read_blocking(void **state) {
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_sftp_read_blocking, setup, teardown)
|
cmocka_unit_test_setup_teardown(torture_sftp_read_blocking, setup, teardown)
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
|
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc = run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -19,14 +19,14 @@ static void torture_sftp_ext_new(void **state) {
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test(torture_sftp_ext_new),
|
cmocka_unit_test(torture_sftp_ext_new),
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
|
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc = run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -651,29 +651,22 @@ int torture_libssh_verbosity(void){
|
|||||||
return verbosity;
|
return verbosity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _torture_filter_tests(UnitTest *tests, size_t ntests){
|
void _torture_filter_tests(struct CMUnitTest *tests, size_t ntests)
|
||||||
|
{
|
||||||
size_t i,j;
|
size_t i,j;
|
||||||
const char *name, *last_name=NULL;
|
const char *name;
|
||||||
if (pattern == NULL){
|
if (pattern == NULL){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (i=0; i < ntests; ++i){
|
for (i=0; i < ntests; ++i){
|
||||||
if(tests[i].function_type == UNIT_TEST_FUNCTION_TYPE_SETUP){
|
name = tests[i].name;
|
||||||
/* match on the next test name */
|
|
||||||
name = tests[i+1].name;
|
|
||||||
} else if (tests[i].function_type == UNIT_TEST_FUNCTION_TYPE_TEARDOWN){
|
|
||||||
/* match on the previous test name */
|
|
||||||
name = last_name;
|
|
||||||
} else {
|
|
||||||
name = last_name = tests[i].name;
|
|
||||||
}
|
|
||||||
/*printf("match(%s,%s)\n",name,pattern);*/
|
/*printf("match(%s,%s)\n",name,pattern);*/
|
||||||
if (!match_pattern(name, pattern)){
|
if (!match_pattern(name, pattern)){
|
||||||
for (j = i; j < ntests-1;++j){
|
for (j = i; j < ntests-1;++j){
|
||||||
tests[j]=tests[j+1];
|
tests[j]=tests[j+1];
|
||||||
}
|
}
|
||||||
tests[ntests-1].name = NULL;
|
tests[ntests-1].name = NULL;
|
||||||
tests[ntests-1].function = NULL;
|
tests[ntests-1].test_func = NULL;
|
||||||
ntests--;
|
ntests--;
|
||||||
--i;
|
--i;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ const char *torture_get_testkey_passphrase(void);
|
|||||||
void torture_write_file(const char *filename, const char *data);
|
void torture_write_file(const char *filename, const char *data);
|
||||||
|
|
||||||
#define torture_filter_tests(tests) _torture_filter_tests(tests, sizeof(tests) / sizeof(tests)[0])
|
#define torture_filter_tests(tests) _torture_filter_tests(tests, sizeof(tests) / sizeof(tests)[0])
|
||||||
void _torture_filter_tests(UnitTest *tests, size_t ntests);
|
void _torture_filter_tests(struct CMUnitTest *tests, size_t ntests);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function must be defined in every unit test file.
|
* This function must be defined in every unit test file.
|
||||||
|
@ -6,15 +6,23 @@
|
|||||||
|
|
||||||
#define LIMIT (8*1024*1024)
|
#define LIMIT (8*1024*1024)
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state) {
|
||||||
ssh_buffer buffer;
|
ssh_buffer buffer;
|
||||||
|
|
||||||
buffer = ssh_buffer_new();
|
buffer = ssh_buffer_new();
|
||||||
|
if (buffer == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
ssh_buffer_set_secure(buffer);
|
ssh_buffer_set_secure(buffer);
|
||||||
*state = (void *) buffer;
|
*state = (void *) buffer;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state) {
|
||||||
ssh_buffer_free(*state);
|
ssh_buffer_free(*state);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -250,20 +258,20 @@ static void torture_buffer_pack_badformat(void **state){
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_growing_buffer, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_growing_buffer, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_growing_buffer_shifting, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_growing_buffer_shifting, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_buffer_prepend, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_buffer_prepend, setup, teardown),
|
||||||
unit_test(torture_buffer_get_ssh_string),
|
cmocka_unit_test(torture_buffer_get_ssh_string),
|
||||||
unit_test_setup_teardown(torture_buffer_add_format, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_buffer_add_format, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_buffer_get_format, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_buffer_get_format, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_buffer_get_format_error, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_buffer_get_format_error, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_buffer_pack_badformat, setup, teardown)
|
cmocka_unit_test_setup_teardown(torture_buffer_pack_badformat, setup, teardown)
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc=run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,8 @@ static int myauthcallback (const char *prompt, char *buf, size_t len,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state)
|
||||||
|
{
|
||||||
struct ssh_callbacks_struct *cb;
|
struct ssh_callbacks_struct *cb;
|
||||||
|
|
||||||
cb = malloc(sizeof(struct ssh_callbacks_struct));
|
cb = malloc(sizeof(struct ssh_callbacks_struct));
|
||||||
@ -27,10 +28,15 @@ static void setup(void **state) {
|
|||||||
|
|
||||||
ssh_callbacks_init(cb);
|
ssh_callbacks_init(cb);
|
||||||
*state = cb;
|
*state = cb;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state)
|
||||||
|
{
|
||||||
free(*state);
|
free(*state);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_callbacks_size(void **state) {
|
static void torture_callbacks_size(void **state) {
|
||||||
@ -98,15 +104,15 @@ static void torture_log_callback(void **state)
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_callbacks_size, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_callbacks_size, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_callbacks_exists, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_callbacks_exists, setup, teardown),
|
||||||
unit_test(torture_log_callback),
|
cmocka_unit_test(torture_log_callback),
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc=run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,13 @@ static void torture_channel_select(void **state)
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test(torture_channel_select),
|
cmocka_unit_test(torture_channel_select),
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc = run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -15,9 +15,13 @@ static void torture_ssh_init(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
UnitTest tests[] = {
|
int rc;
|
||||||
unit_test(torture_ssh_init),
|
struct CMUnitTest tests[] = {
|
||||||
|
cmocka_unit_test(torture_ssh_init),
|
||||||
};
|
};
|
||||||
|
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
return run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -45,13 +45,13 @@ static void torture_ssh_is_ipaddr(void **state) {
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test(torture_ssh_is_ipaddr)
|
cmocka_unit_test(torture_ssh_is_ipaddr)
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc=run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
#define LIBSSH_RSA_TESTKEY "libssh_testkey.id_rsa"
|
#define LIBSSH_RSA_TESTKEY "libssh_testkey.id_rsa"
|
||||||
#define LIBSSH_DSA_TESTKEY "libssh_testkey.id_dsa"
|
#define LIBSSH_DSA_TESTKEY "libssh_testkey.id_dsa"
|
||||||
|
|
||||||
static void setup_rsa_key(void **state) {
|
static int setup_rsa_key(void **state)
|
||||||
|
{
|
||||||
ssh_session session;
|
ssh_session session;
|
||||||
|
|
||||||
unlink(LIBSSH_RSA_TESTKEY);
|
unlink(LIBSSH_RSA_TESTKEY);
|
||||||
@ -19,9 +20,12 @@ static void setup_rsa_key(void **state) {
|
|||||||
|
|
||||||
session = ssh_new();
|
session = ssh_new();
|
||||||
*state = session;
|
*state = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_dsa_key(void **state) {
|
static int setup_dsa_key(void **state)
|
||||||
|
{
|
||||||
ssh_session session;
|
ssh_session session;
|
||||||
|
|
||||||
unlink(LIBSSH_DSA_TESTKEY);
|
unlink(LIBSSH_DSA_TESTKEY);
|
||||||
@ -34,15 +38,26 @@ static void setup_dsa_key(void **state) {
|
|||||||
|
|
||||||
session = ssh_new();
|
session = ssh_new();
|
||||||
*state = session;
|
*state = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_both_keys(void **state) {
|
static int setup_both_keys(void **state) {
|
||||||
setup_rsa_key(state);
|
int rc;
|
||||||
|
|
||||||
|
rc = setup_rsa_key(state);
|
||||||
|
if (rc != 0) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
ssh_free(*state);
|
ssh_free(*state);
|
||||||
setup_dsa_key(state);
|
|
||||||
|
rc = setup_dsa_key(state);
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_both_keys_passphrase(void **state) {
|
static int setup_both_keys_passphrase(void **state)
|
||||||
|
{
|
||||||
ssh_session session;
|
ssh_session session;
|
||||||
|
|
||||||
torture_write_file(LIBSSH_RSA_TESTKEY,
|
torture_write_file(LIBSSH_RSA_TESTKEY,
|
||||||
@ -57,8 +72,12 @@ static void setup_both_keys_passphrase(void **state) {
|
|||||||
|
|
||||||
session = ssh_new();
|
session = ssh_new();
|
||||||
*state = session;
|
*state = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
static void teardown(void **state) {
|
|
||||||
|
static int teardown(void **state)
|
||||||
|
{
|
||||||
unlink(LIBSSH_DSA_TESTKEY);
|
unlink(LIBSSH_DSA_TESTKEY);
|
||||||
unlink(LIBSSH_DSA_TESTKEY ".pub");
|
unlink(LIBSSH_DSA_TESTKEY ".pub");
|
||||||
|
|
||||||
@ -66,6 +85,8 @@ static void teardown(void **state) {
|
|||||||
unlink(LIBSSH_RSA_TESTKEY ".pub");
|
unlink(LIBSSH_RSA_TESTKEY ".pub");
|
||||||
|
|
||||||
ssh_free(*state);
|
ssh_free(*state);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_pubkey_from_file(void **state) {
|
static void torture_pubkey_from_file(void **state) {
|
||||||
@ -255,23 +276,25 @@ static void torture_privatekey_from_file_passphrase(void **state) {
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_pubkey_from_file,
|
cmocka_unit_test_setup_teardown(torture_pubkey_from_file,
|
||||||
setup_rsa_key,
|
setup_rsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pubkey_generate_from_privkey,
|
cmocka_unit_test_setup_teardown(torture_pubkey_generate_from_privkey,
|
||||||
setup_rsa_key, teardown),
|
setup_rsa_key,
|
||||||
unit_test_setup_teardown(torture_privatekey_from_file,
|
teardown),
|
||||||
setup_both_keys,
|
cmocka_unit_test_setup_teardown(torture_privatekey_from_file,
|
||||||
teardown),
|
setup_both_keys,
|
||||||
unit_test_setup_teardown(torture_privatekey_from_file_passphrase,
|
teardown),
|
||||||
setup_both_keys_passphrase, teardown),
|
cmocka_unit_test_setup_teardown(torture_privatekey_from_file_passphrase,
|
||||||
|
setup_both_keys_passphrase,
|
||||||
|
teardown),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc=run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -78,15 +78,15 @@ static void torture_ssh_list_prepend(void **state) {
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test(torture_ssh_list_new),
|
cmocka_unit_test(torture_ssh_list_new),
|
||||||
unit_test(torture_ssh_list_append),
|
cmocka_unit_test(torture_ssh_list_append),
|
||||||
unit_test(torture_ssh_list_prepend),
|
cmocka_unit_test(torture_ssh_list_prepend),
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc=run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,19 @@
|
|||||||
#define TORTURE_TEST_DIR "/usr/local/bin/truc/much/.."
|
#define TORTURE_TEST_DIR "/usr/local/bin/truc/much/.."
|
||||||
|
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state)
|
||||||
|
{
|
||||||
ssh_session session = ssh_new();
|
ssh_session session = ssh_new();
|
||||||
*state = session;
|
*state = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state)
|
||||||
|
{
|
||||||
ssh_free(*state);
|
ssh_free(*state);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_get_user_home_dir(void **state) {
|
static void torture_get_user_home_dir(void **state) {
|
||||||
@ -201,25 +207,25 @@ static void torture_timeout_update(void **state){
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test(torture_get_user_home_dir),
|
cmocka_unit_test(torture_get_user_home_dir),
|
||||||
unit_test(torture_basename),
|
cmocka_unit_test(torture_basename),
|
||||||
unit_test(torture_dirname),
|
cmocka_unit_test(torture_dirname),
|
||||||
unit_test(torture_ntohll),
|
cmocka_unit_test(torture_ntohll),
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
unit_test(torture_path_expand_tilde_win),
|
cmocka_unit_test(torture_path_expand_tilde_win),
|
||||||
#else
|
#else
|
||||||
unit_test(torture_path_expand_tilde_unix),
|
cmocka_unit_test(torture_path_expand_tilde_unix),
|
||||||
#endif
|
#endif
|
||||||
unit_test_setup_teardown(torture_path_expand_escape, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_path_expand_escape, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_path_expand_known_hosts, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_path_expand_known_hosts, setup, teardown),
|
||||||
unit_test(torture_timeout_elapsed),
|
cmocka_unit_test(torture_timeout_elapsed),
|
||||||
unit_test(torture_timeout_update),
|
cmocka_unit_test(torture_timeout_update),
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc=run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,19 @@
|
|||||||
#include <libssh/session.h>
|
#include <libssh/session.h>
|
||||||
#include <libssh/misc.h>
|
#include <libssh/misc.h>
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state)
|
||||||
|
{
|
||||||
ssh_session session = ssh_new();
|
ssh_session session = ssh_new();
|
||||||
*state = session;
|
*state = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state)
|
||||||
|
{
|
||||||
ssh_free(*state);
|
ssh_free(*state);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_set_host(void **state) {
|
static void torture_options_set_host(void **state) {
|
||||||
@ -195,22 +201,22 @@ static void torture_options_proxycommand(void **state) {
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(torture_options_set_host, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_host, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_options_get_host, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_get_host, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_options_set_port, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_port, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_options_get_port, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_get_port, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_options_set_fd, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_fd, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_options_set_user, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_user, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_options_get_user, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_get_user, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_options_set_identity, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_set_identity, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_options_get_identity, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_get_identity, setup, teardown),
|
||||||
unit_test_setup_teardown(torture_options_proxycommand, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_options_proxycommand, setup, teardown),
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc=run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
const unsigned char HASH[] = "12345678901234567890";
|
const unsigned char HASH[] = "12345678901234567890";
|
||||||
|
|
||||||
static void setup_rsa_key(void **state) {
|
static int setup_rsa_key(void **state)
|
||||||
|
{
|
||||||
(void) state; /* unused */
|
(void) state; /* unused */
|
||||||
|
|
||||||
unlink(LIBSSH_RSA_TESTKEY);
|
unlink(LIBSSH_RSA_TESTKEY);
|
||||||
@ -22,9 +23,11 @@ static void setup_rsa_key(void **state) {
|
|||||||
torture_get_testkey(SSH_KEYTYPE_RSA, 0, 0));
|
torture_get_testkey(SSH_KEYTYPE_RSA, 0, 0));
|
||||||
torture_write_file(LIBSSH_RSA_TESTKEY ".pub",
|
torture_write_file(LIBSSH_RSA_TESTKEY ".pub",
|
||||||
torture_get_testkey_pub(SSH_KEYTYPE_RSA, 0));
|
torture_get_testkey_pub(SSH_KEYTYPE_RSA, 0));
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_dsa_key(void **state) {
|
static int setup_dsa_key(void **state) {
|
||||||
(void) state; /* unused */
|
(void) state; /* unused */
|
||||||
|
|
||||||
unlink(LIBSSH_DSA_TESTKEY);
|
unlink(LIBSSH_DSA_TESTKEY);
|
||||||
@ -34,10 +37,12 @@ static void setup_dsa_key(void **state) {
|
|||||||
torture_get_testkey(SSH_KEYTYPE_DSS, 0, 0));
|
torture_get_testkey(SSH_KEYTYPE_DSS, 0, 0));
|
||||||
torture_write_file(LIBSSH_DSA_TESTKEY ".pub",
|
torture_write_file(LIBSSH_DSA_TESTKEY ".pub",
|
||||||
torture_get_testkey_pub(SSH_KEYTYPE_DSS, 0));
|
torture_get_testkey_pub(SSH_KEYTYPE_DSS, 0));
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_OPENSSL_ECC
|
#ifdef HAVE_OPENSSL_ECC
|
||||||
static void setup_ecdsa_key(void **state, int ecdsa_bits) {
|
static int setup_ecdsa_key(void **state, int ecdsa_bits) {
|
||||||
|
|
||||||
(void) state; /* unused */
|
(void) state; /* unused */
|
||||||
|
|
||||||
@ -48,22 +53,30 @@ static void setup_ecdsa_key(void **state, int ecdsa_bits) {
|
|||||||
torture_get_testkey(SSH_KEYTYPE_ECDSA, ecdsa_bits, 0));
|
torture_get_testkey(SSH_KEYTYPE_ECDSA, ecdsa_bits, 0));
|
||||||
torture_write_file(LIBSSH_ECDSA_TESTKEY ".pub",
|
torture_write_file(LIBSSH_ECDSA_TESTKEY ".pub",
|
||||||
torture_get_testkey_pub(SSH_KEYTYPE_ECDSA, ecdsa_bits));
|
torture_get_testkey_pub(SSH_KEYTYPE_ECDSA, ecdsa_bits));
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_ecdsa_key_521(void **state) {
|
static int setup_ecdsa_key_521(void **state) {
|
||||||
setup_ecdsa_key(state, 521);
|
setup_ecdsa_key(state, 521);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_ecdsa_key_384(void **state) {
|
static int setup_ecdsa_key_384(void **state) {
|
||||||
setup_ecdsa_key(state, 384);
|
setup_ecdsa_key(state, 384);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_ecdsa_key_256(void **state) {
|
static int setup_ecdsa_key_256(void **state) {
|
||||||
setup_ecdsa_key(state, 256);
|
setup_ecdsa_key(state, 256);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void setup_ed25519_key(void **state) {
|
static int setup_ed25519_key(void **state) {
|
||||||
(void) state; /* unused */
|
(void) state; /* unused */
|
||||||
|
|
||||||
unlink(LIBSSH_ED25519_TESTKEY);
|
unlink(LIBSSH_ED25519_TESTKEY);
|
||||||
@ -74,16 +87,20 @@ static void setup_ed25519_key(void **state) {
|
|||||||
|
|
||||||
torture_write_file(LIBSSH_ED25519_TESTKEY ".pub",
|
torture_write_file(LIBSSH_ED25519_TESTKEY ".pub",
|
||||||
torture_get_testkey_pub(SSH_KEYTYPE_ED25519,0));
|
torture_get_testkey_pub(SSH_KEYTYPE_ED25519,0));
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_both_keys(void **state) {
|
static int setup_both_keys(void **state) {
|
||||||
(void) state; /* unused */
|
(void) state; /* unused */
|
||||||
|
|
||||||
setup_rsa_key(state);
|
setup_rsa_key(state);
|
||||||
setup_dsa_key(state);
|
setup_dsa_key(state);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state) {
|
||||||
(void) state; /* unused */
|
(void) state; /* unused */
|
||||||
|
|
||||||
unlink(LIBSSH_DSA_TESTKEY);
|
unlink(LIBSSH_DSA_TESTKEY);
|
||||||
@ -94,6 +111,8 @@ static void teardown(void **state) {
|
|||||||
|
|
||||||
unlink(LIBSSH_ECDSA_TESTKEY);
|
unlink(LIBSSH_ECDSA_TESTKEY);
|
||||||
unlink(LIBSSH_ECDSA_TESTKEY ".pub");
|
unlink(LIBSSH_ECDSA_TESTKEY ".pub");
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *read_file(const char *filename) {
|
static char *read_file(const char *filename) {
|
||||||
@ -1467,168 +1486,168 @@ static void torture_pki_ecdsa_name521(void **state)
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
UnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
unit_test(torture_pki_keytype),
|
cmocka_unit_test(torture_pki_keytype),
|
||||||
|
|
||||||
unit_test(torture_pki_signature),
|
cmocka_unit_test(torture_pki_signature),
|
||||||
|
|
||||||
/* ssh_pki_import_privkey_base64 */
|
/* ssh_pki_import_privkey_base64 */
|
||||||
unit_test_setup_teardown(torture_pki_import_privkey_base64_NULL_key,
|
cmocka_unit_test_setup_teardown(torture_pki_import_privkey_base64_NULL_key,
|
||||||
setup_rsa_key,
|
setup_rsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_import_privkey_base64_NULL_str,
|
cmocka_unit_test_setup_teardown(torture_pki_import_privkey_base64_NULL_str,
|
||||||
setup_rsa_key,
|
setup_rsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_import_privkey_base64_RSA,
|
cmocka_unit_test_setup_teardown(torture_pki_import_privkey_base64_RSA,
|
||||||
setup_rsa_key,
|
setup_rsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_import_privkey_base64_DSA,
|
cmocka_unit_test_setup_teardown(torture_pki_import_privkey_base64_DSA,
|
||||||
setup_dsa_key,
|
setup_dsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
unit_test_setup_teardown(torture_pki_import_privkey_base64_ECDSA,
|
cmocka_unit_test_setup_teardown(torture_pki_import_privkey_base64_ECDSA,
|
||||||
setup_ecdsa_key_256,
|
setup_ecdsa_key_256,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_import_privkey_base64_ECDSA,
|
cmocka_unit_test_setup_teardown(torture_pki_import_privkey_base64_ECDSA,
|
||||||
setup_ecdsa_key_384,
|
setup_ecdsa_key_384,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_import_privkey_base64_ECDSA,
|
cmocka_unit_test_setup_teardown(torture_pki_import_privkey_base64_ECDSA,
|
||||||
setup_ecdsa_key_521,
|
setup_ecdsa_key_521,
|
||||||
teardown),
|
teardown),
|
||||||
#endif
|
#endif
|
||||||
unit_test_setup_teardown(torture_pki_import_privkey_base64_ed25519,
|
cmocka_unit_test_setup_teardown(torture_pki_import_privkey_base64_ed25519,
|
||||||
setup_ed25519_key,
|
setup_ed25519_key,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test(torture_pki_import_privkey_base64_passphrase),
|
cmocka_unit_test(torture_pki_import_privkey_base64_passphrase),
|
||||||
/* ssh_pki_export_privkey_to_pubkey */
|
/* ssh_pki_export_privkey_to_pubkey */
|
||||||
unit_test_setup_teardown(torture_pki_pki_publickey_from_privatekey_RSA,
|
cmocka_unit_test_setup_teardown(torture_pki_pki_publickey_from_privatekey_RSA,
|
||||||
setup_rsa_key,
|
setup_rsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_pki_publickey_from_privatekey_DSA,
|
cmocka_unit_test_setup_teardown(torture_pki_pki_publickey_from_privatekey_DSA,
|
||||||
setup_dsa_key,
|
setup_dsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
unit_test_setup_teardown(torture_pki_publickey_from_privatekey_ECDSA,
|
cmocka_unit_test_setup_teardown(torture_pki_publickey_from_privatekey_ECDSA,
|
||||||
setup_ecdsa_key_256,
|
setup_ecdsa_key_256,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_publickey_from_privatekey_ECDSA,
|
cmocka_unit_test_setup_teardown(torture_pki_publickey_from_privatekey_ECDSA,
|
||||||
setup_ecdsa_key_384,
|
setup_ecdsa_key_384,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_publickey_from_privatekey_ECDSA,
|
cmocka_unit_test_setup_teardown(torture_pki_publickey_from_privatekey_ECDSA,
|
||||||
setup_ecdsa_key_521,
|
setup_ecdsa_key_521,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_ecdsa_duplicate_then_demote,
|
cmocka_unit_test_setup_teardown(torture_pki_ecdsa_duplicate_then_demote,
|
||||||
setup_ecdsa_key_256,
|
setup_ecdsa_key_256,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_ecdsa_duplicate_then_demote,
|
cmocka_unit_test_setup_teardown(torture_pki_ecdsa_duplicate_then_demote,
|
||||||
setup_ecdsa_key_384,
|
setup_ecdsa_key_384,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_ecdsa_duplicate_then_demote,
|
cmocka_unit_test_setup_teardown(torture_pki_ecdsa_duplicate_then_demote,
|
||||||
setup_ecdsa_key_521,
|
setup_ecdsa_key_521,
|
||||||
teardown),
|
teardown),
|
||||||
#endif
|
#endif
|
||||||
unit_test_setup_teardown(torture_pki_pki_publickey_from_privatekey_ed25519,
|
cmocka_unit_test_setup_teardown(torture_pki_pki_publickey_from_privatekey_ed25519,
|
||||||
setup_ed25519_key,
|
setup_ed25519_key,
|
||||||
teardown),
|
teardown),
|
||||||
/* public key */
|
/* public key */
|
||||||
unit_test_setup_teardown(torture_pki_publickey_dsa_base64,
|
cmocka_unit_test_setup_teardown(torture_pki_publickey_dsa_base64,
|
||||||
setup_dsa_key,
|
setup_dsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_publickey_rsa_base64,
|
cmocka_unit_test_setup_teardown(torture_pki_publickey_rsa_base64,
|
||||||
setup_rsa_key,
|
setup_rsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
unit_test_setup_teardown(torture_pki_publickey_ecdsa_base64,
|
cmocka_unit_test_setup_teardown(torture_pki_publickey_ecdsa_base64,
|
||||||
setup_ecdsa_key_256,
|
setup_ecdsa_key_256,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_publickey_ecdsa_base64,
|
cmocka_unit_test_setup_teardown(torture_pki_publickey_ecdsa_base64,
|
||||||
setup_ecdsa_key_384,
|
setup_ecdsa_key_384,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_publickey_ecdsa_base64,
|
cmocka_unit_test_setup_teardown(torture_pki_publickey_ecdsa_base64,
|
||||||
setup_ecdsa_key_521,
|
setup_ecdsa_key_521,
|
||||||
teardown),
|
teardown),
|
||||||
#endif
|
#endif
|
||||||
unit_test_setup_teardown(torture_pki_publickey_ed25519_base64,
|
cmocka_unit_test_setup_teardown(torture_pki_publickey_ed25519_base64,
|
||||||
setup_ed25519_key,
|
setup_ed25519_key,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_generate_pubkey_from_privkey_dsa,
|
cmocka_unit_test_setup_teardown(torture_generate_pubkey_from_privkey_dsa,
|
||||||
setup_dsa_key,
|
setup_dsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_generate_pubkey_from_privkey_rsa,
|
cmocka_unit_test_setup_teardown(torture_generate_pubkey_from_privkey_rsa,
|
||||||
setup_rsa_key,
|
setup_rsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
unit_test_setup_teardown(torture_generate_pubkey_from_privkey_ecdsa,
|
cmocka_unit_test_setup_teardown(torture_generate_pubkey_from_privkey_ecdsa,
|
||||||
setup_ecdsa_key_256,
|
setup_ecdsa_key_256,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_generate_pubkey_from_privkey_ecdsa,
|
cmocka_unit_test_setup_teardown(torture_generate_pubkey_from_privkey_ecdsa,
|
||||||
setup_ecdsa_key_384,
|
setup_ecdsa_key_384,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_generate_pubkey_from_privkey_ecdsa,
|
cmocka_unit_test_setup_teardown(torture_generate_pubkey_from_privkey_ecdsa,
|
||||||
setup_ecdsa_key_521,
|
setup_ecdsa_key_521,
|
||||||
teardown),
|
teardown),
|
||||||
#endif
|
#endif
|
||||||
unit_test_setup_teardown(torture_generate_pubkey_from_privkey_ed25519,
|
cmocka_unit_test_setup_teardown(torture_generate_pubkey_from_privkey_ed25519,
|
||||||
setup_rsa_key,
|
setup_rsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_duplicate_key_rsa,
|
cmocka_unit_test_setup_teardown(torture_pki_duplicate_key_rsa,
|
||||||
setup_rsa_key,
|
setup_rsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_duplicate_key_dsa,
|
cmocka_unit_test_setup_teardown(torture_pki_duplicate_key_dsa,
|
||||||
setup_dsa_key,
|
setup_dsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
unit_test_setup_teardown(torture_pki_duplicate_key_ecdsa,
|
cmocka_unit_test_setup_teardown(torture_pki_duplicate_key_ecdsa,
|
||||||
setup_ecdsa_key_256,
|
setup_ecdsa_key_256,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_duplicate_key_ecdsa,
|
cmocka_unit_test_setup_teardown(torture_pki_duplicate_key_ecdsa,
|
||||||
setup_ecdsa_key_384,
|
setup_ecdsa_key_384,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_duplicate_key_ecdsa,
|
cmocka_unit_test_setup_teardown(torture_pki_duplicate_key_ecdsa,
|
||||||
setup_ecdsa_key_521,
|
setup_ecdsa_key_521,
|
||||||
teardown),
|
teardown),
|
||||||
#endif
|
#endif
|
||||||
unit_test_setup_teardown(torture_pki_duplicate_key_dsa,
|
cmocka_unit_test_setup_teardown(torture_pki_duplicate_key_dsa,
|
||||||
setup_dsa_key,
|
setup_dsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test(torture_pki_generate_key_rsa),
|
cmocka_unit_test(torture_pki_generate_key_rsa),
|
||||||
unit_test(torture_pki_generate_key_rsa1),
|
cmocka_unit_test(torture_pki_generate_key_rsa1),
|
||||||
unit_test(torture_pki_generate_key_dsa),
|
cmocka_unit_test(torture_pki_generate_key_dsa),
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
unit_test(torture_pki_generate_key_ecdsa),
|
cmocka_unit_test(torture_pki_generate_key_ecdsa),
|
||||||
#endif
|
#endif
|
||||||
unit_test(torture_pki_generate_key_ed25519),
|
cmocka_unit_test(torture_pki_generate_key_ed25519),
|
||||||
#ifdef HAVE_LIBCRYPTO
|
#ifdef HAVE_LIBCRYPTO
|
||||||
unit_test_setup_teardown(torture_pki_write_privkey_rsa,
|
cmocka_unit_test_setup_teardown(torture_pki_write_privkey_rsa,
|
||||||
setup_rsa_key,
|
setup_rsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_write_privkey_dsa,
|
cmocka_unit_test_setup_teardown(torture_pki_write_privkey_dsa,
|
||||||
setup_dsa_key,
|
setup_dsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
unit_test_setup_teardown(torture_pki_write_privkey_ecdsa,
|
cmocka_unit_test_setup_teardown(torture_pki_write_privkey_ecdsa,
|
||||||
setup_ecdsa_key_256,
|
setup_ecdsa_key_256,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_write_privkey_ecdsa,
|
cmocka_unit_test_setup_teardown(torture_pki_write_privkey_ecdsa,
|
||||||
setup_ecdsa_key_384,
|
setup_ecdsa_key_384,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_write_privkey_ecdsa,
|
cmocka_unit_test_setup_teardown(torture_pki_write_privkey_ecdsa,
|
||||||
setup_ecdsa_key_521,
|
setup_ecdsa_key_521,
|
||||||
teardown),
|
teardown),
|
||||||
#endif
|
#endif
|
||||||
#endif /* HAVE_LIBCRYPTO */
|
#endif /* HAVE_LIBCRYPTO */
|
||||||
unit_test_setup_teardown(torture_pki_write_privkey_ed25519,
|
cmocka_unit_test_setup_teardown(torture_pki_write_privkey_ed25519,
|
||||||
setup_dsa_key,
|
setup_dsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
|
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
unit_test_setup_teardown(torture_pki_ecdsa_name256,
|
cmocka_unit_test_setup_teardown(torture_pki_ecdsa_name256,
|
||||||
setup_ecdsa_key_256,
|
setup_ecdsa_key_256,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_ecdsa_name384,
|
cmocka_unit_test_setup_teardown(torture_pki_ecdsa_name384,
|
||||||
setup_ecdsa_key_384,
|
setup_ecdsa_key_384,
|
||||||
teardown),
|
teardown),
|
||||||
unit_test_setup_teardown(torture_pki_ecdsa_name521,
|
cmocka_unit_test_setup_teardown(torture_pki_ecdsa_name521,
|
||||||
setup_ecdsa_key_521,
|
setup_ecdsa_key_521,
|
||||||
teardown),
|
teardown),
|
||||||
#endif
|
#endif
|
||||||
@ -1638,7 +1657,7 @@ int torture_run_tests(void) {
|
|||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc=run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -110,14 +110,14 @@ static void torture_pki_ed25519_verify_bad(void **state){
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
const UnitTest tests[] = {
|
const struct CMUnitTest tests[] = {
|
||||||
unit_test(torture_pki_ed25519_sign),
|
cmocka_unit_test(torture_pki_ed25519_sign),
|
||||||
unit_test(torture_pki_ed25519_verify),
|
cmocka_unit_test(torture_pki_ed25519_verify),
|
||||||
unit_test(torture_pki_ed25519_verify_bad)
|
cmocka_unit_test(torture_pki_ed25519_verify_bad)
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
ssh_init();
|
||||||
rc=run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -13,17 +13,21 @@
|
|||||||
#endif
|
#endif
|
||||||
#define NUM_THREADS 100
|
#define NUM_THREADS 100
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state) {
|
||||||
(void) state;
|
(void) state;
|
||||||
|
|
||||||
ssh_threads_set_callbacks(ssh_threads_get_pthread());
|
ssh_threads_set_callbacks(ssh_threads_get_pthread());
|
||||||
ssh_init();
|
ssh_init();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state) {
|
||||||
(void) state;
|
(void) state;
|
||||||
|
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *torture_rand_thread(void *threadid) {
|
static void *torture_rand_thread(void *threadid) {
|
||||||
@ -60,10 +64,13 @@ static void torture_rand_threading(void **state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
UnitTest tests[] = {
|
int rc;
|
||||||
unit_test_setup_teardown(torture_rand_threading, setup, teardown),
|
struct CMUnitTest tests[] = {
|
||||||
|
cmocka_unit_test_setup_teardown(torture_rand_threading, setup, teardown),
|
||||||
};
|
};
|
||||||
|
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
return run_tests(tests);
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,13 @@ struct hostkey_state {
|
|||||||
int fd;
|
int fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void setup(void **state) {
|
static int setup(void **state) {
|
||||||
struct hostkey_state *h;
|
struct hostkey_state *h;
|
||||||
mode_t mask;
|
mode_t mask;
|
||||||
|
|
||||||
|
ssh_threads_set_callbacks(ssh_threads_get_pthread());
|
||||||
|
ssh_init();
|
||||||
|
|
||||||
h = malloc(sizeof(struct hostkey_state));
|
h = malloc(sizeof(struct hostkey_state));
|
||||||
assert_non_null(h);
|
assert_non_null(h);
|
||||||
|
|
||||||
@ -39,14 +42,20 @@ static void setup(void **state) {
|
|||||||
torture_write_file(h->hostkey_path, h->hostkey);
|
torture_write_file(h->hostkey_path, h->hostkey);
|
||||||
|
|
||||||
*state = h;
|
*state = h;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teardown(void **state) {
|
static int teardown(void **state) {
|
||||||
struct hostkey_state *h = (struct hostkey_state *)*state;
|
struct hostkey_state *h = (struct hostkey_state *)*state;
|
||||||
|
|
||||||
unlink(h->hostkey);
|
unlink(h->hostkey);
|
||||||
free(h->hostkey_path);
|
free(h->hostkey_path);
|
||||||
free(h);
|
free(h);
|
||||||
|
|
||||||
|
ssh_finalize();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For x11_screen_number, need something that is not equal to htonl
|
/* For x11_screen_number, need something that is not equal to htonl
|
||||||
@ -208,16 +217,13 @@ static void test_ssh_channel_request_x11(void **state) {
|
|||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
const UnitTest tests[] = {
|
const struct CMUnitTest tests[] = {
|
||||||
unit_test_setup_teardown(test_ssh_channel_request_x11,
|
cmocka_unit_test_setup_teardown(test_ssh_channel_request_x11,
|
||||||
setup,
|
setup,
|
||||||
teardown)
|
teardown)
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_threads_set_callbacks(ssh_threads_get_pthread());
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
ssh_init();
|
|
||||||
rc = run_tests(tests);
|
|
||||||
ssh_finalize();
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user