Fix bwrap leak test
Our checking of processes during bwrap leak testing is racy. We handle these races by ignoring a couple exceptions that may happen due to things moving while we iterate over them. However if this happens the first time through the loop sleep_proc won't ever be set then we check its value which is itself an exception. Address this by checking the value of sleep_proc within the try block so that we know no exceptions due to races occured and the value is set. Change-Id: Iea6c7539dceaa3939dcdef5abeccff6481f837f8
This commit is contained in:
parent
57fa349ebf
commit
4821026db6
|
@ -74,10 +74,10 @@ class TestBubblewrap(testtools.TestCase):
|
|||
sleep_proc = [pid for pid in os.listdir("/proc") if
|
||||
os.path.isfile("/proc/%s/cmdline" % pid) and
|
||||
open("/proc/%s/cmdline" % pid).read() == cmdline]
|
||||
if not sleep_proc:
|
||||
break
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except ProcessLookupError:
|
||||
pass
|
||||
if not sleep_proc:
|
||||
break
|
||||
time.sleep(1)
|
||||
|
|
Loading…
Reference in New Issue