From 6b10bbea2fb51e0f61285caa443f88dbae251c9c Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Fri, 31 Aug 2018 11:31:08 +0200 Subject: [PATCH] tests: Properly initilize library in threads tests This was already done in the torture_threads_pki. Without the explicit initialization, we can observe random failures tests (at least of the torture_threads_crypto) from various threads. Signed-off-by: Jakub Jelen Reviewed-by: Andreas Schneider --- tests/unittests/torture_threads_buffer.c | 6 ++++++ tests/unittests/torture_threads_crypto.c | 6 ++++++ tests/unittests/torture_threads_init.c | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/tests/unittests/torture_threads_buffer.c b/tests/unittests/torture_threads_buffer.c index 11252eac..e3cebdc9 100644 --- a/tests/unittests/torture_threads_buffer.c +++ b/tests/unittests/torture_threads_buffer.c @@ -589,8 +589,14 @@ int torture_run_tests(void) cmocka_unit_test(torture_mixed), }; + /* + * If the library is statically linked, ssh_init() is not called + * automatically + */ + ssh_init(); torture_filter_tests(tests); rc = cmocka_run_group_tests(tests, NULL, NULL); + ssh_finalize(); return rc; } diff --git a/tests/unittests/torture_threads_crypto.c b/tests/unittests/torture_threads_crypto.c index 298a4539..12105ae3 100644 --- a/tests/unittests/torture_threads_crypto.c +++ b/tests/unittests/torture_threads_crypto.c @@ -175,7 +175,13 @@ int torture_run_tests(void) cmocka_unit_test(torture_crypto_aes256_cbc), }; + /* + * If the library is statically linked, ssh_init() is not called + * automatically + */ + ssh_init(); rc = cmocka_run_group_tests(tests, NULL, NULL); + ssh_finalize(); return rc; } diff --git a/tests/unittests/torture_threads_init.c b/tests/unittests/torture_threads_init.c index 1b0781e5..8eada0d3 100644 --- a/tests/unittests/torture_threads_init.c +++ b/tests/unittests/torture_threads_init.c @@ -88,8 +88,14 @@ int torture_run_tests(void) cmocka_unit_test(torture_ssh_init), }; + /* + * If the library is statically linked, ssh_init() is not called + * automatically + */ + ssh_init(); torture_filter_tests(tests); rc = cmocka_run_group_tests(tests, NULL, NULL); + ssh_finalize(); return rc; }