Skip to content

Commit ebc3d0d

Browse files
committed
incorporate PR feedback: merge tests
1 parent 9de9922 commit ebc3d0d

File tree

2 files changed

+17
-34
lines changed

2 files changed

+17
-34
lines changed

compiler-rt/test/asan/TestCases/Windows/allocator_may_return_null_set_via_user_function.cpp

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
// RUN: %clangxx_asan -O0 %s -o %t
2-
// RUN: %env_asan_opts=allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1
3-
// RUN: %env_asan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2
2+
// RUN: %env_asan_opts=allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-ABORT
3+
// RUN: %env_asan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-RETURN_NULL
44

5-
// CHECK1: exceeds maximum supported size
6-
// CHECK1: ABORT
5+
// RUN: %clangxx_asan -O0 %s -o %t -DUSER_FUNCTION
6+
// RUN: %env_asan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-RETURN_NULL
77

8-
// CHECK2: Success
8+
#if USER_FUNCTION
9+
// On Windows, flags configured through the user-defined function `__asan_default_options`
10+
// are suspected to not always be honored according to GitHub bug:
11+
// https://github.com/llvm/llvm-project/issues/117925
12+
// This test ensures we do not regress on `allocator_may_return_null` specifically.
13+
extern "C" __declspec(dllexport) extern const char *__asan_default_options() {
14+
return "allocator_may_return_null=1";
15+
}
16+
#endif
917

1018
#include <cstdint>
11-
#include <cstdio>
1219
#include <cstdlib>
1320
#include <limits>
1421

@@ -17,7 +24,10 @@ int main() {
1724
// terminate the program unless `allocator_may_return_null` is set.
1825
size_t max = std::numeric_limits<size_t>::max();
1926

27+
// CHECK-ABORT: exceeds maximum supported size
28+
// CHECK-ABORT: ABORT
2029
free(malloc(max));
21-
printf("Success");
30+
31+
printf("Success"); // CHECK-RETURN_NULL: Success
2232
return 0;
2333
}

0 commit comments

Comments
 (0)