OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import copy | 6 import copy |
7 import datetime | 7 import datetime |
8 import hashlib | 8 import hashlib |
9 import os | 9 import os |
10 import posixpath | 10 import posixpath |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 | 25 |
26 HTTPS_BASE_URL = 'https://commondatastorage.googleapis.com' \ | 26 HTTPS_BASE_URL = 'https://commondatastorage.googleapis.com' \ |
27 '/nativeclient_mirror/nacl/nacl_sdk/' | 27 '/nativeclient_mirror/nacl/nacl_sdk/' |
28 | 28 |
29 OS_CR = ('cros',) | 29 OS_CR = ('cros',) |
30 OS_M = ('mac',) | 30 OS_M = ('mac',) |
31 OS_ML = ('mac', 'linux') | 31 OS_ML = ('mac', 'linux') |
32 OS_MW = ('mac', 'win') | 32 OS_MW = ('mac', 'win') |
33 OS_MLW = ('mac', 'linux', 'win') | 33 OS_MLW = ('mac', 'linux', 'win') |
| 34 POST_STABLE = 'post_stable' |
34 STABLE = 'stable' | 35 STABLE = 'stable' |
35 BETA = 'beta' | 36 BETA = 'beta' |
36 DEV = 'dev' | 37 DEV = 'dev' |
37 CANARY = 'canary' | 38 CANARY = 'canary' |
38 | 39 |
39 | 40 |
40 def GetArchiveUrl(host_os, version): | 41 def GetArchiveUrl(host_os, version): |
41 basename = 'naclsdk_%s.tar.bz2' % (host_os,) | 42 basename = 'naclsdk_%s.tar.bz2' % (host_os,) |
42 return urlparse.urljoin(HTTPS_BASE_URL, posixpath.join(version, basename)) | 43 return urlparse.urljoin(HTTPS_BASE_URL, posixpath.join(version, basename)) |
43 | 44 |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 bundle = copy.deepcopy(B18_0_1025_163_R1_MLW) | 509 bundle = copy.deepcopy(B18_0_1025_163_R1_MLW) |
509 archive_url = bundle.GetArchive('mac').url | 510 archive_url = bundle.GetArchive('mac').url |
510 bundle.GetArchive('mac').url = archive_url.replace('.tar', '') | 511 bundle.GetArchive('mac').url = archive_url.replace('.tar', '') |
511 self.files.Add(bundle) | 512 self.files.Add(bundle) |
512 self._MakeDelegate() | 513 self._MakeDelegate() |
513 self._Run(OS_MLW) | 514 self._Run(OS_MLW) |
514 self._ReadUploadedManifest() | 515 self._ReadUploadedManifest() |
515 self._AssertUploadedManifestHasBundle(bundle, BETA) | 516 self._AssertUploadedManifestHasBundle(bundle, BETA) |
516 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1) | 517 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1) |
517 | 518 |
| 519 def testOnlyOneStableBundle(self): |
| 520 self.manifest = MakeManifest(B18_R1_NONE, B19_R1_NONE) |
| 521 self.history.Add(OS_MLW, STABLE, V18_0_1025_163) |
| 522 self.history.Add(OS_MLW, STABLE, V19_0_1084_41) |
| 523 self.files.Add(B18_0_1025_163_R1_MLW) |
| 524 self.files.Add(B19_0_1084_41_R1_MLW) |
| 525 self._MakeDelegate() |
| 526 self._Run(OS_MLW) |
| 527 self._ReadUploadedManifest() |
| 528 p18_bundle = self.uploaded_manifest.GetBundle(B18_R1_NONE.name) |
| 529 self.assertEqual(p18_bundle.stability, POST_STABLE) |
| 530 p19_bundle = self.uploaded_manifest.GetBundle(B19_R1_NONE.name) |
| 531 self.assertEqual(p19_bundle.stability, STABLE) |
| 532 |
518 | 533 |
519 class TestUpdateVitals(unittest.TestCase): | 534 class TestUpdateVitals(unittest.TestCase): |
520 def setUp(self): | 535 def setUp(self): |
521 f = tempfile.NamedTemporaryFile('w', prefix="test_update_nacl_manifest") | 536 f = tempfile.NamedTemporaryFile('w', prefix="test_update_nacl_manifest") |
522 self.test_file = f.name | 537 self.test_file = f.name |
523 f.close() | 538 f.close() |
524 test_data = "Some test data" | 539 test_data = "Some test data" |
525 self.sha1 = hashlib.sha1(test_data).hexdigest() | 540 self.sha1 = hashlib.sha1(test_data).hexdigest() |
526 self.data_len = len(test_data) | 541 self.data_len = len(test_data) |
527 with open(self.test_file, 'w') as f: | 542 with open(self.test_file, 'w') as f: |
528 f.write(test_data) | 543 f.write(test_data) |
529 | 544 |
530 def tearDown(self): | 545 def tearDown(self): |
531 os.remove(self.test_file) | 546 os.remove(self.test_file) |
532 | 547 |
533 def testUpdateVitals(self): | 548 def testUpdateVitals(self): |
534 archive = manifest_util.Archive(manifest_util.GetHostOS()) | 549 archive = manifest_util.Archive(manifest_util.GetHostOS()) |
535 path = os.path.abspath(self.test_file) | 550 path = os.path.abspath(self.test_file) |
536 if sys.platform == 'win32': | 551 if sys.platform == 'win32': |
537 # On Windows, the path must start with three slashes, i.e. | 552 # On Windows, the path must start with three slashes, i.e. |
538 # (file:///C:\whatever) | 553 # (file:///C:\whatever) |
539 path = '/' + path | 554 path = '/' + path |
540 archive.url = 'file://' + path | 555 archive.url = 'file://' + path |
541 print archive.url | |
542 | 556 |
543 bundle = MakeBundle(18) | 557 bundle = MakeBundle(18) |
544 bundle.AddArchive(archive) | 558 bundle.AddArchive(archive) |
545 manifest = MakeManifest(bundle) | 559 manifest = MakeManifest(bundle) |
546 archive = manifest.GetBundles()[0]['archives'][0] | 560 archive = manifest.GetBundles()[0]['archives'][0] |
547 | 561 |
548 self.assertTrue('size' not in archive) | 562 self.assertTrue('size' not in archive) |
549 self.assertTrue('checksum' not in archive) | 563 self.assertTrue('checksum' not in archive) |
550 self.assertRaises(manifest_util.Error, manifest.Validate) | 564 self.assertRaises(manifest_util.Error, manifest.Validate) |
551 | 565 |
552 manifest.Validate(add_missing_info=True) | 566 manifest.Validate(add_missing_info=True) |
553 | 567 |
554 self.assertEqual(archive['size'], self.data_len) | 568 self.assertEqual(archive['size'], self.data_len) |
555 self.assertEqual(archive['checksum']['sha1'], self.sha1) | 569 self.assertEqual(archive['checksum']['sha1'], self.sha1) |
556 | 570 |
557 | 571 |
558 if __name__ == '__main__': | 572 if __name__ == '__main__': |
559 unittest.main() | 573 unittest.main() |
OLD | NEW |