• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
2 // XFAIL: android
3 //
4 // RUN: %clangxx_asan -mllvm -asan-coverage=1 %s -o %t
5 // RUN: rm -rf %T/coverage-maybe-open-file
6 // RUN: mkdir -p %T/coverage-maybe-open-file && cd %T/coverage-maybe-open-file
7 // RUN: ASAN_OPTIONS=coverage=1 %run %t | FileCheck %s --check-prefix=CHECK-success
8 // RUN: ASAN_OPTIONS=coverage=0 %run %t | FileCheck %s --check-prefix=CHECK-fail
9 // RUN: [ "$(cat test.sancov.packed)" == "test" ]
10 // RUN: cd .. && rm -rf %T/coverage-maybe-open-file
11 
12 #include <stdio.h>
13 #include <string.h>
14 #include <unistd.h>
15 
16 #include <sanitizer/common_interface_defs.h>
17 
main(int argc,char ** argv)18 int main(int argc, char **argv) {
19   int fd = __sanitizer_maybe_open_cov_file("test");
20   if (fd > 0) {
21     printf("SUCCESS\n");
22     const char s[] = "test\n";
23     write(fd, s, strlen(s));
24     close(fd);
25   } else {
26     printf("FAIL\n");
27   }
28 }
29 
30 // CHECK-success: SUCCESS
31 // CHECK-fail: FAIL
32