11
11
from lit .llvm .subst import FindTool
12
12
from lit .llvm .subst import ToolSubst
13
13
14
+ import posixpath
14
15
15
16
def _get_lldb_init_path (config ):
16
17
return os .path .join (config .test_exec_root , "lit-lldb-init-quiet" )
@@ -24,7 +25,7 @@ def _disallow(config, execName):
24
25
config .substitutions .append ((" {0} " .format (execName ), warning .format (execName )))
25
26
26
27
27
- def get_lldb_args (config , suffix = None ):
28
+ def get_lldb_args (config , suffix = "" ):
28
29
lldb_args = []
29
30
if "remote-linux" in config .available_features :
30
31
lldb_args += [
@@ -34,9 +35,9 @@ def get_lldb_args(config, suffix=None):
34
35
f'"platform connect { config .lldb_platform_url } "' ,
35
36
]
36
37
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")
38
39
if suffix :
39
- dir += f"/ { suffix } "
40
+ dir += posixpath . join ( dir , f" { suffix } ")
40
41
lldb_args += [
41
42
"-O" ,
42
43
f'"platform shell mkdir -p { dir } "' ,
@@ -54,22 +55,27 @@ def __init__(
54
55
super ().__init__ (execute_external , extra_substitutions , preamble_commands )
55
56
56
57
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.
57
61
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 ),
69
72
)
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
73
79
return super ().execute (test , litConfig )
74
80
75
81
0 commit comments