Skip to content

Commit

Permalink
Add checkbins.py to Win builder on master.chromium. Implement JSON ou…
Browse files Browse the repository at this point in the history
…tput.

BUG=545480
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1453293003 .

Cr-Commit-Position: refs/heads/master@{#360565}
  • Loading branch information
Paweł Hajdan, Jr committed Nov 19, 2015
1 parent 8008262 commit c8eec9a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
11 changes: 11 additions & 0 deletions testing/buildbot/chromium.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,16 @@
"script": "sizes.py"
}
]
},
"Win": {
"additional_compile_targets": [
"all"
],
"scripts": [
{
"name": "checkbins",
"script": "checkbins.py"
}
]
}
}
44 changes: 44 additions & 0 deletions testing/scripts/checkbins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import json
import os
import sys


import common


def main_run(args):
with common.temporary_file() as tempfile_path:
rc = common.run_command([
sys.executable,
os.path.join(common.SRC_DIR, 'tools', 'checkbins', 'checkbins.py'),
'--verbose',
'--json', tempfile_path,
os.path.join(args.paths['checkout'], 'out', args.build_config_fs),
])

with open(tempfile_path) as f:
checkbins_results = json.load(f)

json.dump({
'valid': True,
'failures': checkbins_results,
}, args.output)

return rc


def main_compile_targets(args):
json.dump([], args.output)


if __name__ == '__main__':
funcs = {
'run': main_run,
'compile_targets': main_compile_targets,
}
sys.exit(common.run_script(sys.argv[1:], funcs))
11 changes: 11 additions & 0 deletions tools/checkbins/checkbins.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/NXCOMPAT, /DYNAMICBASE and /SAFESEH.
"""

import json
import os
import optparse
import sys
Expand Down Expand Up @@ -44,6 +45,8 @@ def main(options, args):
pe_total = 0
pe_passed = 0

failures = []

for file in os.listdir(directory):
path = os.path.abspath(os.path.join(directory, file))
if not IsPEFile(path):
Expand Down Expand Up @@ -103,8 +106,15 @@ def main(options, args):
# Update tally.
if success:
pe_passed = pe_passed + 1
else:
failures.append(path)

print "Result: %d files found, %d files passed" % (pe_total, pe_passed)

if options.json:
with open(options.json, 'w') as f:
json.dump(failures, f)

if pe_passed != pe_total:
sys.exit(1)

Expand All @@ -113,6 +123,7 @@ def main(options, args):
option_parser = optparse.OptionParser(usage=usage)
option_parser.add_option("-v", "--verbose", action="store_true",
default=False, help="Print debug logging")
option_parser.add_option("--json", help="Path to JSON output file")
options, args = option_parser.parse_args()
if not args:
option_parser.print_help()
Expand Down

0 comments on commit c8eec9a

Please sign in to comment.