file (READ "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.am" MAKEFILEAM)
extract_make_variable (hb_shape_fuzzer_SOURCES ${MAKEFILEAM})
extract_make_variable (hb_subset_fuzzer_SOURCES ${MAKEFILEAM})
+ extract_make_variable (hb_subset_get_codepoints_fuzzer_SOURCES ${MAKEFILEAM})
# TODO: enable these two
#extract_make_variable (FUZZING_CPPFLAGS ${MAKEFILEAM}) # extracting regex fail
add_executable (hb-subset-fuzzer ${hb_subset_fuzzer_SOURCES})
target_link_libraries (hb-subset-fuzzer harfbuzz-subset)
+ add_executable (hb-subset-get-codepoints-fuzzer ${hb_subset_get_codepoints_fuzzer_SOURCES})
+ target_link_libraries (hb-subset-get-codepoints-fuzzer harfbuzz-subset)
+
target_compile_definitions(hb-shape-fuzzer PUBLIC ${FUZZING_CPPFLAGS})
target_compile_definitions(hb-subset-fuzzer PUBLIC ${FUZZING_CPPFLAGS})
+ target_compile_definitions(hb-subset-get-codepoints-fuzzer PUBLIC ${FUZZING_CPPFLAGS})
add_test (NAME hb-shape-fuzzer
COMMAND "${PYTHON_EXECUTABLE}" run-shape-fuzzer-tests.py $<TARGET_FILE:hb-shape-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>
+ COMMAND "${PYTHON_EXECUTABLE}" run-subset-fuzzer-tests.py $<TARGET_FILE:hb-subset-fuzzer> $<TARGET_FILE:hb-subset-get-codepoints-fuzzer>
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif ()
check_PROGRAMS = \
hb-shape-fuzzer \
hb-subset-fuzzer \
+ hb-subset-get-codepoints-fuzzer \
$(NULL)
AM_CPPFLAGS = \
lib \
$(NULL)
+hb_subset_get_codepoints_fuzzer_SOURCES = \
+ hb-fuzzer.hh \
+ hb-subset-get-codepoints-fuzzer.cc \
+ main.cc \
+ $(NULL)
+hb_subset_get_codepoints_fuzzer_LDADD = \
+ $(top_builddir)/src/libharfbuzz-subset-fuzzing.la \
+ $(NULL)
+hb_subset_get_codepoints_fuzzer_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ $(NULL)
+hb_subset_get_codepoints_fuzzer_DEPENDENCIES = \
+ lib \
+ $(NULL)
+
check:
EXEEXT="$(EXEEXT)" srcdir="$(srcdir)" builddir="$(builddir)" $(srcdir)/run-shape-fuzzer-tests.py
EXEEXT="$(EXEEXT)" srcdir="$(srcdir)" builddir="$(builddir)" $(srcdir)/run-subset-fuzzer-tests.py
--- /dev/null
+#include "hb-fuzzer.hh"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "hb-subset.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+{
+ printf ("hb-subset-get-codepoints-fuzzer: input size = %zu\n", size);
+ hb_blob_t *blob = hb_blob_create ((const char *)data, size,
+ HB_MEMORY_MODE_READONLY, NULL, NULL);
+ hb_face_t *face = hb_face_create (blob, 0);
+
+ hb_set_t *output = hb_set_create();
+ hb_subset_get_all_codepoints (face, output);
+
+ hb_set_destroy (output);
+ hb_face_destroy (face);
+ hb_blob_destroy (blob);
+
+ return 0;
+}
EXEEXT = os.environ.get ("EXEEXT", "")
top_builddir = os.environ.get ("top_builddir", ".")
hb_subset_fuzzer = os.path.join (top_builddir, "hb-subset-fuzzer" + EXEEXT)
+hb_subset_get_codepoints_fuzzer = os.path.join (top_builddir, "hb-subset-get-codepoints-fuzzer" + EXEEXT)
if not os.path.exists (hb_subset_fuzzer):
- if len (sys.argv) == 1 or not os.path.exists (sys.argv[1]):
+ if len (sys.argv) < 2 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]
+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]
+
print ('hb_subset_fuzzer:', hb_subset_fuzzer)
fails = 0
print ("running subset fuzzer against fonts in %s" % parent_path)
for file in os.listdir (parent_path):
path = os.path.join(parent_path, file)
+
print ("running subset fuzzer against %s" % path)
p = subprocess.Popen ([hb_subset_fuzzer, path])
print ("failed for %s" % path)
fails = fails + 1
+ 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
+
if fails:
print ("%i subset fuzzer related tests failed." % fails)
sys.exit (1)