summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/sancov
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/tools/sancov')
-rw-r--r--llvm/test/tools/sancov/Inputs/foo.cpp5
-rwxr-xr-xllvm/test/tools/sancov/Inputs/test-linux_x86_64bin0 -> 2331068 bytes
-rw-r--r--llvm/test/tools/sancov/Inputs/test-linux_x86_64-1.sancovbin0 -> 80 bytes
-rw-r--r--llvm/test/tools/sancov/Inputs/test-linux_x86_64.sancovbin0 -> 72 bytes
-rw-r--r--llvm/test/tools/sancov/Inputs/test.cpp19
-rw-r--r--llvm/test/tools/sancov/covered_functions.test13
-rw-r--r--llvm/test/tools/sancov/print.test10
7 files changed, 47 insertions, 0 deletions
diff --git a/llvm/test/tools/sancov/Inputs/foo.cpp b/llvm/test/tools/sancov/Inputs/foo.cpp
new file mode 100644
index 00000000000..71b35b32392
--- /dev/null
+++ b/llvm/test/tools/sancov/Inputs/foo.cpp
@@ -0,0 +1,5 @@
+#include <stdio.h>
+#include <string>
+
+__attribute__((noinline))
+void foo() { printf("foo\n"); }
diff --git a/llvm/test/tools/sancov/Inputs/test-linux_x86_64 b/llvm/test/tools/sancov/Inputs/test-linux_x86_64
new file mode 100755
index 00000000000..50060166ac3
--- /dev/null
+++ b/llvm/test/tools/sancov/Inputs/test-linux_x86_64
Binary files differ
diff --git a/llvm/test/tools/sancov/Inputs/test-linux_x86_64-1.sancov b/llvm/test/tools/sancov/Inputs/test-linux_x86_64-1.sancov
new file mode 100644
index 00000000000..08a0521277b
--- /dev/null
+++ b/llvm/test/tools/sancov/Inputs/test-linux_x86_64-1.sancov
Binary files differ
diff --git a/llvm/test/tools/sancov/Inputs/test-linux_x86_64.sancov b/llvm/test/tools/sancov/Inputs/test-linux_x86_64.sancov
new file mode 100644
index 00000000000..f8030c33d6c
--- /dev/null
+++ b/llvm/test/tools/sancov/Inputs/test-linux_x86_64.sancov
Binary files differ
diff --git a/llvm/test/tools/sancov/Inputs/test.cpp b/llvm/test/tools/sancov/Inputs/test.cpp
new file mode 100644
index 00000000000..795468b4bcb
--- /dev/null
+++ b/llvm/test/tools/sancov/Inputs/test.cpp
@@ -0,0 +1,19 @@
+// compile & generate coverage data using:
+// clang++ -g -o test-linux_x86_64 -fsanitize=address -fsanitize-coverage=edge *.cpp
+// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 && mv test-linux_x86_64.*.sancov test-linux_x86_64.sancov
+// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 1 && mv test-linux_x86_64.*.sancov test-linux_x86_64-1.sancov
+
+#include <stdio.h>
+#include <string>
+
+void foo();
+
+__attribute__((noinline))
+std::string bar(std::string str) { printf("bar\n"); return str; }
+
+int main(int argc, char **argv) {
+ if (argc == 2)
+ foo();
+ bar("str");
+ printf("main\n");
+}
diff --git a/llvm/test/tools/sancov/covered_functions.test b/llvm/test/tools/sancov/covered_functions.test
new file mode 100644
index 00000000000..0e110b16482
--- /dev/null
+++ b/llvm/test/tools/sancov/covered_functions.test
@@ -0,0 +1,13 @@
+RUN: sancov -obj %p/Inputs/test-linux_x86_64 -covered_functions %p/Inputs/test-linux_x86_64.sancov | FileCheck %s
+RUN: sancov -obj %p/Inputs/test-linux_x86_64 -covered_functions %p/Inputs/test-linux_x86_64-1.sancov | FileCheck --check-prefix=MULTIPLE_FILES %s
+RUN: sancov -obj %p/Inputs/test-linux_x86_64 -demangle=0 -covered_functions %p/Inputs/test-linux_x86_64.sancov | FileCheck --check-prefix=NO_DEMANGLE %s
+
+CHECK: Inputs/test.cpp:12 bar(std::string)
+CHECK: Inputs/test.cpp:14 main
+
+MULTIPLE_FILES: {{^}}foo.cpp:5 foo()
+MULTIPLE_FILES: {{^}}test.cpp:12 bar(std::string)
+MULTIPLE_FILES: {{^}}test.cpp:14 main
+
+NO_DEMANGLE: Inputs/test.cpp:12 _Z3barSs
+NO_DEMANGLE: Inputs/test.cpp:14 main
diff --git a/llvm/test/tools/sancov/print.test b/llvm/test/tools/sancov/print.test
new file mode 100644
index 00000000000..abc4b3faa63
--- /dev/null
+++ b/llvm/test/tools/sancov/print.test
@@ -0,0 +1,10 @@
+RUN: sancov -obj %p/Inputs/test-linux_x86_64 -print %p/Inputs/test-linux_x86_64.sancov | FileCheck %s
+
+CHECK: 0x4db18b
+CHECK: 0x4db2d2
+CHECK: 0x4db322
+CHECK: 0x4db376
+CHECK: 0x4db3bd
+CHECK: 0x4db3f4
+CHECK: 0x4db427
+CHECK: 0x4db45a
OpenPOWER on IntegriCloud