[llvm] 6a74ad6 - [sancov] Accommodate sancov and coverage report server for use under Windows

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue May 26 14:36:55 PDT 2020


Author: Vitaly Buka
Date: 2020-05-26T14:36:44-07:00
New Revision: 6a74ad6baad45b8572d196f7f290593ed62075b5

URL: https://github.com/llvm/llvm-project/commit/6a74ad6baad45b8572d196f7f290593ed62075b5
DIFF: https://github.com/llvm/llvm-project/commit/6a74ad6baad45b8572d196f7f290593ed62075b5.diff

LOG: [sancov] Accommodate sancov and coverage report server for use under Windows

Summary:
This patch makes the following changes to SanCov and its complementary Python script in order to resolve issues pertaining to non-UNIX file paths in JSON symbolization information:
* Convert all paths to use forward slash.
* Update `coverage-report-server.py` to correctly handle paths to sources which contain spaces.
* Remove Linux platform restriction for all SanCov unit tests. All SanCov tests passed when ran on my local Windows machine.

Patch by Douglas Gliner.

Reviewers: kcc, filcab, phosek, morehouse, vitalybuka, metzman

Reviewed By: vitalybuka

Subscribers: vsk, Dor1s, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D51018

Added: 
    

Modified: 
    llvm/test/tools/sancov/blacklist.test
    llvm/test/tools/sancov/covered_functions.test
    llvm/test/tools/sancov/merge.test
    llvm/test/tools/sancov/not_covered_functions.test
    llvm/test/tools/sancov/print.test
    llvm/test/tools/sancov/stats.test
    llvm/test/tools/sancov/symbolize.test
    llvm/test/tools/sancov/symbolize_noskip_dead_files.test
    llvm/test/tools/sancov/validation.test
    llvm/tools/sancov/coverage-report-server.py
    llvm/tools/sancov/sancov.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/sancov/blacklist.test b/llvm/test/tools/sancov/blacklist.test
index 53f48534dc95..a9cf47f53cdb 100644
--- a/llvm/test/tools/sancov/blacklist.test
+++ b/llvm/test/tools/sancov/blacklist.test
@@ -1,4 +1,4 @@
-REQUIRES: x86_64-linux
+REQUIRES: x86-registered-target && host-byteorder-little-endian
 RUN: sancov -covered-functions %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s --check-prefix=ALL
 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

diff  --git a/llvm/test/tools/sancov/covered_functions.test b/llvm/test/tools/sancov/covered_functions.test
index 8126049a0ca1..bcdfaf8879d4 100644
--- a/llvm/test/tools/sancov/covered_functions.test
+++ b/llvm/test/tools/sancov/covered_functions.test
@@ -1,4 +1,4 @@
-REQUIRES: x86_64-linux
+REQUIRES: x86-registered-target && host-byteorder-little-endian
 RUN: sancov -covered-functions %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 RUN: sancov -covered-functions -strip_path_prefix=Inputs/ %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck --check-prefix=STRIP_PATH %s
 RUN: sancov -demangle=0 -covered-functions %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck --check-prefix=NO_DEMANGLE %s

diff  --git a/llvm/test/tools/sancov/merge.test b/llvm/test/tools/sancov/merge.test
index 9c5ca9e6244c..6c867654583c 100644
--- a/llvm/test/tools/sancov/merge.test
+++ b/llvm/test/tools/sancov/merge.test
@@ -1,4 +1,4 @@
-REQUIRES: x86_64-linux
+REQUIRES: x86-registered-target
 RUN: sancov -merge %p/Inputs/test-linux_x86_64.0.symcov| FileCheck --check-prefix=MERGE1 %s
 RUN: sancov -merge %p/Inputs/test-linux_x86_64.0.symcov %p/Inputs/test-linux_x86_64.1.symcov| FileCheck --check-prefix=MERGE2 %s
 

diff  --git a/llvm/test/tools/sancov/not_covered_functions.test b/llvm/test/tools/sancov/not_covered_functions.test
index 4e0e81a52c2c..d1b91f6e5682 100644
--- a/llvm/test/tools/sancov/not_covered_functions.test
+++ b/llvm/test/tools/sancov/not_covered_functions.test
@@ -1,4 +1,4 @@
-REQUIRES: x86_64-linux
+REQUIRES: x86-registered-target && host-byteorder-little-endian
 RUN: sancov -skip-dead-files=0 -not-covered-functions %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 RUN: sancov -not-covered-functions %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.1.sancov | FileCheck --check-prefix=CHECK1 --allow-empty %s
 

diff  --git a/llvm/test/tools/sancov/print.test b/llvm/test/tools/sancov/print.test
index fe94216b051a..62ab3d991b8e 100644
--- a/llvm/test/tools/sancov/print.test
+++ b/llvm/test/tools/sancov/print.test
@@ -1,4 +1,4 @@
-REQUIRES: x86_64-linux
+REQUIRES: x86-registered-target && host-byteorder-little-endian
 RUN: sancov -print %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 
 CHECK: 0x4e132b

diff  --git a/llvm/test/tools/sancov/stats.test b/llvm/test/tools/sancov/stats.test
index 030d16a9dc61..46ff6e5e5db1 100644
--- a/llvm/test/tools/sancov/stats.test
+++ b/llvm/test/tools/sancov/stats.test
@@ -1,4 +1,4 @@
-REQUIRES: x86_64-linux
+REQUIRES: x86-registered-target && host-byteorder-little-endian
 RUN: sancov -print-coverage-stats %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 
 CHECK: all-edges: 8

diff  --git a/llvm/test/tools/sancov/symbolize.test b/llvm/test/tools/sancov/symbolize.test
index 3cc426f919b9..acf58ae11712 100644
--- a/llvm/test/tools/sancov/symbolize.test
+++ b/llvm/test/tools/sancov/symbolize.test
@@ -1,5 +1,6 @@
-REQUIRES: x86_64-linux
-RUN: sancov -symbolize -strip_path_prefix="llvm/" %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
+REQUIRES: x86-registered-target && host-byteorder-little-endian
+RUN: sancov -symbolize -strip_path_prefix="llvm/" %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s --check-prefixes=CHECK,STRIP
+RUN: sancov -symbolize %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s --check-prefixes=CHECK,NOSTRIP
 
 CHECK: {
 CHECK-NEXT:  "covered-points": [
@@ -11,7 +12,8 @@ CHECK-NEXT:    "4e1586"
 CHECK-NEXT:  ],
 CHECK-NEXT:  "binary-hash": "BB3CDD5045AED83906F6ADCC1C4DAF7E2596A6B5",
 CHECK-NEXT:  "point-symbol-info": {
-CHECK-NEXT:    "test/tools/sancov/Inputs/test.cpp": {
+STRIP-NEXT:    "test/tools/sancov/Inputs/test.cpp": {
+NOSTRIP-NEXT:  "/usr/local/google/home/aizatsky/src/llvm/test/tools/sancov/Inputs/test.cpp": {
 CHECK-NEXT:      "bar(std::string)": {
 CHECK-NEXT:        "4e132b": "12:0"
 CHECK-NEXT:      },

diff  --git a/llvm/test/tools/sancov/symbolize_noskip_dead_files.test b/llvm/test/tools/sancov/symbolize_noskip_dead_files.test
index 9ddf89cbf56d..0038ea197735 100644
--- a/llvm/test/tools/sancov/symbolize_noskip_dead_files.test
+++ b/llvm/test/tools/sancov/symbolize_noskip_dead_files.test
@@ -1,4 +1,4 @@
-REQUIRES: x86_64-linux
+REQUIRES: x86-registered-target && host-byteorder-little-endian
 RUN: sancov -symbolize -skip-dead-files=0 -strip_path_prefix="llvm/" %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
 
 CHECK: {

diff  --git a/llvm/test/tools/sancov/validation.test b/llvm/test/tools/sancov/validation.test
index 437870cf597b..fdcfd0610f82 100644
--- a/llvm/test/tools/sancov/validation.test
+++ b/llvm/test/tools/sancov/validation.test
@@ -1,4 +1,4 @@
-REQUIRES: x86_64-linux
+REQUIRES: x86-registered-target
 RUN: not sancov -covered-functions %p/Inputs/test-linux_x86_64 2>&1 | FileCheck --check-prefix=NOCFILE %s
 
 NOCFILE: WARNING: No coverage file for {{.*}}test-linux_x86_64

diff  --git a/llvm/tools/sancov/coverage-report-server.py b/llvm/tools/sancov/coverage-report-server.py
index 251d8f1b77ba..5ea978fae642 100755
--- a/llvm/tools/sancov/coverage-report-server.py
+++ b/llvm/tools/sancov/coverage-report-server.py
@@ -32,6 +32,7 @@
 import os
 import string
 import math
+import urllib
 
 INDEX_PAGE_TMPL = """
 <html>
@@ -128,6 +129,7 @@ class ServerHandler(http.server.BaseHTTPRequestHandler):
     src_path = None
 
     def do_GET(self):
+        norm_path = os.path.normpath(urllib.parse.unquote(self.path[1:]))
         if self.path == '/':
             self.send_response(200)
             self.send_header("Content-type", "text/html; charset=utf-8")
@@ -147,8 +149,8 @@ def do_GET(self):
             response = string.Template(INDEX_PAGE_TMPL).safe_substitute(
                 filenames='\n'.join(filelist))
             self.wfile.write(response.encode('UTF-8', 'replace'))
-        elif self.symcov_data.has_file(self.path[1:]):
-            filename = self.path[1:]
+        elif self.symcov_data.has_file(norm_path):
+            filename = norm_path
             filepath = os.path.join(self.src_path, filename) 
             if not os.path.exists(filepath):
                 self.send_response(404)

diff  --git a/llvm/tools/sancov/sancov.cpp b/llvm/tools/sancov/sancov.cpp
index ed384a271007..6f949f296365 100644
--- a/llvm/tools/sancov/sancov.cpp
+++ b/llvm/tools/sancov/sancov.cpp
@@ -471,7 +471,7 @@ static std::unique_ptr<symbolize::LLVMSymbolizer> createSymbolizer() {
 static std::string normalizeFilename(const std::string &FileName) {
   SmallString<256> S(FileName);
   sys::path::remove_dots(S, /* remove_dot_dot */ true);
-  return stripPathPrefix(std::string(S));
+  return stripPathPrefix(sys::path::convert_to_slash(std::string(S)));
 }
 
 class Blacklists {


        


More information about the llvm-commits mailing list