diff options
author | Nico Weber <nicolasweber@gmx.de> | 2019-08-05 16:48:12 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2019-08-05 16:48:12 +0000 |
commit | 2f91f4f955190c500ab3a1ec4b92ad3f3af72724 (patch) | |
tree | 14f3bb241fe04d56481582cad0dcb00f3dc1a01e /test/asan/TestCases/Posix/coverage-fork.cpp | |
parent | 9b46f1e9a77b1faa2e9869b9b886f05ac5d39411 (diff) | |
download | compiler-rt-2f91f4f955190c500ab3a1ec4b92ad3f3af72724.tar.gz |
compiler-rt: Rename cc files below test/asan to cpp
See r367803 and similar other changes.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@367887 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan/TestCases/Posix/coverage-fork.cpp')
-rw-r--r-- | test/asan/TestCases/Posix/coverage-fork.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/asan/TestCases/Posix/coverage-fork.cpp b/test/asan/TestCases/Posix/coverage-fork.cpp new file mode 100644 index 000000000..22d2e3584 --- /dev/null +++ b/test/asan/TestCases/Posix/coverage-fork.cpp @@ -0,0 +1,41 @@ +// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s -o %t +// RUN: rm -rf %t-dir +// RUN: mkdir -p %t-dir && cd %t-dir +// RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t 2>&1 | FileCheck %s +// +// UNSUPPORTED: android +// +// Ideally a forked-subprocess should only report it's own coverage, +// not parent's one. But trace-pc-guard currently does nothing special for fork, +// and thus this test is relaxed. + +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +__attribute__((noinline)) +void foo() { printf("foo\n"); } + +__attribute__((noinline)) +void bar() { printf("bar\n"); } + +__attribute__((noinline)) +void baz() { printf("baz\n"); } + +int main(int argc, char **argv) { + pid_t child_pid = fork(); + if (child_pid == 0) { + fprintf(stderr, "Child PID: %d\n", getpid()); + baz(); + } else { + fprintf(stderr, "Parent PID: %d\n", getpid()); + foo(); + bar(); + } + return 0; +} + +// CHECK-DAG: Child PID: [[ChildPID:[0-9]+]] +// CHECK-DAG: [[ChildPID]].sancov: {{.*}} PCs written +// CHECK-DAG: Parent PID: [[ParentPID:[0-9]+]] +// CHECK-DAG: [[ParentPID]].sancov: 3 PCs written |