aboutsummaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2015-09-07 10:39:51 +0200
committerAndreas Schneider <asn@cryptomilk.org>2015-09-07 10:40:12 +0200
commit82a80b205bb5159c3e8da635c47882a14c17120b (patch)
tree9e00b3d674276c9a227f167b4b4712db912a5b96 /tests/unittests
parent5b586fdfecbe12f3f8e69099d809ca96c7cb978e (diff)
downloadlibssh-82a80b205bb5159c3e8da635c47882a14c17120b.tar.gz
libssh-82a80b205bb5159c3e8da635c47882a14c17120b.tar.xz
libssh-82a80b205bb5159c3e8da635c47882a14c17120b.zip
tests: Migrate to new cmocka API
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/torture_buffer.c32
-rw-r--r--tests/unittests/torture_callbacks.c20
-rw-r--r--tests/unittests/torture_channel.c6
-rw-r--r--tests/unittests/torture_init.c10
-rw-r--r--tests/unittests/torture_isipaddr.c6
-rw-r--r--tests/unittests/torture_keyfiles.c61
-rw-r--r--tests/unittests/torture_list.c10
-rw-r--r--tests/unittests/torture_misc.c34
-rw-r--r--tests/unittests/torture_options.c34
-rw-r--r--tests/unittests/torture_pki.c145
-rw-r--r--tests/unittests/torture_pki_ed25519.c10
-rw-r--r--tests/unittests/torture_rand.c17
-rw-r--r--tests/unittests/torture_server_x11.c26
13 files changed, 248 insertions, 163 deletions
diff --git a/tests/unittests/torture_buffer.c b/tests/unittests/torture_buffer.c
index 0934cbf1..390572cd 100644
--- a/tests/unittests/torture_buffer.c
+++ b/tests/unittests/torture_buffer.c
@@ -6,15 +6,23 @@
#define LIMIT (8*1024*1024)
-static void setup(void **state) {
+static int setup(void **state) {
ssh_buffer buffer;
+
buffer = ssh_buffer_new();
+ if (buffer == NULL) {
+ return -1;
+ }
ssh_buffer_set_secure(buffer);
*state = (void *) buffer;
+
+ return 0;
}
-static void teardown(void **state) {
+static int teardown(void **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 rc;
- UnitTest tests[] = {
- unit_test_setup_teardown(torture_growing_buffer, setup, teardown),
- unit_test_setup_teardown(torture_growing_buffer_shifting, setup, teardown),
- unit_test_setup_teardown(torture_buffer_prepend, setup, teardown),
- unit_test(torture_buffer_get_ssh_string),
- unit_test_setup_teardown(torture_buffer_add_format, setup, teardown),
- unit_test_setup_teardown(torture_buffer_get_format, setup, teardown),
- unit_test_setup_teardown(torture_buffer_get_format_error, setup, teardown),
- unit_test_setup_teardown(torture_buffer_pack_badformat, setup, teardown)
+ struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(torture_growing_buffer, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_growing_buffer_shifting, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_buffer_prepend, setup, teardown),
+ cmocka_unit_test(torture_buffer_get_ssh_string),
+ cmocka_unit_test_setup_teardown(torture_buffer_add_format, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_buffer_get_format, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_buffer_get_format_error, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_buffer_pack_badformat, setup, teardown)
};
ssh_init();
torture_filter_tests(tests);
- rc=run_tests(tests);
+ rc = cmocka_run_group_tests(tests, NULL, NULL);
ssh_finalize();
return rc;
}
diff --git a/tests/unittests/torture_callbacks.c b/tests/unittests/torture_callbacks.c
index 0fdeb3d4..9eba19bb 100644
--- a/tests/unittests/torture_callbacks.c
+++ b/tests/unittests/torture_callbacks.c
@@ -15,7 +15,8 @@ static int myauthcallback (const char *prompt, char *buf, size_t len,
return 0;
}
-static void setup(void **state) {
+static int setup(void **state)
+{
struct ssh_callbacks_struct *cb;
cb = malloc(sizeof(struct ssh_callbacks_struct));
@@ -27,10 +28,15 @@ static void setup(void **state) {
ssh_callbacks_init(cb);
*state = cb;
+
+ return 0;
}
-static void teardown(void **state) {
+static int teardown(void **state)
+{
free(*state);
+
+ return 0;
}
static void torture_callbacks_size(void **state) {
@@ -98,15 +104,15 @@ static void torture_log_callback(void **state)
int torture_run_tests(void) {
int rc;
- UnitTest tests[] = {
- unit_test_setup_teardown(torture_callbacks_size, setup, teardown),
- unit_test_setup_teardown(torture_callbacks_exists, setup, teardown),
- unit_test(torture_log_callback),
+ struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(torture_callbacks_size, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_callbacks_exists, setup, teardown),
+ cmocka_unit_test(torture_log_callback),
};
ssh_init();
torture_filter_tests(tests);
- rc=run_tests(tests);
+ rc = cmocka_run_group_tests(tests, NULL, NULL);
ssh_finalize();
return rc;
}
diff --git a/tests/unittests/torture_channel.c b/tests/unittests/torture_channel.c
index a5819d8d..fd98f95d 100644
--- a/tests/unittests/torture_channel.c
+++ b/tests/unittests/torture_channel.c
@@ -37,13 +37,13 @@ static void torture_channel_select(void **state)
int torture_run_tests(void) {
int rc;
- UnitTest tests[] = {
- unit_test(torture_channel_select),
+ struct CMUnitTest tests[] = {
+ cmocka_unit_test(torture_channel_select),
};
ssh_init();
torture_filter_tests(tests);
- rc = run_tests(tests);
+ rc = cmocka_run_group_tests(tests, NULL, NULL);
ssh_finalize();
return rc;
diff --git a/tests/unittests/torture_init.c b/tests/unittests/torture_init.c
index b608c04f..84305ff9 100644
--- a/tests/unittests/torture_init.c
+++ b/tests/unittests/torture_init.c
@@ -15,9 +15,13 @@ static void torture_ssh_init(void **state) {
}
int torture_run_tests(void) {
- UnitTest tests[] = {
- unit_test(torture_ssh_init),
+ int rc;
+ struct CMUnitTest tests[] = {
+ cmocka_unit_test(torture_ssh_init),
};
+
torture_filter_tests(tests);
- return run_tests(tests);
+ rc = cmocka_run_group_tests(tests, NULL, NULL);
+
+ return 0;
}
diff --git a/tests/unittests/torture_isipaddr.c b/tests/unittests/torture_isipaddr.c
index 258082ea..a6582a29 100644
--- a/tests/unittests/torture_isipaddr.c
+++ b/tests/unittests/torture_isipaddr.c
@@ -45,13 +45,13 @@ static void torture_ssh_is_ipaddr(void **state) {
int torture_run_tests(void) {
int rc;
- UnitTest tests[] = {
- unit_test(torture_ssh_is_ipaddr)
+ struct CMUnitTest tests[] = {
+ cmocka_unit_test(torture_ssh_is_ipaddr)
};
ssh_init();
torture_filter_tests(tests);
- rc=run_tests(tests);
+ rc = cmocka_run_group_tests(tests, NULL, NULL);
ssh_finalize();
return rc;
}
diff --git a/tests/unittests/torture_keyfiles.c b/tests/unittests/torture_keyfiles.c
index 1af4ac67..e5f054f9 100644
--- a/tests/unittests/torture_keyfiles.c
+++ b/tests/unittests/torture_keyfiles.c
@@ -6,7 +6,8 @@
#define LIBSSH_RSA_TESTKEY "libssh_testkey.id_rsa"
#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;
unlink(LIBSSH_RSA_TESTKEY);
@@ -19,9 +20,12 @@ static void setup_rsa_key(void **state) {
session = ssh_new();
*state = session;
+
+ return 0;
}
-static void setup_dsa_key(void **state) {
+static int setup_dsa_key(void **state)
+{
ssh_session session;
unlink(LIBSSH_DSA_TESTKEY);
@@ -34,15 +38,26 @@ static void setup_dsa_key(void **state) {
session = ssh_new();
*state = session;
+
+ return 0;
}
-static void setup_both_keys(void **state) {
- setup_rsa_key(state);
+static int setup_both_keys(void **state) {
+ int rc;
+
+ rc = setup_rsa_key(state);
+ if (rc != 0) {
+ return rc;
+ }
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;
torture_write_file(LIBSSH_RSA_TESTKEY,
@@ -57,8 +72,12 @@ static void setup_both_keys_passphrase(void **state) {
session = ssh_new();
*state = session;
+
+ return 0;
}
-static void teardown(void **state) {
+
+static int teardown(void **state)
+{
unlink(LIBSSH_DSA_TESTKEY);
unlink(LIBSSH_DSA_TESTKEY ".pub");
@@ -66,6 +85,8 @@ static void teardown(void **state) {
unlink(LIBSSH_RSA_TESTKEY ".pub");
ssh_free(*state);
+
+ return 0;
}
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 rc;
- UnitTest tests[] = {
- unit_test_setup_teardown(torture_pubkey_from_file,
- setup_rsa_key,
- teardown),
- unit_test_setup_teardown(torture_pubkey_generate_from_privkey,
- setup_rsa_key, teardown),
- unit_test_setup_teardown(torture_privatekey_from_file,
- setup_both_keys,
- teardown),
- unit_test_setup_teardown(torture_privatekey_from_file_passphrase,
- setup_both_keys_passphrase, teardown),
+ struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(torture_pubkey_from_file,
+ setup_rsa_key,
+ teardown),
+ cmocka_unit_test_setup_teardown(torture_pubkey_generate_from_privkey,
+ setup_rsa_key,
+ teardown),
+ cmocka_unit_test_setup_teardown(torture_privatekey_from_file,
+ setup_both_keys,
+ teardown),
+ cmocka_unit_test_setup_teardown(torture_privatekey_from_file_passphrase,
+ setup_both_keys_passphrase,
+ teardown),
};
ssh_init();
torture_filter_tests(tests);
- rc=run_tests(tests);
+ rc = cmocka_run_group_tests(tests, NULL, NULL);
ssh_finalize();
return rc;
}
diff --git a/tests/unittests/torture_list.c b/tests/unittests/torture_list.c
index 09031699..9786c5b6 100644
--- a/tests/unittests/torture_list.c
+++ b/tests/unittests/torture_list.c
@@ -78,15 +78,15 @@ static void torture_ssh_list_prepend(void **state) {
int torture_run_tests(void) {
int rc;
- UnitTest tests[] = {
- unit_test(torture_ssh_list_new),
- unit_test(torture_ssh_list_append),
- unit_test(torture_ssh_list_prepend),
+ struct CMUnitTest tests[] = {
+ cmocka_unit_test(torture_ssh_list_new),
+ cmocka_unit_test(torture_ssh_list_append),
+ cmocka_unit_test(torture_ssh_list_prepend),
};
ssh_init();
torture_filter_tests(tests);
- rc=run_tests(tests);
+ rc = cmocka_run_group_tests(tests, NULL, NULL);
ssh_finalize();
return rc;
}
diff --git a/tests/unittests/torture_misc.c b/tests/unittests/torture_misc.c
index b3b73efd..bc16dfb0 100644
--- a/tests/unittests/torture_misc.c
+++ b/tests/unittests/torture_misc.c
@@ -16,13 +16,19 @@
#define TORTURE_TEST_DIR "/usr/local/bin/truc/much/.."
-static void setup(void **state) {
+static int setup(void **state)
+{
ssh_session session = ssh_new();
*state = session;
+
+ return 0;
}
-static void teardown(void **state) {
+static int teardown(void **state)
+{
ssh_free(*state);
+
+ return 0;
}
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 rc;
- UnitTest tests[] = {
- unit_test(torture_get_user_home_dir),
- unit_test(torture_basename),
- unit_test(torture_dirname),
- unit_test(torture_ntohll),
+ 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),
#ifdef _WIN32
- unit_test(torture_path_expand_tilde_win),
+ cmocka_unit_test(torture_path_expand_tilde_win),
#else
- unit_test(torture_path_expand_tilde_unix),
+ cmocka_unit_test(torture_path_expand_tilde_unix),
#endif
- unit_test_setup_teardown(torture_path_expand_escape, setup, teardown),
- unit_test_setup_teardown(torture_path_expand_known_hosts, setup, teardown),
- unit_test(torture_timeout_elapsed),
- unit_test(torture_timeout_update),
+ cmocka_unit_test_setup_teardown(torture_path_expand_escape, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_path_expand_known_hosts, setup, teardown),
+ cmocka_unit_test(torture_timeout_elapsed),
+ cmocka_unit_test(torture_timeout_update),
};
ssh_init();
torture_filter_tests(tests);
- rc=run_tests(tests);
+ rc = cmocka_run_group_tests(tests, NULL, NULL);
ssh_finalize();
return rc;
}
diff --git a/tests/unittests/torture_options.c b/tests/unittests/torture_options.c
index 9653fa21..4ec3f4cb 100644
--- a/tests/unittests/torture_options.c
+++ b/tests/unittests/torture_options.c
@@ -9,13 +9,19 @@
#include <libssh/session.h>
#include <libssh/misc.h>
-static void setup(void **state) {
+static int setup(void **state)
+{
ssh_session session = ssh_new();
*state = session;
+
+ return 0;
}
-static void teardown(void **state) {
+static int teardown(void **state)
+{
ssh_free(*state);
+
+ return 0;
}
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 rc;
- UnitTest tests[] = {
- unit_test_setup_teardown(torture_options_set_host, setup, teardown),
- unit_test_setup_teardown(torture_options_get_host, setup, teardown),
- unit_test_setup_teardown(torture_options_set_port, setup, teardown),
- unit_test_setup_teardown(torture_options_get_port, setup, teardown),
- unit_test_setup_teardown(torture_options_set_fd, setup, teardown),
- unit_test_setup_teardown(torture_options_set_user, setup, teardown),
- unit_test_setup_teardown(torture_options_get_user, setup, teardown),
- unit_test_setup_teardown(torture_options_set_identity, setup, teardown),
- unit_test_setup_teardown(torture_options_get_identity, setup, teardown),
- unit_test_setup_teardown(torture_options_proxycommand, setup, teardown),
+ struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(torture_options_set_host, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_options_get_host, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_options_set_port, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_options_get_port, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_options_set_fd, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_options_set_user, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_options_get_user, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_options_set_identity, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_options_get_identity, setup, teardown),
+ cmocka_unit_test_setup_teardown(torture_options_proxycommand, setup, teardown),
};
ssh_init();
torture_filter_tests(tests);
- rc=run_tests(tests);
+ rc = cmocka_run_group_tests(tests, NULL, NULL);
ssh_finalize();
return rc;
}
diff --git a/tests/unittests/torture_pki.c b/tests/unittests/torture_pki.c
index d880a5a5..879da6c7 100644
--- a/tests/unittests/torture_pki.c
+++ b/tests/unittests/torture_pki.c
@@ -12,7 +12,8 @@
const unsigned char HASH[] = "12345678901234567890";
-static void setup_rsa_key(void **state) {
+static int setup_rsa_key(void **state)
+{
(void) state; /* unused */
unlink(LIBSSH_RSA_TESTKEY);
@@ -22,9 +23,11 @@ static void setup_rsa_key(void **state) {
torture_get_testkey(SSH_KEYTYPE_RSA, 0, 0));
torture_write_file(LIBSSH_RSA_TESTKEY ".pub",
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 */
unlink(LIBSSH_DSA_TESTKEY);
@@ -34,10 +37,12 @@ static void setup_dsa_key(void **state) {
torture_get_testkey(SSH_KEYTYPE_DSS, 0, 0));
torture_write_file(LIBSSH_DSA_TESTKEY ".pub",
torture_get_testkey_pub(SSH_KEYTYPE_DSS, 0));
+
+ return 0;
}
#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 */
@@ -48,22 +53,30 @@ static void setup_ecdsa_key(void **state, int ecdsa_bits) {
torture_get_testkey(SSH_KEYTYPE_ECDSA, ecdsa_bits, 0));
torture_write_file(LIBSSH_ECDSA_TESTKEY ".pub",
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);
+
+ return 0;
}
-static void setup_ecdsa_key_384(void **state) {
+static int setup_ecdsa_key_384(void **state) {
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);
+
+ return 0;
}
#endif
-static void setup_ed25519_key(void **state) {
+static int setup_ed25519_key(void **state) {
(void) state; /* unused */
unlink(LIBSSH_ED25519_TESTKEY);
@@ -74,16 +87,20 @@ static void setup_ed25519_key(void **state) {
torture_write_file(LIBSSH_ED25519_TESTKEY ".pub",
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 */
setup_rsa_key(state);
setup_dsa_key(state);
+
+ return 0;
}
-static void teardown(void **state) {
+static int teardown(void **state) {
(void) state; /* unused */
unlink(LIBSSH_DSA_TESTKEY);
@@ -94,6 +111,8 @@ static void teardown(void **state) {
unlink(LIBSSH_ECDSA_TESTKEY);
unlink(LIBSSH_ECDSA_TESTKEY ".pub");
+
+ return 0;
}
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 rc;
- UnitTest tests[] = {
- unit_test(torture_pki_keytype),
+ struct CMUnitTest tests[] = {
+ cmocka_unit_test(torture_pki_keytype),
- unit_test(torture_pki_signature),
+ cmocka_unit_test(torture_pki_signature),
/* 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,
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,
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,
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,
teardown),
#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,
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,
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,
teardown),
#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,
teardown),
- unit_test(torture_pki_import_privkey_base64_passphrase),
+ cmocka_unit_test(torture_pki_import_privkey_base64_passphrase),
/* 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,
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,
teardown),
#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,
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,
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,
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,
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,
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,
teardown),
#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,
teardown),
/* public key */
- unit_test_setup_teardown(torture_pki_publickey_dsa_base64,
+ cmocka_unit_test_setup_teardown(torture_pki_publickey_dsa_base64,
setup_dsa_key,
teardown),
- unit_test_setup_teardown(torture_pki_publickey_rsa_base64,
+ cmocka_unit_test_setup_teardown(torture_pki_publickey_rsa_base64,
setup_rsa_key,
teardown),
#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,
teardown),
- unit_test_setup_teardown(torture_pki_publickey_ecdsa_base64,
+ cmocka_unit_test_setup_teardown(torture_pki_publickey_ecdsa_base64,
setup_ecdsa_key_384,
teardown),
- unit_test_setup_teardown(torture_pki_publickey_ecdsa_base64,
+ cmocka_unit_test_setup_teardown(torture_pki_publickey_ecdsa_base64,
setup_ecdsa_key_521,
teardown),
#endif
- unit_test_setup_teardown(torture_pki_publickey_ed25519_base64,
+ cmocka_unit_test_setup_teardown(torture_pki_publickey_ed25519_base64,
setup_ed25519_key,
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,
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,
teardown),
#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,
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,
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,
teardown),
#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,
teardown),
- unit_test_setup_teardown(torture_pki_duplicate_key_rsa,
+ cmocka_unit_test_setup_teardown(torture_pki_duplicate_key_rsa,
setup_rsa_key,
teardown),
- unit_test_setup_teardown(torture_pki_duplicate_key_dsa,
+ cmocka_unit_test_setup_teardown(torture_pki_duplicate_key_dsa,
setup_dsa_key,
teardown),
#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,
teardown),
- unit_test_setup_teardown(torture_pki_duplicate_key_ecdsa,
+ cmocka_unit_test_setup_teardown(torture_pki_duplicate_key_ecdsa,
setup_ecdsa_key_384,
teardown),
- unit_test_setup_teardown(torture_pki_duplicate_key_ecdsa,
+ cmocka_unit_test_setup_teardown(torture_pki_duplicate_key_ecdsa,
setup_ecdsa_key_521,
teardown),
#endif
- unit_test_setup_teardown(torture_pki_duplicate_key_dsa,
+ cmocka_unit_test_setup_teardown(torture_pki_duplicate_key_dsa,
setup_dsa_key,
teardown),
- unit_test(torture_pki_generate_key_rsa),
- unit_test(torture_pki_generate_key_rsa1),
- unit_test(torture_pki_generate_key_dsa),
+ cmocka_unit_test(torture_pki_generate_key_rsa),
+ cmocka_unit_test(torture_pki_generate_key_rsa1),
+ cmocka_unit_test(torture_pki_generate_key_dsa),
#ifdef HAVE_ECC
- unit_test(torture_pki_generate_key_ecdsa),
+ cmocka_unit_test(torture_pki_generate_key_ecdsa),
#endif
- unit_test(torture_pki_generate_key_ed25519),
+ cmocka_unit_test(torture_pki_generate_key_ed25519),
#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,
teardown),
- unit_test_setup_teardown(torture_pki_write_privkey_dsa,
+ cmocka_unit_test_setup_teardown(torture_pki_write_privkey_dsa,
setup_dsa_key,
teardown),
#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,
teardown),
- unit_test_setup_teardown(torture_pki_write_privkey_ecdsa,
+ cmocka_unit_test_setup_teardown(torture_pki_write_privkey_ecdsa,
setup_ecdsa_key_384,
teardown),
- unit_test_setup_teardown(torture_pki_write_privkey_ecdsa,
+ cmocka_unit_test_setup_teardown(torture_pki_write_privkey_ecdsa,
setup_ecdsa_key_521,
teardown),
#endif
#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,
teardown),
#ifdef HAVE_ECC
- unit_test_setup_teardown(torture_pki_ecdsa_name256,
+ cmocka_unit_test_setup_teardown(torture_pki_ecdsa_name256,
setup_ecdsa_key_256,
teardown),
- unit_test_setup_teardown(torture_pki_ecdsa_name384,
+ cmocka_unit_test_setup_teardown(torture_pki_ecdsa_name384,
setup_ecdsa_key_384,
teardown),
- unit_test_setup_teardown(torture_pki_ecdsa_name521,
+ cmocka_unit_test_setup_teardown(torture_pki_ecdsa_name521,
setup_ecdsa_key_521,
teardown),
#endif
@@ -1638,7 +1657,7 @@ int torture_run_tests(void) {
ssh_init();
torture_filter_tests(tests);
- rc=run_tests(tests);
+ rc = cmocka_run_group_tests(tests, NULL, NULL);
ssh_finalize();
return rc;
}
diff --git a/tests/unittests/torture_pki_ed25519.c b/tests/unittests/torture_pki_ed25519.c
index fd04821d..4270d169 100644
--- a/tests/unittests/torture_pki_ed25519.c
+++ b/tests/unittests/torture_pki_ed25519.c
@@ -110,14 +110,14 @@ static void torture_pki_ed25519_verify_bad(void **state){
int torture_run_tests(void) {
int rc;
- const UnitTest tests[] = {
- unit_test(torture_pki_ed25519_sign),
- unit_test(torture_pki_ed25519_verify),
- unit_test(torture_pki_ed25519_verify_bad)
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(torture_pki_ed25519_sign),
+ cmocka_unit_test(torture_pki_ed25519_verify),
+ cmocka_unit_test(torture_pki_ed25519_verify_bad)
};
ssh_init();
- rc=run_tests(tests);
+ rc = cmocka_run_group_tests(tests, NULL, NULL);
ssh_finalize();
return rc;
}
diff --git a/tests/unittests/torture_rand.c b/tests/unittests/torture_rand.c
index b69201a1..95c61316 100644
--- a/tests/unittests/torture_rand.c
+++ b/tests/unittests/torture_rand.c
@@ -13,17 +13,21 @@
#endif
#define NUM_THREADS 100
-static void setup(void **state) {
+static int setup(void **state) {
(void) state;
ssh_threads_set_callbacks(ssh_threads_get_pthread());
ssh_init();
+
+ return 0;
}
-static void teardown(void **state) {
+static int teardown(void **state) {
(void) state;
ssh_finalize();
+
+ return 0;
}
static void *torture_rand_thread(void *threadid) {
@@ -60,10 +64,13 @@ static void torture_rand_threading(void **state) {
}
int torture_run_tests(void) {
- UnitTest tests[] = {
- unit_test_setup_teardown(torture_rand_threading, setup, teardown),
+ int rc;
+ struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(torture_rand_threading, setup, teardown),
};
torture_filter_tests(tests);
- return run_tests(tests);
+ rc = cmocka_run_group_tests(tests, NULL, NULL);
+
+ return rc;
}
diff --git a/tests/unittests/torture_server_x11.c b/tests/unittests/torture_server_x11.c
index 661656a7..486333a2 100644
--- a/tests/unittests/torture_server_x11.c
+++ b/tests/unittests/torture_server_x11.c
@@ -18,10 +18,13 @@ struct hostkey_state {
int fd;
};
-static void setup(void **state) {
+static int setup(void **state) {
struct hostkey_state *h;
mode_t mask;
+ ssh_threads_set_callbacks(ssh_threads_get_pthread());
+ ssh_init();
+
h = malloc(sizeof(struct hostkey_state));
assert_non_null(h);
@@ -39,14 +42,20 @@ static void setup(void **state) {
torture_write_file(h->hostkey_path, h->hostkey);
*state = h;
+
+ return 0;
}
-static void teardown(void **state) {
+static int teardown(void **state) {
struct hostkey_state *h = (struct hostkey_state *)*state;
unlink(h->hostkey);
free(h->hostkey_path);
free(h);
+
+ ssh_finalize();
+
+ return 0;
}
/* 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 rc;
- const UnitTest tests[] = {
- unit_test_setup_teardown(test_ssh_channel_request_x11,
- setup,
- teardown)
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test_setup_teardown(test_ssh_channel_request_x11,
+ setup,
+ teardown)
};
- ssh_threads_set_callbacks(ssh_threads_get_pthread());
- ssh_init();
- rc = run_tests(tests);
- ssh_finalize();
+ rc = cmocka_run_group_tests(tests, NULL, NULL);
return rc;
}