[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / sanitizer_coverage_trace_pc_guard-dso.cpp
blobf6ccbb6981352b0fe4f8ecb998f3b4e2d9549b67
1 // Tests trace pc guard coverage collection.
3 // REQUIRES: has_sancovcc
4 // Doesn't work on big-endian targets.
5 // UNSUPPORTED: ubsan,target={{(powerpc64|s390x|sparc|thumb).*}}
6 // XFAIL: tsan,darwin
7 // XFAIL: android && asan
9 // RUN: rm -rf %t_workdir
10 // RUN: mkdir -p %t_workdir
11 // RUN: cd %t_workdir
12 // RUN: %clangxx -DSHARED1 -O0 -fsanitize-coverage=trace-pc-guard -shared %s -o %t_1.so -fPIC
13 // RUN: %clangxx -DSHARED2 -O0 -fsanitize-coverage=trace-pc-guard -shared %s -o %t_2.so -fPIC
14 // RUN: %clangxx -DMAIN -O0 -fsanitize-coverage=trace-pc-guard %s -o %t %t_1.so %t_2.so
15 // RUN: %env_tool_opts=coverage=1 %t 2>&1 | FileCheck %s
16 // RUN: %sancovcc -covered-functions -strip_path_prefix=TestCases/ *.sancov \
17 // RUN: %t %t_1.so %t_2.so 2>&1 | \
18 // RUN: FileCheck --check-prefix=CHECK-SANCOV %s
19 // RUN: rm -rf %t_workdir
21 #include <stdio.h>
23 extern "C" {
24 int bar();
25 int baz();
28 #ifdef MAIN
30 int foo() {
31 fprintf(stderr, "foo\n");
32 return 1;
35 int main() {
36 fprintf(stderr, "main\n");
37 foo();
38 bar();
39 baz();
42 #endif // MAIN
44 extern "C" {
46 #ifdef SHARED1
47 int bar() {
48 fprintf(stderr, "bar\n");
49 return 1;
51 #endif
53 #ifdef SHARED2
54 int baz() {
55 fprintf(stderr, "baz\n");
56 return 1;
58 #endif
60 } // extern "C"
62 // CHECK: main
63 // CHECK-NEXT: foo
64 // CHECK-NEXT: bar
65 // CHECK-NEXT: baz
66 // CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}.sancov: 2 PCs written
67 // CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}_2.so.{{.*}}.sancov: 1 PCs written
68 // CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}_1.so.{{.*}}.sancov: 1 PCs written
70 // CHECK-SANCOV: Ignoring {{.*}}_1.so and its coverage because __sanitizer_cov* functions were not found.
71 // CHECK-SANCOV: Ignoring {{.*}}_2.so and its coverage because __sanitizer_cov* functions were not found.
72 // CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard-dso.cpp:[[@LINE-42]] foo
73 // CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard-dso.cpp:[[@LINE-38]] main