[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / sanitizer_coverage_trace_pc_guard-init.cpp
blobcd5ea30713a5789d9a4fbbec5b4bec2f6f356ab0
1 // Tests trace pc guard coverage collection.
2 //
3 // REQUIRES: has_sancovcc,stable-runtime,x86_64-linux
4 //
5 // RUN: rm -rf %t_workdir
6 // RUN: mkdir -p %t_workdir
7 // RUN: cd %t_workdir
8 // RUN: %clangxx -DSHARED1 -O0 -fsanitize-coverage=trace-pc-guard -shared %s -o %t_1.so -fPIC
9 // RUN: %clangxx -DSTATIC1 -O0 -fsanitize-coverage=trace-pc-guard %s -c -o %t_2.o
10 // RUN: %clangxx -DMAIN -O0 -fsanitize-coverage=trace-pc-guard %s -o %t %t_1.so %t_2.o
11 // RUN: %env_tool_opts=coverage=1 %t 2>&1 | FileCheck %s
12 // RUN: rm -rf %t_workdir
14 #include <stdio.h>
15 #include <stdint.h>
16 #include <stdlib.h>
18 extern "C" {
19 int bar();
20 int baz();
23 #ifdef MAIN
25 extern "C" void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
26 fprintf(stderr, "__sanitizer_cov_trace_pc_guard_init\n");
29 extern "C" void __sanitizer_cov_trace_pc_guard(uint32_t *guard) { }
32 int foo() {
33 fprintf(stderr, "foo\n");
34 return 1;
37 int main() {
38 fprintf(stderr, "main\n");
39 foo();
40 bar();
41 baz();
44 #endif // MAIN
46 extern "C" {
48 #ifdef SHARED1
49 int bar() {
50 fprintf(stderr, "bar\n");
51 return 1;
53 #endif
55 #ifdef STATIC1
56 int baz() {
57 fprintf(stderr, "baz\n");
58 return 1;
60 #endif
62 } // extern "C"
64 // Init is called once per DSO.
65 // CHECK: __sanitizer_cov_trace_pc_guard_init
66 // CHECK-NEXT: __sanitizer_cov_trace_pc_guard_init
67 // CHECK-NEXT: main
68 // CHECK-NEXT: foo
69 // CHECK-NEXT: bar
70 // CHECK-NEXT: baz