[compiler-rt] b5e3d13 - [asan][test][win] Port more tests to not use clang-cl on MinGW

Alvin Wong via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 21 06:27:26 PDT 2023


Author: Alvin Wong
Date: 2023-04-21T21:25:54+08:00
New Revision: b5e3d131f9ed6687cacffb67de8f54214dd8d2b3

URL: https://github.com/llvm/llvm-project/commit/b5e3d131f9ed6687cacffb67de8f54214dd8d2b3
DIFF: https://github.com/llvm/llvm-project/commit/b5e3d131f9ed6687cacffb67de8f54214dd8d2b3.diff

LOG: [asan][test][win] Port more tests to not use clang-cl on MinGW

Depends on D147432

Differential Revision: https://reviews.llvm.org/D147444

Added: 
    

Modified: 
    compiler-rt/test/asan/TestCases/Windows/crt_initializers.cpp
    compiler-rt/test/asan/TestCases/Windows/demangled_names.cpp
    compiler-rt/test/asan/TestCases/Windows/double_operator_delete.cpp
    compiler-rt/test/asan/TestCases/Windows/operator_array_new_left_oob.cpp
    compiler-rt/test/asan/TestCases/Windows/operator_array_new_right_oob.cpp
    compiler-rt/test/asan/TestCases/Windows/operator_array_new_uaf.cpp
    compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
    compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/asan/TestCases/Windows/crt_initializers.cpp b/compiler-rt/test/asan/TestCases/Windows/crt_initializers.cpp
index a37d47afb167..5a1eee33e701 100644
--- a/compiler-rt/test/asan/TestCases/Windows/crt_initializers.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/crt_initializers.cpp
@@ -1,6 +1,4 @@
-// UNSUPPORTED: target={{.*-windows-gnu}}
-
-// RUN: %clang_cl_asan -Od %s -Fe%t
+// RUN: %clang_cl_asan %Od %s %Fe%t
 // RUN: %run %t | FileCheck %s
 
 // This is a test for http://code.google.com/p/address-sanitizer/issues/detail?id=305

diff  --git a/compiler-rt/test/asan/TestCases/Windows/demangled_names.cpp b/compiler-rt/test/asan/TestCases/Windows/demangled_names.cpp
index d457d4d9e4f7..cc1f146b7306 100644
--- a/compiler-rt/test/asan/TestCases/Windows/demangled_names.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/demangled_names.cpp
@@ -1,7 +1,5 @@
-// UNSUPPORTED: target={{.*-windows-gnu}}
-
-// RUN: %clang_cl_asan -Od %s -Fe%t
-// RUN: not %run %t 2>&1 | FileCheck %s
+// RUN: %clang_cl_asan %Od %s %Fe%t
+// RUN: not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,%if clang-cl %{MSVC%} %else %{MINGW%}
 //
 // This test makes sure ASan symbolizes stack traces the way they are typically
 // symbolized on Windows.
@@ -44,9 +42,11 @@ int main() {
   char *buffer = (char*)malloc(42);
   free(buffer);
   A<char*> a(buffer);
-// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: foo::bar<42>{{.*}}demangled_names.cpp
-// CHECK: foo::spam{{.*}}demangled_names.cpp
-// CHECK: baz<char *,{{ *}}1>{{.*}}demangled_names.cpp
-// CHECK: A<char *>::~A<char *>{{.*}}demangled_names.cpp
+  // CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
+  // CHECK: foo::bar<42>{{.*}}demangled_names.cpp
+  // CHECK: foo::spam{{.*}}demangled_names.cpp
+  // MSVC:  baz<char *,{{ *}}1>{{.*}}demangled_names.cpp
+  // MINGW: baz<char*, true>{{.*}}demangled_names.cpp
+  // MSVC:  A<char *>::~A<char *>{{.*}}demangled_names.cpp
+  // MINGW: A<char*>::~A(){{.*}}demangled_names.cpp
 }

diff  --git a/compiler-rt/test/asan/TestCases/Windows/double_operator_delete.cpp b/compiler-rt/test/asan/TestCases/Windows/double_operator_delete.cpp
index 55304e266a9d..3668a40ce01d 100644
--- a/compiler-rt/test/asan/TestCases/Windows/double_operator_delete.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/double_operator_delete.cpp
@@ -1,6 +1,4 @@
-// UNSUPPORTED: target={{.*-windows-gnu}}
-
-// RUN: %clang_cl_asan -Od %s -Fe%t
+// RUN: %clang_cl_asan %Od %s %Fe%t
 // RUN: not %run %t 2>&1 | FileCheck %s
 
 #include <malloc.h>
@@ -9,19 +7,16 @@ int main() {
   int *x = new int[42];
   delete [] x;
   delete [] x;
-// CHECK: AddressSanitizer: attempting double-free on [[ADDR:0x[0-9a-f]+]]
-// FIXME: The 'operator delete' frame should have [].
-// CHECK-NEXT: {{#0 .* operator delete}}
-// CHECK-NEXT: {{#1 .* main .*double_operator_delete.cpp}}:[[@LINE-4]]
-// CHECK: [[ADDR]] is located 0 bytes inside of 168-byte region
-// CHECK-LABEL: freed by thread T0 here:
-// FIXME: The 'operator delete' frame should have [].
-// CHECK-NEXT: {{#0 .* operator delete}}
-// CHECK-NEXT: {{#1 .* main .*double_operator_delete.cpp}}:[[@LINE-10]]
-// CHECK-LABEL: previously allocated by thread T0 here:
-// FIXME: The 'operator new' frame should have [].
-// CHECK-NEXT: {{#0 .* operator new}}
-// CHECK-NEXT: {{#1 .* main .*double_operator_delete.cpp}}:[[@LINE-15]]
+  // CHECK: AddressSanitizer: attempting double-free on [[ADDR:0x[0-9a-f]+]]
+  // CHECK-NEXT: {{#0 .* operator delete}}[]
+  // CHECK-NEXT: {{#1 .* main .*double_operator_delete.cpp}}:[[@LINE-3]]
+  // CHECK: [[ADDR]] is located 0 bytes inside of 168-byte region
+  // CHECK-LABEL: freed by thread T0 here:
+  // CHECK-NEXT: {{#0 .* operator delete}}[]
+  // CHECK-NEXT: {{#1 .* main .*double_operator_delete.cpp}}:[[@LINE-8]]
+  // CHECK-LABEL: previously allocated by thread T0 here:
+  // CHECK-NEXT: {{#0 .* operator new}}[]
+  // CHECK-NEXT: {{#1 .* main .*double_operator_delete.cpp}}:[[@LINE-12]]
   return 0;
 }
 

diff  --git a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_left_oob.cpp
index f8ffc69ce552..96b9378cc517 100644
--- a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_left_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_left_oob.cpp
@@ -1,19 +1,16 @@
-// UNSUPPORTED: target={{.*-windows-gnu}}
-
-// RUN: %clang_cl_asan -Od %s -Fe%t
+// RUN: %clang_cl_asan %Od %s %Fe%t
 // RUN: not %run %t 2>&1 | FileCheck %s
 
 int main() {
   char *buffer = new char[42];
   buffer[-1] = 42;
-// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: WRITE of size 1 at [[ADDR]] thread T0
-// CHECK-NEXT: {{#0 .* main .*operator_array_new_left_oob.cpp}}:[[@LINE-3]]
-//
-// CHECK: [[ADDR]] is located 1 bytes before 42-byte region
-// CHECK-LABEL: allocated by thread T0 here:
-// FIXME: The 'operator new' frame should have [].
-// CHECK-NEXT: {{#0 .* operator new}}
-// CHECK-NEXT: {{#1 .* main .*operator_array_new_left_oob.cpp}}:[[@LINE-10]]
+  // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+  // CHECK: WRITE of size 1 at [[ADDR]] thread T0
+  // CHECK-NEXT: {{#0 .* main .*operator_array_new_left_oob.cpp}}:[[@LINE-3]]
+  //
+  // CHECK: [[ADDR]] is located 1 bytes before 42-byte region
+  // CHECK-LABEL: allocated by thread T0 here:
+  // CHECK-NEXT: {{#0 .* operator new}}[]
+  // CHECK-NEXT: {{#1 .* main .*operator_array_new_left_oob.cpp}}:[[@LINE-9]]
   delete [] buffer;
 }

diff  --git a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_right_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_right_oob.cpp
index b84e657a88c0..1e29d752a783 100644
--- a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_right_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_right_oob.cpp
@@ -1,6 +1,4 @@
-// UNSUPPORTED: target={{.*-windows-gnu}}
-
-// RUN: %clang_cl_asan -Od %s -Fe%t
+// RUN: %clang_cl_asan %Od %s %Fe%t
 // RUN: not %run %t 2>&1 | FileCheck %s
 
 #include <windows.h>
@@ -8,13 +6,12 @@
 int main() {
   char *buffer = new char[42];
   buffer[42] = 42;
-// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: WRITE of size 1 at [[ADDR]] thread T0
-// CHECK:   {{#0 .* main .*operator_array_new_right_oob.cpp}}:[[@LINE-3]]
-// CHECK: [[ADDR]] is located 0 bytes after 42-byte region
-// CHECK: allocated by thread T0 here:
-// FIXME: The 'operator new' frame should have [].
-// CHECK:   {{#0 .* operator new}}
-// CHECK:   {{#1 .* main .*operator_array_new_right_oob.cpp}}:[[@LINE-9]]
+  // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+  // CHECK: WRITE of size 1 at [[ADDR]] thread T0
+  // CHECK:   {{#0 .* main .*operator_array_new_right_oob.cpp}}:[[@LINE-3]]
+  // CHECK: [[ADDR]] is located 0 bytes after 42-byte region
+  // CHECK: allocated by thread T0 here:
+  // CHECK:   {{#0 .* operator new}}[]
+  // CHECK:   {{#1 .* main .*operator_array_new_right_oob.cpp}}:[[@LINE-8]]
   delete [] buffer;
 }

diff  --git a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_uaf.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_uaf.cpp
index 367162ec5b5a..edeee99a7653 100644
--- a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_uaf.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_uaf.cpp
@@ -1,6 +1,4 @@
-// UNSUPPORTED: target={{.*-windows-gnu}}
-
-// RUN: %clang_cl_asan -Od %s -Fe%t
+// RUN: %clang_cl_asan %Od %s %Fe%t
 // RUN: not %run %t 2>&1 | FileCheck %s
 
 #include <windows.h>
@@ -9,18 +7,16 @@ int main() {
   char *buffer = new char[42];
   delete [] buffer;
   buffer[0] = 42;
-// CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: WRITE of size 1 at [[ADDR]] thread T0
-// CHECK:   {{#0 .* main .*operator_array_new_uaf.cpp}}:[[@LINE-3]]
-// CHECK: [[ADDR]] is located 0 bytes inside of 42-byte region
-// CHECK-LABEL: freed by thread T0 here:
-// FIXME: The 'operator delete' frame should have [].
-// CHECK:   {{#0 .* operator delete}}
-// CHECK:   {{#1 .* main .*operator_array_new_uaf.cpp}}:[[@LINE-9]]
-// CHECK-LABEL: previously allocated by thread T0 here:
-// FIXME: The 'operator new' frame should have [].
-// CHECK:   {{#0 .* operator new}}
-// CHECK:   {{#1 .* main .*operator_array_new_uaf.cpp}}:[[@LINE-14]]
+  // CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
+  // CHECK: WRITE of size 1 at [[ADDR]] thread T0
+  // CHECK:   {{#0 .* main .*operator_array_new_uaf.cpp}}:[[@LINE-3]]
+  // CHECK: [[ADDR]] is located 0 bytes inside of 42-byte region
+  // CHECK-LABEL: freed by thread T0 here:
+  // CHECK:   {{#0 .* operator delete}}[]
+  // CHECK:   {{#1 .* main .*operator_array_new_uaf.cpp}}:[[@LINE-8]]
+  // CHECK-LABEL: previously allocated by thread T0 here:
+  // CHECK:   {{#0 .* operator new}}[]
+  // CHECK:   {{#1 .* main .*operator_array_new_uaf.cpp}}:[[@LINE-12]]
   return 0;
 }
 

diff  --git a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
index 30fc1c749c94..cad28ae8ace2 100644
--- a/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cpp
@@ -1,6 +1,4 @@
-// UNSUPPORTED: target={{.*-windows-gnu}}
-
-// RUN: %clang_cl_asan -Od %s -Fe%t
+// RUN: %clang_cl_asan %Od %s %Fe%t
 // RUN: not %run %t 2>&1 | FileCheck %s
 
 struct C {
@@ -13,17 +11,16 @@ int __attribute__((noinline, optnone)) hide(int x) { return x; }
 int main() {
   C *buffer = new C[42];
   buffer[hide(-(1 + (int)sizeof(void*) / 4))].x = 42;
-// CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
-// CHECK: WRITE of size 4 at [[ADDR]] thread T0
-// CHECK-NEXT: {{#0 .* main .*operator_array_new_with_dtor_left_oob.cpp}}:[[@LINE-3]]
-//
-// FIXME: Currently it says "4 bytes ... left of 172-byte region",
-//        should be "8 bytes ... left of 168-byte region", see
-//        https://code.google.com/p/address-sanitizer/issues/detail?id=314
-// CHECK: [[ADDR]] is located {{.*}} bytes before {{(172|176)}}-byte region
-// CHECK-LABEL: allocated by thread T0 here:
-// FIXME: The 'operator new' frame should have [].
-// CHECK-NEXT: {{#0 .* operator new}}
-// CHECK-NEXT: {{#1 .* main .*operator_array_new_with_dtor_left_oob.cpp}}:[[@LINE-13]]
+  // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+  // CHECK: WRITE of size 4 at [[ADDR]] thread T0
+  // CHECK-NEXT: {{#0 .* main .*operator_array_new_with_dtor_left_oob.cpp}}:[[@LINE-3]]
+  //
+  // FIXME: Currently it says "4 bytes ... left of 172-byte region",
+  //        should be "8 bytes ... left of 168-byte region", see
+  //        https://code.google.com/p/address-sanitizer/issues/detail?id=314
+  // CHECK: [[ADDR]] is located {{.*}} bytes before {{(172|176)}}-byte region
+  // CHECK-LABEL: allocated by thread T0 here:
+  // CHECK-NEXT: {{#0 .* operator new}}[]
+  // CHECK-NEXT: {{#1 .* main .*operator_array_new_with_dtor_left_oob.cpp}}:[[@LINE-12]]
   delete [] buffer;
 }

diff  --git a/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp b/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp
index ce9bd638b12e..1424ee88129f 100644
--- a/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/sse_misalignment.cpp
@@ -1,8 +1,9 @@
-// UNSUPPORTED: target={{.*-windows-gnu}}
-
-// RUN: %clang_cl_asan -Od %s -Fe%t
+// RUN: %clang_cl_asan %Od %s %Fe%t
 // RUN: %env_asan_opts=handle_sigfpe=1 not %run %t 2>&1 | FileCheck %s
 
+// FIXME: On MinGW frame #0 does not include the line number?
+// XFAIL: target={{.*-windows-gnu}}
+
 // Test the error output from misaligned SSE2 memory access. This is a READ
 // memory access. Windows appears to always provide an address of -1 for these
 // types of faults, and there doesn't seem to be a way to distinguish them from
@@ -27,4 +28,4 @@ int main() {
 // CHECK: before alignment fault
 // CHECK: ERROR: AddressSanitizer: access-violation on unknown address {{0x[fF]*}}
 // CHECK-NEXT: The signal is caused by a READ memory access.
-// CHECK-NEXT: #0 {{.*}} in test(void) {{.*}}misalignment.cpp:{{.*}}
+// CHECK-NEXT: #0 {{.*}} in test({{(void)?}}) {{.*}}misalignment.cpp:{{.*}}


        


More information about the llvm-commits mailing list