tests: Detect pcap vs. ioctl recording and run correct one
This commit is contained in:
parent
c989cc4b95
commit
daaafc80c3
1 changed files with 26 additions and 7 deletions
|
@ -17,6 +17,8 @@ try:
|
|||
if version < (0, 13, 2):
|
||||
print('umockdev is too old for test to be reliable, expect random failures!')
|
||||
print('Please update umockdev to at least 0.13.2.')
|
||||
pcap_supported = version >= (0, 15, 6) or os.getenv('CI_COMMIT_SHA') is not None
|
||||
|
||||
except FileNotFoundError:
|
||||
print('umockdev-run not found, skipping test!')
|
||||
print('Please install umockdev.')
|
||||
|
@ -55,14 +57,31 @@ def cmp_pngs(png_a, png_b):
|
|||
|
||||
def get_umockdev_runner(ioctl_basename):
|
||||
ioctl = os.path.join(ddir, "{}.ioctl".format(ioctl_basename))
|
||||
device = os.path.join(ddir, "device")
|
||||
dev = open(ioctl).readline().strip()
|
||||
assert dev.startswith('@DEV ')
|
||||
dev = dev[5:]
|
||||
pcap = os.path.join(ddir, "{}.pcapng".format(ioctl_basename))
|
||||
|
||||
umockdev = ['umockdev-run', '-d', device,
|
||||
'-i', "%s=%s" % (dev, ioctl),
|
||||
'--']
|
||||
device = os.path.join(ddir, "device")
|
||||
|
||||
if os.path.exists(pcap):
|
||||
p = open(device).readline().strip()
|
||||
assert p.startswith('P: ')
|
||||
syspath = '/sys' + p[3:]
|
||||
|
||||
umockdev = ['umockdev-run', '-d', device,
|
||||
'-p', "%s=%s" % (syspath, pcap),
|
||||
'--']
|
||||
|
||||
# Skip test if we detect too old umockdev for pcap replay
|
||||
if not pcap_supported:
|
||||
sys.exit(77)
|
||||
|
||||
else:
|
||||
dev = open(ioctl).readline().strip()
|
||||
assert dev.startswith('@DEV ')
|
||||
dev = dev[5:]
|
||||
|
||||
umockdev = ['umockdev-run', '-d', device,
|
||||
'-i', "%s=%s" % (dev, ioctl),
|
||||
'--']
|
||||
wrapper = os.getenv('LIBFPRINT_TEST_WRAPPER')
|
||||
return umockdev + (wrapper.split(' ') if wrapper else []) + [sys.executable]
|
||||
|
||||
|
|
Loading…
Reference in a new issue