[subset] add a fuzzer target for subset_get_all_codepoints method. (#987)
This commit is contained in:
parent
924803166e
commit
c02b40e58f
|
@ -2,6 +2,7 @@ if (HB_CHECK)
|
||||||
file (READ "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.am" MAKEFILEAM)
|
file (READ "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.am" MAKEFILEAM)
|
||||||
extract_make_variable (hb_shape_fuzzer_SOURCES ${MAKEFILEAM})
|
extract_make_variable (hb_shape_fuzzer_SOURCES ${MAKEFILEAM})
|
||||||
extract_make_variable (hb_subset_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
|
# TODO: enable these two
|
||||||
#extract_make_variable (FUZZING_CPPFLAGS ${MAKEFILEAM}) # extracting regex fail
|
#extract_make_variable (FUZZING_CPPFLAGS ${MAKEFILEAM}) # extracting regex fail
|
||||||
|
@ -15,13 +16,17 @@ if (HB_CHECK)
|
||||||
add_executable (hb-subset-fuzzer ${hb_subset_fuzzer_SOURCES})
|
add_executable (hb-subset-fuzzer ${hb_subset_fuzzer_SOURCES})
|
||||||
target_link_libraries (hb-subset-fuzzer harfbuzz-subset)
|
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-shape-fuzzer PUBLIC ${FUZZING_CPPFLAGS})
|
||||||
target_compile_definitions(hb-subset-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
|
add_test (NAME hb-shape-fuzzer
|
||||||
COMMAND "${PYTHON_EXECUTABLE}" run-shape-fuzzer-tests.py $<TARGET_FILE:hb-shape-fuzzer>
|
COMMAND "${PYTHON_EXECUTABLE}" run-shape-fuzzer-tests.py $<TARGET_FILE:hb-shape-fuzzer>
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
add_test (NAME hb-subset-fuzzer
|
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})
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
|
@ -23,6 +23,7 @@ EXTRA_DIST += \
|
||||||
check_PROGRAMS = \
|
check_PROGRAMS = \
|
||||||
hb-shape-fuzzer \
|
hb-shape-fuzzer \
|
||||||
hb-subset-fuzzer \
|
hb-subset-fuzzer \
|
||||||
|
hb-subset-get-codepoints-fuzzer \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
AM_CPPFLAGS = \
|
AM_CPPFLAGS = \
|
||||||
|
@ -64,6 +65,21 @@ hb_subset_fuzzer_DEPENDENCIES = \
|
||||||
lib \
|
lib \
|
||||||
$(NULL)
|
$(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:
|
check:
|
||||||
EXEEXT="$(EXEEXT)" srcdir="$(srcdir)" builddir="$(builddir)" $(srcdir)/run-shape-fuzzer-tests.py
|
EXEEXT="$(EXEEXT)" srcdir="$(srcdir)" builddir="$(builddir)" $(srcdir)/run-shape-fuzzer-tests.py
|
||||||
EXEEXT="$(EXEEXT)" srcdir="$(srcdir)" builddir="$(builddir)" $(srcdir)/run-subset-fuzzer-tests.py
|
EXEEXT="$(EXEEXT)" srcdir="$(srcdir)" builddir="$(builddir)" $(srcdir)/run-subset-fuzzer-tests.py
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#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;
|
||||||
|
}
|
|
@ -8,15 +8,24 @@ srcdir = os.environ.get ("srcdir", ".")
|
||||||
EXEEXT = os.environ.get ("EXEEXT", "")
|
EXEEXT = os.environ.get ("EXEEXT", "")
|
||||||
top_builddir = os.environ.get ("top_builddir", ".")
|
top_builddir = os.environ.get ("top_builddir", ".")
|
||||||
hb_subset_fuzzer = os.path.join (top_builddir, "hb-subset-fuzzer" + EXEEXT)
|
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 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,
|
print ("""Failed to find hb-subset-fuzzer binary automatically,
|
||||||
please provide it as the first argument to the tool""")
|
please provide it as the first argument to the tool""")
|
||||||
sys.exit (1)
|
sys.exit (1)
|
||||||
|
|
||||||
hb_subset_fuzzer = sys.argv[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)
|
print ('hb_subset_fuzzer:', hb_subset_fuzzer)
|
||||||
fails = 0
|
fails = 0
|
||||||
|
|
||||||
|
@ -24,6 +33,7 @@ parent_path = os.path.join (srcdir, "..", "subset", "data", "fonts")
|
||||||
print ("running subset fuzzer against fonts in %s" % parent_path)
|
print ("running subset fuzzer against fonts in %s" % parent_path)
|
||||||
for file in os.listdir (parent_path):
|
for file in os.listdir (parent_path):
|
||||||
path = os.path.join(parent_path, file)
|
path = os.path.join(parent_path, file)
|
||||||
|
|
||||||
print ("running subset fuzzer against %s" % path)
|
print ("running subset fuzzer against %s" % path)
|
||||||
p = subprocess.Popen ([hb_subset_fuzzer, path])
|
p = subprocess.Popen ([hb_subset_fuzzer, path])
|
||||||
|
|
||||||
|
@ -31,6 +41,13 @@ for file in os.listdir (parent_path):
|
||||||
print ("failed for %s" % path)
|
print ("failed for %s" % path)
|
||||||
fails = fails + 1
|
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:
|
if fails:
|
||||||
print ("%i subset fuzzer related tests failed." % fails)
|
print ("%i subset fuzzer related tests failed." % fails)
|
||||||
sys.exit (1)
|
sys.exit (1)
|
||||||
|
|
Loading…
Reference in New Issue