aboutsummaryrefslogtreecommitdiff
path: root/binary_search_tool/test
diff options
context:
space:
mode:
authorCassidy Burden <cburden@google.com>2016-06-07 13:44:35 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-06-08 16:19:44 -0700
commitbccc576843ee27fefda5094afc88489f4cbff3ff (patch)
tree8039f8c8150cc16e3af3ad5fa74402343f562919 /binary_search_tool/test
parent42c64464b643df152c0f761fff4e7f6e257c27d5 (diff)
downloadtoolchain-utils-bccc576843ee27fefda5094afc88489f4cbff3ff.tar.gz
Add install_script argument to binary search tool.
Add optional install_script argument that will run before test_script use this install_script to perform building/flashing/other misc. setup. If your build or flash succeeds then return 0, otherwise return 1 and this build will be "skipped" (equivalent to the test script returning a 2 exit code). Test=Update unit tests to test for successful and failed install Change-Id: Ic492f08230796f50b7bb93aebe078960419a3c99 Reviewed-on: https://chrome-internal-review.googlesource.com/262988 Commit-Ready: Cassidy Burden <cburden@google.com> Tested-by: Cassidy Burden <cburden@google.com> Reviewed-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'binary_search_tool/test')
-rwxr-xr-xbinary_search_tool/test/binary_search_tool_tester.py21
-rwxr-xr-xbinary_search_tool/test/common.py2
-rwxr-xr-xbinary_search_tool/test/install.py18
-rwxr-xr-xbinary_search_tool/test/install_bad.py15
-rwxr-xr-xbinary_search_tool/test/is_good.py2
5 files changed, 58 insertions, 0 deletions
diff --git a/binary_search_tool/test/binary_search_tool_tester.py b/binary_search_tool/test/binary_search_tool_tester.py
index 45ce0642..475680c6 100755
--- a/binary_search_tool/test/binary_search_tool_tester.py
+++ b/binary_search_tool/test/binary_search_tool_tester.py
@@ -42,7 +42,26 @@ class BisectingUtilsTest(unittest.TestCase):
'./switch_to_good.py', '--switch_to_bad', './switch_to_bad.py',
'--test_script', './is_good.py', '--prune', '--file_args']
binary_search_state.Main(args)
+ self.check_output()
+ def test_install_script(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',
+ '--install_script', './install.py']
+ common.installed = False
+ binary_search_state.Main(args)
+ self.check_output()
+
+ def test_bad_install_script(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',
+ '--install_script', './install_bad.py']
+ with self.assertRaises(AssertionError):
+ binary_search_state.Main(args)
+
+ def check_output(self):
_, out, _ = command_executer.GetCommandExecuter().RunCommandWOutput(
'tail -n 10 logs/binary_search_state.py.out')
ls = out.splitlines()
@@ -63,6 +82,8 @@ def Main(argv):
suite = unittest.TestSuite()
for _ in range(0, num_tests):
suite.addTest(BisectingUtilsTest())
+ suite.addTest(BisectingUtilsTest('test_install_script'))
+ suite.addTest(BisectingUtilsTest('test_bad_install_script'))
runner = unittest.TextTestRunner()
runner.run(suite)
diff --git a/binary_search_tool/test/common.py b/binary_search_tool/test/common.py
index baac9434..382274b9 100755
--- a/binary_search_tool/test/common.py
+++ b/binary_search_tool/test/common.py
@@ -6,6 +6,8 @@ DEFAULT_BAD_OBJECT_NUMBER = 23
OBJECTS_FILE = 'objects.txt'
WORKING_SET_FILE = 'working_set.txt'
+installed = True
+
def ReadWorkingSet():
working_set = []
diff --git a/binary_search_tool/test/install.py b/binary_search_tool/test/install.py
new file mode 100755
index 00000000..21cf97a1
--- /dev/null
+++ b/binary_search_tool/test/install.py
@@ -0,0 +1,18 @@
+#!/usr/bin/python2
+"""Emulate installation of files, is_good.py should fail without this."""
+
+from __future__ import print_function
+
+import sys
+
+import common
+
+
+def Main():
+ common.installed = True
+ return 0
+
+
+if __name__ == '__main__':
+ retval = Main()
+ sys.exit(retval)
diff --git a/binary_search_tool/test/install_bad.py b/binary_search_tool/test/install_bad.py
new file mode 100755
index 00000000..8b49a3f8
--- /dev/null
+++ b/binary_search_tool/test/install_bad.py
@@ -0,0 +1,15 @@
+#!/usr/bin/python2
+"""Emulate installation that fails (i.e. failed flash to device)"""
+
+from __future__ import print_function
+
+import sys
+
+
+def Main():
+ return 1 ## False, flashing failure
+
+
+if __name__ == '__main__':
+ retval = Main()
+ sys.exit(retval)
diff --git a/binary_search_tool/test/is_good.py b/binary_search_tool/test/is_good.py
index 586d6911..e2ab4642 100755
--- a/binary_search_tool/test/is_good.py
+++ b/binary_search_tool/test/is_good.py
@@ -9,6 +9,8 @@ import common
def Main():
+ if not common.installed:
+ return 1
working_set = common.ReadWorkingSet()
for w in working_set:
if w == 1: