mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
Merge pull request #18730 from y-bharath14/srib-tests-v14
tests: Proper handling of resource allocation
This commit is contained in:
commit
99f6f32dde
|
@ -619,13 +619,13 @@ def iproute2_is_json_capable():
|
||||||
"""
|
"""
|
||||||
if is_linux():
|
if is_linux():
|
||||||
try:
|
try:
|
||||||
subp = subprocess.Popen(
|
with subprocess.Popen(
|
||||||
["ip", "-json", "route", "show"],
|
["ip", "-json", "route", "show"],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
)
|
) as subp:
|
||||||
iproute2_err = subp.communicate()[1].splitlines()[0].split()[0]
|
iproute2_err = subp.communicate()[1].splitlines()[0].split()[0]
|
||||||
|
|
||||||
if iproute2_err != "Error:":
|
if iproute2_err != "Error:":
|
||||||
return True
|
return True
|
||||||
|
@ -644,13 +644,13 @@ def iproute2_is_vrf_capable():
|
||||||
|
|
||||||
if is_linux():
|
if is_linux():
|
||||||
try:
|
try:
|
||||||
subp = subprocess.Popen(
|
with subprocess.Popen(
|
||||||
["ip", "route", "show", "vrf"],
|
["ip", "route", "show", "vrf"],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
)
|
) as subp:
|
||||||
iproute2_err = subp.communicate()[1].splitlines()[0].split()[0]
|
iproute2_err = subp.communicate()[1].splitlines()[0].split()[0]
|
||||||
|
|
||||||
if iproute2_err != "Error:":
|
if iproute2_err != "Error:":
|
||||||
return True
|
return True
|
||||||
|
@ -669,13 +669,13 @@ def iproute2_is_fdb_get_capable():
|
||||||
|
|
||||||
if is_linux():
|
if is_linux():
|
||||||
try:
|
try:
|
||||||
subp = subprocess.Popen(
|
with subprocess.Popen(
|
||||||
["bridge", "fdb", "get", "help"],
|
["bridge", "fdb", "get", "help"],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
)
|
) as subp:
|
||||||
iproute2_out = subp.communicate()[1].splitlines()[0].split()[0]
|
iproute2_out = subp.communicate()[1].splitlines()[0].split()[0]
|
||||||
|
|
||||||
if "Usage" in str(iproute2_out):
|
if "Usage" in str(iproute2_out):
|
||||||
return True
|
return True
|
||||||
|
@ -1472,7 +1472,8 @@ class Router(Node):
|
||||||
self.ns_cmd = "sudo nsenter -a -t {} ".format(self.pid)
|
self.ns_cmd = "sudo nsenter -a -t {} ".format(self.pid)
|
||||||
try:
|
try:
|
||||||
# Allow escaping from running inside docker
|
# 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)
|
m = re.search("[0-9]+:cpuset:/docker/([a-f0-9]+)", cgroup)
|
||||||
if m:
|
if m:
|
||||||
self.ns_cmd = "docker exec -it {} ".format(m.group(1)) + self.ns_cmd
|
self.ns_cmd = "docker exec -it {} ".format(m.group(1)) + self.ns_cmd
|
||||||
|
@ -2076,7 +2077,8 @@ class Router(Node):
|
||||||
try:
|
try:
|
||||||
fname = f"{valgrind_logbase}.{p.pid}"
|
fname = f"{valgrind_logbase}.{p.pid}"
|
||||||
logging.info("Checking %s for valgrind launch info", fname)
|
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:
|
except FileNotFoundError:
|
||||||
logging.info("%s not present yet", fname)
|
logging.info("%s not present yet", fname)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue