torture: Add torture_teardown_socket_dir().

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>

(cherry-picked from commit fd09c4cb)
This commit is contained in:
Andreas Schneider
2014-04-15 21:50:19 +02:00
committed by Jakub Jelen
parent 3567524fb2
commit ae3e2a19c8
2 changed files with 26 additions and 0 deletions

View File

@@ -689,6 +689,30 @@ void torture_setup_socket_dir(void **state)
*state = s;
}
void torture_teardown_socket_dir(void **state)
{
struct torture_state *s = *state;
char *env = getenv("TORTURE_SKIP_CLEANUP");
int rc;
if (env != NULL && env[0] == '1') {
fprintf(stderr, ">>> Skipping cleanup of %s\n", s->socket_dir);
} else {
rc = torture_rmdirs(s->socket_dir);
if (rc < 0) {
fprintf(stderr,
"torture_rmdirs(%s) failed: %s",
s->socket_dir,
strerror(errno));
}
}
free(s->socket_dir);
free(s->pcap_file);
free(s->srv_pidfile);
free(s);
}
int torture_libssh_verbosity(void){
return verbosity;
}

View File

@@ -106,6 +106,8 @@ void _torture_filter_tests(UnitTest *tests, size_t ntests);
void torture_setup_socket_dir(void **state);
void torture_teardown_socket_dir(void **state);
/*
* This function must be defined in every unit test file.
*/