1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-07-29 13:01:13 +03:00

tests: Do not crash on cleanup when sshd does not come up

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 8fb2c5d2fd)
This commit is contained in:
Jakub Jelen
2024-08-09 12:33:28 +02:00
parent 1fa9ea7f43
commit 960a6d1cdd
2 changed files with 19 additions and 14 deletions

View File

@ -103,7 +103,8 @@ static int session_teardown(void **state)
return 0;
}
static int setup_session(void **state)
static int setup_pkcs11(void **state)
{
struct torture_state *s = *state;
struct pki_st *test_state = NULL;
@ -144,7 +145,7 @@ static int sshd_setup(void **state)
{
torture_setup_sshd_server(state, true);
setup_session(state);
setup_pkcs11(state);
return 0;
}
@ -155,18 +156,20 @@ static int sshd_teardown(void **state) {
struct pki_st *test_state = s->private_data;
int rc;
torture_cleanup_tokens(test_state->temp_dir);
if (test_state != NULL) {
torture_cleanup_tokens(test_state->temp_dir);
rc = torture_change_dir(test_state->orig_dir);
assert_int_equal(rc, 0);
rc = torture_change_dir(test_state->orig_dir);
assert_int_equal(rc, 0);
rc = torture_rmdirs(test_state->temp_dir);
assert_int_equal(rc, 0);
rc = torture_rmdirs(test_state->temp_dir);
assert_int_equal(rc, 0);
SAFE_FREE(test_state->temp_dir);
SAFE_FREE(test_state->orig_dir);
SAFE_FREE(test_state->keys_dir);
SAFE_FREE(test_state);
SAFE_FREE(test_state->temp_dir);
SAFE_FREE(test_state->orig_dir);
SAFE_FREE(test_state->keys_dir);
SAFE_FREE(test_state);
}
torture_teardown_sshd_server(state);