mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 18:04:25 +09:00
Finalize OpenSSL context from tests to make the valgrind output clean
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
809898b980
commit
ab3e08c2b5
@@ -1976,10 +1976,28 @@ __attribute__((weak)) int torture_run_tests(void)
|
|||||||
}
|
}
|
||||||
#endif /* defined(HAVE_WEAK_ATTRIBUTE) && defined(TORTURE_SHARED) */
|
#endif /* defined(HAVE_WEAK_ATTRIBUTE) && defined(TORTURE_SHARED) */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finalize the torture context. No-op except for OpenSSL.
|
||||||
|
*
|
||||||
|
* When OpenSSL is built without the at-exit handlers, it won't call the
|
||||||
|
* OPENSSL_cleanup() from destructor or at-exit handler, which means we need to
|
||||||
|
* do it manually in the tests.
|
||||||
|
*
|
||||||
|
* It is never a good idea to call this function from the library context as we
|
||||||
|
* can not be sure the libssh is really the last one using the OpenSSL
|
||||||
|
*/
|
||||||
|
static void torture_finalize(void)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_LIBCRYPTO
|
||||||
|
OPENSSL_cleanup();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct argument_s arguments;
|
struct argument_s arguments;
|
||||||
char *env = getenv("LIBSSH_VERBOSITY");
|
char *env = getenv("LIBSSH_VERBOSITY");
|
||||||
|
int rv;
|
||||||
|
|
||||||
arguments.verbose = 0;
|
arguments.verbose = 0;
|
||||||
arguments.pattern = NULL;
|
arguments.pattern = NULL;
|
||||||
@@ -1997,7 +2015,11 @@ int main(int argc, char **argv)
|
|||||||
cmocka_set_test_filter(pattern);
|
cmocka_set_test_filter(pattern);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return torture_run_tests();
|
rv = torture_run_tests();
|
||||||
|
|
||||||
|
torture_finalize();
|
||||||
|
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user