• Home
  • Raw
  • Download

Lines Matching refs:self

188   def test_init(self):  argument
189 target_info = common.BuildInfo(self.TEST_INFO_DICT, None)
190 self.assertEqual('product-device', target_info.device)
191 self.assertEqual('build-fingerprint', target_info.fingerprint)
192 self.assertFalse(target_info.is_ab)
193 self.assertIsNone(target_info.oem_props)
195 def test_init_with_oem_props(self): argument
196 target_info = common.BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS,
197 self.TEST_OEM_DICTS)
198 self.assertEqual('device1', target_info.device)
199 self.assertEqual('brand1/product-name/device1:build-thumbprint',
203 oem_dicts = copy.copy(self.TEST_OEM_DICTS)
205 target_info = common.BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS,
207 self.assertEqual('device3', target_info.device)
208 self.assertEqual('brand3/product-name/device3:build-thumbprint',
211 def test_init_badFingerprint(self): argument
212 info_dict = copy.deepcopy(self.TEST_INFO_DICT)
215 self.assertRaises(ValueError, common.BuildInfo, info_dict, None)
219 self.assertRaises(ValueError, common.BuildInfo, info_dict, None)
221 def test_init_goodFingerprint(self): argument
222 info_dict = copy.deepcopy(self.TEST_INFO_FINGERPRINT_DICT)
224 self.assertEqual(
232 self.assertEqual(
237 self.assertRaises(common.ExternalError, common.BuildInfo, info_dict, None,
243 self.assertEqual(
248 def test___getitem__(self): argument
249 target_info = common.BuildInfo(self.TEST_INFO_DICT, None)
250 self.assertEqual('value1', target_info['property1'])
251 self.assertEqual(4096, target_info['property2'])
252 self.assertEqual('build-foo',
255 def test___getitem__with_oem_props(self): argument
256 target_info = common.BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS,
257 self.TEST_OEM_DICTS)
258 self.assertEqual('value1', target_info['property1'])
259 self.assertEqual(4096, target_info['property2'])
260 self.assertIsNone(target_info['build.prop'].GetProp('ro.build.foo'))
262 def test___setitem__(self): argument
263 target_info = common.BuildInfo(copy.deepcopy(self.TEST_INFO_DICT), None)
264 self.assertEqual('value1', target_info['property1'])
266 self.assertEqual('value2', target_info['property1'])
268 self.assertEqual('build-foo',
271 self.assertEqual('build-bar',
274 def test_get(self): argument
275 target_info = common.BuildInfo(self.TEST_INFO_DICT, None)
276 self.assertEqual('value1', target_info.get('property1'))
277 self.assertEqual(4096, target_info.get('property2'))
278 self.assertEqual(4096, target_info.get('property2', 1024))
279 self.assertEqual(1024, target_info.get('property-nonexistent', 1024))
280 self.assertEqual('build-foo',
283 def test_get_with_oem_props(self): argument
284 target_info = common.BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS,
285 self.TEST_OEM_DICTS)
286 self.assertEqual('value1', target_info.get('property1'))
287 self.assertEqual(4096, target_info.get('property2'))
288 self.assertEqual(4096, target_info.get('property2', 1024))
289 self.assertEqual(1024, target_info.get('property-nonexistent', 1024))
290 self.assertIsNone(target_info.get('build.prop').GetProp('ro.build.foo'))
292 def test_items(self): argument
293 target_info = common.BuildInfo(self.TEST_INFO_DICT, None)
295 self.assertIn(('property1', 'value1'), items)
296 self.assertIn(('property2', 4096), items)
298 def test_GetBuildProp(self): argument
299 target_info = common.BuildInfo(self.TEST_INFO_DICT, None)
300 self.assertEqual('build-foo', target_info.GetBuildProp('ro.build.foo'))
301 self.assertRaises(common.ExternalError, target_info.GetBuildProp,
304 def test_GetBuildProp_with_oem_props(self): argument
305 target_info = common.BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS,
306 self.TEST_OEM_DICTS)
307 self.assertEqual('build-bar', target_info.GetBuildProp('ro.build.bar'))
308 self.assertRaises(common.ExternalError, target_info.GetBuildProp,
311 def test_GetPartitionFingerprint(self): argument
312 target_info = common.BuildInfo(self.TEST_INFO_DICT, None)
313 self.assertEqual(
319 def test_GetPartitionFingerprint_system_other_uses_system(self): argument
320 target_info = common.BuildInfo(self.TEST_INFO_DICT, None)
321 self.assertEqual(
325 def test_GetPartitionFingerprint_uses_fingerprint_prop_if_available(self): argument
326 info_dict = copy.deepcopy(self.TEST_INFO_DICT)
330 self.assertEqual(
334 def test_WriteMountOemScript(self): argument
335 target_info = common.BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS,
336 self.TEST_OEM_DICTS)
339 self.assertEqual([('Mount', '/oem', None)], script_writer.lines)
341 def test_WriteDeviceAssertions(self): argument
342 target_info = common.BuildInfo(self.TEST_INFO_DICT, None)
345 self.assertEqual([('AssertDevice', 'product-device')], script_writer.lines)
347 def test_WriteDeviceAssertions_with_oem_props(self): argument
348 target_info = common.BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS,
349 self.TEST_OEM_DICTS)
352 self.assertEqual(
361 def test_ResolveRoProductProperty_FromVendor(self): argument
362 info_dict = copy.deepcopy(self.TEST_INFO_DICT_PROPERTY_SOURCE_ORDER)
364 self.assertEqual('vendor-product-device',
367 def test_ResolveRoProductProperty_FromSystem(self): argument
368 info_dict = copy.deepcopy(self.TEST_INFO_DICT_PROPERTY_SOURCE_ORDER)
371 self.assertEqual('system-product-device',
374 def test_ResolveRoProductProperty_InvalidPropertySearchOrder(self): argument
375 info_dict = copy.deepcopy(self.TEST_INFO_DICT_PROPERTY_SOURCE_ORDER)
378 with self.assertRaisesRegexp(common.ExternalError,
383 def test_ResolveRoProductProperty_Android10PropertySearchOrder(self): argument
385 self.TEST_INFO_DICT_PROPERTY_SOURCE_ORDER_ANDROID_10)
387 self.assertEqual('vendor-product-device',
390 def test_ResolveRoProductProperty_Android9PropertySearchOrder(self): argument
392 self.TEST_INFO_DICT_PROPERTY_SOURCE_ORDER_ANDROID_9)
394 self.assertEqual('product-device',
400 def _verify(self, zip_file, zip_file_name, arcname, expected_hash, argument
406 self.assertEqual(int(expected_stat.st_mode), int(new_stat.st_mode))
407 self.assertEqual(int(expected_stat.st_mtime), int(new_stat.st_mtime))
414 self.assertEqual(info.date_time, (2009, 1, 1, 0, 0, 0))
418 self.assertEqual(mode, expected_mode)
421 self.assertEqual(info.compress_type, expected_compress_type)
428 self.assertEqual(expected_hash, sha1_hash.hexdigest())
429 self.assertIsNone(zip_file.testzip())
431 def _test_ZipWrite(self, contents, extra_zipwrite_args=None): argument
464 self._verify(zip_file, zip_file_name, arcname, sha1_hash.hexdigest(),
471 def _test_ZipWriteStr(self, zinfo_or_arcname, contents, extra_args=None): argument
499 self._verify(zip_file, zip_file_name, arcname, sha1(contents).hexdigest(),
505 def _test_ZipWriteStr_large_file(self, large, small, extra_args=None): argument
542 self._verify(zip_file, zip_file_name, arcname_large,
547 self._verify(zip_file, zip_file_name, arcname_small,
554 def _test_reset_ZIP64_LIMIT(self, func, *args): argument
556 self.assertEqual(default_limit, zipfile.ZIP64_LIMIT)
558 self.assertEqual(default_limit, zipfile.ZIP64_LIMIT)
560 def test_ZipWrite(self): argument
562 self._test_ZipWrite(file_contents)
564 def test_ZipWrite_with_opts(self): argument
566 self._test_ZipWrite(file_contents, {
571 self._test_ZipWrite(file_contents, {
577 def test_ZipWrite_large_file(self): argument
579 self._test_ZipWrite(file_contents, {
583 def test_ZipWrite_resets_ZIP64_LIMIT(self): argument
584 self._test_reset_ZIP64_LIMIT(self._test_ZipWrite, "")
586 def test_ZipWriteStr(self): argument
589 self._test_ZipWriteStr("foo", random_string)
593 self._test_ZipWriteStr(zinfo, random_string)
597 self._test_ZipWriteStr(zinfo, random_string)
599 def test_ZipWriteStr_with_opts(self): argument
602 self._test_ZipWriteStr("foo", random_string, {
606 self._test_ZipWriteStr("bar", random_string, {
612 self._test_ZipWriteStr(zinfo, random_string, {
615 self._test_ZipWriteStr(zinfo, random_string, {
619 self._test_ZipWriteStr(zinfo, random_string, {
624 def test_ZipWriteStr_large_file(self): argument
630 self._test_ZipWriteStr_large_file(long_string, short_string, {
634 def test_ZipWriteStr_resets_ZIP64_LIMIT(self): argument
635 self._test_reset_ZIP64_LIMIT(self._test_ZipWriteStr, 'foo', b'')
637 self._test_reset_ZIP64_LIMIT(self._test_ZipWriteStr, zinfo, b'')
639 def test_bug21309935(self): argument
661 self._verify(zip_file, zip_file_name, "foo",
664 self._verify(zip_file, zip_file_name, "bar",
667 self._verify(zip_file, zip_file_name, "baz",
670 self._verify(zip_file, zip_file_name, "qux",
677 def test_ZipDelete(self): argument
693 self.assertTrue('Test1' in entries)
694 self.assertFalse('Test2' in entries)
695 self.assertTrue('Test3' in entries)
697 self.assertRaises(
701 self.assertTrue('Test1' in entries)
702 self.assertFalse('Test2' in entries)
703 self.assertTrue('Test3' in entries)
708 self.assertTrue('Test1' in entries)
709 self.assertFalse('Test2' in entries)
710 self.assertFalse('Test3' in entries)
715 self.assertFalse('Test1' in entries)
716 self.assertFalse('Test2' in entries)
717 self.assertFalse('Test3' in entries)
739 def test_UnzipTemp(self): argument
740 zip_file = self._test_UnzipTemp_createZipFile()
742 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Test1')))
743 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Test2')))
744 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Foo3')))
745 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Bar4')))
746 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Dir5/Baz5')))
749 def test_UnzipTemp_withPatterns(self): argument
750 zip_file = self._test_UnzipTemp_createZipFile()
753 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Test1')))
754 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Test2')))
755 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Foo3')))
756 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Bar4')))
757 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Dir5/Baz5')))
760 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Test1')))
761 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Test2')))
762 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Foo3')))
763 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Bar4')))
764 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Dir5/Baz5')))
767 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Test1')))
768 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Test2')))
769 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Foo3')))
770 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Bar4')))
771 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Dir5/Baz5')))
774 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Test1')))
775 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Test2')))
776 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Foo3')))
777 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Bar4')))
778 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Dir5/Baz5')))
780 def test_UnzipTemp_withEmptyPatterns(self): argument
781 zip_file = self._test_UnzipTemp_createZipFile()
783 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Test1')))
784 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Test2')))
785 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Foo3')))
786 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Bar4')))
787 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Dir5/Baz5')))
790 def test_UnzipTemp_withPartiallyMatchingPatterns(self): argument
791 zip_file = self._test_UnzipTemp_createZipFile()
793 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Test1')))
794 self.assertTrue(os.path.exists(os.path.join(unzipped_dir, 'Test2')))
795 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Foo3')))
796 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Bar4')))
797 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Dir5/Baz5')))
799 def test_UnzipTemp_withNoMatchingPatterns(self): argument
800 zip_file = self._test_UnzipTemp_createZipFile()
802 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Test1')))
803 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Test2')))
804 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Foo3')))
805 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Bar4')))
806 self.assertFalse(os.path.exists(os.path.join(unzipped_dir, 'Dir5/Baz5')))
873 def setUp(self): argument
874 self.testdata_dir = test_utils.get_testdata_dir()
887 def test_ReadApkCerts_NoncompressedApks(self): argument
888 target_files = self._write_apkcerts_txt(self.APKCERTS_TXT1)
892 self.assertDictEqual(self.APKCERTS_CERTMAP1, certmap)
893 self.assertIsNone(ext)
895 def test_ReadApkCerts_CompressedApks(self): argument
898 target_files = self._write_apkcerts_txt(
899 self.APKCERTS_TXT2,
905 self.assertDictEqual(self.APKCERTS_CERTMAP2, certmap)
906 self.assertEqual('.gz', ext)
909 target_files = self._write_apkcerts_txt(
910 self.APKCERTS_TXT3, ['Compressed4.apk.xz'])
915 self.assertDictEqual(self.APKCERTS_CERTMAP3, certmap)
916 self.assertEqual('.xz', ext)
918 def test_ReadApkCerts_CompressedAndNoncompressedApks(self): argument
919 target_files = self._write_apkcerts_txt(
920 self.APKCERTS_TXT1 + self.APKCERTS_TXT2,
926 certmap_merged = self.APKCERTS_CERTMAP1.copy()
927 certmap_merged.update(self.APKCERTS_CERTMAP2)
928 self.assertDictEqual(certmap_merged, certmap)
929 self.assertEqual('.gz', ext)
931 def test_ReadApkCerts_MultipleCompressionMethods(self): argument
932 target_files = self._write_apkcerts_txt(
933 self.APKCERTS_TXT2 + self.APKCERTS_TXT3,
937 self.assertRaises(ValueError, common.ReadApkCerts, input_zip)
939 def test_ReadApkCerts_MismatchingKeys(self): argument
944 target_files = self._write_apkcerts_txt(malformed_apkcerts_txt)
947 self.assertRaises(ValueError, common.ReadApkCerts, input_zip)
949 def test_ReadApkCerts_WithWithoutOptionalFields(self): argument
950 target_files = self._write_apkcerts_txt(self.APKCERTS_TXT4)
954 self.assertDictEqual(self.APKCERTS_CERTMAP4, certmap)
955 self.assertIsNone(ext)
957 def test_ExtractPublicKey(self): argument
958 cert = os.path.join(self.testdata_dir, 'testkey.x509.pem')
959 pubkey = os.path.join(self.testdata_dir, 'testkey.pubkey.pem')
961 self.assertEqual(pubkey_fp.read(), common.ExtractPublicKey(cert))
963 def test_ExtractPublicKey_invalidInput(self): argument
964 wrong_input = os.path.join(self.testdata_dir, 'testkey.pk8')
965 self.assertRaises(AssertionError, common.ExtractPublicKey, wrong_input)
968 def test_ExtractAvbPublicKey(self): argument
969 privkey = os.path.join(self.testdata_dir, 'testkey.key')
970 pubkey = os.path.join(self.testdata_dir, 'testkey.pubkey.pem')
975 self.assertEqual(privkey_fp.read(), pubkey_fp.read())
977 def test_ParseCertificate(self): argument
978 cert = os.path.join(self.testdata_dir, 'testkey.x509.pem')
984 self.assertEqual(0, proc.returncode)
988 self.assertEqual(expected, actual)
991 def test_GetMinSdkVersion(self): argument
992 test_app = os.path.join(self.testdata_dir, 'TestApp.apk')
993 self.assertEqual('24', common.GetMinSdkVersion(test_app))
996 def test_GetMinSdkVersion_invalidInput(self): argument
997 self.assertRaises(
1001 def test_GetMinSdkVersionInt(self): argument
1002 test_app = os.path.join(self.testdata_dir, 'TestApp.apk')
1003 self.assertEqual(24, common.GetMinSdkVersionInt(test_app, {}))
1006 def test_GetMinSdkVersionInt_invalidInput(self): argument
1007 self.assertRaises(
1014 def setUp(self): argument
1015 self.testdata_dir = test_utils.get_testdata_dir()
1018 def test_GetSparseImage_emptyBlockMapFile(self): argument
1035 self.assertDictEqual(
1042 def test_PartitionMapFromTargetFiles(self): argument
1051 self.assertDictEqual(
1063 def test_SharedUidPartitionViolations(self): argument
1076 self.assertEqual(errors, [])
1078 def test_SharedUidPartitionViolations_Violation(self): argument
1087 self.assertIn(
1091 def test_GetSparseImage_missingImageFile(self): argument
1092 self.assertRaises(
1093 AssertionError, common.GetSparseImage, 'system2', self.testdata_dir,
1095 self.assertRaises(
1096 AssertionError, common.GetSparseImage, 'unknown', self.testdata_dir,
1100 def test_GetSparseImage_missingBlockMapFile(self): argument
1114 self.assertRaises(
1119 def test_GetSparseImage_sharedBlocks_notAllowed(self): argument
1137 self.assertRaises(
1142 def test_GetSparseImage_sharedBlocks_allowed(self): argument
1163 self.assertDictEqual(
1174 self.assertTrue(
1176 self.assertNotIn(
1180 self.assertEqual(1, len(sparse_image.file_map['/system/file1'].extra))
1183 self.assertFalse(sparse_image.file_map['__COPY'].extra)
1184 self.assertFalse(sparse_image.file_map['__NONZERO-0'].extra)
1187 def test_GetSparseImage_incompleteRanges(self): argument
1207 self.assertEqual(
1210 self.assertTrue(sparse_image.file_map['/system/file2'].extra['incomplete'])
1213 def test_GetSparseImage_systemRootImage_filenameWithExtraLeadingSlash(self): argument
1235 self.assertEqual(
1238 self.assertTrue(sparse_image.file_map['//system/file2'].extra['incomplete'])
1239 self.assertTrue(
1243 def test_GetSparseImage_systemRootImage_nonSystemFiles(self): argument
1262 self.assertEqual(
1265 self.assertTrue(sparse_image.file_map['//init.rc'].extra['incomplete'])
1268 def test_GetSparseImage_fileNotFound(self): argument
1283 self.assertRaises(
1288 def test_GetAvbChainedPartitionArg(self): argument
1289 pubkey = os.path.join(self.testdata_dir, 'testkey.pubkey.pem')
1296 self.assertEqual(3, len(args))
1297 self.assertEqual('system', args[0])
1298 self.assertEqual('2', args[1])
1299 self.assertTrue(os.path.exists(args[2]))
1302 def test_GetAvbChainedPartitionArg_withPrivateKey(self): argument
1303 key = os.path.join(self.testdata_dir, 'testkey.key')
1310 self.assertEqual(3, len(args))
1311 self.assertEqual('product', args[0])
1312 self.assertEqual('2', args[1])
1313 self.assertTrue(os.path.exists(args[2]))
1316 def test_GetAvbChainedPartitionArg_withSpecifiedKey(self): argument
1322 pubkey = os.path.join(self.testdata_dir, 'testkey.pubkey.pem')
1325 self.assertEqual(3, len(args))
1326 self.assertEqual('system', args[0])
1327 self.assertEqual('2', args[1])
1328 self.assertTrue(os.path.exists(args[2]))
1331 def test_GetAvbChainedPartitionArg_invalidKey(self): argument
1332 pubkey = os.path.join(self.testdata_dir, 'testkey_with_passwd.x509.pem')
1338 self.assertRaises(
1350 def test_LoadListFromFile(self): argument
1351 file_path = os.path.join(self.testdata_dir,
1365 self.assertEqual(sorted(contents), sorted(expected_contents))
1386 def test_LoadInfoDict(self): argument
1387 target_files = self._test_LoadInfoDict_createTargetFiles(
1388 self.INFO_DICT_DEFAULT,
1392 self.assertEqual(3, loaded_dict['recovery_api_version'])
1393 self.assertEqual(2, loaded_dict['fstab_version'])
1394 self.assertIn('/', loaded_dict['fstab'])
1395 self.assertIn('/system', loaded_dict['fstab'])
1397 def test_LoadInfoDict_legacyRecoveryFstabPath(self): argument
1398 target_files = self._test_LoadInfoDict_createTargetFiles(
1399 self.INFO_DICT_DEFAULT,
1403 self.assertEqual(3, loaded_dict['recovery_api_version'])
1404 self.assertEqual(2, loaded_dict['fstab_version'])
1405 self.assertIn('/', loaded_dict['fstab'])
1406 self.assertIn('/system', loaded_dict['fstab'])
1409 def test_LoadInfoDict_dirInput(self): argument
1410 target_files = self._test_LoadInfoDict_createTargetFiles(
1411 self.INFO_DICT_DEFAULT,
1415 self.assertEqual(3, loaded_dict['recovery_api_version'])
1416 self.assertEqual(2, loaded_dict['fstab_version'])
1417 self.assertIn('/', loaded_dict['fstab'])
1418 self.assertIn('/system', loaded_dict['fstab'])
1421 def test_LoadInfoDict_dirInput_legacyRecoveryFstabPath(self): argument
1422 target_files = self._test_LoadInfoDict_createTargetFiles(
1423 self.INFO_DICT_DEFAULT,
1427 self.assertEqual(3, loaded_dict['recovery_api_version'])
1428 self.assertEqual(2, loaded_dict['fstab_version'])
1429 self.assertIn('/', loaded_dict['fstab'])
1430 self.assertIn('/system', loaded_dict['fstab'])
1432 def test_LoadInfoDict_systemRootImageFalse(self): argument
1435 info_dict = copy.copy(self.INFO_DICT_DEFAULT)
1439 target_files = self._test_LoadInfoDict_createTargetFiles(
1444 self.assertEqual(3, loaded_dict['recovery_api_version'])
1445 self.assertEqual(2, loaded_dict['fstab_version'])
1446 self.assertNotIn('/', loaded_dict['fstab'])
1447 self.assertIn('/system', loaded_dict['fstab'])
1449 def test_LoadInfoDict_recoveryAsBootFalse(self): argument
1452 info_dict = copy.copy(self.INFO_DICT_DEFAULT)
1455 target_files = self._test_LoadInfoDict_createTargetFiles(
1460 self.assertEqual(3, loaded_dict['recovery_api_version'])
1461 self.assertEqual(2, loaded_dict['fstab_version'])
1462 self.assertIn('/', loaded_dict['fstab'])
1463 self.assertIn('/system', loaded_dict['fstab'])
1465 def test_LoadInfoDict_noRecoveryTrue(self): argument
1467 info_dict = copy.copy(self.INFO_DICT_DEFAULT)
1469 target_files = self._test_LoadInfoDict_createTargetFiles(
1474 self.assertEqual(3, loaded_dict['recovery_api_version'])
1475 self.assertEqual(2, loaded_dict['fstab_version'])
1476 self.assertIsNone(loaded_dict['fstab'])
1479 def test_LoadInfoDict_missingMetaMiscInfoTxt(self): argument
1480 target_files = self._test_LoadInfoDict_createTargetFiles(
1481 self.INFO_DICT_DEFAULT,
1485 self.assertRaises(ValueError, common.LoadInfoDict, target_files_zip)
1488 def test_LoadInfoDict_repacking(self): argument
1489 target_files = self._test_LoadInfoDict_createTargetFiles(
1490 self.INFO_DICT_DEFAULT,
1494 self.assertEqual(3, loaded_dict['recovery_api_version'])
1495 self.assertEqual(2, loaded_dict['fstab_version'])
1496 self.assertIn('/', loaded_dict['fstab'])
1497 self.assertIn('/system', loaded_dict['fstab'])
1498 self.assertEqual(
1500 self.assertEqual(
1504 def test_LoadInfoDict_repackingWithZipFileInput(self): argument
1505 target_files = self._test_LoadInfoDict_createTargetFiles(
1506 self.INFO_DICT_DEFAULT,
1509 self.assertRaises(
1512 def test_MergeDynamicPartitionInfoDicts_ReturnsMergedDict(self): argument
1544 self.assertEqual(merged_dict, expected_merged_dict)
1546 def test_MergeDynamicPartitionInfoDicts_IgnoringFrameworkGroupSize(self): argument
1575 self.assertEqual(merged_dict, expected_merged_dict)
1577 def test_GetAvbPartitionArg(self): argument
1580 self.assertEqual(
1584 def test_AppendVBMetaArgsForPartition_vendorAsChainedPartition(self): argument
1593 self.assertEqual(2, len(cmd))
1594 self.assertEqual('--chain_partition', cmd[0])
1596 self.assertEqual(3, len(chained_partition_args))
1597 self.assertEqual('vendor', chained_partition_args[0])
1598 self.assertEqual('5', chained_partition_args[1])
1599 self.assertTrue(os.path.exists(chained_partition_args[2]))
1602 def test_AppendVBMetaArgsForPartition_recoveryAsChainedPartition_nonAb(self): argument
1612 self.assertFalse(cmd)
1615 def test_AppendVBMetaArgsForPartition_recoveryAsChainedPartition_ab(self): argument
1626 self.assertEqual(2, len(cmd))
1627 self.assertEqual('--chain_partition', cmd[0])
1629 self.assertEqual(3, len(chained_partition_args))
1630 self.assertEqual('recovery', chained_partition_args[0])
1631 self.assertEqual('3', chained_partition_args[1])
1632 self.assertTrue(os.path.exists(chained_partition_args[2]))
1634 def test_BuildVBMeta_appendAftlCommandSyntax(self): argument
1670 self.assertEqual(cmd[:3], expected_cmd[:3])
1671 self.assertEqual(cmd[4:], expected_cmd[4:])
1674 def test_BuildVBMeta_appendAftlContactServer(self): argument
1717 def test_AppendGkiSigningArgs_NoSigningKeyPath(self): argument
1730 self.assertEqual(cmd, expected_cmd)
1732 def test_AppendGkiSigningArgs_NoSigningAlgorithm(self): argument
1733 pubkey = os.path.join(self.testdata_dir, 'testkey_gki.pem')
1736 self.assertTrue(os.path.exists(pubkey))
1749 self.assertEqual(cmd, expected_cmd)
1752 def test_AppendGkiSigningArgs(self): argument
1753 pubkey = os.path.join(self.testdata_dir, 'testkey_gki.pem')
1756 self.assertTrue(os.path.exists(pubkey))
1772 self.assertEqual(cmd, expected_cmd)
1775 def test_AppendGkiSigningArgs_KeyPathNotFound(self): argument
1776 pubkey = os.path.join(self.testdata_dir, 'no_testkey_gki.pem')
1777 self.assertFalse(os.path.exists(pubkey))
1785 self.assertRaises(common.ExternalError, common.AppendGkiSigningArgs, cmd)
1788 def test_AppendGkiSigningArgs_SearchKeyPath(self): argument
1790 self.assertFalse(os.path.exists(pubkey))
1798 self.assertTrue(os.path.exists(search_pubkey))
1815 self.assertEqual(cmd, expected_cmd)
1818 def test_AppendGkiSigningArgs_SearchKeyPathNotFound(self): argument
1820 self.assertFalse(os.path.exists(pubkey))
1826 self.assertFalse(os.path.exists(search_pubkey))
1835 self.assertRaises(common.ExternalError, common.AppendGkiSigningArgs, cmd)
1844 def setUp(self): argument
1845 self._tempdir = common.MakeTempDir()
1847 self._info = {"fstab" : {}}
1851 self._info["fstab"] = common.LoadRecoveryFSTab("\n".join, 2, fake_fstab)
1853 self.recovery_data = bytearray([
1859 self.boot_data = bytearray([
1864 def _out_tmp_sink(self, name, data, prefix="SYSTEM"): argument
1865 loc = os.path.join(self._tempdir, prefix, name)
1871 def test_full_recovery(self): argument
1872 recovery_image = common.File("recovery.img", self.recovery_data)
1873 boot_image = common.File("boot.img", self.boot_data)
1874 self._info["full_recovery_image"] = "true"
1876 common.MakeRecoveryPatch(self._tempdir, self._out_tmp_sink,
1877 recovery_image, boot_image, self._info)
1878 validate_target_files.ValidateInstallRecoveryScript(self._tempdir,
1879 self._info)
1882 def test_recovery_from_boot(self): argument
1883 recovery_image = common.File("recovery.img", self.recovery_data)
1884 self._out_tmp_sink("recovery.img", recovery_image.data, "IMAGES")
1885 boot_image = common.File("boot.img", self.boot_data)
1886 self._out_tmp_sink("boot.img", boot_image.data, "IMAGES")
1888 common.MakeRecoveryPatch(self._tempdir, self._out_tmp_sink,
1889 recovery_image, boot_image, self._info)
1890 validate_target_files.ValidateInstallRecoveryScript(self._tempdir,
1891 self._info)
1893 self._out_tmp_sink("etc/recovery-resource.dat", b"bonus", "SYSTEM")
1894 common.MakeRecoveryPatch(self._tempdir, self._out_tmp_sink,
1895 recovery_image, boot_image, self._info)
1896 validate_target_files.ValidateInstallRecoveryScript(self._tempdir,
1897 self._info)
1902 def __init__(self, partition, tgt, src=None): argument
1903 self.partition = partition
1904 self.tgt = tgt
1905 self.src = src
1907 def WriteScript(self, script, _, progress=None, argument
1911 script.AppendExtra("patch({});".format(self.partition))
1913 self.WritePostInstallVerifyScript(script)
1915 def WritePostInstallVerifyScript(self, script): argument
1916 script.AppendExtra("verify({});".format(self.partition))
1921 def __init__(self, size): argument
1922 self.blocksize = 4096
1923 self.total_blocks = size // 4096
1936 def setUp(self): argument
1937 self.script = test_utils.MockScriptWriter()
1938 self.output_path = common.MakeTempFile(suffix='.zip')
1940 def test_full(self): argument
1951 with zipfile.ZipFile(self.output_path, 'w', allowZip64=True) as output_zip:
1952 dp_diff.WriteScript(self.script, output_zip, write_verify_script=True)
1954 self.assertEqual(str(self.script).strip(), """
1964 lines = self.get_op_list(self.output_path)
1973 self.assertLess(remove_all_groups, add_group,
1975 self.assertLess(add_group, min(add_vendor, add_system),
1977 self.assertLess(add_system, resize_system,
1979 self.assertLess(add_vendor, resize_vendor,
1982 def test_inc_groups(self): argument
1999 with zipfile.ZipFile(self.output_path, 'w', allowZip64=True) as output_zip:
2000 dp_diff.WriteScript(self.script, output_zip, write_verify_script=True)
2002 lines = self.get_op_list(self.output_path)
2009 self.assertLess(max(removed, shrunk),
2014 def test_incremental(self): argument
2043 with zipfile.ZipFile(self.output_path, 'w', allowZip64=True) as output_zip:
2044 dp_diff.WriteScript(self.script, output_zip, write_verify_script=True)
2046 metadata_idx = self.script.lines.index(
2049 self.assertLess(self.script.lines.index('patch(vendor);'), metadata_idx)
2050 self.assertLess(metadata_idx, self.script.lines.index('verify(vendor);'))
2052 patch_idx = self.script.lines.index("patch({});".format(p))
2053 verify_idx = self.script.lines.index("verify({});".format(p))
2054 self.assertLess(metadata_idx, patch_idx,
2056 self.assertLess(patch_idx, verify_idx,
2059 self.assertNotIn("patch(system_ext);", self.script.lines)
2061 lines = self.get_op_list(self.output_path)
2076 self.assertLess(max_idx_move_partition_out_foo, shrink_group,
2080 self.assertLess(add_group_bar, move_product_in,
2083 self.assertLess(max_idx_move_partition_out_foo,
2088 def test_remove_partition(self): argument
2114 with zipfile.ZipFile(self.output_path, 'w', allowZip64=True) as output_zip:
2115 dp_diff.WriteScript(self.script, output_zip, write_verify_script=True)
2117 self.assertNotIn("block_image_update", str(self.script),
2120 lines = self.get_op_list(self.output_path)
2121 self.assertEqual(lines, ["remove foo"])
2125 def setUp(self): argument
2126 self.odm_build_prop = [
2143 def test_parseBuildProps_noImportStatement(self): argument
2150 input_file = self._BuildZipFile({
2161 self.assertEqual({
2168 self.assertEqual(set(), partition_props.prop_overrides)
2170 def test_parseBuildProps_singleImportStatement(self): argument
2180 input_file = self._BuildZipFile({
2181 'ODM/etc/build.prop': '\n'.join(self.odm_build_prop),
2193 self.assertEqual({
2208 self.assertEqual({
2216 def test_parseBuildProps_noPlaceHolders(self): argument
2217 build_prop = copy.copy(self.odm_build_prop)
2218 input_file = self._BuildZipFile({
2226 self.assertEqual({
2233 self.assertEqual(set(), partition_props.prop_overrides)
2235 def test_parseBuildProps_multipleImportStatements(self): argument
2236 build_prop = copy.deepcopy(self.odm_build_prop)
2257 input_file = self._BuildZipFile({
2274 self.assertEqual({
2291 self.assertEqual({
2299 def test_parseBuildProps_defineAfterOverride(self): argument
2300 build_prop = copy.deepcopy(self.odm_build_prop)
2310 input_file = self._BuildZipFile({
2321 self.assertRaises(ValueError, common.PartitionBuildProps.FromInputFile,
2324 def test_parseBuildProps_duplicateOverride(self): argument
2325 build_prop = copy.deepcopy(self.odm_build_prop)
2345 input_file = self._BuildZipFile({
2358 self.assertRaises(ValueError, common.PartitionBuildProps.FromInputFile,