[subset] Add a test runner for hb-subset-fuzzer and cmake build config.

This commit is contained in:
Garret Rieger 2018-03-14 19:15:33 -07:00 committed by Behdad Esfahbod
parent aa9612d35f
commit 474afaafd9
3 changed files with 42 additions and 1 deletions

View File

@ -1,6 +1,7 @@
if (HB_CHECK)
file (READ "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.am" MAKEFILEAM)
extract_make_variable (hb_fuzzer_SOURCES ${MAKEFILEAM})
extract_make_variable (hb_subset_fuzzer_SOURCES ${MAKEFILEAM})
# TODO: enable these two
#extract_make_variable (FUZZING_CPPFLAGS ${MAKEFILEAM}) # extracting regex fail
@ -11,8 +12,16 @@ if (HB_CHECK)
add_executable (hb-fuzzer ${hb_fuzzer_SOURCES})
target_link_libraries (hb-fuzzer harfbuzz)
add_executable (hb-subset-fuzzer ${hb_subset_fuzzer_SOURCES})
target_link_libraries (hb-subset-fuzzer harfbuzz-subset)
target_compile_definitions(hb-fuzzer PUBLIC ${FUZZING_CPPFLAGS})
target_compile_definitions(hb-subset-fuzzer PUBLIC ${FUZZING_CPPFLAGS})
add_test (NAME hb-fuzzer
COMMAND "${PYTHON_EXECUTABLE}" run-fuzzer-tests.py $<TARGET_FILE:hb-fuzzer>
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_test (NAME hb-subset-fuzzer
COMMAND "${PYTHON_EXECUTABLE}" run-subset-fuzzer-tests.py $<TARGET_FILE:hb-subset-fuzzer>
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif ()

View File

@ -48,7 +48,7 @@ hb_fuzzer_DEPENDENCIES = \
$(NULL)
hb_subset_fuzzer_SOURCES = \
hb-subset.hh \
hb-fuzzer.hh \
hb-subset-fuzzer.cc \
main.cc \
$(NULL)
@ -64,5 +64,6 @@ hb_subset_fuzzer_DEPENDENCIES = \
check:
EXEEXT="$(EXEEXT)" srcdir="$(srcdir)" builddir="$(builddir)" $(srcdir)/run-fuzzer-tests.py
EXEEXT="$(EXEEXT)" srcdir="$(srcdir)" builddir="$(builddir)" $(srcdir)/run-subset-fuzzer-tests.py
-include $(top_srcdir)/git.mk

View File

@ -0,0 +1,31 @@
#!/usr/bin/env python
from __future__ import print_function
import sys, os, subprocess
srcdir = os.environ.get ("srcdir", ".")
EXEEXT = os.environ.get ("EXEEXT", "")
top_builddir = os.environ.get ("top_builddir", ".")
hb_subset_fuzzer = os.path.join (top_builddir, "hb-subset-fuzzer" + EXEEXT)
if not os.path.exists (hb_subset_fuzzer):
if len (sys.argv) == 1 or not os.path.exists (sys.argv[1]):
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]
print ('hb_subset_fuzzer:', hb_subset_fuzzer)
fails = 0
parent_path = os.path.join (srcdir, "..", "subset", "data", "fonts")
for file in os.listdir (parent_path):
p = subprocess.Popen ([hb_subset_fuzzer, os.path.join(parent_path, file)])
if p.wait () != 0:
fails = fails + 1
if fails:
print ("%i fuzzer related tests failed." % fails)
sys.exit (1)