forked from OSchip/llvm-project
[gcov][test] Call wait() to make gcov-fork.c reliable
If the parent exit before the child, the line counts might be 1. next:18'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 26: 1: 21: if (fork() == -1) return 1; // CHECK-NEXT: 1: [[#@LINE]]: next:18'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 27: 1: 22: func2(); // CHECK-NEXT: 2: [[#@LINE]]: next:18'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 28: 1: 23: return 0; // CHECK-NEXT: 2: [[#@LINE]]: next:18'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
parent
e79a86e45b
commit
ca1cc5c4e0
|
@ -1,10 +1,6 @@
|
|||
/// A basic block with fork/exec* is split. .gcda is flushed immediately before
|
||||
/// fork/exec* so the lines before fork are counted once while succeeding
|
||||
/// lines are counted twice.
|
||||
// UNSUPPORTED: darwin
|
||||
/// FIXME: http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/50913
|
||||
// UNSUPPORTED: host-byteorder-big-endian
|
||||
|
||||
// RUN: mkdir -p %t.d && cd %t.d
|
||||
// RUN: %clang --coverage %s -o %t
|
||||
// RUN: test -f gcov-fork.gcno
|
||||
|
@ -17,8 +13,12 @@
|
|||
void func1() {} // CHECK: 1: [[#@LINE]]:void func1()
|
||||
void func2() {} // CHECK-NEXT: 2: [[#@LINE]]:
|
||||
int main(void) { // CHECK-NEXT: 1: [[#@LINE]]:
|
||||
int status; // CHECK-NEXT: -: [[#@LINE]]:
|
||||
func1(); // CHECK-NEXT: 1: [[#@LINE]]:
|
||||
if (fork() == -1) return 1; // CHECK-NEXT: 1: [[#@LINE]]:
|
||||
pid_t pid = fork(); // CHECK-NEXT: 1: [[#@LINE]]:
|
||||
if (pid == -1) return 1; // CHECK-NEXT: 2: [[#@LINE]]:
|
||||
if (pid) // CHECK-NEXT: 2: [[#@LINE]]:
|
||||
wait(&status); // CHECK-NEXT: 1: [[#@LINE]]:
|
||||
func2(); // CHECK-NEXT: 2: [[#@LINE]]:
|
||||
return 0; // CHECK-NEXT: 2: [[#@LINE]]:
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue