diff --git a/test/fuzzing/CMakeLists.txt b/test/fuzzing/CMakeLists.txt index fe4cf7909..cb41dc18d 100644 --- a/test/fuzzing/CMakeLists.txt +++ b/test/fuzzing/CMakeLists.txt @@ -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 $ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + add_test (NAME hb-subset-fuzzer + COMMAND "${PYTHON_EXECUTABLE}" run-subset-fuzzer-tests.py $ + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endif () diff --git a/test/fuzzing/Makefile.am b/test/fuzzing/Makefile.am index 27f59d9d7..d1f49e570 100644 --- a/test/fuzzing/Makefile.am +++ b/test/fuzzing/Makefile.am @@ -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 diff --git a/test/fuzzing/run-subset-fuzzer-tests.py b/test/fuzzing/run-subset-fuzzer-tests.py new file mode 100755 index 000000000..9450cb431 --- /dev/null +++ b/test/fuzzing/run-subset-fuzzer-tests.py @@ -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)