tests: Fix test_input_accel() leaking a daemon
test_input_accel() uses umockdev-run, and killing umockdev-run doesn't kill the child iio-sensor-proxy daemon we make it spawn, making any test running after this one fail. As the tests are run alphabetically, we were lucky that this test was the last one, but we can't rely on that. Instead, use psutil to list all the children processes and kill those before killing umockdev-run.
This commit is contained in:
@@ -13,6 +13,7 @@ variables:
|
|||||||
git
|
git
|
||||||
python3-gobject
|
python3-gobject
|
||||||
python3-dbusmock
|
python3-dbusmock
|
||||||
|
python3-psutil
|
||||||
umockdev
|
umockdev
|
||||||
|
|
||||||
build_stable:
|
build_stable:
|
||||||
|
@@ -23,6 +23,7 @@ import sys
|
|||||||
import dbus
|
import dbus
|
||||||
import tempfile
|
import tempfile
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import psutil
|
||||||
import unittest
|
import unittest
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@@ -176,6 +177,8 @@ class Tests(dbusmock.DBusTestCase):
|
|||||||
|
|
||||||
if self.daemon:
|
if self.daemon:
|
||||||
try:
|
try:
|
||||||
|
for child in psutil.Process(self.daemon.pid).children(recursive=True):
|
||||||
|
child.kill()
|
||||||
self.daemon.kill()
|
self.daemon.kill()
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
Reference in New Issue
Block a user