Skip to content
Snippets Groups Projects
Commit 75fb5b38 authored by Razvan Deaconescu's avatar Razvan Deaconescu
Browse files

asg/parallel-graph: Fix tests to use timeout


Use `Popen.communicate()` to use a timeout argument in case a process
blocks indefinitely because of improper synchronization.

Signed-off-by: default avatarRazvan Deaconescu <razvan.deaconescu@upb.ro>
parent 02edde74
No related branches found
No related tags found
No related merge requests found
Pipeline #45400 passed
......@@ -22,11 +22,23 @@ def check(testname):
"""
with subprocess.Popen([os.path.join(src, "serial"), testname],
stdout=subprocess.PIPE) as proc_serial_res:
serial_out = str(proc_serial_res.stdout.read()).strip("\n")
try:
outs, _ = proc_serial_res.communicate(timeout=3)
serial_out = str(outs).strip("\n")
except subprocess.TimeoutExpired:
proc_serial_res.kill()
outs, _ = proc_serial_res.communicate()
serial_out = ""
for _ in range(0, 100):
with subprocess.Popen([os.path.join(src, "parallel"), testname],
stdout=subprocess.PIPE) as proc_parallel_res:
parallel_out = str(proc_parallel_res.stdout.read()).strip("\n")
try:
outs, _ = proc_parallel_res.communicate(timeout=3)
parallel_out = str(outs).strip("\n")
except subprocess.TimeoutExpired:
proc_parallel_res.kill()
outs, _ = proc_parallel_res.communicate()
parallel_out = ""
if serial_out != parallel_out:
return False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment