aboutsummaryrefslogtreecommitdiff
path: root/llvm_tools
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2021-01-28 12:40:22 -0800
committerGeorge Burgess <gbiv@chromium.org>2021-01-28 22:52:35 +0000
commit2844e62d0405e009f4a57093eedab9c37416e54c (patch)
tree3bdffe3f679f9544b5ec888a8038492ebcaaa13a /llvm_tools
parent92fff664338311355a744616074c58d9c98527b5 (diff)
downloadtoolchain-utils-2844e62d0405e009f4a57093eedab9c37416e54c.tar.gz
llvm_tools: make the lexan 4c uploader ignore old clang(s)
Lexan saw a crash from clang 9.0.0 uploaded to their bucket. There's ~nothing we care to do about these crashes, and 4c even fails to parse the header of them. Seems best to warn & ignore these cases automatically (if an actual _user_ wants this functionality, 4c can easily be fixed, but I doubt anyone cares) No test is provided since submit_test_case has quite a few side-effects. Doesn't seem worth splitting it or mocking a lot to add an automated test for this peephole. BUG=None TEST=manually ran on chrotomation Change-Id: Iae131913e7b9494015262e41af8ad4193c9d62f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2657875 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Tested-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'llvm_tools')
-rwxr-xr-xllvm_tools/upload_lexan_crashes_to_forcey.py29
-rwxr-xr-xllvm_tools/upload_lexan_crashes_to_forcey_test.py24
2 files changed, 46 insertions, 7 deletions
diff --git a/llvm_tools/upload_lexan_crashes_to_forcey.py b/llvm_tools/upload_lexan_crashes_to_forcey.py
index b93f51a7..486fe664 100755
--- a/llvm_tools/upload_lexan_crashes_to_forcey.py
+++ b/llvm_tools/upload_lexan_crashes_to_forcey.py
@@ -101,21 +101,29 @@ def temp_dir() -> Generator[str, None, None]:
shutil.rmtree(loc)
+def download_and_unpack_test_case(gs_url: str, tempdir: str) -> None:
+ suffix = os.path.splitext(gs_url)[1]
+ target_name = 'test_case' + suffix
+ target = os.path.join(tempdir, target_name)
+ subprocess.run(['gsutil.py', 'cp', gs_url, target], check=True)
+ subprocess.run(['tar', 'xaf', target_name], check=True, cwd=tempdir)
+ os.unlink(target)
+
+
def submit_test_case(gs_url: str, cr_tool: str) -> None:
logging.info('Submitting %s', gs_url)
- suffix = os.path.splitext(gs_url)[1]
with temp_dir() as tempdir:
- target_name = 'test_case' + suffix
- target = os.path.join(tempdir, target_name)
- subprocess.run(['gsutil.py', 'cp', gs_url, target], check=True)
- subprocess.run(['tar', 'xaf', target_name], check=True, cwd=tempdir)
- os.unlink(target)
+ download_and_unpack_test_case(gs_url, tempdir)
# Sometimes (e.g., in
# gs://chrome-clang-crash-reports/v1/2020/03/27/
# chromium.clang-ToTiOS-12754-GTXToolKit-2bfcde.tgz)
# we'll get `.crash` files. Unclear why, but let's filter them out anyway.
- repro_files = [x for x in os.listdir(tempdir) if not x.endswith('.crash')]
+ repro_files = [
+ os.path.join(tempdir, x)
+ for x in os.listdir(tempdir)
+ if not x.endswith('.crash')
+ ]
assert len(repro_files) == 2, repro_files
if repro_files[0].endswith('.sh'):
sh_file, src_file = repro_files
@@ -124,6 +132,13 @@ def submit_test_case(gs_url: str, cr_tool: str) -> None:
src_file, sh_file = repro_files
assert sh_file.endswith('.sh'), repro_files
+ # Peephole: lexan got a crash upload with a way old clang. Ignore it.
+ with open(sh_file, encoding='utf-8') as f:
+ if 'Crash reproducer for clang version 9.0.0' in f.read():
+ logging.warning('Skipping upload for %s; seems to be with an old clang',
+ gs_url)
+ return
+
subprocess.run(
[
cr_tool,
diff --git a/llvm_tools/upload_lexan_crashes_to_forcey_test.py b/llvm_tools/upload_lexan_crashes_to_forcey_test.py
index 3c9c0d4b..937cbf8e 100755
--- a/llvm_tools/upload_lexan_crashes_to_forcey_test.py
+++ b/llvm_tools/upload_lexan_crashes_to_forcey_test.py
@@ -7,6 +7,7 @@
"""Tests for upload_lexan_crashes_to_forcey."""
import datetime
+import os
import unittest
import unittest.mock
@@ -117,6 +118,29 @@ class Test(unittest.TestCase):
),
])
+ @unittest.mock.patch(
+ 'upload_lexan_crashes_to_forcey.download_and_unpack_test_case')
+ @unittest.mock.patch('subprocess.run')
+ def test_test_case_submission_functions(self, subprocess_run_mock,
+ download_and_unpack_mock):
+ mock_gs_url = 'gs://foo/bar/baz'
+
+ def side_effect(gs_url: str, tempdir: str) -> None:
+ self.assertEqual(gs_url, mock_gs_url)
+
+ with open(os.path.join(tempdir, 'test_case.c'), 'w') as f:
+ # All we need is an empty file here.
+ pass
+
+ with open(
+ os.path.join(tempdir, 'test_case.sh'), 'w', encoding='utf-8') as f:
+ f.write('# Crash reproducer for clang version 9.0.0 (...)\n')
+ f.write('clang something or other\n')
+
+ download_and_unpack_mock.side_effect = side_effect
+ upload_lexan_crashes_to_forcey.submit_test_case(mock_gs_url, '4c')
+ subprocess_run_mock.assert_not_called()
+
if __name__ == '__main__':
unittest.main()