Merge pull request #18730 from y-bharath14/srib-tests-v14

tests: Proper handling of resource allocation
This commit is contained in:
Donald Sharp 2025-04-28 15:24:42 -04:00 committed by GitHub
commit 99f6f32dde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -619,12 +619,12 @@ def iproute2_is_json_capable():
"""
if is_linux():
try:
subp = subprocess.Popen(
with subprocess.Popen(
["ip", "-json", "route", "show"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
)
) as subp:
iproute2_err = subp.communicate()[1].splitlines()[0].split()[0]
if iproute2_err != "Error:":
@ -644,12 +644,12 @@ def iproute2_is_vrf_capable():
if is_linux():
try:
subp = subprocess.Popen(
with subprocess.Popen(
["ip", "route", "show", "vrf"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
)
) as subp:
iproute2_err = subp.communicate()[1].splitlines()[0].split()[0]
if iproute2_err != "Error:":
@ -669,12 +669,12 @@ def iproute2_is_fdb_get_capable():
if is_linux():
try:
subp = subprocess.Popen(
with subprocess.Popen(
["bridge", "fdb", "get", "help"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
)
) as subp:
iproute2_out = subp.communicate()[1].splitlines()[0].split()[0]
if "Usage" in str(iproute2_out):
@ -1472,7 +1472,8 @@ class Router(Node):
self.ns_cmd = "sudo nsenter -a -t {} ".format(self.pid)
try:
# Allow escaping from running inside docker
cgroup = open("/proc/1/cgroup").read()
with open("/proc/1/cgroup") as file:
cgroup = file.read()
m = re.search("[0-9]+:cpuset:/docker/([a-f0-9]+)", cgroup)
if m:
self.ns_cmd = "docker exec -it {} ".format(m.group(1)) + self.ns_cmd
@ -2076,7 +2077,8 @@ class Router(Node):
try:
fname = f"{valgrind_logbase}.{p.pid}"
logging.info("Checking %s for valgrind launch info", fname)
o = open(fname, encoding="ascii").read()
with open(fname, encoding="ascii") as file:
o = file.read()
except FileNotFoundError:
logging.info("%s not present yet", fname)
else: