mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
Update Crashpad bot scripts to python3.
Change-Id: Ie3848c2f2bbbe34ca3a5e7da5e7d05e3cfba5b72 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3549021 Reviewed-by: Mark Mentovai <mark@chromium.org> Commit-Queue: Justin Cohen <justincohen@chromium.org>
This commit is contained in:
parent
f88a116c0e
commit
dedbc0f61b
32
.vpython3
Normal file
32
.vpython3
Normal file
@ -0,0 +1,32 @@
|
||||
# Copyright 2022 The Crashpad Authors. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This is a vpython "spec" file.
|
||||
#
|
||||
# It describes patterns for python wheel dependencies of the python scripts.
|
||||
#
|
||||
# Read more about `vpython` and how to modify this file here:
|
||||
# https://chromium.googlesource.com/infra/infra/+/master/doc/users/vpython.md
|
||||
|
||||
# This is needed for snapshot/win/end_to_end_test.py.
|
||||
wheel: <
|
||||
name: "infra/python/wheels/pywin32/${vpython_platform}"
|
||||
version: "version:300"
|
||||
match_tag: <
|
||||
platform: "win32"
|
||||
>
|
||||
match_tag: <
|
||||
platform: "win_amd64"
|
||||
>
|
||||
>
|
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright 2014 The Crashpad Authors. All rights reserved.
|
||||
#
|
||||
@ -15,8 +14,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import pipes
|
||||
@ -40,7 +37,7 @@ def _FindGNFromBinaryDir(binary_dir):
|
||||
|
||||
build_ninja = os.path.join(binary_dir, 'build.ninja')
|
||||
if os.path.isfile(build_ninja):
|
||||
with open(build_ninja, 'rb') as f:
|
||||
with open(build_ninja, 'r') as f:
|
||||
# Look for the always-generated regeneration rule of the form:
|
||||
#
|
||||
# rule gn
|
||||
@ -78,10 +75,11 @@ def _BinaryDirTargetOS(binary_dir):
|
||||
],
|
||||
shell=IS_WINDOWS_HOST,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=open(os.devnull))
|
||||
stderr=open(os.devnull),
|
||||
text=True)
|
||||
value = popen.communicate()[0]
|
||||
if popen.returncode == 0:
|
||||
match = re.match('target_os = "(.*)"$', value.decode('utf-8'))
|
||||
match = re.match('target_os = "(.*)"$', value)
|
||||
if match:
|
||||
return match.group(1)
|
||||
|
||||
@ -196,13 +194,14 @@ def _RunOnAndroidTarget(binary_dir, test, android_device, extra_command_line):
|
||||
child = subprocess.Popen(adb_command,
|
||||
shell=IS_WINDOWS_HOST,
|
||||
stdin=open(os.devnull),
|
||||
stdout=subprocess.PIPE)
|
||||
stdout=subprocess.PIPE,
|
||||
text=True)
|
||||
|
||||
FINAL_LINE_RE = re.compile('status=(\d+)$')
|
||||
final_line = None
|
||||
while True:
|
||||
# Use readline so that the test output appears “live” when running.
|
||||
data = child.stdout.readline().decode('utf-8')
|
||||
data = child.stdout.readline()
|
||||
if data == '':
|
||||
break
|
||||
if final_line is not None:
|
||||
@ -369,10 +368,11 @@ def _RunOnIOSTarget(binary_dir, test, is_xcuitest=False):
|
||||
|
||||
xctestrun_path = f.name
|
||||
print(xctestrun_path)
|
||||
with open(xctestrun_path, 'wb') as fp:
|
||||
if is_xcuitest:
|
||||
plistlib.writePlist(xcuitest(binary_dir, test), xctestrun_path)
|
||||
plistlib.dump(xcuitest(binary_dir, test), fp)
|
||||
else:
|
||||
plistlib.writePlist(xctest(binary_dir, test), xctestrun_path)
|
||||
plistlib.dump(xctest(binary_dir, test), fp)
|
||||
|
||||
subprocess.check_call([
|
||||
'xcodebuild', 'test-without-building', '-xctestrun', xctestrun_path,
|
||||
@ -421,10 +421,11 @@ def main(args):
|
||||
android_device = os.environ.get('ANDROID_DEVICE')
|
||||
if not android_device:
|
||||
adb_devices = subprocess.check_output(['adb', 'devices'],
|
||||
shell=IS_WINDOWS_HOST)
|
||||
shell=IS_WINDOWS_HOST,
|
||||
text=True)
|
||||
devices = []
|
||||
for line in adb_devices.splitlines():
|
||||
line = line.decode('utf-8')
|
||||
line = line
|
||||
if (line == 'List of devices attached' or
|
||||
re.match('^\* daemon .+ \*$', line) or line == ''):
|
||||
continue
|
||||
|
@ -14,13 +14,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import platform
|
||||
import pywintypes
|
||||
import random
|
||||
import re
|
||||
import struct
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
@ -104,7 +103,7 @@ def NamedPipeExistsAndReady(pipe_name):
|
||||
try:
|
||||
win32pipe.WaitNamedPipe(pipe_name, win32pipe.NMPWAIT_WAIT_FOREVER)
|
||||
except pywintypes.error as e:
|
||||
if e[0] == winerror.ERROR_FILE_NOT_FOUND:
|
||||
if e.winerror == winerror.ERROR_FILE_NOT_FOUND:
|
||||
return False
|
||||
raise
|
||||
return True
|
||||
@ -152,6 +151,14 @@ def GetDumpFromProgram(out_dir, pipe_name, executable_name, expect_exit_code,
|
||||
] + list(args))
|
||||
print('Running %s' % os.path.basename(command[0]))
|
||||
exit_code = subprocess.call(command)
|
||||
|
||||
# Some win32con codes are negative signed integers, whereas all exit
|
||||
# codes are unsigned integers. Convert from signed to unsigned.
|
||||
if expect_exit_code < 0:
|
||||
expect_exit_code = struct.unpack('I',
|
||||
struct.pack('i',
|
||||
expect_exit_code))[0]
|
||||
|
||||
if exit_code != expect_exit_code:
|
||||
raise subprocess.CalledProcessError(exit_code, executable_name)
|
||||
|
||||
@ -160,7 +167,8 @@ def GetDumpFromProgram(out_dir, pipe_name, executable_name, expect_exit_code,
|
||||
'--database=' + test_database,
|
||||
'--show-pending-reports',
|
||||
'--show-all-report-info',
|
||||
])
|
||||
],
|
||||
text=True)
|
||||
for line in out.splitlines():
|
||||
if line.strip().startswith('Path:'):
|
||||
return line.partition(':')[2].strip()
|
||||
@ -205,7 +213,7 @@ class CdbRun(object):
|
||||
# Run a command line that loads the dump, runs the specified cdb
|
||||
# command, and then quits, and capturing stdout.
|
||||
self.out = subprocess.check_output(
|
||||
[cdb_path, '-z', dump_path, '-c', command + ';q'])
|
||||
[cdb_path, '-z', dump_path, '-c', command + ';q'], text=True)
|
||||
|
||||
def Check(self, pattern, message, re_flags=0):
|
||||
match_obj = re.search(pattern, self.out, re_flags)
|
||||
|
Loading…
x
Reference in New Issue
Block a user