1/// Test we close file handle on flush, so the .gcda file can be deleted on
2/// Windows while the process is still running. In addition, test we create
3/// a new .gcda on flush, so there is a file when the process exists.
4// RUN: mkdir -p %t.d && cd %t.d
5// RUN: %clang --coverage -o %t %s
6// RUN: test -f gcov-dump-and-remove.gcno
7
8// RUN: rm -f gcov-dump-and-remove.gcda && %run %t
9// RUN: llvm-cov gcov -t gcov-dump-and-remove.gcda | FileCheck %s
10
11extern void __gcov_dump(void);
12extern void __gcov_reset(void);
13extern int remove(const char *); // CHECK: -: [[#@LINE]]:extern int remove
14int main(void) { // CHECK-NEXT: 1: [[#@LINE]]:
15 __gcov_dump(); // CHECK-NEXT: 1: [[#@LINE]]:
16 __gcov_reset(); // CHECK-NEXT: 1: [[#@LINE]]:
17 if (remove("gcov-dump-and-remove.gcda") != 0) // CHECK-NEXT: 1: [[#@LINE]]:
18 return 1; // CHECK-NEXT: #####: [[#@LINE]]: return 1;
19 // CHECK-NEXT: -: [[#@LINE]]:
20 __gcov_dump(); // CHECK-NEXT: 1: [[#@LINE]]:
21 __gcov_reset(); // CHECK-NEXT: 1: [[#@LINE]]:
22 __gcov_dump(); // CHECK-NEXT: 1: [[#@LINE]]:
23 if (remove("gcov-dump-and-remove.gcda") != 0) // CHECK-NEXT: 1: [[#@LINE]]:
24 return 1; // CHECK-NEXT: #####: [[#@LINE]]: return 1;
25
26 return 0;
27}
28