Commit 83582888 authored by Chris Müller's avatar Chris Müller
Browse files

Add signal handler for releasing test ressources.

parent ff90c24e
......@@ -18,6 +18,7 @@
// Module internal helper functions
static int monitor_testprocess(pid_t worker_pid, unsigned int timeout);
static void update_statistics(int return_code);
static void release_module_ressource(int signal);
static void print_usage(FILE* stream, const char* programm, int exit_code);
static void print_verbose_testprocess_status(const char* desc, int return_code, suseconds_t time);
static void print_testprocess_status(int return_code);
......@@ -39,6 +40,13 @@ static int FailureNumber = 0;
static int SkippedNumber = 0;
static void
release_module_ressource(int signal)
{
if(Testlog != 0) {
cry_free(Testlog);
}
}
void
cry_unittest_initialize(int argc, char** argv)
......@@ -90,6 +98,9 @@ cry_unittest_initialize(int argc, char** argv)
strftime(Testlog, 64, "%Y%m%d_%H%M%S.testlog", time_struct);
}
signal(SIGTERM, release_module_ressource);
signal(SIGINT, release_module_ressource);
}
......@@ -131,7 +142,7 @@ cry_unittest_run(const char* desc, cry_modulechecker handler, const_pointer data
}
pid_t process_pid = fork();
struct timeval start, end;
if(process_pid > 0) {
......@@ -147,11 +158,14 @@ cry_unittest_run(const char* desc, cry_modulechecker handler, const_pointer data
update_statistics(status);
if(Verbose)
if(Verbose) {
print_verbose_testprocess_status(desc, status, diff_s * 1000000L + diff_ms);
else
} else {
print_testprocess_status(status);
}
fflush(stdout);
} else {
int i = 0;
......@@ -164,7 +178,9 @@ cry_unittest_run(const char* desc, cry_modulechecker handler, const_pointer data
fclose(stderr);
fclose(stdout);
cry_free(Testlog);
exit(EXIT_SUCCESS);
}
}
......@@ -205,7 +221,8 @@ monitor_testprocess(pid_t worker_pid, unsigned int timeout)
} else {
sleep(timeout);
kill(worker_pid, SIGINT);
exit(EXIT_SUCCESS);
exit(EXIT_SUCCESS);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment