From 0bc768520648649bd6646f4aee6ee8a4049ad37c Mon Sep 17 00:00:00 2001 From: Louis Scalbert Date: Fri, 18 Feb 2022 13:37:00 +0100 Subject: [PATCH] topotests: set router name as title in screen and xterm When running a topotest with the --shell or --vtysh argument, the window titles of the routers are generic. Set the router name as title to identify correctly the window. Signed-off-by: Louis Scalbert --- tests/topotests/lib/micronet.py | 3 +++ tests/topotests/lib/micronet_cli.py | 6 +++--- tests/topotests/lib/topotest.py | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/topotests/lib/micronet.py b/tests/topotests/lib/micronet.py index 05f1edc106..59dd80ff7b 100644 --- a/tests/topotests/lib/micronet.py +++ b/tests/topotests/lib/micronet.py @@ -358,6 +358,9 @@ class Commander(object): # pylint: disable=R0205 # wait for not supported in screen for now channel = None cmd = [self.get_exec_path("screen")] + if title: + cmd.append("-t") + cmd.append(title) if not os.path.exists( "/run/screen/S-{}/{}".format(os.environ["USER"], os.environ["STY"]) ): diff --git a/tests/topotests/lib/micronet_cli.py b/tests/topotests/lib/micronet_cli.py index 6459d5d151..4292f47ce0 100644 --- a/tests/topotests/lib/micronet_cli.py +++ b/tests/topotests/lib/micronet_cli.py @@ -113,11 +113,11 @@ def doline(unet, line, writef): hosts = [unet.hosts[x] for x in args] for host in hosts: if cmd == "t" or cmd == "term": - host.run_in_window("bash") + host.run_in_window("bash", title="sh-%s" % host) elif cmd == "v" or cmd == "vtysh": - host.run_in_window("vtysh") + host.run_in_window("vtysh", title="vt-%s" % host) elif cmd == "x" or cmd == "xterm": - host.run_in_window("bash", forcex=True) + host.run_in_window("bash", title="sh-%s" % host, forcex=True) elif cmd == "sh": hosts, cmd = host_cmd_split(unet, oargs) for host in hosts: diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index 6be644ac00..d3438f67e5 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -1613,7 +1613,7 @@ class Router(Node): shell_routers = g_extra_config["shell"] if "all" in shell_routers or self.name in shell_routers: - self.run_in_window(os.getenv("SHELL", "bash")) + self.run_in_window(os.getenv("SHELL", "bash"), title="sh-%s" % self.name) if self.daemons["eigrpd"] == 1: eigrpd_path = os.path.join(self.daemondir, "eigrpd") @@ -1631,7 +1631,7 @@ class Router(Node): vtysh_routers = g_extra_config["vtysh"] if "all" in vtysh_routers or self.name in vtysh_routers: - self.run_in_window("vtysh") + self.run_in_window("vtysh", title="vt-%s" % self.name) return status -- 2.39.5