Files
clang-p2996/compiler-rt/test/asan/TestCases/Posix/coverage-fork.cc
Filipe Cabecinhas 6a9c719ee1 [compiler-rt] Get rid of "%T" expansions
Summary:
Original patch by Kuba Mracek

The %T lit expansion expands to a common directory shared between all
the tests in the same directory, which is unexpected and unintuitive,
and more importantly, it's been a source of subtle race conditions and
flaky tests. In https://reviews.llvm.org/D35396, it was agreed that it
would be best to simply ban %T and only keep %t, which is unique to each
test. When a test needs a temporary directory, it can just create one
using mkdir %t.

This patch removes %T in compiler-rt.

Differential Revision: https://reviews.llvm.org/D48618

llvm-svn: 336661
2018-07-10 12:53:46 +00:00

42 lines
1.1 KiB
C++

// 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