From 354edda8b52242a6835951218fa34d84e6d9c0f3 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 25 May 2017 11:15:09 -0400
Subject: [PATCH 08/28] FIXME: move the selftest .json files to correct place

---
 gcc/firehose.c                                     |   7 +-
 .../checker-output/test-clang-analyzer.json        | 122 +++++++++++++++++++++
 .../selftests/checker-output/test-cppcheck.json    |  50 +++++++++
 test-clang-analyzer.json                           | 122 ---------------------
 test-cppcheck.json                                 |  50 ---------
 5 files changed, 176 insertions(+), 175 deletions(-)
 create mode 100644 gcc/testsuite/selftests/checker-output/test-clang-analyzer.json
 create mode 100644 gcc/testsuite/selftests/checker-output/test-cppcheck.json
 delete mode 100644 test-clang-analyzer.json
 delete mode 100644 test-cppcheck.json

diff --git a/gcc/firehose.c b/gcc/firehose.c
index 6ffe42c..8a06b7e 100644
--- a/gcc/firehose.c
+++ b/gcc/firehose.c
@@ -422,10 +422,10 @@ namespace selftest {
 static void
 test_parsing_clang_analyzer ()
 {
-  const char *filename = "../../src/test-clang-analyzer.json";
-  // FIXME: filename ^^^
+  char *filename = locate_file ("checker-output/test-clang-analyzer.json");
   char *buffer = selftest::read_file (SELFTEST_LOCATION, filename);
   ASSERT_TRUE (buffer != NULL);
+  free (filename);
 
   char *err = NULL;
   json::value *jv = json::parse_utf8_string (buffer, &err);
@@ -476,9 +476,10 @@ test_parsing_clang_analyzer ()
 static void
 test_parsing_cppcheck ()
 {
-  const char *filename = "../../src/test-cppcheck.json"; // FIXME
+  char *filename = locate_file ("checker-output/test-cppcheck.json");
   char *buffer = selftest::read_file (SELFTEST_LOCATION, filename);
   ASSERT_TRUE (buffer != NULL);
+  free (filename);
 
   char *err = NULL;
   json::value *jv = json::parse_utf8_string (buffer, &err);
diff --git a/gcc/testsuite/selftests/checker-output/test-clang-analyzer.json b/gcc/testsuite/selftests/checker-output/test-clang-analyzer.json
new file mode 100644
index 0000000..eda9abc
--- /dev/null
+++ b/gcc/testsuite/selftests/checker-output/test-clang-analyzer.json
@@ -0,0 +1,122 @@
+{
+ "customfields": {
+  "scan-build-invocation": "scan-build -v -plist --use-analyzer /usr/bin/clang -o /tmp/tmp8ytuRj gcc -B. -c ../../src/bogus.c", 
+  "returncode": 0, 
+  "stdout": "scan-build: Using '/usr/bin/clang' for static analysis\nscan-build: Emitting reports for this run to '/tmp/tmp8ytuRj/2017-05-24-001755-39710-1'.\nscan-build: Analysis run complete.\nscan-build: Analysis results (plist files) deposited in '/tmp/tmp8ytuRj/2017-05-24-001755-39710-1'\n", 
+  "stderr": "../../src/bogus.c: In function \u2018test\u2019:\n../../src/bogus.c:5:10: warning: function returns address of local variable [-Wreturn-local-addr]\n   return tmp;\n          ^~~\n../../src/bogus.c:5:3: warning: Address of stack memory associated with local variable 'tmp' returned to caller\n  return tmp;\n  ^~~~~~~~~~\n1 warning generated.\n", 
+  "plistpath": "/tmp/tmp8ytuRj/2017-05-24-001755-39710-1/report-DEoPmt.plist"
+ }, 
+ "results": [
+  {
+   "severity": null, 
+   "trace": {
+    "states": [
+     {
+      "notes": null, 
+      "location": {
+       "function": {
+        "name": ""
+       }, 
+       "range_": {
+        "start": {
+         "column": 3, 
+         "line": 3
+        }, 
+        "end": {
+         "column": 6, 
+         "line": 3
+        }
+       }, 
+       "file": {
+        "abspath": null, 
+        "givenpath": "../../src/bogus.c", 
+        "hash_": null
+       }, 
+       "point": null
+      }
+     }, 
+     {
+      "notes": null, 
+      "location": {
+       "function": {
+        "name": ""
+       }, 
+       "range_": {
+        "start": {
+         "column": 3, 
+         "line": 5
+        }, 
+        "end": {
+         "column": 8, 
+         "line": 5
+        }
+       }, 
+       "file": {
+        "abspath": null, 
+        "givenpath": "../../src/bogus.c", 
+        "hash_": null
+       }, 
+       "point": null
+      }
+     }, 
+     {
+      "notes": {
+       "text": "Address of stack memory associated with local variable 'tmp' returned to caller"
+      }, 
+      "location": {
+       "function": {
+        "name": ""
+       }, 
+       "range_": null, 
+       "file": {
+        "abspath": null, 
+        "givenpath": "../../src/bogus.c", 
+        "hash_": null
+       }, 
+       "point": {
+        "column": 3, 
+        "line": 5
+       }
+      }
+     }
+    ]
+   }, 
+   "type": "Issue", 
+   "notes": null, 
+   "testid": null, 
+   "message": {
+    "text": "Address of stack memory associated with local variable 'tmp' returned to caller"
+   }, 
+   "cwe": null, 
+   "customfields": null, 
+   "location": {
+    "function": null, 
+    "range_": null, 
+    "file": {
+     "abspath": null, 
+     "givenpath": "../../src/bogus.c", 
+     "hash_": null
+    }, 
+    "point": {
+     "column": 3, 
+     "line": 5
+    }
+   }
+  }
+ ], 
+ "metadata": {
+  "stats": {
+   "wallclocktime": 0.22788214683532715
+  }, 
+  "sut": null, 
+  "file_": {
+   "abspath": "/home/david/coding-3/gcc-git-static-analysis/build/gcc/../../src/bogus.c", 
+   "givenpath": "../../src/bogus.c", 
+   "hash_": null
+  }, 
+  "generator": {
+   "version": null, 
+   "name": "clang-analyzer"
+  }
+ }
+}
\ No newline at end of file
diff --git a/gcc/testsuite/selftests/checker-output/test-cppcheck.json b/gcc/testsuite/selftests/checker-output/test-cppcheck.json
new file mode 100644
index 0000000..c9651ee
--- /dev/null
+++ b/gcc/testsuite/selftests/checker-output/test-cppcheck.json
@@ -0,0 +1,50 @@
+{
+ "customfields": {
+  "cppcheck-invocation": "cppcheck --xml --xml-version=2 ../../src/test-sources/conditional-leak.c", 
+  "returncode": 0, 
+  "stdout": "Checking ../../src/test-sources/conditional-leak.c...\n", 
+  "stderr": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<results version=\"2\">\n    <cppcheck version=\"1.63\"/>\n    <errors>\n        <error id=\"memleak\" severity=\"error\" msg=\"Memory leak: ptr_1\" verbose=\"Memory leak: ptr_1\">\n            <location file=\"../../src/test-sources/conditional-leak.c\" line=\"11\"/>\n        </error>\n    </errors>\n</results>\n"
+ }, 
+ "results": [
+  {
+   "severity": "error", 
+   "trace": null, 
+   "type": "Issue", 
+   "notes": null, 
+   "testid": "memleak", 
+   "message": {
+    "text": "Memory leak: ptr_1"
+   }, 
+   "cwe": null, 
+   "customfields": null, 
+   "location": {
+    "function": null, 
+    "range_": null, 
+    "file": {
+     "abspath": null, 
+     "givenpath": "../../src/test-sources/conditional-leak.c", 
+     "hash_": null
+    }, 
+    "point": {
+     "column": 0, 
+     "line": 11
+    }
+   }
+  }
+ ], 
+ "metadata": {
+  "stats": {
+   "wallclocktime": 0.006749868392944336
+  }, 
+  "sut": null, 
+  "file_": {
+   "abspath": "/home/david/coding-3/gcc-git-static-analysis/build/gcc/../../src/test-sources/conditional-leak.c", 
+   "givenpath": "../../src/test-sources/conditional-leak.c", 
+   "hash_": null
+  }, 
+  "generator": {
+   "version": "1.63", 
+   "name": "cppcheck"
+  }
+ }
+}
\ No newline at end of file
diff --git a/test-clang-analyzer.json b/test-clang-analyzer.json
deleted file mode 100644
index eda9abc..0000000
--- a/test-clang-analyzer.json
+++ /dev/null
@@ -1,122 +0,0 @@
-{
- "customfields": {
-  "scan-build-invocation": "scan-build -v -plist --use-analyzer /usr/bin/clang -o /tmp/tmp8ytuRj gcc -B. -c ../../src/bogus.c", 
-  "returncode": 0, 
-  "stdout": "scan-build: Using '/usr/bin/clang' for static analysis\nscan-build: Emitting reports for this run to '/tmp/tmp8ytuRj/2017-05-24-001755-39710-1'.\nscan-build: Analysis run complete.\nscan-build: Analysis results (plist files) deposited in '/tmp/tmp8ytuRj/2017-05-24-001755-39710-1'\n", 
-  "stderr": "../../src/bogus.c: In function \u2018test\u2019:\n../../src/bogus.c:5:10: warning: function returns address of local variable [-Wreturn-local-addr]\n   return tmp;\n          ^~~\n../../src/bogus.c:5:3: warning: Address of stack memory associated with local variable 'tmp' returned to caller\n  return tmp;\n  ^~~~~~~~~~\n1 warning generated.\n", 
-  "plistpath": "/tmp/tmp8ytuRj/2017-05-24-001755-39710-1/report-DEoPmt.plist"
- }, 
- "results": [
-  {
-   "severity": null, 
-   "trace": {
-    "states": [
-     {
-      "notes": null, 
-      "location": {
-       "function": {
-        "name": ""
-       }, 
-       "range_": {
-        "start": {
-         "column": 3, 
-         "line": 3
-        }, 
-        "end": {
-         "column": 6, 
-         "line": 3
-        }
-       }, 
-       "file": {
-        "abspath": null, 
-        "givenpath": "../../src/bogus.c", 
-        "hash_": null
-       }, 
-       "point": null
-      }
-     }, 
-     {
-      "notes": null, 
-      "location": {
-       "function": {
-        "name": ""
-       }, 
-       "range_": {
-        "start": {
-         "column": 3, 
-         "line": 5
-        }, 
-        "end": {
-         "column": 8, 
-         "line": 5
-        }
-       }, 
-       "file": {
-        "abspath": null, 
-        "givenpath": "../../src/bogus.c", 
-        "hash_": null
-       }, 
-       "point": null
-      }
-     }, 
-     {
-      "notes": {
-       "text": "Address of stack memory associated with local variable 'tmp' returned to caller"
-      }, 
-      "location": {
-       "function": {
-        "name": ""
-       }, 
-       "range_": null, 
-       "file": {
-        "abspath": null, 
-        "givenpath": "../../src/bogus.c", 
-        "hash_": null
-       }, 
-       "point": {
-        "column": 3, 
-        "line": 5
-       }
-      }
-     }
-    ]
-   }, 
-   "type": "Issue", 
-   "notes": null, 
-   "testid": null, 
-   "message": {
-    "text": "Address of stack memory associated with local variable 'tmp' returned to caller"
-   }, 
-   "cwe": null, 
-   "customfields": null, 
-   "location": {
-    "function": null, 
-    "range_": null, 
-    "file": {
-     "abspath": null, 
-     "givenpath": "../../src/bogus.c", 
-     "hash_": null
-    }, 
-    "point": {
-     "column": 3, 
-     "line": 5
-    }
-   }
-  }
- ], 
- "metadata": {
-  "stats": {
-   "wallclocktime": 0.22788214683532715
-  }, 
-  "sut": null, 
-  "file_": {
-   "abspath": "/home/david/coding-3/gcc-git-static-analysis/build/gcc/../../src/bogus.c", 
-   "givenpath": "../../src/bogus.c", 
-   "hash_": null
-  }, 
-  "generator": {
-   "version": null, 
-   "name": "clang-analyzer"
-  }
- }
-}
\ No newline at end of file
diff --git a/test-cppcheck.json b/test-cppcheck.json
deleted file mode 100644
index c9651ee..0000000
--- a/test-cppcheck.json
+++ /dev/null
@@ -1,50 +0,0 @@
-{
- "customfields": {
-  "cppcheck-invocation": "cppcheck --xml --xml-version=2 ../../src/test-sources/conditional-leak.c", 
-  "returncode": 0, 
-  "stdout": "Checking ../../src/test-sources/conditional-leak.c...\n", 
-  "stderr": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<results version=\"2\">\n    <cppcheck version=\"1.63\"/>\n    <errors>\n        <error id=\"memleak\" severity=\"error\" msg=\"Memory leak: ptr_1\" verbose=\"Memory leak: ptr_1\">\n            <location file=\"../../src/test-sources/conditional-leak.c\" line=\"11\"/>\n        </error>\n    </errors>\n</results>\n"
- }, 
- "results": [
-  {
-   "severity": "error", 
-   "trace": null, 
-   "type": "Issue", 
-   "notes": null, 
-   "testid": "memleak", 
-   "message": {
-    "text": "Memory leak: ptr_1"
-   }, 
-   "cwe": null, 
-   "customfields": null, 
-   "location": {
-    "function": null, 
-    "range_": null, 
-    "file": {
-     "abspath": null, 
-     "givenpath": "../../src/test-sources/conditional-leak.c", 
-     "hash_": null
-    }, 
-    "point": {
-     "column": 0, 
-     "line": 11
-    }
-   }
-  }
- ], 
- "metadata": {
-  "stats": {
-   "wallclocktime": 0.006749868392944336
-  }, 
-  "sut": null, 
-  "file_": {
-   "abspath": "/home/david/coding-3/gcc-git-static-analysis/build/gcc/../../src/test-sources/conditional-leak.c", 
-   "givenpath": "../../src/test-sources/conditional-leak.c", 
-   "hash_": null
-  }, 
-  "generator": {
-   "version": "1.63", 
-   "name": "cppcheck"
-  }
- }
-}
\ No newline at end of file
-- 
1.8.5.3

