mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-07-31 00:03:07 +03:00
tests: Verify error returned by kill
Verify the error code returned by kill() in torture_terminate_process(). The error code is raised when killing the process failed. Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
@ -194,7 +194,8 @@ static int agent_teardown(void **state)
|
|||||||
assert_non_null(ssh_agent_pidfile);
|
assert_non_null(ssh_agent_pidfile);
|
||||||
|
|
||||||
/* kill agent pid */
|
/* kill agent pid */
|
||||||
torture_terminate_process(ssh_agent_pidfile);
|
rc = torture_terminate_process(ssh_agent_pidfile);
|
||||||
|
assert_return_code(rc, errno);
|
||||||
|
|
||||||
unlink(ssh_agent_pidfile);
|
unlink(ssh_agent_pidfile);
|
||||||
|
|
||||||
|
@ -285,9 +285,7 @@ static int stop_server(void **state)
|
|||||||
assert_non_null(s);
|
assert_non_null(s);
|
||||||
|
|
||||||
rc = torture_terminate_process(s->srv_pidfile);
|
rc = torture_terminate_process(s->srv_pidfile);
|
||||||
if (rc != 0) {
|
assert_return_code(rc, errno);
|
||||||
fprintf(stderr, "XXXXXX Failed to terminate sshd\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
unlink(s->srv_pidfile);
|
unlink(s->srv_pidfile);
|
||||||
|
|
||||||
|
@ -246,8 +246,12 @@ int torture_terminate_process(const char *pidfile)
|
|||||||
|
|
||||||
rc = kill(pid, 0);
|
rc = kill(pid, 0);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
is_running = 0;
|
/* Process not found */
|
||||||
break;
|
if (errno == ESRCH) {
|
||||||
|
is_running = 0;
|
||||||
|
rc = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +260,7 @@ int torture_terminate_process(const char *pidfile)
|
|||||||
"WARNING: The process with pid %u is still running!\n", pid);
|
"WARNING: The process with pid %u is still running!\n", pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_session torture_ssh_session(struct torture_state *s,
|
ssh_session torture_ssh_session(struct torture_state *s,
|
||||||
@ -923,9 +927,7 @@ torture_reload_sshd_server(void **state)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = torture_terminate_process(s->srv_pidfile);
|
rc = torture_terminate_process(s->srv_pidfile);
|
||||||
if (rc != 0) {
|
assert_return_code(rc, errno);
|
||||||
fprintf(stderr, "XXXXXX Failed to terminate sshd\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return torture_start_sshd_server(state);
|
return torture_start_sshd_server(state);
|
||||||
}
|
}
|
||||||
@ -963,9 +965,7 @@ void torture_teardown_sshd_server(void **state)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = torture_terminate_process(s->srv_pidfile);
|
rc = torture_terminate_process(s->srv_pidfile);
|
||||||
if (rc != 0) {
|
assert_return_code(rc, errno);
|
||||||
fprintf(stderr, "XXXXXX Failed to terminate sshd\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
torture_teardown_socket_dir(state);
|
torture_teardown_socket_dir(state);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user