[LVI] Add trunc to i1 handling. (#124480)
[llvm-project.git] / compiler-rt / test / asan / TestCases / Windows / report_globals_reload_dll.cpp
blobf9627b9ad3b5790005f97c5de546063e348e0d31
1 // Make sure we can handle reloading the same DLL multiple times.
2 // RUN: %clang_cl_asan %LD %Od -DDLL %s %Fe%t.dll
3 // RUN: %clang_cl_asan %Od -DEXE %s %Fe%te.exe
4 // RUN: %env_asan_opts=report_globals=1 %run %te.exe %t.dll 2>&1 | FileCheck %s
6 #include <windows.h>
7 #include <stdio.h>
8 #include <string.h>
10 #if defined(EXE)
11 int main(int argc, char **argv) {
12 if (argc != 2) {
13 printf("Usage: %s [client].dll\n", argv[0]);
14 return 101;
16 const char *dll_name = argv[1];
18 // CHECK: time to load DLL
19 printf("time to load DLL\n");
20 fflush(0);
22 // CHECK: in DLL(reason=1)
23 // CHECK: in DLL(reason=0)
24 // CHECK: in DLL(reason=1)
25 // CHECK: in DLL(reason=0)
26 // CHECK: in DLL(reason=1)
27 // CHECK: in DLL(reason=0)
28 for (int i = 0; i < 30; ++i) {
29 HMODULE dll = LoadLibrary(dll_name);
30 if (dll == NULL)
31 return 3;
33 if (!FreeLibrary(dll))
34 return 4;
37 // CHECK: All OK!
38 printf("All OK!\n");
39 fflush(0);
41 #elif defined(DLL)
42 extern "C" {
43 BOOL WINAPI DllMain(HMODULE, DWORD reason, LPVOID) {
44 printf("in DLL(reason=%d)\n", (int)reason);
45 fflush(0);
46 return TRUE;
49 #else
50 # error oops!
51 #endif