glib/fuzzing/meson.build
Philip Withnall fa5947d3e7 fuzzing: Add unit tests to check fuzzers
Test the fuzzers with one arbitrary input each, to ensure that they work
at a very basic level.

This should catch regressions in each of the fuzzers without having to
wait for them to be picked up by oss-fuzz.

These tests can be run using `meson test --suite fuzzing`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-05 14:06:57 +01:00

52 lines
1.5 KiB
Meson
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

fuzz_targets = [
'fuzz_bookmark',
'fuzz_canonicalize_filename',
'fuzz_date_parse',
'fuzz_date_time_new_from_iso8601',
'fuzz_dbus_message',
'fuzz_inet_address_mask_new_from_string',
'fuzz_inet_address_new_from_string',
'fuzz_inet_socket_address_new_from_string',
'fuzz_key',
'fuzz_network_address_parse',
'fuzz_network_address_parse_uri',
'fuzz_paths',
'fuzz_resolver',
'fuzz_uri_escape',
'fuzz_uri_parse',
'fuzz_uri_parse_params',
'fuzz_variant_binary',
'fuzz_variant_text',
]
deps = [libgmodule_dep, libgio_dep, libglib_dep, libgobject_dep]
extra_sources = []
extra_c_args = cc.get_supported_arguments('-Werror=unused-function')
# Links in a static library provided by oss-fuzz, else a standalone driver.
# https://google.github.io/oss-fuzz/getting-started/new-project-guide/#buildsh-script-environment
fuzzing_engine = cxx.find_library('FuzzingEngine', required : get_option('oss_fuzz'))
if fuzzing_engine.found()
deps += fuzzing_engine
else
extra_sources += 'driver.c'
endif
foreach target_name : fuzz_targets
exe = executable(target_name, [extra_sources, target_name + '.c'],
c_args : extra_c_args,
dependencies : deps,
)
# If the FuzzingEngine isnt available, build some unit tests to check that
# the fuzzing files do basically work. This doesnt do any actual fuzzing though.
# Pass in the README as an arbitrary fuzzing input, just so we have something.
if not fuzzing_engine.found()
test(target_name, exe,
args : files('README.md'),
suite : 'fuzzing',
)
endif
endforeach