@@ -576,6 +576,7 @@ def enableLogChannelsForCurrentTest(self):
576
576
# confirm that the file is writeable
577
577
host_log_path = "{}-host.log" .format (log_basename )
578
578
open (host_log_path , 'w' ).close ()
579
+ self .log_files .append (host_log_path )
579
580
580
581
log_enable = "log enable -Tpn -f {} " .format (host_log_path )
581
582
for channel_with_categories in lldbtest_config .channels :
@@ -602,6 +603,7 @@ def enableLogChannelsForCurrentTest(self):
602
603
if lldb .remote_platform is None :
603
604
server_log_path = "{}-server.log" .format (log_basename )
604
605
open (server_log_path , 'w' ).close ()
606
+ self .log_files .append (server_log_path )
605
607
os .environ ["LLDB_DEBUGSERVER_LOG_FILE" ] = server_log_path
606
608
607
609
# Communicate channels to lldb-server
@@ -623,12 +625,13 @@ def disableLogChannelsForCurrentTest(self):
623
625
# Retrieve the server log (if any) from the remote system. It is assumed the server log
624
626
# is writing to the "server.log" file in the current test directory. This can be
625
627
# achieved by setting LLDB_DEBUGSERVER_LOG_FILE="server.log" when starting remote
626
- # platform. If the remote logging is not enabled, then just let the Get() command silently
627
- # fail.
628
+ # platform.
628
629
if lldb .remote_platform :
629
- lldb .remote_platform .Get (
630
- lldb .SBFileSpec ("server.log" ), lldb .SBFileSpec (
631
- self .getLogBasenameForCurrentTest () + "-server.log" ))
630
+ server_log_path = self .getLogBasenameForCurrentTest () + "-server.log"
631
+ if lldb .remote_platform .Get (
632
+ lldb .SBFileSpec ("server.log" ),
633
+ lldb .SBFileSpec (server_log_path )).Success ():
634
+ self .log_files .append (server_log_path )
632
635
633
636
def setPlatformWorkingDir (self ):
634
637
if not lldb .remote_platform or not configuration .lldb_platform_working_dir :
@@ -800,11 +803,12 @@ def setUp(self):
800
803
# List of forked process PIDs
801
804
self .forkedProcessPids = []
802
805
803
- # Create a string buffer to record the session info, to be dumped into a
804
- # test case specific file if test failure is encountered.
805
- self .log_basename = self .getLogBasenameForCurrentTest ()
806
+ # List of log files produced by the current test.
807
+ self .log_files = []
808
+
809
+ session_file = self .getLogBasenameForCurrentTest ()+ ".log"
810
+ self .log_files .append (session_file )
806
811
807
- session_file = "{}.log" .format (self .log_basename )
808
812
# Python 3 doesn't support unbuffered I/O in text mode. Open buffered.
809
813
self .session = encoded_file .open (session_file , "utf-8" , mode = "w" )
810
814
@@ -1218,14 +1222,13 @@ def dumpSessionInfo(self):
1218
1222
del self .session
1219
1223
1220
1224
# process the log files
1221
- log_files_for_this_test = glob .glob (self .log_basename + "*" )
1222
-
1223
1225
if prefix != 'Success' or lldbtest_config .log_success :
1224
1226
# keep all log files, rename them to include prefix
1227
+ src_log_basename = self .getLogBasenameForCurrentTest (None )
1225
1228
dst_log_basename = self .getLogBasenameForCurrentTest (prefix )
1226
- for src in log_files_for_this_test :
1229
+ for src in self . log_files :
1227
1230
if os .path .isfile (src ):
1228
- dst = src .replace (self . log_basename , dst_log_basename )
1231
+ dst = src .replace (src_log_basename , dst_log_basename )
1229
1232
if os .name == "nt" and os .path .isfile (dst ):
1230
1233
# On Windows, renaming a -> b will throw an exception if
1231
1234
# b exists. On non-Windows platforms it silently
@@ -1239,8 +1242,9 @@ def dumpSessionInfo(self):
1239
1242
os .rename (src , dst )
1240
1243
else :
1241
1244
# success! (and we don't want log files) delete log files
1242
- for log_file in log_files_for_this_test :
1243
- remove_file (log_file )
1245
+ for log_file in self .log_files :
1246
+ if os .path .isfile (log_file ):
1247
+ remove_file (log_file )
1244
1248
1245
1249
# ====================================================
1246
1250
# Config. methods supported through a plugin interface
0 commit comments