1
1
# lldb test suite imports
2
2
from lldbsuite .test .decorators import *
3
3
from lldbsuite .test .lldbtest import TestBase
4
+ from lldbsuite .test import lldbutil
4
5
5
6
# gdb-remote-specific imports
6
7
import lldbgdbserverutils
@@ -117,6 +118,7 @@ def test_platform_file_wronly_creat_excl_fail(self):
117
118
temp_file = self .getBuildArtifact ("test" )
118
119
with open (temp_file , "wb" ):
119
120
pass
121
+ temp_file = lldbutil .install_to_target (self , temp_file )
120
122
121
123
# attempt to open the file with O_CREAT|O_EXCL
122
124
self .do_handshake ()
@@ -140,6 +142,7 @@ def test_platform_file_size(self):
140
142
test_data = b"test data of some length"
141
143
with open (temp_path , "wb" ) as temp_file :
142
144
temp_file .write (test_data )
145
+ temp_path = lldbutil .install_to_target (self , temp_path )
143
146
144
147
self .do_handshake ()
145
148
self .test_sequence .add_log_lines (
@@ -167,7 +170,11 @@ def test_platform_file_mode(self):
167
170
test_mode = 0o751
168
171
169
172
with open (temp_path , "wb" ) as temp_file :
170
- os .chmod (temp_file .fileno (), test_mode )
173
+ if lldbplatformutil .getHostPlatform () == "windows" :
174
+ test_mode = 0o700
175
+ else :
176
+ os .chmod (temp_file .fileno (), test_mode )
177
+ temp_path = lldbutil .install_to_target (self , temp_path )
171
178
172
179
self .do_handshake ()
173
180
self .test_sequence .add_log_lines (
@@ -213,6 +220,7 @@ def test_platform_file_exists(self):
213
220
temp_path = self .getBuildArtifact ("test" )
214
221
with open (temp_path , "wb" ):
215
222
pass
223
+ temp_path = lldbutil .install_to_target (self , temp_path )
216
224
217
225
self .do_handshake ()
218
226
self .test_sequence .add_log_lines (
@@ -244,6 +252,10 @@ def test_platform_file_exists_not(self):
244
252
self .expect_gdbremote_sequence ()
245
253
246
254
@skipIfWindows
255
+ # FIXME: lldb.remote_platform.Install() cannot copy opened temp file on Windows.
256
+ # It is possible to use tempfile.NamedTemporaryFile(..., delete=False) and
257
+ # delete the temp file manually at the end.
258
+ @skipIf (hostoslist = ["windows" ])
247
259
@add_test_categories (["llgs" ])
248
260
def test_platform_file_fstat (self ):
249
261
server = self .connect_to_debug_monitor ()
@@ -252,12 +264,13 @@ def test_platform_file_fstat(self):
252
264
with tempfile .NamedTemporaryFile () as temp_file :
253
265
temp_file .write (b"some test data for stat" )
254
266
temp_file .flush ()
267
+ temp_path = lldbutil .install_to_target (self , temp_file .name )
255
268
256
269
self .do_handshake ()
257
270
self .test_sequence .add_log_lines (
258
271
[
259
272
"read packet: $vFile:open:%s,0,0#00"
260
- % (binascii .b2a_hex (temp_file . name .encode ()).decode (),),
273
+ % (binascii .b2a_hex (temp_path .encode ()).decode (),),
261
274
{
262
275
"direction" : "send" ,
263
276
"regex" : r"^\$F([0-9a-fA-F]+)#[0-9a-fA-F]{2}$" ,
@@ -359,9 +372,12 @@ def vFile_test(
359
372
360
373
if creat :
361
374
self .assertFalse (os .path .exists (temp_path ))
375
+ if lldb .remote_platform :
376
+ temp_path = lldbutil .append_to_process_working_directory (self , "test" )
362
377
else :
363
378
with open (temp_path , "wb" ) as temp_file :
364
379
temp_file .write (test_data .encode ())
380
+ temp_path = lldbutil .install_to_target (self , temp_path )
365
381
366
382
# open the file for reading
367
383
self .do_handshake ()
@@ -448,8 +464,19 @@ def vFile_test(
448
464
449
465
if write :
450
466
# check if the data was actually written
467
+ if lldb .remote_platform :
468
+ local_path = self .getBuildArtifact ("file_from_target" )
469
+ error = lldb .remote_platform .Get (
470
+ lldb .SBFileSpec (temp_path , False ), lldb .SBFileSpec (local_path , True )
471
+ )
472
+ self .assertTrue (
473
+ error .Success (),
474
+ "Reading file {0} failed: {1}" .format (temp_path , error ),
475
+ )
476
+ temp_path = local_path
477
+
451
478
with open (temp_path , "rb" ) as temp_file :
452
- if creat :
479
+ if creat and lldbplatformutil . getHostPlatform () != "windows" :
453
480
self .assertEqual (
454
481
os .fstat (temp_file .fileno ()).st_mode & 0o7777 , 0o640
455
482
)
0 commit comments