OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 import commands | |
7 import glob | |
8 import logging | |
9 import os | |
10 import sys | |
11 import unittest | |
12 | |
13 import pyauto_functional # Must import before pyauto | |
14 import pyauto | |
15 | |
16 class CodesignTest(pyauto.PyUITest): | |
17 """Test if the build is code signed""" | |
18 | |
19 def testCodeSign(self): | |
20 """Check the app for codesign and bail out if it's non-branded.""" | |
21 browser_info = self.GetBrowserInfo() | |
22 | |
23 # bail out if not a branded build | |
24 if browser_info['properties']['branding'] != 'Google Chrome': | |
25 return | |
26 | |
27 # TODO: Add functionality for other operating systems (see crbug.com/47902) | |
28 if self.IsMac(): | |
29 self._MacCodeSign(browser_info) | |
30 | |
31 def _MacCodeSign(self, browser_info): | |
32 valid_text = 'valid on disk' | |
33 app_name = 'Google Chrome.app' | |
34 | |
35 # Codesign of the app @ xcodebuild/Release/Google Chrome.app/ | |
36 app_path = browser_info['child_process_path'] | |
37 app_path = app_path[:app_path.find(app_name)] | |
38 app_path = app_path + app_name | |
39 self.assertTrue(valid_text in self._checkCodeSign(app_path)) | |
40 | |
41 # Codesign of the frameWork | |
42 framework_path = glob.glob(os.path.join(app_path, 'Contents', 'Versions', | |
43 '*.*.*.*'))[0] | |
44 framework_path = os.path.join(framework_path, | |
45 'Google Chrome Framework.framework') | |
46 self.assertTrue(valid_text in self._checkCodeSign(framework_path)) | |
47 | |
48 def _checkCodeSign(self, file_path): | |
49 """Return the output of the codesign""" | |
50 return commands.getoutput('codesign -vvv "%s"' % file_path) | |
51 | |
52 | |
53 if __name__ == '__main__': | |
54 pyauto_functional.Main() | |
OLD | NEW |