Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: native_client_sdk/src/build_tools/tests/test_update_nacl_manifest.py

Issue 11200002: update_nacl_manifest improvements (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 os 9 import os
9 import posixpath 10 import posixpath
10 import subprocess 11 import subprocess
11 import sys 12 import sys
13 import tempfile
12 import unittest 14 import unittest
13 import urlparse 15 import urlparse
14 16
15 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 17 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
16 BUILD_TOOLS_DIR = os.path.dirname(SCRIPT_DIR) 18 BUILD_TOOLS_DIR = os.path.dirname(SCRIPT_DIR)
17 19
18 sys.path.append(BUILD_TOOLS_DIR) 20 sys.path.append(BUILD_TOOLS_DIR)
19 import manifest_util 21 import manifest_util
20 import update_nacl_manifest 22 import update_nacl_manifest
21 from update_nacl_manifest import CANARY_BUNDLE_NAME 23 from update_nacl_manifest import CANARY_BUNDLE_NAME
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 new_bundle.AddArchive(archive) 153 new_bundle.AddArchive(archive)
152 self[path + '.json'] = new_bundle.GetDataAsString() 154 self[path + '.json'] = new_bundle.GetDataAsString()
153 155
154 156
155 class TestDelegate(update_nacl_manifest.Delegate): 157 class TestDelegate(update_nacl_manifest.Delegate):
156 def __init__(self, manifest, history, files, version_mapping): 158 def __init__(self, manifest, history, files, version_mapping):
157 self.manifest = manifest 159 self.manifest = manifest
158 self.history = history 160 self.history = history
159 self.files = files 161 self.files = files
160 self.version_mapping = version_mapping 162 self.version_mapping = version_mapping
163 self.dryrun = 0
161 164
162 def GetRepoManifest(self): 165 def GetRepoManifest(self):
163 return self.manifest 166 return self.manifest
164 167
165 def GetHistory(self): 168 def GetHistory(self):
166 return self.history 169 return self.history
167 170
168 def GetTrunkRevision(self, version): 171 def GetTrunkRevision(self, version):
169 return self.version_mapping[version] 172 return self.version_mapping[version]
170 173
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 archive_url = bundle.GetArchive('mac').url 509 archive_url = bundle.GetArchive('mac').url
507 bundle.GetArchive('mac').url = archive_url.replace('.tar', '') 510 bundle.GetArchive('mac').url = archive_url.replace('.tar', '')
508 self.files.Add(bundle) 511 self.files.Add(bundle)
509 self._MakeDelegate() 512 self._MakeDelegate()
510 self._Run(OS_MLW) 513 self._Run(OS_MLW)
511 self._ReadUploadedManifest() 514 self._ReadUploadedManifest()
512 self._AssertUploadedManifestHasBundle(bundle, BETA) 515 self._AssertUploadedManifestHasBundle(bundle, BETA)
513 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1) 516 self.assertEqual(len(self.uploaded_manifest.GetBundles()), 1)
514 517
515 518
516 def main(): 519 class TestUpdateVitals(unittest.TestCase):
517 suite = unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__])
518 result = unittest.TextTestRunner(verbosity=2).run(suite)
519 520
520 return int(not result.wasSuccessful()) 521 def setUp(self):
522 f = tempfile.NamedTemporaryFile('w', prefix="test_update_nacl_manifest")
523 self.test_file = f.name
524 f.close()
525 test_data = "Some test data\n"
526 self.sha1 = hashlib.sha1(test_data).hexdigest()
527 with open(self.test_file, 'w') as f:
528 f.write(test_data)
529
530 def tearDown(self):
531 os.remove(self.test_file)
532
533 def testUpdateVitals(self):
534 self.manifest = MakeManifest(B18_R1_NONE)
binji 2012/10/16 23:09:10 remove, self.manifest is defined below
535 archive = manifest_util.Archive(manifest_util.GetHostOS())
536 archive.url = 'file://%s' % os.path.abspath(self.test_file)
537 bundle = MakeBundle(18)
538 bundle.AddArchive(archive)
539 self.manifest = MakeManifest(bundle)
540 archive = self.manifest.GetBundles()[0]['archives'][0]
541
542 self.assertTrue('size' not in archive)
543 self.assertTrue('checksum' not in archive)
544
545 self.manifest.Validate()
546
547 self.assertEqual(archive['size'], 15)
548 self.assertEqual(archive['checksum']['sha1'], self.sha1)
549
521 550
522 if __name__ == '__main__': 551 if __name__ == '__main__':
523 sys.exit(main()) 552 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698