2023-11-14 23:02:42 +00:00
|
|
|
#!/usr/bin/env python
|
2018-09-24 16:32:10 +00:00
|
|
|
#
|
|
|
|
# Post-process the output of test-dumpevents and check it for correctness.
|
|
|
|
#
|
|
|
|
|
|
|
|
import math
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
|
|
|
text = sys.stdin.readlines()
|
|
|
|
|
|
|
|
try:
|
|
|
|
expect_inserted_pos = text.index("Inserted:\n")
|
|
|
|
expect_active_pos = text.index("Active:\n")
|
|
|
|
got_inserted_pos = text.index("Inserted events:\n")
|
|
|
|
got_active_pos = text.index("Active events:\n")
|
|
|
|
except ValueError:
|
2023-11-14 23:02:42 +00:00
|
|
|
sys.stderr.write("Missing expected dividing line in dumpevents output")
|
2018-09-24 16:32:10 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if not (expect_inserted_pos < expect_active_pos <
|
|
|
|
got_inserted_pos < got_active_pos):
|
2023-11-14 23:02:42 +00:00
|
|
|
sys.stderr.write("Sections out of order in dumpevents output")
|
2018-09-24 16:32:10 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
now,T= text[1].split()
|
|
|
|
T = float(T)
|
|
|
|
|
|
|
|
want_inserted = set(text[expect_inserted_pos+1:expect_active_pos])
|
|
|
|
want_active = set(text[expect_active_pos+1:got_inserted_pos-1])
|
|
|
|
got_inserted = set(text[got_inserted_pos+1:got_active_pos])
|
|
|
|
got_active = set(text[got_active_pos+1:])
|
|
|
|
|
|
|
|
pat = re.compile(r'Timeout=([0-9\.]+)')
|
|
|
|
def replace_time(m):
|
|
|
|
t = float(m.group(1))
|
|
|
|
if .9 < abs(t-T) < 1.1:
|
|
|
|
return "Timeout=T+1"
|
|
|
|
elif 2.4 < abs(t-T) < 2.6:
|
|
|
|
return "Timeout=T+2.5"
|
|
|
|
else:
|
|
|
|
return m.group(0)
|
|
|
|
|
|
|
|
cleaned_inserted = set( pat.sub(replace_time, s) for s in got_inserted
|
|
|
|
if "Internal" not in s)
|
|
|
|
|
|
|
|
if cleaned_inserted != want_inserted:
|
2023-11-14 23:02:42 +00:00
|
|
|
sys.stderr.write("Inserted event lists were not as expected!")
|
2018-09-24 16:32:10 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if set(got_active) != set(want_active):
|
2023-11-14 23:02:42 +00:00
|
|
|
sys.stderr.write("Active event lists were not as expected!")
|
2018-09-24 16:32:10 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|