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

Side by Side Diff: pnacl/driver/tests/path_length_test.py

Issue 800553003: Update PNaCl to LLVM/Clang/Libcxx 223109 (nacl-change) (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: fix rebase Created 5 years, 10 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 | « pnacl/driver/pnacl-ld.py ('k') | pnacl/prune_test.py » ('j') | 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/python 1 #!/usr/bin/python
2 # Copyright (c) 2014 The Native Client Authors. All rights reserved. 2 # Copyright (c) 2014 The Native Client 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 """Tests of the pnacl driver. 6 """Tests of the pnacl driver.
7 7
8 This tests that we give useful errors when paths are too long, and don't 8 This tests that we give useful errors when paths are too long, and don't
9 unnecessarily generate temp file names that are too long ourselves. 9 unnecessarily generate temp file names that are too long ourselves.
10 10
(...skipping 15 matching lines...) Expand all
26 super(TestPathNames, self).setUp() 26 super(TestPathNames, self).setUp()
27 driver_test_utils.ApplyTestEnvOverrides(env) 27 driver_test_utils.ApplyTestEnvOverrides(env)
28 self.backup_exit = sys.exit 28 self.backup_exit = sys.exit
29 sys.exit = driver_test_utils.FakeExit 29 sys.exit = driver_test_utils.FakeExit
30 cwd_len = len(os.getcwd()) 30 cwd_len = len(os.getcwd())
31 # Create a directory whose path will be exactly 240 chars long 31 # Create a directory whose path will be exactly 240 chars long
32 dir_len = 240 - cwd_len - 1 32 dir_len = 240 - cwd_len - 1
33 self.cwd_backup = os.getcwd() 33 self.cwd_backup = os.getcwd()
34 self.LongTempDir = os.path.join(self.cwd_backup, 'a' * dir_len) 34 self.LongTempDir = os.path.join(self.cwd_backup, 'a' * dir_len)
35 os.mkdir(self.LongTempDir) 35 os.mkdir(self.LongTempDir)
36 # Create a directory whose path will be exactly 235 chars long
Karl 2015/02/20 16:30:43 Should there be a check to verify that the path is
jvoung (off chromium) 2015/02/23 22:12:00 Added an assert that it's exactly 235 (if that's w
Karl 2015/02/23 22:18:18 Actually, what I meant (both here and with path te
jvoung (off chromium) 2015/02/23 22:41:22 I see, I added another check for cwd's len.
37 shorter_dir_len = 235 - cwd_len - 1
38 self.ShorterTempDir = os.path.join(self.cwd_backup, 'a' * shorter_dir_len)
39 os.mkdir(self.ShorterTempDir)
36 40
37 def tearDown(self): 41 def tearDown(self):
38 super(TestPathNames, self).tearDown() 42 super(TestPathNames, self).tearDown()
39 os.chdir(self.cwd_backup) 43 os.chdir(self.cwd_backup)
40 sys.exit = self.backup_exit 44 sys.exit = self.backup_exit
41 shutil.rmtree(self.LongTempDir) 45 shutil.rmtree(self.LongTempDir)
46 shutil.rmtree(self.ShorterTempDir)
42 47
43 def WriteCFile(self, filename): 48 def WriteCFile(self, filename):
44 with open(filename, 'w') as f: 49 with open(filename, 'w') as f:
45 f.write('int main() { return 0; }') 50 f.write('int main() { return 0; }')
46 51
47 def AssertRaisesAndReturnOutput(self, exc, func, *args): 52 def AssertRaisesAndReturnOutput(self, exc, func, *args):
48 capture_out = cStringIO.StringIO() 53 capture_out = cStringIO.StringIO()
49 driver_log.Log.CaptureToStream(capture_out) 54 driver_log.Log.CaptureToStream(capture_out)
50 self.assertRaises(exc, func, *args) 55 self.assertRaises(exc, func, *args)
51 driver_log.Log.ResetStreams() 56 driver_log.Log.ResetStreams()
52 return capture_out.getvalue() 57 return capture_out.getvalue()
53 58
54 def test_PathWithSpaces(self): 59 def test_PathWithSpaces(self):
55 '''Test that the driver correctly handles paths containing spaces''' 60 '''Test that the driver correctly handles paths containing spaces'''
56 if not driver_test_utils.CanRunHost(): 61 if not driver_test_utils.CanRunHost():
57 return 62 return
58 63
59 name = os.path.join(self.LongTempDir, 'a file') 64 name = os.path.join(self.ShorterTempDir, 'a file')
60 self.WriteCFile(name + '.c') 65 self.WriteCFile(name + '.c')
61 driver_tools.RunDriver('pnacl-clang', 66 driver_tools.RunDriver('pnacl-clang',
62 [name + '.c', '-c', '-o', name + '.o']) 67 [name + '.c', '-c', '-o', name + '.o'])
63 self.assertEqual('po', filetype.FileType(name + '.o')) 68 self.assertEqual('po', filetype.FileType(name + '.o'))
64 69
65 def test_InputPathTooLong(self): 70 def test_InputPathTooLong(self):
66 '''Test that clang and ld reject input paths that are too long 71 '''Test that clang and ld reject input paths that are too long
67 72
68 Test that compiling and linking paths shorter than 255 succeeds and paths 73 Test that compiling and linking paths shorter than 255 succeeds and paths
69 longer than 255 fails. 74 longer than 255 fails.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 longname = os.path.join(longerdir, 'a' * 3) 184 longname = os.path.join(longerdir, 'a' * 3)
180 os.rename(shortname + '.o', longname + '.o') 185 os.rename(shortname + '.o', longname + '.o')
181 186
182 output = self.AssertRaisesAndReturnOutput( 187 output = self.AssertRaisesAndReturnOutput(
183 driver_test_utils.DriverExitException, 188 driver_test_utils.DriverExitException,
184 driver_tools.RunDriver, 189 driver_tools.RunDriver,
185 'pnacl-ld', 190 'pnacl-ld',
186 [longname + '.o', '-o', longname]) 191 [longname + '.o', '-o', longname])
187 192
188 self.assertIn('.pexe is too long', output) 193 self.assertIn('.pexe is too long', output)
OLDNEW
« no previous file with comments | « pnacl/driver/pnacl-ld.py ('k') | pnacl/prune_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698