1 // Tests trace pc guard coverage collection.
3 // REQUIRES: has_sancovcc,stable-runtime
4 // XFAIL: tsan,darwin,powerpc64,s390x
7 // RUN: CLANG_ARGS="-O0 -fsanitize-coverage=trace-pc-guard"
11 // RUN: %clangxx -DSHARED1 $CLANG_ARGS -shared %s -o %t_1.so -fPIC
12 // RUN: %clangxx -DSHARED2 $CLANG_ARGS -shared %s -o %t_2.so -fPIC
13 // RUN: %clangxx -DMAIN $CLANG_ARGS %s -o %t %t_1.so %t_2.so
14 // RUN: %env_tool_opts=coverage=1 %t 2>&1 | FileCheck %s
15 // RUN: %sancovcc -covered-functions -strip_path_prefix=TestCases/ *.sancov \
16 // RUN: %t %t_1.so %t_2.so 2>&1 | \
17 // RUN: FileCheck --check-prefix=CHECK-SANCOV %s
30 fprintf(stderr, "foo\n");
35 fprintf(stderr, "main\n");
47 fprintf(stderr, "bar\n");
54 fprintf(stderr, "baz\n");
65 // CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}.sancov 2 PCs written
66 // CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}_2.so.{{.*}}.sancov 1 PCs written
67 // CHECK-DAG: SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.{{.*}}_1.so.{{.*}}.sancov 1 PCs written
69 // CHECK-SANCOV: Ignoring {{.*}}_1.so and its coverage because __sanitizer_cov* functions were not found.
70 // CHECK-SANCOV: Ignoring {{.*}}_2.so and its coverage because __sanitizer_cov* functions were not found.
71 // CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard-dso.cc:29 foo
72 // CHECK-SANCOV-NEXT: sanitizer_coverage_trace_pc_guard-dso.cc:34 main