This repository was archived by the owner on May 21, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +73
-0
lines changed
test/sanitizer_common/TestCases Expand file tree Collapse file tree 1 file changed +73
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Tests trace pc guard coverage collection.
2
+ //
3
+ // REQUIRES: has_sancovcc,stable-runtime,x86_64-linux
4
+ // XFAIL: tsan
5
+ //
6
+ // RUN: DIR=%t_workdir
7
+ // RUN: CLANG_ARGS="-O0 -fsanitize-coverage=trace-pc-guard"
8
+ // RUN: rm -rf $DIR
9
+ // RUN: mkdir -p $DIR
10
+ // RUN: cd $DIR
11
+ // RUN: %clangxx -DSHARED1 $CLANG_ARGS -shared %s -o %t_1.so -fPIC
12
+ // RUN: %clangxx -DSTATIC1 $CLANG_ARGS %s -c -o %t_2.o
13
+ // RUN: %clangxx -DMAIN $CLANG_ARGS %s -o %t %t_1.so %t_2.o
14
+ // RUN: %env_tool_opts=coverage=1 %t 2>&1 | FileCheck %s
15
+ // RUN: rm -rf $DIR
16
+
17
+ #include < stdio.h>
18
+ #include < stdint.h>
19
+ #include < stdlib.h>
20
+
21
+ extern " C" {
22
+ int bar ();
23
+ int baz ();
24
+ }
25
+
26
+ #ifdef MAIN
27
+
28
+ extern " C" void __sanitizer_cov_trace_pc_guard_init (uint32_t *start, uint32_t *stop) {
29
+ fprintf (stderr, " __sanitizer_cov_trace_pc_guard_init\n " );
30
+ }
31
+
32
+ extern " C" void __sanitizer_cov_trace_pc_guard (uint32_t *guard) { }
33
+
34
+
35
+ int foo () {
36
+ fprintf (stderr, " foo\n " );
37
+ return 1 ;
38
+ }
39
+
40
+ int main () {
41
+ fprintf (stderr, " main\n " );
42
+ foo ();
43
+ bar ();
44
+ baz ();
45
+ }
46
+
47
+ #endif // MAIN
48
+
49
+ extern " C" {
50
+
51
+ #ifdef SHARED1
52
+ int bar () {
53
+ fprintf (stderr, " bar\n " );
54
+ return 1 ;
55
+ }
56
+ #endif
57
+
58
+ #ifdef STATIC1
59
+ int baz () {
60
+ fprintf (stderr, " baz\n " );
61
+ return 1 ;
62
+ }
63
+ #endif
64
+
65
+ } // extern "C"
66
+
67
+ // Init is called once per DSO.
68
+ // CHECK: __sanitizer_cov_trace_pc_guard_init
69
+ // CHECK-NEXT: __sanitizer_cov_trace_pc_guard_init
70
+ // CHECK-NEXT: main
71
+ // CHECK-NEXT: foo
72
+ // CHECK-NEXT: bar
73
+ // CHECK-NEXT: baz
You can’t perform that action at this time.
0 commit comments