aboutsummaryrefslogtreecommitdiff
path: root/binary_search_tool/test
diff options
context:
space:
mode:
Diffstat (limited to 'binary_search_tool/test')
-rw-r--r--binary_search_tool/test/__init__.py5
-rwxr-xr-xbinary_search_tool/test/binary_search_tool_test.py (renamed from binary_search_tool/test/binary_search_tool_tester.py)74
-rwxr-xr-xbinary_search_tool/test/cmd_script.py9
-rw-r--r--binary_search_tool/test/cmd_script_no_support.py10
-rwxr-xr-xbinary_search_tool/test/common.py35
-rwxr-xr-xbinary_search_tool/test/gen_init_list.py9
-rwxr-xr-xbinary_search_tool/test/gen_obj.py20
-rwxr-xr-xbinary_search_tool/test/generate_cmd.py9
-rwxr-xr-xbinary_search_tool/test/is_good.py9
-rwxr-xr-xbinary_search_tool/test/is_good_noinc_prune.py13
-rwxr-xr-xbinary_search_tool/test/switch_tmp.py11
-rwxr-xr-xbinary_search_tool/test/switch_to_bad.py9
-rwxr-xr-xbinary_search_tool/test/switch_to_bad_noinc_prune.py9
-rwxr-xr-xbinary_search_tool/test/switch_to_bad_set_file.py9
-rwxr-xr-xbinary_search_tool/test/switch_to_good.py9
-rwxr-xr-xbinary_search_tool/test/switch_to_good_noinc_prune.py9
-rwxr-xr-xbinary_search_tool/test/switch_to_good_set_file.py9
-rwxr-xr-xbinary_search_tool/test/test_setup.py9
-rwxr-xr-xbinary_search_tool/test/test_setup_bad.py7
19 files changed, 180 insertions, 94 deletions
diff --git a/binary_search_tool/test/__init__.py b/binary_search_tool/test/__init__.py
index 8b137891..76500def 100644
--- a/binary_search_tool/test/__init__.py
+++ b/binary_search_tool/test/__init__.py
@@ -1 +1,4 @@
-
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
diff --git a/binary_search_tool/test/binary_search_tool_tester.py b/binary_search_tool/test/binary_search_tool_test.py
index aff45a86..ca9313b5 100755
--- a/binary_search_tool/test/binary_search_tool_tester.py
+++ b/binary_search_tool/test/binary_search_tool_test.py
@@ -1,10 +1,12 @@
-#!/usr/bin/env python2
-
-# Copyright 2018 The Chromium OS Authors. All rights reserved.
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+
"""Tests for bisecting tool."""
+from __future__ import division
from __future__ import print_function
__author__ = 'shenhan@google.com (Han Shen)'
@@ -16,15 +18,15 @@ import unittest
from cros_utils import command_executer
from binary_search_tool import binary_search_state
-from binary_search_tool import bisect
+from binary_search_tool import run_bisect
-import common
-import gen_obj
+from binary_search_tool.test import common
+from binary_search_tool.test import gen_obj
def GenObj():
obj_num = random.randint(100, 1000)
- bad_obj_num = random.randint(obj_num / 100, obj_num / 20)
+ bad_obj_num = random.randint(obj_num // 100, obj_num // 20)
if bad_obj_num == 0:
bad_obj_num = 1
gen_obj.Main(['--obj_num', str(obj_num), '--bad_obj_num', str(bad_obj_num)])
@@ -38,10 +40,10 @@ def CleanObj():
class BisectTest(unittest.TestCase):
- """Tests for bisect.py"""
+ """Tests for run_bisect.py"""
def setUp(self):
- with open('./is_setup', 'w'):
+ with open('./is_setup', 'w', encoding='utf-8'):
pass
try:
@@ -57,8 +59,8 @@ class BisectTest(unittest.TestCase):
except OSError:
pass
- class FullBisector(bisect.Bisector):
- """Test bisector to test bisect.py with"""
+ class FullBisector(run_bisect.Bisector):
+ """Test bisector to test run_bisect.py with"""
def __init__(self, options, overrides):
super(BisectTest.FullBisector, self).__init__(options, overrides)
@@ -81,14 +83,14 @@ class BisectTest(unittest.TestCase):
return 0
def test_full_bisector(self):
- ret = bisect.Run(self.FullBisector({}, {}))
- self.assertEquals(ret, 0)
+ ret = run_bisect.Run(self.FullBisector({}, {}))
+ self.assertEqual(ret, 0)
self.assertFalse(os.path.exists(common.OBJECTS_FILE))
self.assertFalse(os.path.exists(common.WORKING_SET_FILE))
def check_output(self):
_, out, _ = command_executer.GetCommandExecuter().RunCommandWOutput(
- ('grep "Bad items are: " logs/binary_search_tool_tester.py.out | '
+ ('grep "Bad items are: " logs/binary_search_tool_test.py.out | '
'tail -n1'))
ls = out.splitlines()
self.assertEqual(len(ls), 1)
@@ -113,7 +115,7 @@ class BisectingUtilsTest(unittest.TestCase):
"""Generate [100-1000] object files, and 1-5% of which are bad ones."""
GenObj()
- with open('./is_setup', 'w'):
+ with open('./is_setup', 'w', encoding='utf-8'):
pass
try:
@@ -146,7 +148,7 @@ class BisectingUtilsTest(unittest.TestCase):
test_script='./is_good.py',
prune=True,
file_args=True)
- self.assertEquals(ret, 0)
+ self.assertEqual(ret, 0)
self.check_output()
def test_arg_parse(self):
@@ -156,7 +158,7 @@ class BisectingUtilsTest(unittest.TestCase):
'--test_script', './is_good.py', '--prune', '--file_args'
]
ret = binary_search_state.Main(args)
- self.assertEquals(ret, 0)
+ self.assertEqual(ret, 0)
self.check_output()
def test_test_setup_script(self):
@@ -178,7 +180,7 @@ class BisectingUtilsTest(unittest.TestCase):
test_setup_script='./test_setup.py',
prune=True,
file_args=True)
- self.assertEquals(ret, 0)
+ self.assertEqual(ret, 0)
self.check_output()
def test_bad_test_setup_script(self):
@@ -196,15 +198,15 @@ class BisectingUtilsTest(unittest.TestCase):
state_file = binary_search_state.STATE_FILE
hidden_state_file = os.path.basename(binary_search_state.HIDDEN_STATE_FILE)
- with open(state_file, 'w') as f:
+ with open(state_file, 'w', encoding='utf-8') as f:
f.write('test123')
bss = binary_search_state.MockBinarySearchState()
with self.assertRaises(binary_search_state.Error):
bss.SaveState()
- with open(state_file, 'r') as f:
- self.assertEquals(f.read(), 'test123')
+ with open(state_file, 'r', encoding='utf-8') as f:
+ self.assertEqual(f.read(), 'test123')
os.remove(state_file)
@@ -243,9 +245,9 @@ class BisectingUtilsTest(unittest.TestCase):
bss = None
bss2 = binary_search_state.MockBinarySearchState.LoadState()
- self.assertEquals(bss2.all_items, test_items)
- self.assertEquals(bss2.currently_good_items, set([]))
- self.assertEquals(bss2.currently_bad_items, set([]))
+ self.assertEqual(bss2.all_items, test_items)
+ self.assertEqual(bss2.currently_good_items, set([]))
+ self.assertEqual(bss2.currently_bad_items, set([]))
def test_tmp_cleanup(self):
bss = binary_search_state.MockBinarySearchState(
@@ -255,14 +257,14 @@ class BisectingUtilsTest(unittest.TestCase):
bss.SwitchToGood(['0', '1', '2', '3'])
tmp_file = None
- with open('tmp_file', 'r') as f:
+ with open('tmp_file', 'r', encoding='utf-8') as f:
tmp_file = f.read()
os.remove('tmp_file')
self.assertFalse(os.path.exists(tmp_file))
ws = common.ReadWorkingSet()
for i in range(3):
- self.assertEquals(ws[i], 42)
+ self.assertEqual(ws[i], 42)
def test_verify_fail(self):
bss = binary_search_state.MockBinarySearchState(
@@ -298,11 +300,11 @@ class BisectingUtilsTest(unittest.TestCase):
prune=False,
file_args=True)
bss.DoSearchBadItems()
- self.assertEquals(len(bss.found_items), 1)
+ self.assertEqual(len(bss.found_items), 1)
bad_objs = common.ReadObjectsFile()
found_obj = int(bss.found_items.pop())
- self.assertEquals(bad_objs[found_obj], 1)
+ self.assertEqual(bad_objs[found_obj], 1)
def test_set_file(self):
binary_search_state.Run(
@@ -326,12 +328,12 @@ class BisectingUtilsTest(unittest.TestCase):
noincremental=True,
file_args=True,
verify=False)
- self.assertEquals(ret, 0)
+ self.assertEqual(ret, 0)
self.check_output()
def check_output(self):
_, out, _ = command_executer.GetCommandExecuter().RunCommandWOutput(
- ('grep "Bad items are: " logs/binary_search_tool_tester.py.out | '
+ ('grep "Bad items are: " logs/binary_search_tool_test.py.out | '
'tail -n1'))
ls = out.splitlines()
self.assertEqual(len(ls), 1)
@@ -354,7 +356,7 @@ class BisectingUtilsPassTest(BisectingUtilsTest):
def check_pass_output(self, pass_name, pass_num, trans_num):
_, out, _ = command_executer.GetCommandExecuter().RunCommandWOutput(
- ('grep "Bad pass: " logs/binary_search_tool_tester.py.out | '
+ ('grep "Bad pass: " logs/binary_search_tool_test.py.out | '
'tail -n1'))
ls = out.splitlines()
self.assertEqual(len(ls), 1)
@@ -365,7 +367,7 @@ class BisectingUtilsPassTest(BisectingUtilsTest):
_, out, _ = command_executer.GetCommandExecuter().RunCommandWOutput(
('grep "Bad transformation number: '
- '" logs/binary_search_tool_tester.py.out | '
+ '" logs/binary_search_tool_test.py.out | '
'tail -n1'))
ls = out.splitlines()
self.assertEqual(len(ls), 1)
@@ -383,7 +385,7 @@ class BisectingUtilsPassTest(BisectingUtilsTest):
pass_bisect='./generate_cmd.py',
prune=True,
file_args=True)
- self.assertEquals(ret, 1)
+ self.assertEqual(ret, 1)
def test_gen_cmd_script(self):
bss = binary_search_state.MockBinarySearchState(
@@ -488,7 +490,7 @@ class BisectStressTest(unittest.TestCase):
prune=True,
file_args=True,
verify=False)
- self.assertEquals(ret, 0)
+ self.assertEqual(ret, 0)
self.check_output()
def test_every_index_is_bad(self):
@@ -506,12 +508,12 @@ class BisectStressTest(unittest.TestCase):
test_script='./is_good.py',
prune=True,
file_args=True)
- self.assertEquals(ret, 0)
+ self.assertEqual(ret, 0)
self.check_output()
def check_output(self):
_, out, _ = command_executer.GetCommandExecuter().RunCommandWOutput(
- ('grep "Bad items are: " logs/binary_search_tool_tester.py.out | '
+ ('grep "Bad items are: " logs/binary_search_tool_test.py.out | '
'tail -n1'))
ls = out.splitlines()
self.assertEqual(len(ls), 1)
diff --git a/binary_search_tool/test/cmd_script.py b/binary_search_tool/test/cmd_script.py
index eb91fe9b..bfd56052 100755
--- a/binary_search_tool/test/cmd_script.py
+++ b/binary_search_tool/test/cmd_script.py
@@ -1,4 +1,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Command script without compiler support for pass level bisection.
This script generates a pseudo log which a workable compiler should print out.
@@ -11,7 +16,7 @@ from __future__ import print_function
import os
import sys
-import common
+from binary_search_tool.test import common
def Main(argv):
diff --git a/binary_search_tool/test/cmd_script_no_support.py b/binary_search_tool/test/cmd_script_no_support.py
index a817f300..badbedc8 100644
--- a/binary_search_tool/test/cmd_script_no_support.py
+++ b/binary_search_tool/test/cmd_script_no_support.py
@@ -1,3 +1,8 @@
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Command script without compiler support for pass level bisection.
This script generates a pseudo log when certain bisecting flags are not
@@ -13,8 +18,9 @@ import sys
def Main():
if not os.path.exists('./is_setup'):
return 1
- print('No support for -opt-bisect-limit or -print-debug-counter.',
- file=sys.stderr)
+ print(
+ 'No support for -opt-bisect-limit or -print-debug-counter.',
+ file=sys.stderr)
return 0
diff --git a/binary_search_tool/test/common.py b/binary_search_tool/test/common.py
index 5c3ff538..cf5300f5 100755
--- a/binary_search_tool/test/common.py
+++ b/binary_search_tool/test/common.py
@@ -1,4 +1,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Common utility functions."""
DEFAULT_OBJECT_NUMBER = 1238
@@ -9,33 +14,29 @@ WORKING_SET_FILE = 'working_set.txt'
def ReadWorkingSet():
working_set = []
- f = open(WORKING_SET_FILE, 'r')
- for l in f:
- working_set.append(int(l))
- f.close()
+ with open(WORKING_SET_FILE, 'r', encoding='utf-8') as f:
+ for l in f:
+ working_set.append(int(l))
return working_set
def WriteWorkingSet(working_set):
- f = open(WORKING_SET_FILE, 'w')
- for o in working_set:
- f.write('{0}\n'.format(o))
- f.close()
+ with open(WORKING_SET_FILE, 'w', encoding='utf-8') as f:
+ for o in working_set:
+ f.write('{0}\n'.format(o))
def ReadObjectsFile():
objects_file = []
- f = open(OBJECTS_FILE, 'r')
- for l in f:
- objects_file.append(int(l))
- f.close()
+ with open(OBJECTS_FILE, 'r', encoding='utf-8') as f:
+ for l in f:
+ objects_file.append(int(l))
return objects_file
def ReadObjectIndex(filename):
object_index = []
- f = open(filename, 'r')
- for o in f:
- object_index.append(int(o))
- f.close()
+ with open(filename, 'r', encoding='utf-8') as f:
+ for o in f:
+ object_index.append(int(o))
return object_index
diff --git a/binary_search_tool/test/gen_init_list.py b/binary_search_tool/test/gen_init_list.py
index 002fc352..bc5dd8fe 100755
--- a/binary_search_tool/test/gen_init_list.py
+++ b/binary_search_tool/test/gen_init_list.py
@@ -1,4 +1,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Prints out index for every object file, starting from 0."""
from __future__ import print_function
@@ -6,7 +11,7 @@ from __future__ import print_function
import sys
from cros_utils import command_executer
-import common
+from binary_search_tool.test import common
def Main():
diff --git a/binary_search_tool/test/gen_obj.py b/binary_search_tool/test/gen_obj.py
index a2bc7d93..4f65c71b 100755
--- a/binary_search_tool/test/gen_obj.py
+++ b/binary_search_tool/test/gen_obj.py
@@ -1,4 +1,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Script to generate a list of object files.
0 represents a good object file.
@@ -12,7 +17,7 @@ import os
import random
import sys
-import common
+from binary_search_tool.test import common
def Main(argv):
@@ -77,12 +82,11 @@ def Main(argv):
if os.path.isfile(common.WORKING_SET_FILE):
os.remove(common.WORKING_SET_FILE)
- f = open(common.OBJECTS_FILE, 'w')
- w = open(common.WORKING_SET_FILE, 'w')
- for i in obj_list:
- f.write('{0}\n'.format(i))
- w.write('{0}\n'.format(i))
- f.close()
+ with open(common.OBJECTS_FILE, 'w', encoding='utf-8') as f:
+ with open(common.WORKING_SET_FILE, 'w', encoding='utf-8') as w:
+ for i in obj_list:
+ f.write('{0}\n'.format(i))
+ w.write('{0}\n'.format(i))
obj_num = len(obj_list)
bad_obj_num = obj_list.count(1)
diff --git a/binary_search_tool/test/generate_cmd.py b/binary_search_tool/test/generate_cmd.py
index f6876eda..51b36b0a 100755
--- a/binary_search_tool/test/generate_cmd.py
+++ b/binary_search_tool/test/generate_cmd.py
@@ -1,4 +1,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Generate a virtual cmd script for pass level bisection.
This is a required argument for pass level bisecting. For unit test, we use
@@ -15,7 +20,7 @@ def Main():
if not os.path.exists('./is_setup'):
return 1
file_name = 'cmd_script.sh'
- with open(file_name, 'w') as f:
+ with open(file_name, 'w', encoding='utf-8') as f:
f.write('Generated by generate_cmd.py')
return 0
diff --git a/binary_search_tool/test/is_good.py b/binary_search_tool/test/is_good.py
index a0be4a08..662921e8 100755
--- a/binary_search_tool/test/is_good.py
+++ b/binary_search_tool/test/is_good.py
@@ -1,4 +1,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Check to see if the working set produces a good executable."""
from __future__ import print_function
@@ -6,7 +11,7 @@ from __future__ import print_function
import os
import sys
-import common
+from binary_search_tool.test import common
def Main():
diff --git a/binary_search_tool/test/is_good_noinc_prune.py b/binary_search_tool/test/is_good_noinc_prune.py
index a900bd32..c0e42bb1 100755
--- a/binary_search_tool/test/is_good_noinc_prune.py
+++ b/binary_search_tool/test/is_good_noinc_prune.py
@@ -1,4 +1,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Check to see if the working set produces a good executable.
This test script is made for the noincremental-prune test. This makes sure
@@ -12,16 +17,16 @@ from __future__ import print_function
import os
import sys
-import common
+from binary_search_tool.test import common
def Main():
working_set = common.ReadWorkingSet()
- with open('noinc_prune_good', 'r') as good_args:
+ with open('noinc_prune_good', 'r', encoding='utf-8') as good_args:
num_good_args = len(good_args.readlines())
- with open('noinc_prune_bad', 'r') as bad_args:
+ with open('noinc_prune_bad', 'r', encoding='utf-8') as bad_args:
num_bad_args = len(bad_args.readlines())
num_args = num_good_args + num_bad_args
diff --git a/binary_search_tool/test/switch_tmp.py b/binary_search_tool/test/switch_tmp.py
index 51b7110e..0f3c4234 100755
--- a/binary_search_tool/test/switch_tmp.py
+++ b/binary_search_tool/test/switch_tmp.py
@@ -1,4 +1,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Change portions of the object files to good.
This file is a test switch script. Used only for the test test_tmp_cleanup.
@@ -11,7 +16,7 @@ from __future__ import print_function
import sys
-import common
+from binary_search_tool.test import common
def Main(argv):
@@ -23,7 +28,7 @@ def Main(argv):
working_set[int(oi)] = 42
common.WriteWorkingSet(working_set)
- with open('tmp_file', 'w') as f:
+ with open('tmp_file', 'w', encoding='utf-8') as f:
f.write(argv[1])
return 0
diff --git a/binary_search_tool/test/switch_to_bad.py b/binary_search_tool/test/switch_to_bad.py
index a1b6bd59..e3553eb6 100755
--- a/binary_search_tool/test/switch_to_bad.py
+++ b/binary_search_tool/test/switch_to_bad.py
@@ -1,11 +1,16 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Switch part of the objects file in working set to (possible) bad ones."""
from __future__ import print_function
import sys
-import common
+from binary_search_tool.test import common
def Main(argv):
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 db76acad..81b558e1 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,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""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
@@ -18,7 +23,7 @@ from __future__ import print_function
import shutil
import sys
-import common
+from binary_search_tool.test import common
def Main(argv):
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 edf226d3..5b941c62 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,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""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
@@ -10,7 +15,7 @@ from __future__ import print_function
import os
import sys
-import common
+from binary_search_tool.test import common
def Main(_):
diff --git a/binary_search_tool/test/switch_to_good.py b/binary_search_tool/test/switch_to_good.py
index 59a118c1..97479329 100755
--- a/binary_search_tool/test/switch_to_good.py
+++ b/binary_search_tool/test/switch_to_good.py
@@ -1,4 +1,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Change portions of the object files to good.
The "portion" is defined by the file (which is passed as the only argument to
@@ -10,7 +15,7 @@ from __future__ import print_function
import sys
-import common
+from binary_search_tool.test import common
def Main(argv):
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 00488a74..0b91a0d8 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,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Change portions of the object files to good.
The "portion" is defined by the file (which is passed as the only argument to
@@ -18,7 +23,7 @@ from __future__ import print_function
import shutil
import sys
-import common
+from binary_search_tool.test import common
def Main(argv):
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 b5e521f9..1cb05e0c 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,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Change portions of the object files to good.
The "portion" is defined by the file (which is passed as the only argument to
@@ -14,7 +19,7 @@ from __future__ import print_function
import os
import sys
-import common
+from binary_search_tool.test import common
def Main(_):
diff --git a/binary_search_tool/test/test_setup.py b/binary_search_tool/test/test_setup.py
index 0d6a410e..ecc8eb97 100755
--- a/binary_search_tool/test/test_setup.py
+++ b/binary_search_tool/test/test_setup.py
@@ -1,4 +1,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Emulate running of test setup script, is_good.py should fail without this."""
from __future__ import print_function
@@ -8,7 +13,7 @@ import sys
def Main():
# create ./is_setup
- with open('./is_setup', 'w'):
+ with open('./is_setup', 'w', encoding='utf-8'):
pass
return 0
diff --git a/binary_search_tool/test/test_setup_bad.py b/binary_search_tool/test/test_setup_bad.py
index d715f57a..cbca3c21 100755
--- a/binary_search_tool/test/test_setup_bad.py
+++ b/binary_search_tool/test/test_setup_bad.py
@@ -1,4 +1,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
"""Emulate test setup that fails (i.e. failed flash to device)"""
from __future__ import print_function