Skip to content

Commit fd19238

Browse files
committed
Proper remote paths concatenation for Shell tests
1 parent 2a433d0 commit fd19238

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

lldb/test/Shell/helper/toolchain.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from lit.llvm.subst import FindTool
1212
from lit.llvm.subst import ToolSubst
1313

14+
import posixpath
1415

1516
def _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

Comments
 (0)