brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 0a028e2 Raw
49 lines · cpp
1// Check that without suppressions, we catch the issue.2// RUN: %clangxx_asan -O0 %s -o %t3// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s4 5// If the executable is started from a different location, we should still6// find the suppression file located relative to the location of the executable.7// RUN: rm -rf %t-dir8// RUN: mkdir -p %t-dir9// RUN: %clangxx_asan -O0 %s -o %t-dir/exec10// RUN: echo "interceptor_via_fun:crash_function" > \11// RUN:   %t-dir/supp.txt12// RUN: %env_asan_opts=suppressions='"supp.txt"' \13// RUN:   %run %t-dir/exec 2>&1 | \14// RUN:   FileCheck --check-prefix=CHECK-IGNORE %s15// RUN: rm -rf %t-dir16 17// If the wrong absolute path is given, we don't try to construct18// a relative path with it.19// RUN: %env_asan_opts=suppressions='"/absolute/path"' not %run %t 2>&1 | \20// RUN:   FileCheck --check-prefix=CHECK-WRONG-FILE-NAME %s21 22// Test that we reject directory as filename.23// RUN: %env_asan_opts=suppressions='"folder/only/"' not %run %t 2>&1 | \24// RUN:   FileCheck --check-prefix=CHECK-WRONG-FILE-NAME %s25 26// FIXME: Upload suppressions to device.27// XFAIL: android28// UNSUPPORTED: ios29 30#include <stdio.h>31#include <stdlib.h>32#include <string.h>33 34void crash_function() {35  char *a = (char *)malloc(6);36  free(a);37  size_t len = strlen(a); // BOOM38  fprintf(stderr, "strlen ignored, len = %zu\n", len);39}40 41int main() {42  crash_function();43}44 45// CHECK-CRASH: AddressSanitizer: heap-use-after-free46// CHECK-IGNORE-NOT: AddressSanitizer: heap-buffer-overflow47// CHECK-IGNORE: ignored48// CHECK-WRONG-FILE-NAME: failed to read suppressions file49