Tao Bao | 481bab8 | 2017-12-21 11:23:09 -0800 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2018 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
| 17 | import copy |
| 18 | import unittest |
| 19 | |
| 20 | import common |
| 21 | from ota_from_target_files import ( |
Tao Bao | df3a48b | 2018-01-10 16:30:43 -0800 | [diff] [blame^] | 22 | _LoadOemDicts, BuildInfo, GetPackageMetadata, WriteFingerprintAssertion) |
Tao Bao | 481bab8 | 2017-12-21 11:23:09 -0800 | [diff] [blame] | 23 | |
| 24 | |
| 25 | class MockScriptWriter(object): |
| 26 | """A class that mocks edify_generator.EdifyGenerator. |
| 27 | |
| 28 | It simply pushes the incoming arguments onto script stack, which is to assert |
| 29 | the calls to EdifyGenerator functions. |
| 30 | """ |
| 31 | |
| 32 | def __init__(self): |
| 33 | self.script = [] |
| 34 | |
| 35 | def Mount(self, *args): |
| 36 | self.script.append(('Mount',) + args) |
| 37 | |
| 38 | def AssertDevice(self, *args): |
| 39 | self.script.append(('AssertDevice',) + args) |
| 40 | |
| 41 | def AssertOemProperty(self, *args): |
| 42 | self.script.append(('AssertOemProperty',) + args) |
| 43 | |
| 44 | def AssertFingerprintOrThumbprint(self, *args): |
| 45 | self.script.append(('AssertFingerprintOrThumbprint',) + args) |
| 46 | |
| 47 | def AssertSomeFingerprint(self, *args): |
| 48 | self.script.append(('AssertSomeFingerprint',) + args) |
| 49 | |
| 50 | def AssertSomeThumbprint(self, *args): |
| 51 | self.script.append(('AssertSomeThumbprint',) + args) |
| 52 | |
| 53 | |
| 54 | class BuildInfoTest(unittest.TestCase): |
| 55 | |
| 56 | TEST_INFO_DICT = { |
| 57 | 'build.prop' : { |
| 58 | 'ro.product.device' : 'product-device', |
| 59 | 'ro.product.name' : 'product-name', |
| 60 | 'ro.build.fingerprint' : 'build-fingerprint', |
| 61 | 'ro.build.foo' : 'build-foo', |
| 62 | }, |
| 63 | 'vendor.build.prop' : { |
| 64 | 'ro.vendor.build.fingerprint' : 'vendor-build-fingerprint', |
| 65 | }, |
| 66 | 'property1' : 'value1', |
| 67 | 'property2' : 4096, |
| 68 | } |
| 69 | |
| 70 | TEST_INFO_DICT_USES_OEM_PROPS = { |
| 71 | 'build.prop' : { |
| 72 | 'ro.product.name' : 'product-name', |
| 73 | 'ro.build.thumbprint' : 'build-thumbprint', |
| 74 | 'ro.build.bar' : 'build-bar', |
| 75 | }, |
| 76 | 'vendor.build.prop' : { |
| 77 | 'ro.vendor.build.fingerprint' : 'vendor-build-fingerprint', |
| 78 | }, |
| 79 | 'property1' : 'value1', |
| 80 | 'property2' : 4096, |
| 81 | 'oem_fingerprint_properties' : 'ro.product.device ro.product.brand', |
| 82 | } |
| 83 | |
| 84 | TEST_OEM_DICTS = [ |
| 85 | { |
| 86 | 'ro.product.brand' : 'brand1', |
| 87 | 'ro.product.device' : 'device1', |
| 88 | }, |
| 89 | { |
| 90 | 'ro.product.brand' : 'brand2', |
| 91 | 'ro.product.device' : 'device2', |
| 92 | }, |
| 93 | { |
| 94 | 'ro.product.brand' : 'brand3', |
| 95 | 'ro.product.device' : 'device3', |
| 96 | }, |
| 97 | ] |
| 98 | |
| 99 | def test_init(self): |
| 100 | target_info = BuildInfo(self.TEST_INFO_DICT, None) |
| 101 | self.assertEqual('product-device', target_info.device) |
| 102 | self.assertEqual('build-fingerprint', target_info.fingerprint) |
| 103 | self.assertFalse(target_info.is_ab) |
| 104 | self.assertIsNone(target_info.oem_props) |
| 105 | |
| 106 | def test_init_with_oem_props(self): |
| 107 | target_info = BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS, |
| 108 | self.TEST_OEM_DICTS) |
| 109 | self.assertEqual('device1', target_info.device) |
| 110 | self.assertEqual('brand1/product-name/device1:build-thumbprint', |
| 111 | target_info.fingerprint) |
| 112 | |
| 113 | # Swap the order in oem_dicts, which would lead to different BuildInfo. |
| 114 | oem_dicts = copy.copy(self.TEST_OEM_DICTS) |
| 115 | oem_dicts[0], oem_dicts[2] = oem_dicts[2], oem_dicts[0] |
| 116 | target_info = BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS, oem_dicts) |
| 117 | self.assertEqual('device3', target_info.device) |
| 118 | self.assertEqual('brand3/product-name/device3:build-thumbprint', |
| 119 | target_info.fingerprint) |
| 120 | |
| 121 | # Missing oem_dict should be rejected. |
| 122 | self.assertRaises(AssertionError, BuildInfo, |
| 123 | self.TEST_INFO_DICT_USES_OEM_PROPS, None) |
| 124 | |
| 125 | def test___getitem__(self): |
| 126 | target_info = BuildInfo(self.TEST_INFO_DICT, None) |
| 127 | self.assertEqual('value1', target_info['property1']) |
| 128 | self.assertEqual(4096, target_info['property2']) |
| 129 | self.assertEqual('build-foo', target_info['build.prop']['ro.build.foo']) |
| 130 | |
| 131 | def test___getitem__with_oem_props(self): |
| 132 | target_info = BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS, |
| 133 | self.TEST_OEM_DICTS) |
| 134 | self.assertEqual('value1', target_info['property1']) |
| 135 | self.assertEqual(4096, target_info['property2']) |
| 136 | self.assertRaises(KeyError, |
| 137 | lambda: target_info['build.prop']['ro.build.foo']) |
| 138 | |
| 139 | def test_get(self): |
| 140 | target_info = BuildInfo(self.TEST_INFO_DICT, None) |
| 141 | self.assertEqual('value1', target_info.get('property1')) |
| 142 | self.assertEqual(4096, target_info.get('property2')) |
| 143 | self.assertEqual(4096, target_info.get('property2', 1024)) |
| 144 | self.assertEqual(1024, target_info.get('property-nonexistent', 1024)) |
| 145 | self.assertEqual('build-foo', target_info.get('build.prop')['ro.build.foo']) |
| 146 | |
| 147 | def test_get_with_oem_props(self): |
| 148 | target_info = BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS, |
| 149 | self.TEST_OEM_DICTS) |
| 150 | self.assertEqual('value1', target_info.get('property1')) |
| 151 | self.assertEqual(4096, target_info.get('property2')) |
| 152 | self.assertEqual(4096, target_info.get('property2', 1024)) |
| 153 | self.assertEqual(1024, target_info.get('property-nonexistent', 1024)) |
| 154 | self.assertIsNone(target_info.get('build.prop').get('ro.build.foo')) |
| 155 | self.assertRaises(KeyError, |
| 156 | lambda: target_info.get('build.prop')['ro.build.foo']) |
| 157 | |
| 158 | def test_GetBuildProp(self): |
| 159 | target_info = BuildInfo(self.TEST_INFO_DICT, None) |
| 160 | self.assertEqual('build-foo', target_info.GetBuildProp('ro.build.foo')) |
| 161 | self.assertRaises(common.ExternalError, target_info.GetBuildProp, |
| 162 | 'ro.build.nonexistent') |
| 163 | |
| 164 | def test_GetBuildProp_with_oem_props(self): |
| 165 | target_info = BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS, |
| 166 | self.TEST_OEM_DICTS) |
| 167 | self.assertEqual('build-bar', target_info.GetBuildProp('ro.build.bar')) |
| 168 | self.assertRaises(common.ExternalError, target_info.GetBuildProp, |
| 169 | 'ro.build.nonexistent') |
| 170 | |
| 171 | def test_GetVendorBuildProp(self): |
| 172 | target_info = BuildInfo(self.TEST_INFO_DICT, None) |
| 173 | self.assertEqual('vendor-build-fingerprint', |
| 174 | target_info.GetVendorBuildProp( |
| 175 | 'ro.vendor.build.fingerprint')) |
| 176 | self.assertRaises(common.ExternalError, target_info.GetVendorBuildProp, |
| 177 | 'ro.build.nonexistent') |
| 178 | |
| 179 | def test_GetVendorBuildProp_with_oem_props(self): |
| 180 | target_info = BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS, |
| 181 | self.TEST_OEM_DICTS) |
| 182 | self.assertEqual('vendor-build-fingerprint', |
| 183 | target_info.GetVendorBuildProp( |
| 184 | 'ro.vendor.build.fingerprint')) |
| 185 | self.assertRaises(common.ExternalError, target_info.GetVendorBuildProp, |
| 186 | 'ro.build.nonexistent') |
| 187 | |
| 188 | def test_WriteMountOemScript(self): |
| 189 | target_info = BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS, |
| 190 | self.TEST_OEM_DICTS) |
| 191 | script_writer = MockScriptWriter() |
| 192 | target_info.WriteMountOemScript(script_writer) |
| 193 | self.assertEqual([('Mount', '/oem', None)], script_writer.script) |
| 194 | |
| 195 | def test_WriteDeviceAssertions(self): |
| 196 | target_info = BuildInfo(self.TEST_INFO_DICT, None) |
| 197 | script_writer = MockScriptWriter() |
| 198 | target_info.WriteDeviceAssertions(script_writer, False) |
| 199 | self.assertEqual([('AssertDevice', 'product-device')], script_writer.script) |
| 200 | |
| 201 | def test_WriteDeviceAssertions_with_oem_props(self): |
| 202 | target_info = BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS, |
| 203 | self.TEST_OEM_DICTS) |
| 204 | script_writer = MockScriptWriter() |
| 205 | target_info.WriteDeviceAssertions(script_writer, False) |
| 206 | self.assertEqual( |
| 207 | [ |
| 208 | ('AssertOemProperty', 'ro.product.device', |
| 209 | ['device1', 'device2', 'device3'], False), |
| 210 | ('AssertOemProperty', 'ro.product.brand', |
| 211 | ['brand1', 'brand2', 'brand3'], False), |
| 212 | ], |
| 213 | script_writer.script) |
| 214 | |
| 215 | def test_WriteFingerprintAssertion_without_oem_props(self): |
| 216 | target_info = BuildInfo(self.TEST_INFO_DICT, None) |
| 217 | source_info_dict = copy.deepcopy(self.TEST_INFO_DICT) |
| 218 | source_info_dict['build.prop']['ro.build.fingerprint'] = ( |
| 219 | 'source-build-fingerprint') |
| 220 | source_info = BuildInfo(source_info_dict, None) |
| 221 | |
| 222 | script_writer = MockScriptWriter() |
| 223 | WriteFingerprintAssertion(script_writer, target_info, source_info) |
| 224 | self.assertEqual( |
| 225 | [('AssertSomeFingerprint', 'source-build-fingerprint', |
| 226 | 'build-fingerprint')], |
| 227 | script_writer.script) |
| 228 | |
| 229 | def test_WriteFingerprintAssertion_with_source_oem_props(self): |
| 230 | target_info = BuildInfo(self.TEST_INFO_DICT, None) |
| 231 | source_info = BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS, |
| 232 | self.TEST_OEM_DICTS) |
| 233 | |
| 234 | script_writer = MockScriptWriter() |
| 235 | WriteFingerprintAssertion(script_writer, target_info, source_info) |
| 236 | self.assertEqual( |
| 237 | [('AssertFingerprintOrThumbprint', 'build-fingerprint', |
| 238 | 'build-thumbprint')], |
| 239 | script_writer.script) |
| 240 | |
| 241 | def test_WriteFingerprintAssertion_with_target_oem_props(self): |
| 242 | target_info = BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS, |
| 243 | self.TEST_OEM_DICTS) |
| 244 | source_info = BuildInfo(self.TEST_INFO_DICT, None) |
| 245 | |
| 246 | script_writer = MockScriptWriter() |
| 247 | WriteFingerprintAssertion(script_writer, target_info, source_info) |
| 248 | self.assertEqual( |
| 249 | [('AssertFingerprintOrThumbprint', 'build-fingerprint', |
| 250 | 'build-thumbprint')], |
| 251 | script_writer.script) |
| 252 | |
| 253 | def test_WriteFingerprintAssertion_with_both_oem_props(self): |
| 254 | target_info = BuildInfo(self.TEST_INFO_DICT_USES_OEM_PROPS, |
| 255 | self.TEST_OEM_DICTS) |
| 256 | source_info_dict = copy.deepcopy(self.TEST_INFO_DICT_USES_OEM_PROPS) |
| 257 | source_info_dict['build.prop']['ro.build.thumbprint'] = ( |
| 258 | 'source-build-thumbprint') |
| 259 | source_info = BuildInfo(source_info_dict, self.TEST_OEM_DICTS) |
| 260 | |
| 261 | script_writer = MockScriptWriter() |
| 262 | WriteFingerprintAssertion(script_writer, target_info, source_info) |
| 263 | self.assertEqual( |
| 264 | [('AssertSomeThumbprint', 'build-thumbprint', |
| 265 | 'source-build-thumbprint')], |
| 266 | script_writer.script) |
| 267 | |
| 268 | |
| 269 | class LoadOemDictsTest(unittest.TestCase): |
| 270 | |
| 271 | def tearDown(self): |
| 272 | common.Cleanup() |
| 273 | |
| 274 | def test_NoneDict(self): |
| 275 | self.assertIsNone(_LoadOemDicts(None)) |
| 276 | |
| 277 | def test_SingleDict(self): |
| 278 | dict_file = common.MakeTempFile() |
| 279 | with open(dict_file, 'w') as dict_fp: |
| 280 | dict_fp.write('abc=1\ndef=2\nxyz=foo\na.b.c=bar\n') |
| 281 | |
| 282 | oem_dicts = _LoadOemDicts([dict_file]) |
| 283 | self.assertEqual(1, len(oem_dicts)) |
| 284 | self.assertEqual('foo', oem_dicts[0]['xyz']) |
| 285 | self.assertEqual('bar', oem_dicts[0]['a.b.c']) |
| 286 | |
| 287 | def test_MultipleDicts(self): |
| 288 | oem_source = [] |
| 289 | for i in range(3): |
| 290 | dict_file = common.MakeTempFile() |
| 291 | with open(dict_file, 'w') as dict_fp: |
| 292 | dict_fp.write( |
| 293 | 'ro.build.index={}\ndef=2\nxyz=foo\na.b.c=bar\n'.format(i)) |
| 294 | oem_source.append(dict_file) |
| 295 | |
| 296 | oem_dicts = _LoadOemDicts(oem_source) |
| 297 | self.assertEqual(3, len(oem_dicts)) |
| 298 | for i, oem_dict in enumerate(oem_dicts): |
| 299 | self.assertEqual('2', oem_dict['def']) |
| 300 | self.assertEqual('foo', oem_dict['xyz']) |
| 301 | self.assertEqual('bar', oem_dict['a.b.c']) |
| 302 | self.assertEqual('{}'.format(i), oem_dict['ro.build.index']) |
Tao Bao | df3a48b | 2018-01-10 16:30:43 -0800 | [diff] [blame^] | 303 | |
| 304 | |
| 305 | class OtaFromTargetFilesTest(unittest.TestCase): |
| 306 | |
| 307 | TEST_TARGET_INFO_DICT = { |
| 308 | 'build.prop' : { |
| 309 | 'ro.product.device' : 'product-device', |
| 310 | 'ro.build.fingerprint' : 'build-fingerprint-target', |
| 311 | 'ro.build.version.incremental' : 'build-version-incremental-target', |
| 312 | 'ro.build.date.utc' : '1500000000', |
| 313 | }, |
| 314 | } |
| 315 | |
| 316 | TEST_SOURCE_INFO_DICT = { |
| 317 | 'build.prop' : { |
| 318 | 'ro.product.device' : 'product-device', |
| 319 | 'ro.build.fingerprint' : 'build-fingerprint-source', |
| 320 | 'ro.build.version.incremental' : 'build-version-incremental-source', |
| 321 | 'ro.build.date.utc' : '1400000000', |
| 322 | }, |
| 323 | } |
| 324 | |
| 325 | def setUp(self): |
| 326 | # Reset the global options as in ota_from_target_files.py. |
| 327 | common.OPTIONS.incremental_source = None |
| 328 | common.OPTIONS.downgrade = False |
| 329 | common.OPTIONS.timestamp = False |
| 330 | common.OPTIONS.wipe_user_data = False |
| 331 | |
| 332 | def test_GetPackageMetadata_abOta_full(self): |
| 333 | target_info_dict = copy.deepcopy(self.TEST_TARGET_INFO_DICT) |
| 334 | target_info_dict['ab_update'] = 'true' |
| 335 | target_info = BuildInfo(target_info_dict, None) |
| 336 | metadata = GetPackageMetadata(target_info) |
| 337 | self.assertDictEqual( |
| 338 | { |
| 339 | 'ota-type' : 'AB', |
| 340 | 'ota-required-cache' : '0', |
| 341 | 'post-build' : 'build-fingerprint-target', |
| 342 | 'post-build-incremental' : 'build-version-incremental-target', |
| 343 | 'post-timestamp' : '1500000000', |
| 344 | 'pre-device' : 'product-device', |
| 345 | }, |
| 346 | metadata) |
| 347 | |
| 348 | def test_GetPackageMetadata_abOta_incremental(self): |
| 349 | target_info_dict = copy.deepcopy(self.TEST_TARGET_INFO_DICT) |
| 350 | target_info_dict['ab_update'] = 'true' |
| 351 | target_info = BuildInfo(target_info_dict, None) |
| 352 | source_info = BuildInfo(self.TEST_SOURCE_INFO_DICT, None) |
| 353 | common.OPTIONS.incremental_source = '' |
| 354 | metadata = GetPackageMetadata(target_info, source_info) |
| 355 | self.assertDictEqual( |
| 356 | { |
| 357 | 'ota-type' : 'AB', |
| 358 | 'ota-required-cache' : '0', |
| 359 | 'post-build' : 'build-fingerprint-target', |
| 360 | 'post-build-incremental' : 'build-version-incremental-target', |
| 361 | 'post-timestamp' : '1500000000', |
| 362 | 'pre-device' : 'product-device', |
| 363 | 'pre-build' : 'build-fingerprint-source', |
| 364 | 'pre-build-incremental' : 'build-version-incremental-source', |
| 365 | }, |
| 366 | metadata) |
| 367 | |
| 368 | def test_GetPackageMetadata_nonAbOta_full(self): |
| 369 | target_info = BuildInfo(self.TEST_TARGET_INFO_DICT, None) |
| 370 | metadata = GetPackageMetadata(target_info) |
| 371 | self.assertDictEqual( |
| 372 | { |
| 373 | 'ota-type' : 'BLOCK', |
| 374 | 'post-build' : 'build-fingerprint-target', |
| 375 | 'post-build-incremental' : 'build-version-incremental-target', |
| 376 | 'post-timestamp' : '1500000000', |
| 377 | 'pre-device' : 'product-device', |
| 378 | }, |
| 379 | metadata) |
| 380 | |
| 381 | def test_GetPackageMetadata_nonAbOta_incremental(self): |
| 382 | target_info = BuildInfo(self.TEST_TARGET_INFO_DICT, None) |
| 383 | source_info = BuildInfo(self.TEST_SOURCE_INFO_DICT, None) |
| 384 | common.OPTIONS.incremental_source = '' |
| 385 | metadata = GetPackageMetadata(target_info, source_info) |
| 386 | self.assertDictEqual( |
| 387 | { |
| 388 | 'ota-type' : 'BLOCK', |
| 389 | 'post-build' : 'build-fingerprint-target', |
| 390 | 'post-build-incremental' : 'build-version-incremental-target', |
| 391 | 'post-timestamp' : '1500000000', |
| 392 | 'pre-device' : 'product-device', |
| 393 | 'pre-build' : 'build-fingerprint-source', |
| 394 | 'pre-build-incremental' : 'build-version-incremental-source', |
| 395 | }, |
| 396 | metadata) |
| 397 | |
| 398 | def test_GetPackageMetadata_wipe(self): |
| 399 | target_info = BuildInfo(self.TEST_TARGET_INFO_DICT, None) |
| 400 | common.OPTIONS.wipe_user_data = True |
| 401 | metadata = GetPackageMetadata(target_info) |
| 402 | self.assertDictEqual( |
| 403 | { |
| 404 | 'ota-type' : 'BLOCK', |
| 405 | 'ota-wipe' : 'yes', |
| 406 | 'post-build' : 'build-fingerprint-target', |
| 407 | 'post-build-incremental' : 'build-version-incremental-target', |
| 408 | 'post-timestamp' : '1500000000', |
| 409 | 'pre-device' : 'product-device', |
| 410 | }, |
| 411 | metadata) |
| 412 | |
| 413 | @staticmethod |
| 414 | def _test_GetPackageMetadata_swapBuildTimestamps(target_info, source_info): |
| 415 | (target_info['build.prop']['ro.build.date.utc'], |
| 416 | source_info['build.prop']['ro.build.date.utc']) = ( |
| 417 | source_info['build.prop']['ro.build.date.utc'], |
| 418 | target_info['build.prop']['ro.build.date.utc']) |
| 419 | |
| 420 | def test_GetPackageMetadata_unintentionalDowngradeDetected(self): |
| 421 | target_info_dict = copy.deepcopy(self.TEST_TARGET_INFO_DICT) |
| 422 | source_info_dict = copy.deepcopy(self.TEST_SOURCE_INFO_DICT) |
| 423 | self._test_GetPackageMetadata_swapBuildTimestamps( |
| 424 | target_info_dict, source_info_dict) |
| 425 | |
| 426 | target_info = BuildInfo(target_info_dict, None) |
| 427 | source_info = BuildInfo(source_info_dict, None) |
| 428 | common.OPTIONS.incremental_source = '' |
| 429 | self.assertRaises(RuntimeError, GetPackageMetadata, target_info, |
| 430 | source_info) |
| 431 | |
| 432 | def test_GetPackageMetadata_downgrade(self): |
| 433 | target_info_dict = copy.deepcopy(self.TEST_TARGET_INFO_DICT) |
| 434 | source_info_dict = copy.deepcopy(self.TEST_SOURCE_INFO_DICT) |
| 435 | self._test_GetPackageMetadata_swapBuildTimestamps( |
| 436 | target_info_dict, source_info_dict) |
| 437 | |
| 438 | target_info = BuildInfo(target_info_dict, None) |
| 439 | source_info = BuildInfo(source_info_dict, None) |
| 440 | common.OPTIONS.incremental_source = '' |
| 441 | common.OPTIONS.downgrade = True |
| 442 | common.OPTIONS.wipe_user_data = True |
| 443 | metadata = GetPackageMetadata(target_info, source_info) |
| 444 | self.assertDictEqual( |
| 445 | { |
| 446 | 'ota-downgrade' : 'yes', |
| 447 | 'ota-type' : 'BLOCK', |
| 448 | 'ota-wipe' : 'yes', |
| 449 | 'post-build' : 'build-fingerprint-target', |
| 450 | 'post-build-incremental' : 'build-version-incremental-target', |
| 451 | 'pre-device' : 'product-device', |
| 452 | 'pre-build' : 'build-fingerprint-source', |
| 453 | 'pre-build-incremental' : 'build-version-incremental-source', |
| 454 | }, |
| 455 | metadata) |
| 456 | |
| 457 | def test_GetPackageMetadata_overrideTimestamp(self): |
| 458 | target_info_dict = copy.deepcopy(self.TEST_TARGET_INFO_DICT) |
| 459 | source_info_dict = copy.deepcopy(self.TEST_SOURCE_INFO_DICT) |
| 460 | self._test_GetPackageMetadata_swapBuildTimestamps( |
| 461 | target_info_dict, source_info_dict) |
| 462 | |
| 463 | target_info = BuildInfo(target_info_dict, None) |
| 464 | source_info = BuildInfo(source_info_dict, None) |
| 465 | common.OPTIONS.incremental_source = '' |
| 466 | common.OPTIONS.timestamp = True |
| 467 | metadata = GetPackageMetadata(target_info, source_info) |
| 468 | self.assertDictEqual( |
| 469 | { |
| 470 | 'ota-type' : 'BLOCK', |
| 471 | 'post-build' : 'build-fingerprint-target', |
| 472 | 'post-build-incremental' : 'build-version-incremental-target', |
| 473 | 'post-timestamp' : '1500000001', |
| 474 | 'pre-device' : 'product-device', |
| 475 | 'pre-build' : 'build-fingerprint-source', |
| 476 | 'pre-build-incremental' : 'build-version-incremental-source', |
| 477 | }, |
| 478 | metadata) |