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).*}}
7 // XFAIL: android && asan
9 // RUN: rm -rf %t_workdir
10 // RUN: mkdir -p %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
31 fprintf(stderr
, "foo\n");
36 fprintf(stderr
, "main\n");
48 fprintf(stderr
, "bar\n");
55 fprintf(stderr
, "baz\n");
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