umockdev-test: Make possible to use a wrapper to run tests
Support LIBFPRINT_TEST_WRAPPER env variable to run tests with a wrapper.
This commit is contained in:
parent
9892eb1c03
commit
19a50cfdc3
1 changed files with 14 additions and 17 deletions
|
@ -50,17 +50,22 @@ def cmp_pngs(png_a, png_b):
|
||||||
for y in range(img_a.get_height()):
|
for y in range(img_a.get_height()):
|
||||||
assert(data_a[y * stride + x * 4] == data_b[y * stride + x * 4])
|
assert(data_a[y * stride + x * 4] == data_b[y * stride + x * 4])
|
||||||
|
|
||||||
def capture():
|
def get_umockdev_runner(ioctl_basename):
|
||||||
ioctl = os.path.join(ddir, "capture.ioctl")
|
ioctl = os.path.join(ddir, "{}.ioctl".format(ioctl_basename))
|
||||||
device = os.path.join(ddir, "device")
|
device = os.path.join(ddir, "device")
|
||||||
dev = open(ioctl).readline().strip()
|
dev = open(ioctl).readline().strip()
|
||||||
assert dev.startswith('@DEV ')
|
assert dev.startswith('@DEV ')
|
||||||
dev = dev[5:]
|
dev = dev[5:]
|
||||||
|
|
||||||
subprocess.check_call(['umockdev-run', '-d', device,
|
umockdev = ['umockdev-run', '-d', device,
|
||||||
'-i', "%s=%s" % (dev, ioctl),
|
'-i', "%s=%s" % (dev, ioctl),
|
||||||
'--',
|
'--']
|
||||||
'%s' % os.path.join(edir, "capture.py"),
|
wrapper = os.getenv('LIBFPRINT_TEST_WRAPPER')
|
||||||
|
return umockdev + (wrapper.split(' ') if wrapper else []) + [sys.executable]
|
||||||
|
|
||||||
|
def capture():
|
||||||
|
subprocess.check_call(get_umockdev_runner("capture") +
|
||||||
|
['%s' % os.path.join(edir, "capture.py"),
|
||||||
'%s' % os.path.join(tmpdir, "capture.png")])
|
'%s' % os.path.join(tmpdir, "capture.png")])
|
||||||
|
|
||||||
assert os.path.isfile(os.path.join(tmpdir, "capture.png"))
|
assert os.path.isfile(os.path.join(tmpdir, "capture.png"))
|
||||||
|
@ -69,16 +74,8 @@ def capture():
|
||||||
cmp_pngs(os.path.join(tmpdir, "capture.png"), os.path.join(ddir, "capture.png"))
|
cmp_pngs(os.path.join(tmpdir, "capture.png"), os.path.join(ddir, "capture.png"))
|
||||||
|
|
||||||
def custom():
|
def custom():
|
||||||
ioctl = os.path.join(ddir, "custom.ioctl")
|
subprocess.check_call(get_umockdev_runner("custom") +
|
||||||
device = os.path.join(ddir, "device")
|
['%s' % os.path.join(ddir, "custom.py")])
|
||||||
dev = open(ioctl).readline().strip()
|
|
||||||
assert dev.startswith('@DEV ')
|
|
||||||
dev = dev[5:]
|
|
||||||
|
|
||||||
subprocess.check_call(['umockdev-run', '-d', device,
|
|
||||||
'-i', "%s=%s" % (dev, ioctl),
|
|
||||||
'--',
|
|
||||||
'%s' % os.path.join(ddir, "custom.py")])
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if os.path.exists(os.path.join(ddir, "capture.ioctl")):
|
if os.path.exists(os.path.join(ddir, "capture.ioctl")):
|
||||||
|
|
Loading…
Reference in a new issue