diff options
author | Caroline Tice <cmtice@google.com> | 2017-04-06 17:16:05 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-04-08 19:40:20 -0700 |
commit | f6ef4395fe1896ba68c80e52cb24763b0fcfe7f8 (patch) | |
tree | 7612123711db98f0746e56b66368d16b388192bd /binary_search_tool | |
parent | 8c18be1425c8a4ecfc059a7c637fc93f33edab1f (diff) | |
download | toolchain-utils-f6ef4395fe1896ba68c80e52cb24763b0fcfe7f8.tar.gz |
[toolchain-utils] Fix remaining lint errors in toolchain-utils.
In addition to fixing the lint errors, this also fixes the Python
formatting issues (ran tc_pyformat on nearly all the files).
BUG=chromium:570450
TEST=Ran all crosperf & bisect tool unit tests.
Ran afe_lock_machine.py (check machine status)
Ran full crosperf test (octane, speedometer, BootPerf) on alex.
Change-Id: Ic86f9192801ac67769f3de30f1c5f0d203ce0831
Reviewed-on: https://chromium-review.googlesource.com/471886
Commit-Ready: Caroline Tice <cmtice@chromium.org>
Tested-by: Caroline Tice <cmtice@chromium.org>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Diffstat (limited to 'binary_search_tool')
22 files changed, 126 insertions, 111 deletions
diff --git a/binary_search_tool/binary_search_perforce.py b/binary_search_tool/binary_search_perforce.py index 7ac2fba6..aaa09eef 100755 --- a/binary_search_tool/binary_search_perforce.py +++ b/binary_search_tool/binary_search_perforce.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Module of binary serch for perforce.""" from __future__ import print_function @@ -368,8 +368,8 @@ class P4GCCBinarySearcher(P4BinarySearcher): self.CleanupCLs() # Change the revision of only the gcc part of the toolchain. command = ('cd %s/gcctools/google_vendor_src_branch/gcc ' - '&& g4 revert ...; g4 sync @%s' % - (self.checkout_dir, current_revision)) + '&& g4 revert ...; g4 sync @%s' % (self.checkout_dir, + current_revision)) self.current_ce.RunCommand(command) self.HandleBrokenCLs(current_revision) @@ -402,11 +402,13 @@ def Main(argv): '-s', '--script', dest='script', help='Script to run for every version.') options = parser.parse_args(argv) # First get all revisions - p4_paths = ['//depot2/gcctools/google_vendor_src_branch/gcc/gcc-4.4.3/...', - '//depot2/gcctools/google_vendor_src_branch/binutils/' - 'binutils-2.20.1-mobile/...', - '//depot2/gcctools/google_vendor_src_branch/' - 'binutils/binutils-20100303/...'] + p4_paths = [ + '//depot2/gcctools/google_vendor_src_branch/gcc/gcc-4.4.3/...', + '//depot2/gcctools/google_vendor_src_branch/binutils/' + 'binutils-2.20.1-mobile/...', + '//depot2/gcctools/google_vendor_src_branch/' + 'binutils/binutils-20100303/...' + ] p4gccbs = P4GCCBinarySearcher('perforce2:2666', p4_paths, '') # Main loop: @@ -425,8 +427,8 @@ def Main(argv): ce = command_executer.GetCommandExecuter() command = '%s %s' % (script, p4gccbs.checkout_dir) status = ce.RunCommand(command) - message = ('Revision: %s produced: %d status\n' % - (current_revision, status)) + message = ('Revision: %s produced: %d status\n' % (current_revision, + status)) logger.GetLogger().LogOutput(message, print_to_console=verbose) terminated = p4gccbs.SetStatus(status) num_tries -= 1 diff --git a/binary_search_tool/binary_search_state.py b/binary_search_tool/binary_search_state.py index a10e90b9..19065252 100755 --- a/binary_search_tool/binary_search_state.py +++ b/binary_search_tool/binary_search_state.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """The binary search wrapper.""" from __future__ import print_function @@ -559,8 +559,8 @@ def Run(get_initial_items, try: bss.DoSearch() bss.RemoveState() - logger.GetLogger().LogOutput('Total execution time: %s' % - bss.ElapsedTimeString()) + logger.GetLogger().LogOutput( + 'Total execution time: %s' % bss.ElapsedTimeString()) except Error as e: logger.GetLogger().LogError(e) return 1 diff --git a/binary_search_tool/bisect.py b/binary_search_tool/bisect.py index d5a8b710..c7dd5238 100755 --- a/binary_search_tool/bisect.py +++ b/binary_search_tool/bisect.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """The unified package/object bisecting tool.""" from __future__ import print_function @@ -193,9 +193,9 @@ class BisectObject(Bisector): if options.dir: os.environ['BISECT_DIR'] = options.dir self.options.dir = os.environ.get('BISECT_DIR', '/tmp/sysroot_bisect') - self.setup_cmd = ('%s %s %s %s' % (self.sysroot_wrapper_setup, - self.options.board, self.options.remote, - self.options.package)) + self.setup_cmd = ('%s %s %s %s' % + (self.sysroot_wrapper_setup, self.options.board, + self.options.remote, self.options.package)) self.ArgOverride(self.default_kwargs, overrides) diff --git a/binary_search_tool/compiler_wrapper.py b/binary_search_tool/compiler_wrapper.py index 3d6403a2..a6d189b5 100755 --- a/binary_search_tool/compiler_wrapper.py +++ b/binary_search_tool/compiler_wrapper.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Prototype compiler wrapper. Only tested with: gcc, g++, clang, clang++ diff --git a/binary_search_tool/cros_pkg/create_cleanup_script.py b/binary_search_tool/cros_pkg/create_cleanup_script.py index 32a1f160..ed4eab61 100755 --- a/binary_search_tool/cros_pkg/create_cleanup_script.py +++ b/binary_search_tool/cros_pkg/create_cleanup_script.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 # # Copyright 2015 Google Inc. All Rights Reserved """The script to generate a cleanup script after setup.sh. @@ -90,8 +90,8 @@ def Main(argv): if options.renamed_tree: # Old build tree existed and was a real tree, so it got # renamed. Move the renamed tree back to the original tree. - out_file.write('sudo mv /build/%s.save /build/%s\n' % - (options.board, options.board)) + out_file.write('sudo mv /build/%s.save /build/%s\n' % (options.board, + options.board)) else: # Old tree existed and was already a soft link. Re-create the # original soft link. diff --git a/binary_search_tool/run_bisect_test.py b/binary_search_tool/run_bisect_test.py index c2776cce..53acc805 100755 --- a/binary_search_tool/run_bisect_test.py +++ b/binary_search_tool/run_bisect_test.py @@ -1,4 +1,5 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 +"""Run full bisection test.""" from __future__ import print_function @@ -89,7 +90,7 @@ Is your compiler wrapper properly set up? [Y/n] inp = sys.stdin.readline() inp = inp.strip() inp = inp.lower() - return (not inp or inp == 'y' or inp == 'yes') + return not inp or inp == 'y' or inp == 'yes' def Main(argv): @@ -121,13 +122,13 @@ def Main(argv): if not bisect_dir: bisect_dir = DEFAULT_BISECT_DIR - retval = populate_good_files(cwd, ce, bisect_dir) - if retval != 0: - return retval + retv = populate_good_files(cwd, ce, bisect_dir) + if retv != 0: + return retv - retval = populate_bad_files(cwd, ce, bisect_dir) - if retval != 0: - return retval + retv = populate_bad_files(cwd, ce, bisect_dir) + if retv != 0: + return retv # Set up good/bad work soft links cmd = ('rm -f %s/%s/good-objects; ln -s %s/good %s/%s/good-objects' % @@ -146,8 +147,8 @@ def Main(argv): print('Error executing: %s; exiting now.' % cmd) return status - retval = run_main_bisection_test(cwd, ce) - return retval + retv = run_main_bisection_test(cwd, ce) + return retv if __name__ == '__main__': diff --git a/binary_search_tool/sysroot_wrapper/testing_test.py b/binary_search_tool/sysroot_wrapper/testing_test.py index 2f7bc4c3..a0d6ca10 100755 --- a/binary_search_tool/sysroot_wrapper/testing_test.py +++ b/binary_search_tool/sysroot_wrapper/testing_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Test for sysroot_wrapper bisector. All files in bad_files will be determined to be bad. This test was made for @@ -15,9 +15,9 @@ import os base_path = ('/var/cache/chromeos-chrome/chrome-src-internal/src/out_daisy/' 'Release/obj/') bad_files = [ - os.path.join(base_path, 'base/base.cpu.o'), - os.path.join(base_path, 'base/base.version.o'), - os.path.join(base_path, 'apps/apps.launcher.o') + os.path.join(base_path, 'base/base.cpu.o'), os.path.join( + base_path, 'base/base.version.o'), os.path.join(base_path, + 'apps/apps.launcher.o') ] bisect_dir = os.environ.get('BISECT_DIR', '/tmp/sysroot_bisect') diff --git a/binary_search_tool/test/binary_search_tool_tester.py b/binary_search_tool/test/binary_search_tool_tester.py index 775c1715..e733d9c4 100755 --- a/binary_search_tool/test/binary_search_tool_tester.py +++ b/binary_search_tool/test/binary_search_tool_tester.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 # Copyright 2012 Google Inc. All Rights Reserved. """Tests for bisecting tool.""" @@ -66,12 +66,13 @@ class BisectTest(unittest.TestCase): return 0 def Run(self): - return binary_search_state.Run(get_initial_items='./gen_init_list.py', - switch_to_good='./switch_to_good.py', - switch_to_bad='./switch_to_bad.py', - test_script='./is_good.py', - prune=True, - file_args=True) + return binary_search_state.Run( + get_initial_items='./gen_init_list.py', + switch_to_good='./switch_to_good.py', + switch_to_bad='./switch_to_bad.py', + test_script='./is_good.py', + prune=True, + file_args=True) def PostRun(self): CleanObj() @@ -127,26 +128,31 @@ class BisectingUtilsTest(unittest.TestCase): except OSError: pass - cleanup_list = ['./is_setup', binary_search_state.STATE_FILE, - 'noinc_prune_bad', 'noinc_prune_good'] + cleanup_list = [ + './is_setup', binary_search_state.STATE_FILE, 'noinc_prune_bad', + 'noinc_prune_good' + ] for f in cleanup_list: if os.path.exists(f): os.remove(f) def runTest(self): - ret = binary_search_state.Run(get_initial_items='./gen_init_list.py', - switch_to_good='./switch_to_good.py', - switch_to_bad='./switch_to_bad.py', - test_script='./is_good.py', - prune=True, - file_args=True) + ret = binary_search_state.Run( + get_initial_items='./gen_init_list.py', + switch_to_good='./switch_to_good.py', + switch_to_bad='./switch_to_bad.py', + test_script='./is_good.py', + prune=True, + file_args=True) self.assertEquals(ret, 0) self.check_output() def test_arg_parse(self): - args = ['--get_initial_items', './gen_init_list.py', '--switch_to_good', - './switch_to_good.py', '--switch_to_bad', './switch_to_bad.py', - '--test_script', './is_good.py', '--prune', '--file_args'] + args = [ + '--get_initial_items', './gen_init_list.py', '--switch_to_good', + './switch_to_good.py', '--switch_to_bad', './switch_to_bad.py', + '--test_script', './is_good.py', '--prune', '--file_args' + ] ret = binary_search_state.Main(args) self.assertEquals(ret, 0) self.check_output() @@ -154,32 +160,35 @@ class BisectingUtilsTest(unittest.TestCase): def test_test_setup_script(self): os.remove('./is_setup') with self.assertRaises(AssertionError): - ret = binary_search_state.Run(get_initial_items='./gen_init_list.py', - switch_to_good='./switch_to_good.py', - switch_to_bad='./switch_to_bad.py', - test_script='./is_good.py', - prune=True, - file_args=True) - - ret = binary_search_state.Run(get_initial_items='./gen_init_list.py', - switch_to_good='./switch_to_good.py', - switch_to_bad='./switch_to_bad.py', - test_script='./is_good.py', - test_setup_script='./test_setup.py', - prune=True, - file_args=True) + ret = binary_search_state.Run( + get_initial_items='./gen_init_list.py', + switch_to_good='./switch_to_good.py', + switch_to_bad='./switch_to_bad.py', + test_script='./is_good.py', + prune=True, + file_args=True) + + ret = binary_search_state.Run( + get_initial_items='./gen_init_list.py', + switch_to_good='./switch_to_good.py', + switch_to_bad='./switch_to_bad.py', + test_script='./is_good.py', + test_setup_script='./test_setup.py', + prune=True, + file_args=True) self.assertEquals(ret, 0) self.check_output() def test_bad_test_setup_script(self): with self.assertRaises(AssertionError): - binary_search_state.Run(get_initial_items='./gen_init_list.py', - switch_to_good='./switch_to_good.py', - switch_to_bad='./switch_to_bad.py', - test_script='./is_good.py', - test_setup_script='./test_setup_bad.py', - prune=True, - file_args=True) + binary_search_state.Run( + get_initial_items='./gen_init_list.py', + switch_to_good='./switch_to_good.py', + switch_to_bad='./switch_to_bad.py', + test_script='./is_good.py', + test_setup_script='./test_setup_bad.py', + prune=True, + file_args=True) def test_bad_save_state(self): state_file = binary_search_state.STATE_FILE @@ -294,13 +303,14 @@ class BisectingUtilsTest(unittest.TestCase): self.assertEquals(bad_objs[found_obj], 1) def test_set_file(self): - binary_search_state.Run(get_initial_items='./gen_init_list.py', - switch_to_good='./switch_to_good_set_file.py', - switch_to_bad='./switch_to_bad_set_file.py', - test_script='./is_good.py', - prune=True, - file_args=True, - verify=True) + binary_search_state.Run( + get_initial_items='./gen_init_list.py', + switch_to_good='./switch_to_good_set_file.py', + switch_to_bad='./switch_to_bad_set_file.py', + test_script='./is_good.py', + prune=True, + file_args=True, + verify=True) self.check_output() def test_noincremental_prune(self): @@ -343,13 +353,14 @@ class BisectStressTest(unittest.TestCase): def test_every_obj_bad(self): amt = 25 gen_obj.Main(['--obj_num', str(amt), '--bad_obj_num', str(amt)]) - ret = binary_search_state.Run(get_initial_items='./gen_init_list.py', - switch_to_good='./switch_to_good.py', - switch_to_bad='./switch_to_bad.py', - test_script='./is_good.py', - prune=True, - file_args=True, - verify=False) + ret = binary_search_state.Run( + get_initial_items='./gen_init_list.py', + switch_to_good='./switch_to_good.py', + switch_to_bad='./switch_to_bad.py', + test_script='./is_good.py', + prune=True, + file_args=True, + verify=False) self.assertEquals(ret, 0) self.check_output() @@ -360,13 +371,14 @@ class BisectStressTest(unittest.TestCase): obj_list[i] = '1' obj_list = ','.join(obj_list) gen_obj.Main(['--obj_list', obj_list]) - ret = binary_search_state.Run(get_initial_items='./gen_init_list.py', - switch_to_good='./switch_to_good.py', - switch_to_bad='./switch_to_bad.py', - test_setup_script='./test_setup.py', - test_script='./is_good.py', - prune=True, - file_args=True) + ret = binary_search_state.Run( + get_initial_items='./gen_init_list.py', + switch_to_good='./switch_to_good.py', + switch_to_bad='./switch_to_bad.py', + test_setup_script='./test_setup.py', + test_script='./is_good.py', + prune=True, + file_args=True) self.assertEquals(ret, 0) self.check_output() diff --git a/binary_search_tool/test/common.py b/binary_search_tool/test/common.py index baac9434..5c3ff538 100755 --- a/binary_search_tool/test/common.py +++ b/binary_search_tool/test/common.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Common utility functions.""" DEFAULT_OBJECT_NUMBER = 1238 diff --git a/binary_search_tool/test/gen_init_list.py b/binary_search_tool/test/gen_init_list.py index 4a79a1b1..002fc352 100755 --- a/binary_search_tool/test/gen_init_list.py +++ b/binary_search_tool/test/gen_init_list.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Prints out index for every object file, starting from 0.""" from __future__ import print_function diff --git a/binary_search_tool/test/gen_obj.py b/binary_search_tool/test/gen_obj.py index 265729d2..d17e93f5 100755 --- a/binary_search_tool/test/gen_obj.py +++ b/binary_search_tool/test/gen_obj.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Script to generate a list of object files. 0 represents a good object file. @@ -86,8 +86,8 @@ def Main(argv): obj_num = len(obj_list) bad_obj_num = obj_list.count('1') - print('Generated {0} object files, with {1} bad ones.'.format(obj_num, - bad_obj_num)) + print('Generated {0} object files, with {1} bad ones.'.format( + obj_num, bad_obj_num)) return 0 diff --git a/binary_search_tool/test/is_good.py b/binary_search_tool/test/is_good.py index bfe9cc32..a0be4a08 100755 --- a/binary_search_tool/test/is_good.py +++ b/binary_search_tool/test/is_good.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Check to see if the working set produces a good executable.""" from __future__ import print_function diff --git a/binary_search_tool/test/is_good_noinc_prune.py b/binary_search_tool/test/is_good_noinc_prune.py index 5aafd6c2..a900bd32 100755 --- a/binary_search_tool/test/is_good_noinc_prune.py +++ b/binary_search_tool/test/is_good_noinc_prune.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Check to see if the working set produces a good executable. This test script is made for the noincremental-prune test. This makes sure diff --git a/binary_search_tool/test/switch_tmp.py b/binary_search_tool/test/switch_tmp.py index 165004ed..51b7110e 100755 --- a/binary_search_tool/test/switch_tmp.py +++ b/binary_search_tool/test/switch_tmp.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Change portions of the object files to good. This file is a test switch script. Used only for the test test_tmp_cleanup. diff --git a/binary_search_tool/test/switch_to_bad.py b/binary_search_tool/test/switch_to_bad.py index b8602421..a1b6bd59 100755 --- a/binary_search_tool/test/switch_to_bad.py +++ b/binary_search_tool/test/switch_to_bad.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Switch part of the objects file in working set to (possible) bad ones.""" from __future__ import print_function diff --git a/binary_search_tool/test/switch_to_bad_noinc_prune.py b/binary_search_tool/test/switch_to_bad_noinc_prune.py index 87bf1584..db76acad 100755 --- a/binary_search_tool/test/switch_to_bad_noinc_prune.py +++ b/binary_search_tool/test/switch_to_bad_noinc_prune.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Switch part of the objects file in working set to (possible) bad ones. The "portion" is defined by the file (which is passed as the only argument to diff --git a/binary_search_tool/test/switch_to_bad_set_file.py b/binary_search_tool/test/switch_to_bad_set_file.py index f535fdfd..edf226d3 100755 --- a/binary_search_tool/test/switch_to_bad_set_file.py +++ b/binary_search_tool/test/switch_to_bad_set_file.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Switch part of the objects file in working set to (possible) bad ones. This script is meant to be specifically used with the set_file test. This uses diff --git a/binary_search_tool/test/switch_to_good.py b/binary_search_tool/test/switch_to_good.py index 68e9633f..59a118c1 100755 --- a/binary_search_tool/test/switch_to_good.py +++ b/binary_search_tool/test/switch_to_good.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Change portions of the object files to good. The "portion" is defined by the file (which is passed as the only argument to diff --git a/binary_search_tool/test/switch_to_good_noinc_prune.py b/binary_search_tool/test/switch_to_good_noinc_prune.py index c5e78e45..00488a74 100755 --- a/binary_search_tool/test/switch_to_good_noinc_prune.py +++ b/binary_search_tool/test/switch_to_good_noinc_prune.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Change portions of the object files to good. The "portion" is defined by the file (which is passed as the only argument to diff --git a/binary_search_tool/test/switch_to_good_set_file.py b/binary_search_tool/test/switch_to_good_set_file.py index 83777af0..b5e521f9 100755 --- a/binary_search_tool/test/switch_to_good_set_file.py +++ b/binary_search_tool/test/switch_to_good_set_file.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Change portions of the object files to good. The "portion" is defined by the file (which is passed as the only argument to diff --git a/binary_search_tool/test/test_setup.py b/binary_search_tool/test/test_setup.py index 3fb5a23c..0d6a410e 100755 --- a/binary_search_tool/test/test_setup.py +++ b/binary_search_tool/test/test_setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Emulate running of test setup script, is_good.py should fail without this.""" from __future__ import print_function diff --git a/binary_search_tool/test/test_setup_bad.py b/binary_search_tool/test/test_setup_bad.py index 8d72763e..d715f57a 100755 --- a/binary_search_tool/test/test_setup_bad.py +++ b/binary_search_tool/test/test_setup_bad.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 """Emulate test setup that fails (i.e. failed flash to device)""" from __future__ import print_function |