[analyzer] Fix scan-build and exploded-graph-rewriter tests on Windows.

Detect script locations in a more straightforward way: we don't need to
search for them because we know exactly where they are anyway.

Fix a file path escaping issue in exploded-graph-rewriter with Windows
backslashes in the path.

'REQUIRES: shell' remains in scan-build tests for now, so that to
observe the buildbot reaction on removing it in a cleaner experiment.

Patch by Denys Petrov!

Differential Revision: https://reviews.llvm.org/D76768
This commit is contained in:
Artem Dergachev 2020-04-06 20:18:13 +03:00
parent b36c19bc4f
commit 2ddd3325c4
26 changed files with 19 additions and 84 deletions

View File

@ -97,9 +97,13 @@ inline void printSourceLocationAsJson(raw_ostream &Out, SourceLocation Loc,
// The macro expansion and spelling pos is identical for file locs. // The macro expansion and spelling pos is identical for file locs.
if (AddBraces) if (AddBraces)
Out << "{ "; Out << "{ ";
std::string filename(PLoc.getFilename());
#ifdef _WIN32 // Handle windows-specific path delimiters.
std::replace(filename.begin(), filename.end(), '\\', '/');
#endif
Out << "\"line\": " << PLoc.getLine() Out << "\"line\": " << PLoc.getLine()
<< ", \"column\": " << PLoc.getColumn() << ", \"column\": " << PLoc.getColumn()
<< ", \"file\": \"" << PLoc.getFilename() << "\""; << ", \"file\": \"" << filename << "\"";
if (AddBraces) if (AddBraces)
Out << " }"; Out << " }";
return; return;

View File

@ -1,8 +1,5 @@
// RUN: %exploded_graph_rewriter %s | FileCheck %s // RUN: %exploded_graph_rewriter %s | FileCheck %s
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
// CHECK: <b>Checker State: </b> // CHECK: <b>Checker State: </b>
// CHECK-SAME: <td align="left"><i>alpha.core.FooChecker</i>:</td> // CHECK-SAME: <td align="left"><i>alpha.core.FooChecker</i>:</td>
// CHECK-SAME: <td align="left">Foo stuff:</td> // CHECK-SAME: <td align="left">Foo stuff:</td>

View File

@ -1,8 +1,5 @@
// RUN: %exploded_graph_rewriter -d %s | FileCheck %s // RUN: %exploded_graph_rewriter -d %s | FileCheck %s
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
Node0x1 [shape=record,label= Node0x1 [shape=record,label=
"{ "{
{ "state_id": 2, { "state_id": 2,

View File

@ -1,8 +1,5 @@
// RUN: %exploded_graph_rewriter %s | FileCheck %s // RUN: %exploded_graph_rewriter %s | FileCheck %s
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
// CHECK: <tr><td align="left"><b>Ranges: </b></td></tr> // CHECK: <tr><td align="left"><b>Ranges: </b></td></tr>
// CHECK-SAME: <tr><td align="left"><table border="0"> // CHECK-SAME: <tr><td align="left"><table border="0">
// CHECK-SAME: <tr> // CHECK-SAME: <tr>

View File

@ -1,8 +1,5 @@
// RUN: %exploded_graph_rewriter -d %s | FileCheck %s // RUN: %exploded_graph_rewriter -d %s | FileCheck %s
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
Node0x1 [shape=record,label= Node0x1 [shape=record,label=
"{ "{
{ {

View File

@ -5,9 +5,6 @@
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s // RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
// REQUIRES: asserts // REQUIRES: asserts
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
struct S {}; struct S {};
void test() { void test() {

View File

@ -1,9 +1,6 @@
// RUN: %exploded_graph_rewriter %s | FileCheck %s -check-prefix=LIGHT // RUN: %exploded_graph_rewriter %s | FileCheck %s -check-prefix=LIGHT
// RUN: %exploded_graph_rewriter --dark %s | FileCheck %s -check-prefixes=DARK // RUN: %exploded_graph_rewriter --dark %s | FileCheck %s -check-prefixes=DARK
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
Node0x1 [shape=record,label= Node0x1 [shape=record,label=
"{{ "state_id": 0, "program_state": null, "program_points": [ "{{ "state_id": 0, "program_state": null, "program_points": [
{ {

View File

@ -2,9 +2,6 @@
// RUN: %exploded_graph_rewriter --dark %s | FileCheck %s \ // RUN: %exploded_graph_rewriter --dark %s | FileCheck %s \
// RUN: -check-prefixes=CHECK,DARK // RUN: -check-prefixes=CHECK,DARK
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
digraph "Exploded Graph" { digraph "Exploded Graph" {
label="Exploded Graph"; label="Exploded Graph";
} }

View File

@ -1,8 +1,5 @@
// RUN: %exploded_graph_rewriter %s | FileCheck %s // RUN: %exploded_graph_rewriter %s | FileCheck %s
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
// CHECK: <b>Expressions: </b> // CHECK: <b>Expressions: </b>
// CHECK-SAME: <table border="0"> // CHECK-SAME: <table border="0">
// CHECK-SAME: <tr> // CHECK-SAME: <tr>

View File

@ -1,8 +1,5 @@
// RUN: %exploded_graph_rewriter -d %s | FileCheck %s // RUN: %exploded_graph_rewriter -d %s | FileCheck %s
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
// No diffs on the first node, nothing to check. // No diffs on the first node, nothing to check.
Node0x1 [shape=record,label= Node0x1 [shape=record,label=
"{ "{

View File

@ -5,9 +5,6 @@
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s // RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
// REQUIRES: asserts // REQUIRES: asserts
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
void escapes() { void escapes() {
// CHECK: <td align="left"><b>Store: </b> <font color="gray">(0x{{[0-9a-f]*}})</font></td> // CHECK: <td align="left"><b>Store: </b> <font color="gray">(0x{{[0-9a-f]*}})</font></td>
// CHECK-SAME: <td align="left">foo</td><td align="left">0</td> // CHECK-SAME: <td align="left">foo</td><td align="left">0</td>

View File

@ -5,9 +5,6 @@
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s // RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
// REQUIRES: asserts // REQUIRES: asserts
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
struct A { struct A {
A() {} A() {}
}; };

View File

@ -9,10 +9,9 @@ config.test_format = lit.formats.ShTest(use_lit_shell == "0")
config.substitutions.append(('%exploded_graph_rewriter', config.substitutions.append(('%exploded_graph_rewriter',
'\'%s\' %s --dump-dot-only' % ( '\'%s\' %s --dump-dot-only' % (
config.python_executable, config.python_executable,
lit.util.which('exploded-graph-rewriter.py', os.path.join(
os.path.join( config.clang_src_dir,
config.clang_src_dir, 'utils', 'analyzer', 'exploded-graph-rewriter.py'))))
'utils', 'analyzer')))))
config.suffixes.add('.dot') config.suffixes.add('.dot')

View File

@ -1,3 +1,11 @@
#define NULL 0
void *foo() {
return NULL;
}
// The code above shall go first, because check tags below are sensetive to the line numbers on which the code is placed.
// You can change lines below in the way you need.
// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg. // FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
// RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \ // RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \
// RUN: -analyzer-checker=core \ // RUN: -analyzer-checker=core \
@ -5,14 +13,7 @@
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s // RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
// REQUIRES: asserts // REQUIRES: asserts
// FIXME: Substitution doesn't seem to work on Windows. // CHECK: macros.c:<b>3</b>:<b>10</b>
// UNSUPPORTED: system-windows
// CHECK: macros.c:<b>17</b>:<b>10</b>
// CHECK-SAME: <font color="royalblue1"> // CHECK-SAME: <font color="royalblue1">
// CHECK-SAME: (<i>spelling at </i> macros.c:<b>15</b>:<b>14</b>) // CHECK-SAME: (<i>spelling at </i> macros.c:<b>1</b>:<b>14</b>)
// CHECK-SAME: </font> // CHECK-SAME: </font>
#define NULL 0
void *foo() {
return NULL;
}

View File

@ -7,9 +7,6 @@
// RUN: %exploded_graph_rewriter %s --gray --dark \ // RUN: %exploded_graph_rewriter %s --gray --dark \
// RUN: | FileCheck %s -check-prefixes CHECK,DARK,GRAY // RUN: | FileCheck %s -check-prefixes CHECK,DARK,GRAY
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
// LIGHT: Node0x1 [shape=record,label=< // LIGHT: Node0x1 [shape=record,label=<
// DARK: Node0x1 [shape=record,color="white",fontcolor="gray80",label=< // DARK: Node0x1 [shape=record,color="white",fontcolor="gray80",label=<
// CHECK-SAME: <tr> // CHECK-SAME: <tr>

View File

@ -6,9 +6,6 @@
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s // RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
// REQUIRES: asserts // REQUIRES: asserts
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
struct S { struct S {
S() {} S() {}
}; };

View File

@ -1,8 +1,5 @@
// RUN: %exploded_graph_rewriter %s | FileCheck %s // RUN: %exploded_graph_rewriter %s | FileCheck %s
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
// CHECK: <b>Program points:</b> // CHECK: <b>Program points:</b>
// CHECK-SAME: <table border="0" align="left" width="0"> // CHECK-SAME: <table border="0" align="left" width="0">
// CHECK-SAME: <tr> // CHECK-SAME: <tr>

View File

@ -1,8 +1,5 @@
// RUN: %exploded_graph_rewriter %s | FileCheck %s // RUN: %exploded_graph_rewriter %s | FileCheck %s
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
// CHECK: <b>Store: </b> // CHECK: <b>Store: </b>
// CHECK-SAME: <font color="gray">(0x2)</font> // CHECK-SAME: <font color="gray">(0x2)</font>
// CHECK-SAME: <table border="0"> // CHECK-SAME: <table border="0">

View File

@ -1,8 +1,5 @@
// RUN: %exploded_graph_rewriter -d %s | FileCheck %s // RUN: %exploded_graph_rewriter -d %s | FileCheck %s
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
Node0x1 [shape=record,label= Node0x1 [shape=record,label=
"{ "{
{ "node_id": 1, { "node_id": 1,

View File

@ -3,9 +3,6 @@
// RUN: %exploded_graph_rewriter -t %s \ // RUN: %exploded_graph_rewriter -t %s \
// RUN: | FileCheck -check-prefixes=TOPOLOGY %s // RUN: | FileCheck -check-prefixes=TOPOLOGY %s
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
// NORMAL: Program point // NORMAL: Program point
// TOPOLOGY-NOT: Program point // TOPOLOGY-NOT: Program point
// NORMAL: Checker State // NORMAL: Checker State

View File

@ -13,9 +13,6 @@
// RUN: %exploded_graph_rewriter --to 4 -s %s \ // RUN: %exploded_graph_rewriter --to 4 -s %s \
// RUN: | FileCheck %s -check-prefixes=ONE,TWO,NOTHREE,FOUR // RUN: | FileCheck %s -check-prefixes=ONE,TWO,NOTHREE,FOUR
// FIXME: Substitution doesn't seem to work on Windows.
// UNSUPPORTED: system-windows
Node0x1 [shape=record,label= Node0x1 [shape=record,label=
"{{ "state_id": 0, "program_state": null, "program_points": [ "{{ "state_id": 0, "program_state": null, "program_points": [
{ {

View File

@ -1,9 +1,6 @@
// FIXME: Actually, "perl". // FIXME: Actually, "perl".
REQUIRES: shell REQUIRES: shell
// FIXME: Should ideally work on Windows.
UNSUPPORTED: system-windows
RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: %scan-build -o %t.output_dir %clang -S \ RUN: %scan-build -o %t.output_dir %clang -S \
RUN: %S/Inputs/multidirectory_project/directory1/file1.c \ RUN: %S/Inputs/multidirectory_project/directory1/file1.c \

View File

@ -1,9 +1,6 @@
// FIXME: Actually, "perl". // FIXME: Actually, "perl".
REQUIRES: shell REQUIRES: shell
// FIXME: Should ideally work on Windows.
UNSUPPORTED: system-windows
RUN: %scan-build -h | FileCheck %s RUN: %scan-build -h | FileCheck %s
RUN: %scan-build --help | FileCheck %s RUN: %scan-build --help | FileCheck %s

View File

@ -1,9 +1,6 @@
// FIXME: Actually, "perl". // FIXME: Actually, "perl".
REQUIRES: shell REQUIRES: shell
// FIXME: Should ideally work on Windows.
UNSUPPORTED: system-windows
RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: %scan-build -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \ RUN: %scan-build -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \
RUN: | FileCheck %s -check-prefix CHECK-STDOUT RUN: | FileCheck %s -check-prefix CHECK-STDOUT

View File

@ -1,9 +1,6 @@
// FIXME: Actually, "perl". // FIXME: Actually, "perl".
REQUIRES: shell REQUIRES: shell
// FIXME: Should ideally work on Windows.
UNSUPPORTED: system-windows
RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: %scan-build -plist-html -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \ RUN: %scan-build -plist-html -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \
RUN: | FileCheck %s -check-prefix CHECK-STDOUT RUN: | FileCheck %s -check-prefix CHECK-STDOUT

View File

@ -1,9 +1,6 @@
// FIXME: Actually, "perl". // FIXME: Actually, "perl".
REQUIRES: shell REQUIRES: shell
// FIXME: Should ideally work on Windows.
UNSUPPORTED: system-windows
RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: %scan-build -plist -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \ RUN: %scan-build -plist -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \
RUN: | FileCheck %s -check-prefix CHECK-STDOUT RUN: | FileCheck %s -check-prefix CHECK-STDOUT