1111from lit .llvm .subst import FindTool
1212from lit .llvm .subst import ToolSubst
1313
14+ import posixpath
1415
1516def _get_lldb_init_path (config ):
1617 return os .path .join (config .test_exec_root , "lit-lldb-init-quiet" )
@@ -24,7 +25,7 @@ def _disallow(config, execName):
2425 config .substitutions .append ((" {0} " .format (execName ), warning .format (execName )))
2526
2627
27- def get_lldb_args (config , suffix = None ):
28+ def get_lldb_args (config , suffix = "" ):
2829 lldb_args = []
2930 if "remote-linux" in config .available_features :
3031 lldb_args += [
@@ -34,9 +35,9 @@ def get_lldb_args(config, suffix=None):
3435 f'"platform connect { config .lldb_platform_url } "' ,
3536 ]
3637 if config .lldb_platform_working_dir :
37- dir = f"{ config .lldb_platform_working_dir } / shell"
38+ dir = posixpath . join ( f"{ config .lldb_platform_working_dir } " , " shell")
3839 if suffix :
39- dir += f"/ { suffix } "
40+ dir += posixpath . join ( dir , f" { suffix } ")
4041 lldb_args += [
4142 "-O" ,
4243 f'"platform shell mkdir -p { dir } "' ,
@@ -54,22 +55,27 @@ def __init__(
5455 super ().__init__ (execute_external , extra_substitutions , preamble_commands )
5556
5657 def execute (self , test , litConfig ):
58+ # Run each Shell test in a separate directory (on remote).
59+
60+ # Find directory change command in %lldb substitution.
5761 for i , t in enumerate (test .config .substitutions ):
58- try :
59- if re .match (t [0 ], "%lldb" ):
60- cmd = t [1 ]
61- if '-O "platform settings -w ' in cmd :
62- args_def = " " .join (get_lldb_args (test .config ))
63- args_unique = " " .join (
64- get_lldb_args (test .config , "/" .join (test .path_in_suite ))
65- )
66- test .config .substitutions [i ] = (
67- t [0 ],
68- cmd .replace (args_def , args_unique ),
62+ if re .match (t [0 ], "%lldb" ):
63+ cmd = t [1 ]
64+ if '-O "platform settings -w ' in cmd :
65+ # If command is present, it is added by get_lldb_args.
66+ # Replace the path with the tests' path in suite.
67+ args_def = " " .join (get_lldb_args (test .config ))
68+ args_unique = " " .join (
69+ get_lldb_args (
70+ test .config ,
71+ posixpath .join (* test .path_in_suite ),
6972 )
70- break
71- except :
72- pass
73+ )
74+ test .config .substitutions [i ] = (
75+ t [0 ],
76+ cmd .replace (args_def , args_unique ),
77+ )
78+ break
7379 return super ().execute (test , litConfig )
7480
7581
0 commit comments