Hash :
84dd65a8
Author :
Date :
2020-10-13T20:21:28
[test] Remove timeout from test runners See https://github.com/harfbuzz/harfbuzz/issues/2707#issuecomment-707744079 This wasn’t inconsistent as well, HB_TEST_SUBSET_FUZZER_TIMEOUT defaulted to 12 in the test runner, but it was overridden to 50 in meson.build, and then meson has its own test timeout.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
#!/usr/bin/env python3
import sys, os, subprocess, tempfile, shutil
def cmd (command):
# https://stackoverflow.com/a/4408409 as we might have huge output sometimes
with tempfile.TemporaryFile () as tempf:
p = subprocess.Popen (command, stderr=tempf)
try:
p.wait ()
tempf.seek (0)
text = tempf.read ()
#TODO: Detect debug mode with a better way
is_debug_mode = b"SANITIZE" in text
return ("" if is_debug_mode else text.decode ("utf-8").strip ()), p.returncode
except subprocess.TimeoutExpired:
return 'error: timeout, ' + ' '.join (command), 1
srcdir = os.getenv ("srcdir", ".")
EXEEXT = os.getenv ("EXEEXT", "")
top_builddir = os.getenv ("top_builddir", ".")
hb_shape_fuzzer = os.path.join (top_builddir, "hb-shape-fuzzer" + EXEEXT)
if not os.path.exists (hb_shape_fuzzer):
if len (sys.argv) == 1 or not os.path.exists (sys.argv[1]):
sys.exit ("""Failed to find hb-shape-fuzzer binary automatically,
please provide it as the first argument to the tool""")
hb_shape_fuzzer = sys.argv[1]
print ('hb_shape_fuzzer:', hb_shape_fuzzer)
fails = 0
valgrind = None
if os.getenv ('RUN_VALGRIND', ''):
valgrind = shutil.which ('valgrind')
if valgrind is None:
sys.exit ("""Valgrind requested but not found.""")
parent_path = os.path.join (srcdir, "fonts")
for file in os.listdir (parent_path):
path = os.path.join (parent_path, file)
if valgrind:
text, returncode = cmd ([valgrind, '--leak-check=full', '--error-exitcode=1', hb_shape_fuzzer, path])
else:
text, returncode = cmd ([hb_shape_fuzzer, path])
if 'error' in text:
returncode = 1
if (not valgrind or returncode) and text.strip ():
print (text)
if returncode != 0:
print ('failure on %s' % file)
fails = fails + 1
if fails:
sys.exit ("%d shape fuzzer related tests failed." % fails)