[sancov] using normalized filenames for blacklist checks.
authorMike Aizatsky <aizatsky@chromium.org>
Thu, 21 Apr 2016 23:38:45 +0000 (23:38 +0000)
committerMike Aizatsky <aizatsky@chromium.org>
Thu, 21 Apr 2016 23:38:45 +0000 (23:38 +0000)
Differential Revision: http://reviews.llvm.org/D19395

llvm-svn: 267078

llvm/test/tools/sancov/Inputs/fun_blacklist.txt [moved from llvm/test/tools/sancov/Inputs/blacklist.txt with 100% similarity]
llvm/test/tools/sancov/Inputs/src_blacklist.txt [new file with mode: 0644]
llvm/test/tools/sancov/Inputs/test-linux_x86_64
llvm/test/tools/sancov/Inputs/test-linux_x86_64.0.sancov
llvm/test/tools/sancov/Inputs/test-linux_x86_64.1.sancov
llvm/test/tools/sancov/Inputs/test.cpp
llvm/test/tools/sancov/blacklist.test
llvm/test/tools/sancov/print.test
llvm/test/tools/sancov/print_coverage_pcs.test
llvm/test/tools/sancov/stats.test
llvm/tools/sancov/sancov.cc

diff --git a/llvm/test/tools/sancov/Inputs/src_blacklist.txt b/llvm/test/tools/sancov/Inputs/src_blacklist.txt
new file mode 100644 (file)
index 0000000..8f5cbc8
--- /dev/null
@@ -0,0 +1,3 @@
+# this path looks like sancov/Inputs/../Inputs/ in the binary. 
+# Make sure it is filtered out correctly.
+src:*/sancov/Inputs/foo.cpp
index 2d141b6..9ffac6f 100755 (executable)
Binary files a/llvm/test/tools/sancov/Inputs/test-linux_x86_64 and b/llvm/test/tools/sancov/Inputs/test-linux_x86_64 differ
index e5ed81e..4603e96 100644 (file)
Binary files a/llvm/test/tools/sancov/Inputs/test-linux_x86_64.0.sancov and b/llvm/test/tools/sancov/Inputs/test-linux_x86_64.0.sancov differ
index a1c7f7b..2de5f51 100644 (file)
Binary files a/llvm/test/tools/sancov/Inputs/test-linux_x86_64.1.sancov and b/llvm/test/tools/sancov/Inputs/test-linux_x86_64.1.sancov differ
index 5690409..a14b4cb 100644 (file)
@@ -1,7 +1,7 @@
 // compile & generate coverage data using:
-// clang++ -g -o test-linux_x86_64 -fsanitize=address -fsanitize-coverage=bb test.cpp foo.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
+// clang++ -g -o test-linux_x86_64 -fsanitize=address -fsanitize-coverage=bb test.cpp ../Inputs/foo.cpp
+// ASAN_OPTIONS="coverage=1" ./test-linux_x86_64 && mv test-linux_x86_64.??*.sancov test-linux_x86_64.0.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>
index 2deb383..6af1799 100644 (file)
@@ -1,5 +1,10 @@
 REQUIRES: x86_64-linux
-RUN: sancov -covered-functions -blacklist %p/Inputs/blacklist.txt %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
+RUN: sancov -covered-functions -blacklist %p/Inputs/fun_blacklist.txt %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
+RUN: sancov -covered-functions -blacklist %p/Inputs/src_blacklist.txt %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.1.sancov | FileCheck --check-prefix=CHECK1 %s
 
 CHECK-NOT: Inputs{{[/\\]}}test.cpp:12 bar(std::string)
 CHECK: Inputs{{[/\\]}}test.cpp:14 main
+
+CHECK1-NOT: foo
+CHECK1: Inputs{{[/\\]}}test.cpp:12 bar(std::string)
+CHECK1: Inputs{{[/\\]}}test.cpp:14 main
index f43733f..fe94216 100644 (file)
@@ -1,11 +1,9 @@
 REQUIRES: x86_64-linux
 RUN: sancov -print %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 
-CHECK: 0x4dbe2b
-CHECK: 0x4dbf72
-CHECK: 0x4dbfec
-CHECK: 0x4dc033
-CHECK: 0x4dc06a
-CHECK: 0x4dc09d
-CHECK: 0x4dc0d0
+CHECK: 0x4e132b
+CHECK: 0x4e1472
+CHECK: 0x4e1520
+CHECK: 0x4e1553
+CHECK: 0x4e1586
 
index 572bce8..2756eb0 100644 (file)
@@ -1,20 +1,13 @@
 REQUIRES: x86_64-linux
 RUN: sancov -print-coverage-pcs %p/Inputs/test-linux_x86_64 | FileCheck %s
 
-CHECK: 0x4cced1
-CHECK: 0x4ccf01
-CHECK: 0x4dbe2b
-CHECK: 0x4dbf72
-CHECK: 0x4dbfc2
-CHECK: 0x4dbfec
-CHECK: 0x4dc033
-CHECK: 0x4dc06a
-CHECK: 0x4dc09d
-CHECK: 0x4dc0d0
-CHECK: 0x4dc17f
-CHECK: 0x4dc1c6
-CHECK: 0x4dc20d
-CHECK: 0x4dc237
-CHECK: 0x4dc265
-CHECK: 0x4dc34c
+CHECK: 0x4e132b
+CHECK: 0x4e1472
+CHECK: 0x4e14c2
+CHECK: 0x4e1520
+CHECK: 0x4e1553
+CHECK: 0x4e1586
+CHECK: 0x4e1635
+CHECK: 0x4e1690
+CHECK: 0x4e178c
 
index 2e1324d..05e712b 100644 (file)
@@ -1,8 +1,8 @@
 REQUIRES: x86_64-linux
 RUN: sancov -print-coverage-stats %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 
-CHECK: all-edges: 16
-CHECK: cov-edges: 7
+CHECK: all-edges: 9
+CHECK: cov-edges: 5
 CHECK: all-functions: 3
 CHECK: cov-functions: 2
 
index 6ab5f14..294b687 100644 (file)
@@ -241,14 +241,16 @@ public:
       : DefaultBlacklist(createDefaultBlacklist()),
         UserBlacklist(createUserBlacklist()) {}
 
-  bool isBlacklisted(const DILineInfo &DI) {
-    if (DefaultBlacklist && DefaultBlacklist->inSection("fun", DI.FunctionName))
+  // AddrInfo contains normalized filename. It is important to check it rather
+  // than DILineInfo.
+  bool isBlacklisted(const AddrInfo &AI) {
+    if (DefaultBlacklist && DefaultBlacklist->inSection("fun", AI.FunctionName))
       return true;
-    if (DefaultBlacklist && DefaultBlacklist->inSection("src", DI.FileName))
+    if (DefaultBlacklist && DefaultBlacklist->inSection("src", AI.FileName))
       return true;
-    if (UserBlacklist && UserBlacklist->inSection("fun", DI.FunctionName))
+    if (UserBlacklist && UserBlacklist->inSection("fun", AI.FunctionName))
       return true;
-    if (UserBlacklist && UserBlacklist->inSection("src", DI.FileName))
+    if (UserBlacklist && UserBlacklist->inSection("src", AI.FileName))
       return true;
     return false;
   }
@@ -286,17 +288,19 @@ static std::vector<AddrInfo> getAddrInfo(std::string ObjectFile,
   for (auto Addr : Addrs) {
     auto LineInfo = Symbolizer->symbolizeCode(ObjectFile, Addr);
     FailIfError(LineInfo);
-    if (B.isBlacklisted(*LineInfo))
+    auto LineAddrInfo = AddrInfo(*LineInfo, Addr);
+    if (B.isBlacklisted(LineAddrInfo))
       continue;
-    Result.push_back(AddrInfo(*LineInfo, Addr));
+    Result.push_back(LineAddrInfo);
     if (InlinedCode) {
       auto InliningInfo = Symbolizer->symbolizeInlinedCode(ObjectFile, Addr);
       FailIfError(InliningInfo);
       for (uint32_t I = 0; I < InliningInfo->getNumberOfFrames(); ++I) {
         auto FrameInfo = InliningInfo->getFrame(I);
-        if (B.isBlacklisted(FrameInfo))
+        auto FrameAddrInfo = AddrInfo(FrameInfo, Addr);
+        if (B.isBlacklisted(FrameAddrInfo))
           continue;
-        Result.push_back(AddrInfo(FrameInfo, Addr));
+        Result.push_back(FrameAddrInfo);
       }
     }
   }