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

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: update clang revision Created 5 years, 9 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
11 """ 11 """
12 12
13 import driver_log 13 import driver_log
14 from driver_env import env 14 from driver_env import env
15 import driver_test_utils 15 import driver_test_utils
16 import driver_tools 16 import driver_tools
17 import filetype 17 import filetype
18 18
19 import cStringIO 19 import cStringIO
20 import os 20 import os
21 import shutil 21 import shutil
22 import sys 22 import sys
23 23
24 class TestPathNames(driver_test_utils.DriverTesterCommon): 24 class TestPathNames(driver_test_utils.DriverTesterCommon):
25 def setUp(self): 25 def setUp(self):
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 self.cwd_backup = os.getcwd()
31 cwd_len = len(self.cwd_backup)
32 # Create a directory whose path will be exactly 235 chars long
33 assert(cwd_len < 235)
34 shorter_dir_len = 235 - cwd_len - 1
35 self.ShorterTempDir = os.path.join(self.cwd_backup, 'a' * shorter_dir_len)
36 assert(235 == len(self.ShorterTempDir),
37 "ShorterTempDir isn't 235 chars: %d" % len(self.ShorterTempDir))
38 os.mkdir(self.ShorterTempDir)
31 # Create a directory whose path will be exactly 240 chars long 39 # Create a directory whose path will be exactly 240 chars long
32 dir_len = 240 - cwd_len - 1 40 dir_len = 240 - cwd_len - 1
33 self.cwd_backup = os.getcwd()
34 self.LongTempDir = os.path.join(self.cwd_backup, 'a' * dir_len) 41 self.LongTempDir = os.path.join(self.cwd_backup, 'a' * dir_len)
42 assert(240 == len(self.LongTempDir),
43 "LongTempDir isn't 240 chars: %d" % len(self.LongTempDir))
35 os.mkdir(self.LongTempDir) 44 os.mkdir(self.LongTempDir)
36 45
37 def tearDown(self): 46 def tearDown(self):
38 super(TestPathNames, self).tearDown() 47 super(TestPathNames, self).tearDown()
39 os.chdir(self.cwd_backup) 48 os.chdir(self.cwd_backup)
40 sys.exit = self.backup_exit 49 sys.exit = self.backup_exit
41 shutil.rmtree(self.LongTempDir) 50 shutil.rmtree(self.LongTempDir)
51 shutil.rmtree(self.ShorterTempDir)
42 52
43 def WriteCFile(self, filename): 53 def WriteCFile(self, filename):
44 with open(filename, 'w') as f: 54 with open(filename, 'w') as f:
45 f.write('int main() { return 0; }') 55 f.write('int main() { return 0; }')
46 56
47 def AssertRaisesAndReturnOutput(self, exc, func, *args): 57 def AssertRaisesAndReturnOutput(self, exc, func, *args):
48 capture_out = cStringIO.StringIO() 58 capture_out = cStringIO.StringIO()
49 driver_log.Log.CaptureToStream(capture_out) 59 driver_log.Log.CaptureToStream(capture_out)
50 self.assertRaises(exc, func, *args) 60 self.assertRaises(exc, func, *args)
51 driver_log.Log.ResetStreams() 61 driver_log.Log.ResetStreams()
52 return capture_out.getvalue() 62 return capture_out.getvalue()
53 63
54 def test_PathWithSpaces(self): 64 def test_PathWithSpaces(self):
55 '''Test that the driver correctly handles paths containing spaces''' 65 '''Test that the driver correctly handles paths containing spaces'''
56 if not driver_test_utils.CanRunHost(): 66 if not driver_test_utils.CanRunHost():
57 return 67 return
58 68
59 name = os.path.join(self.LongTempDir, 'a file') 69 name = os.path.join(self.ShorterTempDir, 'a file')
60 self.WriteCFile(name + '.c') 70 self.WriteCFile(name + '.c')
61 driver_tools.RunDriver('pnacl-clang', 71 driver_tools.RunDriver('pnacl-clang',
62 [name + '.c', '-c', '-o', name + '.o']) 72 [name + '.c', '-c', '-o', name + '.o'])
63 self.assertEqual('po', filetype.FileType(name + '.o')) 73 self.assertEqual('po', filetype.FileType(name + '.o'))
64 74
65 def test_InputPathTooLong(self): 75 def test_InputPathTooLong(self):
66 '''Test that clang and ld reject input paths that are too long 76 '''Test that clang and ld reject input paths that are too long
67 77
68 Test that compiling and linking paths shorter than 255 succeeds and paths 78 Test that compiling and linking paths shorter than 255 succeeds and paths
69 longer than 255 fails. 79 longer than 255 fails.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 longname = os.path.join(longerdir, 'a' * 3) 189 longname = os.path.join(longerdir, 'a' * 3)
180 os.rename(shortname + '.o', longname + '.o') 190 os.rename(shortname + '.o', longname + '.o')
181 191
182 output = self.AssertRaisesAndReturnOutput( 192 output = self.AssertRaisesAndReturnOutput(
183 driver_test_utils.DriverExitException, 193 driver_test_utils.DriverExitException,
184 driver_tools.RunDriver, 194 driver_tools.RunDriver,
185 'pnacl-ld', 195 'pnacl-ld',
186 [longname + '.o', '-o', longname]) 196 [longname + '.o', '-o', longname])
187 197
188 self.assertIn('.pexe is too long', output) 198 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