]> git.proxmox.com Git - rustc.git/blob
1b787f143d467ce6ee36b42bdcdf74545ec7a658
[rustc.git] /
1 // Tests trace pc guard coverage collection.
2 //
3 // REQUIRES: has_sancovcc,stable-runtime
4 // XFAIL: tsan,darwin,powerpc64,s390x
5 //
6 // RUN: DIR=%t_workdir
7 // RUN: rm -rf $DIR
8 // RUN: mkdir -p $DIR
9 // RUN: cd $DIR
10 // RUN: %clangxx -O0 -fsanitize-coverage=trace-pc-guard %s -ldl -o %t
11 // RUN: %env_tool_opts=coverage=1 %t 2>&1 | FileCheck %s
12 // RUN: %sancovcc -covered-functions -strip_path_prefix=TestCases/ *.sancov %t 2>&1 | \
13 // RUN: FileCheck --check-prefix=CHECK-SANCOV %s
14 // RUN: %env_tool_opts=coverage=0 %t 2>&1 | FileCheck --check-prefix=CHECK-NOCOV %s
15 // RUN: rm -rf $DIR
16 // Make some room to stabilize line numbers
17 //
18 //
19 //
20 #include <stdio.h>
21
22 int foo() {
23 fprintf(stderr, "foo\n");
24 return 1;
25 }
26
27 int main() {
28 fprintf(stderr, "main\n");
29 foo();
30 foo();
31 }
32
33 // CHECK: main
34 // CHECK-NEXT: foo
35 // CHECK-NEXT: foo
36 // CHECK-NEXT: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard.{{.*}}.sancov 2 PCs written
37 //
38 // CHECK-SANCOV: sanitizer_coverage_trace_pc_guard.cc:22 foo
39 // CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard.cc:27 main
40 //
41 // CHECK-NOCOV-NOT: SanitizerCoverage