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):
|
if version < (0, 13, 2):
|
||||||
print('umockdev is too old for test to be reliable, expect random failures!')
|
print('umockdev is too old for test to be reliable, expect random failures!')
|
||||||
print('Please update umockdev to at least 0.13.2.')
|
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:
|
except FileNotFoundError:
|
||||||
print('umockdev-run not found, skipping test!')
|
print('umockdev-run not found, skipping test!')
|
||||||
print('Please install umockdev.')
|
print('Please install umockdev.')
|
||||||
|
@ -55,7 +57,24 @@ def cmp_pngs(png_a, png_b):
|
||||||
|
|
||||||
def get_umockdev_runner(ioctl_basename):
|
def get_umockdev_runner(ioctl_basename):
|
||||||
ioctl = os.path.join(ddir, "{}.ioctl".format(ioctl_basename))
|
ioctl = os.path.join(ddir, "{}.ioctl".format(ioctl_basename))
|
||||||
|
pcap = os.path.join(ddir, "{}.pcapng".format(ioctl_basename))
|
||||||
|
|
||||||
device = os.path.join(ddir, "device")
|
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()
|
dev = open(ioctl).readline().strip()
|
||||||
assert dev.startswith('@DEV ')
|
assert dev.startswith('@DEV ')
|
||||||
dev = dev[5:]
|
dev = dev[5:]
|
||||||
|
|
Loading…
Reference in a new issue