aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnderson Toshiyuki Sasaki <ansasaki@redhat.com>2020-04-06 12:07:28 +0200
committerAndreas Schneider <asn@cryptomilk.org>2020-04-09 11:25:49 +0200
commitdba2114ed78796caa06fc9d53268cb9cc302699f (patch)
treec570b67dc5b55a47f9b4ecd2b64f265e5ea08ff5 /tests
parente3e52394c11e7b9bafa3086e7be937388540daeb (diff)
downloadlibssh-dba2114ed78796caa06fc9d53268cb9cc302699f.tar.gz
libssh-dba2114ed78796caa06fc9d53268cb9cc302699f.tar.xz
libssh-dba2114ed78796caa06fc9d53268cb9cc302699f.zip
init: Introduce internal is_ssh_initialized()
The introduced function returns whether the library is initialized or not. Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/torture_init.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unittests/torture_init.c b/tests/unittests/torture_init.c
index 6a97a182..f719fc99 100644
--- a/tests/unittests/torture_init.c
+++ b/tests/unittests/torture_init.c
@@ -2,6 +2,7 @@
#define LIBSSH_STATIC
+#include <errno.h>
#include "torture.h"
#include "libssh/libssh.h"
@@ -32,11 +33,33 @@ static void torture_ssh_init_after_finalize(void **state) {
assert_int_equal(rc, SSH_OK);
}
+static void torture_is_ssh_initialized(UNUSED_PARAM(void **state)) {
+
+ int rc;
+ bool initialized = false;
+
+ /* Make sure the library is not initialized */
+ while (is_ssh_initialized()) {
+ rc = ssh_finalize();
+ assert_return_code(rc, errno);
+ }
+
+ rc = ssh_init();
+ assert_return_code(rc, errno);
+ initialized = is_ssh_initialized();
+ assert_true(initialized);
+ rc = ssh_finalize();
+ assert_return_code(rc, errno);
+ initialized = is_ssh_initialized();
+ assert_false(initialized);
+}
+
int torture_run_tests(void) {
int rc;
struct CMUnitTest tests[] = {
cmocka_unit_test(torture_ssh_init),
cmocka_unit_test(torture_ssh_init_after_finalize),
+ cmocka_unit_test(torture_is_ssh_initialized),
};
torture_filter_tests(tests);