crt: test: Check DLL_PROCESS_DETACH event counter in t_tls_exe_native test Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/testcases/t_tls_exe_native.c b/mingw-w64-crt/testcases/t_tls_exe_native.c index df59f96..d3e9280 100644 --- a/mingw-w64-crt/testcases/t_tls_exe_native.c +++ b/mingw-w64-crt/testcases/t_tls_exe_native.c
@@ -27,6 +27,11 @@ } else if (reason == DLL_THREAD_ATTACH) { thread_attach++; } else if (reason == DLL_PROCESS_DETACH) { + if (process_detach != 0) { + printf("Error after main: PE TLS callback for DLL_PROCESS_DETACH was called more times\n"); + /* exit, _exit, or ExitProcess calls TLS callbacks, so use TerminateProcess() which is not calling them */ + TerminateProcess(GetCurrentProcess(), 1); + } process_detach++; } else if (reason == DLL_THREAD_DETACH) { thread_detach++; @@ -131,6 +136,11 @@ } } + if (process_detach != 0) { + printf("Error: PE TLS callback for DLL_PROCESS_DETACH was called before exiting process\n"); + ret = 1; + } + if (ret) printf("FAILED\n"); else printf("PASSED\n"); return ret; }