xref: /aosp_15_r20/external/cronet/testing/scripts/checkperms.py (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1#!/usr/bin/env python
2# Copyright 2015 The Chromium Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import json
7import os
8import sys
9
10
11# Add src/testing/ into sys.path for importing common without pylint errors.
12sys.path.append(
13    os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
14from scripts import common
15
16
17def main_run(args):
18  with common.temporary_file() as tempfile_path:
19    rc = common.run_command([
20        os.path.join(common.SRC_DIR, 'tools', 'checkperms', 'checkperms.py'),
21        '--root', args.paths['checkout'],
22        '--json', tempfile_path
23    ])
24
25    with open(tempfile_path) as f:
26      checkperms_results = json.load(f)
27
28  result_set = set()
29  for result in checkperms_results:
30    result_set.add((result['rel_path'], result['error']))
31
32  failures = ['%s: %s' % (r[0], r[1]) for r in result_set]
33  common.record_local_script_results(
34      'checkperms', args.output, failures, True)
35
36  return rc
37
38
39def main_compile_targets(args):
40  json.dump([], args.output)
41
42
43if __name__ == '__main__':
44  funcs = {
45    'run': main_run,
46    'compile_targets': main_compile_targets,
47  }
48  sys.exit(common.run_script(sys.argv[1:], funcs))
49