Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / Darwin / suppressions-sandbox.cpp
blob966f21346e4fe2617c15d52b09f97f6b2199a770
1 // Check that without suppressions, we catch the issue.
2 // RUN: %clangxx_asan -O0 %s -o %t -framework Foundation
3 // RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
5 // Check that suppressing a function name works within a no-fork sandbox
6 // RUN: echo "interceptor_via_fun:CFStringCreateWithBytes" > %t.supp
7 // RUN: %env_asan_opts=suppressions='"%t.supp"' \
8 // RUN: sandbox-exec -p '(version 1)(allow default)(deny process-fork)' \
9 // RUN: %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
11 // sandbox-exec isn't available on iOS
12 // UNSUPPORTED: ios
14 #include <CoreFoundation/CoreFoundation.h>
16 int main() {
17 char *a = (char *)malloc(6);
18 strcpy(a, "hello");
19 CFStringRef str =
20 CFStringCreateWithBytes(kCFAllocatorDefault, (unsigned char *)a, 10,
21 kCFStringEncodingUTF8, FALSE); // BOOM
22 fprintf(stderr, "Ignored.\n");
23 free(a);
24 CFRelease(str);
27 // CHECK-CRASH: AddressSanitizer: heap-buffer-overflow
28 // CHECK-CRASH-NOT: Ignored.
29 // CHECK-IGNORE-NOT: AddressSanitizer: heap-buffer-overflow
30 // CHECK-IGNORE: Ignored.