Skip to content

Commit

Permalink
code: fix {} parsing and ns_only for L3Qemu
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Hopps <chopps@labn.net>
  • Loading branch information
choppsv1 committed Aug 3, 2023
1 parent 0869d8f commit d7d5f65
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion munet/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ def run_in_window(
# XXX need to test ssh in Xterm
sudo_path = get_exec_path_host(["sudo"])
# This first test case seems same as last but using list instead of string?
if self.is_vm and self.use_ssh: # pylint: disable=E1101
if self.is_vm and self.use_ssh and not ns_only: # pylint: disable=E1101
if isinstance(cmd, str):
cmd = shlex.split(cmd)
cmd = ["/usr/bin/env", f"MUNET_NODENAME={self.name}"] + cmd
Expand Down
5 changes: 3 additions & 2 deletions munet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,14 @@ def get_shcmd(unet, host, kinds, execfmt, ucmd):
if not execfmt:
return ""

# Do substitutions for {} in string
# Do substitutions for {} and {N} in string
numfmt = len(re.findall(r"{\d*}", execfmt))
if numfmt > 1:
ucmd = execfmt.format(*shlex.split(ucmd))
elif numfmt:
ucmd = execfmt.format(ucmd)
elif len(re.findall(r"{[a-zA-Z_][0-9a-zA-Z_\.]*}", execfmt)):
# look for any pair of {}s but do not count escaped {{ or }}
elif len(re.findall(r"{[^}]+}", execfmt.replace("{{", "").replace("}}", ""))):
if execfmt.endswith('"'):
fstring = "f'''" + execfmt + "'''"
else:
Expand Down
5 changes: 3 additions & 2 deletions munet/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,14 @@ def pytest_hook_open_shell(self):

bps = self.unet.cfgopt.getoption("--gdb-breakpoints", "").split(",")
for bp in bps:
gdbcmd += f" '-ex=b {bp}'"
if bp:
gdbcmd += f" '-ex=b {bp}'"

cmds = self.config.get("gdb-run-cmd", [])
for cmd in cmds:
gdbcmd += f" '-ex={cmd}'"

self.run_in_window(gdbcmd)
self.run_in_window(gdbcmd, ns_only=True)
elif should_gdb and use_emacs:
gdbcmd = gdbcmd.replace("gdb ", "gdb -i=mi ")
ecbin = self.get_exec_path("emacsclient")
Expand Down

0 comments on commit d7d5f65

Please sign in to comment.