mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-01 11:26:52 +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:
@ -103,7 +103,8 @@ static int session_teardown(void **state)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static int setup_session(void **state)
|
|
||||||
|
static int setup_pkcs11(void **state)
|
||||||
{
|
{
|
||||||
struct torture_state *s = *state;
|
struct torture_state *s = *state;
|
||||||
struct pki_st *test_state = NULL;
|
struct pki_st *test_state = NULL;
|
||||||
@ -144,7 +145,7 @@ static int sshd_setup(void **state)
|
|||||||
{
|
{
|
||||||
|
|
||||||
torture_setup_sshd_server(state, true);
|
torture_setup_sshd_server(state, true);
|
||||||
setup_session(state);
|
setup_pkcs11(state);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -155,6 +156,7 @@ static int sshd_teardown(void **state) {
|
|||||||
struct pki_st *test_state = s->private_data;
|
struct pki_st *test_state = s->private_data;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (test_state != NULL) {
|
||||||
torture_cleanup_tokens(test_state->temp_dir);
|
torture_cleanup_tokens(test_state->temp_dir);
|
||||||
|
|
||||||
rc = torture_change_dir(test_state->orig_dir);
|
rc = torture_change_dir(test_state->orig_dir);
|
||||||
@ -167,6 +169,7 @@ static int sshd_teardown(void **state) {
|
|||||||
SAFE_FREE(test_state->orig_dir);
|
SAFE_FREE(test_state->orig_dir);
|
||||||
SAFE_FREE(test_state->keys_dir);
|
SAFE_FREE(test_state->keys_dir);
|
||||||
SAFE_FREE(test_state);
|
SAFE_FREE(test_state);
|
||||||
|
}
|
||||||
|
|
||||||
torture_teardown_sshd_server(state);
|
torture_teardown_sshd_server(state);
|
||||||
|
|
||||||
|
@ -236,6 +236,10 @@ int torture_terminate_process(const char *pidfile)
|
|||||||
|
|
||||||
/* read the pidfile */
|
/* read the pidfile */
|
||||||
pid = torture_read_pidfile(pidfile);
|
pid = torture_read_pidfile(pidfile);
|
||||||
|
if (pid == -1) {
|
||||||
|
fprintf(stderr, "Failed to read PID file %s\n", pidfile);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
assert_int_not_equal(pid, -1);
|
assert_int_not_equal(pid, -1);
|
||||||
|
|
||||||
for (count = 0; count < 10; count++) {
|
for (count = 0; count < 10; count++) {
|
||||||
@ -1367,10 +1371,8 @@ torture_update_sshd_config(void **state, const char *config)
|
|||||||
void torture_teardown_sshd_server(void **state)
|
void torture_teardown_sshd_server(void **state)
|
||||||
{
|
{
|
||||||
struct torture_state *s = *state;
|
struct torture_state *s = *state;
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = torture_terminate_process(s->srv_pidfile);
|
torture_terminate_process(s->srv_pidfile);
|
||||||
assert_return_code(rc, errno);
|
|
||||||
torture_teardown_socket_dir(state);
|
torture_teardown_socket_dir(state);
|
||||||
}
|
}
|
||||||
#endif /* SSHD_EXECUTABLE */
|
#endif /* SSHD_EXECUTABLE */
|
||||||
|
Reference in New Issue
Block a user