run-shape-fuzzer-tests.py 1.1 KB
Newer Older
1 2
#!/usr/bin/env python

3 4
from __future__ import print_function, division, absolute_import

5 6
import sys, os, subprocess

7 8
if os.environ.get ("SKIPFUZZERTESTS", "") != "": sys.exit (0)

9 10 11
srcdir = os.environ.get ("srcdir", ".")
EXEEXT = os.environ.get ("EXEEXT", "")
top_builddir = os.environ.get ("top_builddir", ".")
12
hb_shape_fuzzer = os.path.join (top_builddir, "hb-shape-fuzzer" + EXEEXT)
13

14
if not os.path.exists (hb_shape_fuzzer):
15
	if len (sys.argv) == 1 or not os.path.exists (sys.argv[1]):
16
		print ("""Failed to find hb-shape-fuzzer binary automatically,
17 18 19
please provide it as the first argument to the tool""")
		sys.exit (1)

20
	hb_shape_fuzzer = sys.argv[1]
21

22
print ('hb_shape_fuzzer:', hb_shape_fuzzer)
23 24
fails = 0

25 26
parent_path = os.path.join (srcdir, "..", "shaping", "data", "in-house", "tests")
for line in open (os.path.join (parent_path, "fuzzed.tests")):
27
	font = line.split (":")[0]
28
	font_path = os.path.join (parent_path, font)
29

30
	p = subprocess.Popen ([hb_shape_fuzzer, font_path])
31 32 33 34 35

	if p.wait () != 0:
		fails = fails + 1

if fails:
36
	print ("%i shape fuzzer related tests failed." % fails)
37
	sys.exit (1)