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

Side by Side Diff: native_client_sdk/src/tools/tests/create_nmf_test.py

Issue 15891011: [NaCl SDK] Fix create_nmf handling of missing libraries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
« no previous file with comments | « native_client_sdk/src/tools/create_nmf.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import os 5 import os
6 import shutil 6 import shutil
7 import subprocess 7 import subprocess
8 import sys 8 import sys
9 import tempfile 9 import tempfile
10 import unittest 10 import unittest
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 self.assertEqual(p.returncode, 0) 138 self.assertEqual(p.returncode, 0)
139 return name 139 return name
140 140
141 def tearDown(self): 141 def tearDown(self):
142 if self.tempdir: 142 if self.tempdir:
143 shutil.rmtree(self.tempdir) 143 shutil.rmtree(self.tempdir)
144 144
145 def Mktemp(self): 145 def Mktemp(self):
146 self.tempdir = tempfile.mkdtemp() 146 self.tempdir = tempfile.mkdtemp()
147 147
148 def CreateNmfUtils(self): 148 def CreateNmfUtils(self, libdir=None):
149 libdir = os.path.join(self.toolchain, 'x86_64-nacl', 'lib32') 149 if not libdir:
150 libdir = os.path.join(self.toolchain, 'x86_64-nacl', 'lib32')
150 return create_nmf.NmfUtils([self.dyn_nexe], 151 return create_nmf.NmfUtils([self.dyn_nexe],
151 lib_path=[libdir], 152 lib_path=[libdir],
152 objdump=self.objdump) 153 objdump=self.objdump)
153 154
154 def testGetNeededStatic(self): 155 def testGetNeededStatic(self):
155 nexe = os.path.join(DATA_DIR, 'test_static_x86_32.nexe') 156 nexe = os.path.join(DATA_DIR, 'test_static_x86_32.nexe')
156 nmf = create_nmf.NmfUtils([nexe]) 157 nmf = create_nmf.NmfUtils([nexe])
157 needed = nmf.GetNeeded() 158 needed = nmf.GetNeeded()
158 159
159 # static nexe should have exactly one needed file 160 # static nexe should have exactly one needed file
(...skipping 27 matching lines...) Expand all
187 # this nexe has 5 dependencies 188 # this nexe has 5 dependencies
188 expected = set(self.dyn_deps) 189 expected = set(self.dyn_deps)
189 expected.add(os.path.basename(self.dyn_nexe)) 190 expected.add(os.path.basename(self.dyn_nexe))
190 191
191 basenames = set(self.StripDependencies(names)) 192 basenames = set(self.StripDependencies(names))
192 self.assertEqual(expected, basenames) 193 self.assertEqual(expected, basenames)
193 194
194 def testStageDependencies(self): 195 def testStageDependencies(self):
195 self.Mktemp() 196 self.Mktemp()
196 nmf = self.CreateNmfUtils() 197 nmf = self.CreateNmfUtils()
198 #create_nmf.DebugPrint.debug_mode = True
199 #create_nmf.Trace.verbose = True
197 200
198 # Stage dependencies 201 # Stage dependencies
199 nmf.StageDependencies(self.tempdir) 202 nmf.StageDependencies(self.tempdir)
200 203
201 # Verify directory contents 204 # Verify directory contents
202 contents = set(os.listdir(self.tempdir)) 205 contents = set(os.listdir(self.tempdir))
203 expectedContents = set((os.path.basename(self.dyn_nexe), 'lib32')) 206 expectedContents = set((os.path.basename(self.dyn_nexe), 'lib32'))
204 self.assertEqual(contents, expectedContents) 207 self.assertEqual(contents, expectedContents)
205 208
206 contents = os.listdir(os.path.join(self.tempdir, 'lib32')) 209 contents = os.listdir(os.path.join(self.tempdir, 'lib32'))
207 contents = self.StripDependencies(contents) 210 contents = self.StripDependencies(contents)
208 contents = set(contents) 211 contents = set(contents)
209 expectedContents = self.dyn_deps 212 expectedContents = self.dyn_deps
210 self.assertEqual(contents, expectedContents) 213 self.assertEqual(contents, expectedContents)
211 214
215 def testMissingArchLibrary(self):
216 self.Mktemp()
217 nmf = self.CreateNmfUtils()
218 # CreateNmfUtils uses the 32-bit library path, but not the 64-bit one
219 # so searching for a 32-bit library should succeed while searching for
220 # a 64-bit one should fail.
221 nmf.GleanFromObjdump(['libgcc_s.so.1'], 'x86-32')
222 self.assertRaises(create_nmf.Error,
223 nmf.GleanFromObjdump, ['libgcc_s.so.1'], 'x86-64')
224
212 225
213 if __name__ == '__main__': 226 if __name__ == '__main__':
214 unittest.main() 227 unittest.main()
OLDNEW
« no previous file with comments | « native_client_sdk/src/tools/create_nmf.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698