[llvm] r252933 - sancov test suite
Mike Aizatsky via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 12 11:34:21 PST 2015
Author: aizatsky
Date: Thu Nov 12 13:34:21 2015
New Revision: 252933
URL: http://llvm.org/viewvc/llvm-project?rev=252933&view=rev
Log:
sancov test suite
Differential Revision: http://reviews.llvm.org/D14589
Added:
llvm/trunk/test/tools/sancov/
llvm/trunk/test/tools/sancov/Inputs/
llvm/trunk/test/tools/sancov/Inputs/foo.cpp
llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64 (with props)
llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64-1.sancov
llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.sancov
llvm/trunk/test/tools/sancov/Inputs/test.cpp
llvm/trunk/test/tools/sancov/covered_functions.test
llvm/trunk/test/tools/sancov/print.test
Modified:
llvm/trunk/test/CMakeLists.txt
llvm/trunk/tools/sancov/sancov.cc
Modified: llvm/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CMakeLists.txt?rev=252933&r1=252932&r2=252933&view=diff
==============================================================================
--- llvm/trunk/test/CMakeLists.txt (original)
+++ llvm/trunk/test/CMakeLists.txt Thu Nov 12 13:34:21 2015
@@ -19,11 +19,12 @@ endif()
# Set the depends list as a variable so that it can grow conditionally.
# NOTE: Sync the substitutions in test/lit.cfg when adding to this list.
set(LLVM_TEST_DEPENDS
- llvm-config
- UnitTests
BugpointPasses
+ FileCheck
LLVMHello
+ UnitTests
bugpoint
+ count
llc
lli
lli-child-target
@@ -31,6 +32,7 @@ set(LLVM_TEST_DEPENDS
llvm-as
llvm-bcanalyzer
llvm-c-test
+ llvm-config
llvm-cov
llvm-cxxdump
llvm-diff
@@ -54,14 +56,13 @@ set(LLVM_TEST_DEPENDS
llvm-split
llvm-symbolizer
llvm-tblgen
- opt
- FileCheck
- count
not
- yaml-bench
- yaml2obj
obj2yaml
+ opt
+ sancov
verify-uselistorder
+ yaml-bench
+ yaml2obj
)
# If Intel JIT events are supported, depend on a tool that tests the listener.
Added: llvm/trunk/test/tools/sancov/Inputs/foo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/Inputs/foo.cpp?rev=252933&view=auto
==============================================================================
--- llvm/trunk/test/tools/sancov/Inputs/foo.cpp (added)
+++ llvm/trunk/test/tools/sancov/Inputs/foo.cpp Thu Nov 12 13:34:21 2015
@@ -0,0 +1,5 @@
+#include <stdio.h>
+#include <string>
+
+__attribute__((noinline))
+void foo() { printf("foo\n"); }
Added: llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64?rev=252933&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64 (added) and llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64 Thu Nov 12 13:34:21 2015 differ
Propchange: llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64
------------------------------------------------------------------------------
svn:executable = *
Added: llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64-1.sancov
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64-1.sancov?rev=252933&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64-1.sancov (added) and llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64-1.sancov Thu Nov 12 13:34:21 2015 differ
Added: llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.sancov
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.sancov?rev=252933&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.sancov (added) and llvm/trunk/test/tools/sancov/Inputs/test-linux_x86_64.sancov Thu Nov 12 13:34:21 2015 differ
Added: llvm/trunk/test/tools/sancov/Inputs/test.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/Inputs/test.cpp?rev=252933&view=auto
==============================================================================
--- llvm/trunk/test/tools/sancov/Inputs/test.cpp (added)
+++ llvm/trunk/test/tools/sancov/Inputs/test.cpp Thu Nov 12 13:34:21 2015
@@ -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");
+}
Added: llvm/trunk/test/tools/sancov/covered_functions.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/covered_functions.test?rev=252933&view=auto
==============================================================================
--- llvm/trunk/test/tools/sancov/covered_functions.test (added)
+++ llvm/trunk/test/tools/sancov/covered_functions.test Thu Nov 12 13:34:21 2015
@@ -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
Added: llvm/trunk/test/tools/sancov/print.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/sancov/print.test?rev=252933&view=auto
==============================================================================
--- llvm/trunk/test/tools/sancov/print.test (added)
+++ llvm/trunk/test/tools/sancov/print.test Thu Nov 12 13:34:21 2015
@@ -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
Modified: llvm/trunk/tools/sancov/sancov.cc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/sancov/sancov.cc?rev=252933&r1=252932&r2=252933&view=diff
==============================================================================
--- llvm/trunk/tools/sancov/sancov.cc (original)
+++ llvm/trunk/tools/sancov/sancov.cc Thu Nov 12 13:34:21 2015
@@ -178,7 +178,7 @@ class CoverageData {
return;
symbolize::LLVMSymbolizer::Options SymbolizerOptions;
SymbolizerOptions.Demangle = ClDemangle;
- symbolize::LLVMSymbolizer Symbolizer;
+ symbolize::LLVMSymbolizer Symbolizer(SymbolizerOptions);
struct FileLoc {
std::string FileName;
@@ -226,8 +226,11 @@ class CoverageData {
if (!ProcessedFunctions.insert(FunctionName).second)
continue;
- out << FileName.substr(FilePrefix.size()) << ":" << Line << " "
- << FunctionName << "\n";
+ // Don't strip prefix if we only have a single file.
+ if (FileName.size() > FilePrefix.size())
+ FileName = FileName.substr(FilePrefix.size());
+
+ out << FileName << ":" << Line << " " << FunctionName << "\n";
}
}
}
More information about the llvm-commits
mailing list