2018-03-15 03:15:33 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2018-03-29 10:18:47 +02:00
|
|
|
from __future__ import print_function, division, absolute_import
|
|
|
|
|
2018-03-15 03:15:33 +01:00
|
|
|
import sys, os, subprocess
|
|
|
|
|
2018-10-01 08:10:29 +02:00
|
|
|
if os.environ.get ("SKIPFUZZERTESTS", "") != "": sys.exit (0)
|
|
|
|
|
2018-03-15 03:15:33 +01:00
|
|
|
srcdir = os.environ.get ("srcdir", ".")
|
|
|
|
EXEEXT = os.environ.get ("EXEEXT", "")
|
|
|
|
top_builddir = os.environ.get ("top_builddir", ".")
|
2018-03-16 02:27:01 +01:00
|
|
|
hb_subset_fuzzer = os.path.join (top_builddir, "hb-subset-fuzzer" + EXEEXT)
|
2018-04-17 16:21:22 +02:00
|
|
|
hb_subset_get_codepoints_fuzzer = os.path.join (top_builddir, "hb-subset-get-codepoints-fuzzer" + EXEEXT)
|
2018-03-15 03:15:33 +01:00
|
|
|
|
|
|
|
if not os.path.exists (hb_subset_fuzzer):
|
2018-04-17 16:21:22 +02:00
|
|
|
if len (sys.argv) < 2 or not os.path.exists (sys.argv[1]):
|
2018-03-15 03:15:33 +01:00
|
|
|
print ("""Failed to find hb-subset-fuzzer binary automatically,
|
|
|
|
please provide it as the first argument to the tool""")
|
|
|
|
sys.exit (1)
|
|
|
|
|
|
|
|
hb_subset_fuzzer = sys.argv[1]
|
|
|
|
|
2018-04-17 16:21:22 +02:00
|
|
|
if not os.path.exists (hb_subset_get_codepoints_fuzzer):
|
|
|
|
if len (sys.argv) < 3 or not os.path.exists (sys.argv[2]):
|
|
|
|
print ("""Failed to find hb-subset-get-codepoints-fuzzer binary automatically,
|
|
|
|
please provide it as the second argument to the tool""")
|
|
|
|
sys.exit (1)
|
|
|
|
|
|
|
|
hb_subset_get_codepoints_fuzzer = sys.argv[2]
|
|
|
|
|
2018-03-15 03:15:33 +01:00
|
|
|
print ('hb_subset_fuzzer:', hb_subset_fuzzer)
|
|
|
|
fails = 0
|
|
|
|
|
|
|
|
parent_path = os.path.join (srcdir, "..", "subset", "data", "fonts")
|
2018-03-15 23:41:08 +01:00
|
|
|
print ("running subset fuzzer against fonts in %s" % parent_path)
|
2018-03-15 03:15:33 +01:00
|
|
|
for file in os.listdir (parent_path):
|
2018-03-15 23:41:08 +01:00
|
|
|
path = os.path.join(parent_path, file)
|
2018-04-17 16:21:22 +02:00
|
|
|
|
2018-03-15 23:41:08 +01:00
|
|
|
print ("running subset fuzzer against %s" % path)
|
|
|
|
p = subprocess.Popen ([hb_subset_fuzzer, path])
|
2018-03-15 03:15:33 +01:00
|
|
|
|
|
|
|
if p.wait () != 0:
|
2018-03-15 23:41:08 +01:00
|
|
|
print ("failed for %s" % path)
|
2018-03-15 03:15:33 +01:00
|
|
|
fails = fails + 1
|
|
|
|
|
2018-04-17 16:21:22 +02:00
|
|
|
print ("running subset get codepoints fuzzer against %s" % path)
|
|
|
|
p = subprocess.Popen ([hb_subset_get_codepoints_fuzzer, path])
|
|
|
|
|
|
|
|
if p.wait () != 0:
|
|
|
|
print ("failed for %s" % path)
|
|
|
|
fails = fails + 1
|
|
|
|
|
2018-03-15 03:15:33 +01:00
|
|
|
if fails:
|
2018-03-15 23:41:08 +01:00
|
|
|
print ("%i subset fuzzer related tests failed." % fails)
|
2018-03-15 03:15:33 +01:00
|
|
|
sys.exit (1)
|