Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 1 | // RUN: %clangxx_asan -fsanitize-coverage=func %s -o %t |
| 2 | // RUN: export ASAN_OPTIONS=$ASAN_OPTIONS:coverage=1:coverage_direct=0:verbosity=1 |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 3 | // RUN: rm -rf %T/coverage-fork |
| 4 | // RUN: mkdir -p %T/coverage-fork && cd %T/coverage-fork |
| 5 | // RUN: %run %t 2>&1 | FileCheck %s |
| 6 | // |
| 7 | // XFAIL: android |
| 8 | |
| 9 | #include <stdio.h> |
| 10 | #include <string.h> |
| 11 | #include <unistd.h> |
| 12 | |
| 13 | __attribute__((noinline)) |
| 14 | void foo() { printf("foo\n"); } |
| 15 | |
| 16 | __attribute__((noinline)) |
| 17 | void bar() { printf("bar\n"); } |
| 18 | |
| 19 | __attribute__((noinline)) |
| 20 | void baz() { printf("baz\n"); } |
| 21 | |
| 22 | int main(int argc, char **argv) { |
| 23 | pid_t child_pid = fork(); |
| 24 | if (child_pid == 0) { |
| 25 | fprintf(stderr, "Child PID: %d\n", getpid()); |
| 26 | baz(); |
| 27 | } else { |
| 28 | fprintf(stderr, "Parent PID: %d\n", getpid()); |
| 29 | foo(); |
| 30 | bar(); |
| 31 | } |
| 32 | return 0; |
| 33 | } |
| 34 | |
| 35 | // CHECK-DAG: Child PID: [[ChildPID:[0-9]+]] |
| 36 | // CHECK-DAG: [[ChildPID]].sancov: 1 PCs written |
| 37 | // CHECK-DAG: Parent PID: [[ParentPID:[0-9]+]] |
| 38 | // CHECK-DAG: [[ParentPID]].sancov: 3 PCs written |