releasetools: Move build_image.RunCommand into common.py.

build_image.RunCommand and common.Run are essentially doing the same
work, but with different interfaces and return values. This CL
consolidates them by moving build_image.RunCommand into common.py as
common.RunAndCheckOutput, with the former calling common.Run internally.

common.RunAndCheckOutput checks the exit code: it returns the output
string on success, or raises common.ExternalError otherwise.

Test: `m dist` with aosp_marlin-userdebug
Test: python -m unittest test_build_image
Test: python -m unittest test_common
Change-Id: I3cd0e9301c576572194618eba8dc00db06c3c35f
This commit is contained in:
Tao Bao
2018-10-04 15:46:16 -07:00
parent 0443b46066
commit 986ee86854
4 changed files with 84 additions and 142 deletions

View File

@@ -334,8 +334,8 @@ class CommonZipTest(unittest.TestCase):
self.assertFalse('Test2' in entries)
self.assertTrue('Test3' in entries)
self.assertRaises(AssertionError, common.ZipDelete, zip_file.name,
'Test2')
self.assertRaises(
common.ExternalError, common.ZipDelete, zip_file.name, 'Test2')
with zipfile.ZipFile(zip_file.name, 'r') as check_zip:
entries = check_zip.namelist()
self.assertTrue('Test1' in entries)
@@ -782,7 +782,8 @@ class CommonUtilsTest(unittest.TestCase):
'avb_system_rollback_index_location': 2,
}
self.assertRaises(
AssertionError, common.GetAvbChainedPartitionArg, 'system', info_dict)
common.ExternalError, common.GetAvbChainedPartitionArg, 'system',
info_dict)
INFO_DICT_DEFAULT = {
'recovery_api_version': 3,