crt: test: Fix cleanup on assert in test t_fstat Cleanup via atexit is called only when test finish successfuly. If the test fails on assert then atexit is not called. So register also SIGABRT handler which is called from assert. Signed-off-by: LIU Hao <lh_mouse@126.com>
diff --git a/mingw-w64-crt/testcases/t_fstat.c b/mingw-w64-crt/testcases/t_fstat.c index 3fb9da4..f59c162 100644 --- a/mingw-w64-crt/testcases/t_fstat.c +++ b/mingw-w64-crt/testcases/t_fstat.c
@@ -1,5 +1,6 @@ #include <assert.h> #include <fcntl.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> @@ -15,6 +16,7 @@ static char dirpath[MAX_PATH + sizeof(TMPTMPL)]; static void remove_dirpath(void) { rmdir(dirpath); } +static void sigabrt_handler(int sig) { (void)sig; remove_dirpath(); } int main() { @@ -38,6 +40,7 @@ strcat(dirpath, TMPTMPL); assert(mkdtemp(dirpath)); + signal(SIGABRT, sigabrt_handler); assert(atexit(remove_dirpath) == 0); printf("mkdtemp(): path=%s\n", dirpath);