diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-06-26 18:07:25 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-08-03 13:37:16 +0200 |
commit | cbc55c4cce7e8a076dbeb5bc7a9660e20338b7e6 (patch) | |
tree | afa00146b30f58bddcb17193bec1ba27c3985424 | |
parent | meson: merge declarations of normal and test executables (diff) | |
download | systemd-cbc55c4cce7e8a076dbeb5bc7a9660e20338b7e6.tar.xz systemd-cbc55c4cce7e8a076dbeb5bc7a9660e20338b7e6.zip |
meson: also merge declarations of fuzzers with other executables
-rw-r--r-- | meson.build | 151 | ||||
-rw-r--r-- | src/boot/efi/meson.build | 12 | ||||
-rw-r--r-- | src/core/meson.build | 33 | ||||
-rw-r--r-- | src/journal-remote/meson.build | 21 | ||||
-rw-r--r-- | src/journal/meson.build | 86 | ||||
-rw-r--r-- | src/libsystemd-network/meson.build | 32 | ||||
-rw-r--r-- | src/network/meson.build | 39 | ||||
-rw-r--r-- | src/nspawn/meson.build | 15 | ||||
-rw-r--r-- | src/resolve/meson.build | 38 | ||||
-rw-r--r-- | src/systemctl/meson.build | 19 | ||||
-rw-r--r-- | src/udev/meson.build | 48 | ||||
-rw-r--r-- | src/xdg-autostart-generator/meson.build | 5 | ||||
-rw-r--r-- | test/fuzz/meson.build | 56 | ||||
-rw-r--r-- | test/meson.build | 4 |
14 files changed, 241 insertions, 318 deletions
diff --git a/meson.build b/meson.build index 320302f15d..cf217c1bf0 100644 --- a/meson.build +++ b/meson.build @@ -2174,12 +2174,12 @@ man_page_depends = [] simple_tests = [] libsystemd_tests = [] -fuzzers = [] simple_fuzzers = [] catalogs = [] modules = [] # nss, pam, and other plugins executables = [] executables_by_name = {} +fuzzer_exes = [] # binaries that have --help and are intended for use by humans, # usually, but not always, installed in /bin. @@ -2354,6 +2354,29 @@ test_additional_kwargs = { 'link_depends' : runtest_env, } +fuzz_template = executable_template + { + 'build_by_default' : fuzzer_build, + 'install' : false, +} + +if want_ossfuzz or (want_libfuzzer and fuzzing_engine.found()) + fuzz_additional_kwargs = { + 'dependencies' : fuzzing_engine, + } +elif want_libfuzzer and not fuzzing_engine.found() + fuzz_additional_kwargs = { + 'link_args' : ['-fsanitize=fuzzer'], + } +else + fuzz_additional_kwargs = { + 'sources' : files('src/fuzz/fuzz-main.c'), + } +endif +fuzz_additional_kwargs += { + 'include_directories' : include_directories('src/fuzz'), + 'c_args' : test_cflags, +} + nss_template = { 'version' : '2', 'include_directories' : includes, @@ -2502,6 +2525,7 @@ subdir('src/systemd') subdir('src/test') subdir('src/fuzz') subdir('src/ukify/test') # needs to be last for test_env variable +subdir('test/fuzz') alias_target('devel', libsystemd_pc, libudev_pc, systemd_pc, udev_pc) @@ -2515,14 +2539,19 @@ foreach test : libsystemd_tests executables += test_template + test endforeach +foreach fuzzer : simple_fuzzers + executables += fuzz_template + { 'sources' : [fuzzer] } +endforeach + foreach dict : executables name = dict.get('name', '') if name == '' name = fs.stem(dict.get('sources')[0]) - assert(name.split('-')[0] == 'test') + assert(name.split('-')[0] in ['test', 'fuzz']) endif is_test = name.startswith('test-') + is_fuzz = name.startswith('fuzz-') build = true foreach cond : dict.get('conditions', []) @@ -2556,6 +2585,12 @@ foreach dict : executables endforeach endif + if is_fuzz + foreach key, val : fuzz_additional_kwargs + kwargs += { key : [ kwargs.get(key, []), val ] } + endforeach + endif + exe = executable( name, kwargs : kwargs, @@ -2594,8 +2629,33 @@ foreach dict : executables is_parallel : dict.get('parallel', true)) endif endif + + if is_fuzz + fuzzer_exes += exe + + if want_tests != 'false' + # Run the fuzz regression tests without any sanitizers enabled. + # Additional invocations with sanitizers may be added below. + fuzz_ins = fuzz_regression_tests.get(name, {}) + foreach directive : fuzz_ins.get('directives', []) + test('@0@_@1@'.format(name, fs.name(directive.full_path())), + exe, + suite : 'fuzz', + args : directive.full_path(), + depends : directive) + endforeach + foreach file : fuzz_ins.get('files', []) + test('@0@_@1@'.format(name, fs.name(file)), + exe, + suite : 'fuzz', + args : file) + endforeach + endif + endif endforeach +alias_target('fuzzers', fuzzer_exes) + ############################################################ test_dlopen = executables_by_name.get('test-dlopen') @@ -2677,71 +2737,6 @@ subdir('test') ############################################################ -foreach fuzzer : simple_fuzzers - fuzzers += { 'sources' : [fuzzer] } -endforeach - -fuzzer_exes = [] - -foreach fuzzer : fuzzers - sources = fuzzer.get('sources') - base = fuzzer.get('base', {}) - dependencies = [base.get('dependencies', []), fuzzer.get('dependencies', [])] - link_args = [] - - if want_ossfuzz - dependencies += fuzzing_engine - elif want_libfuzzer - if fuzzing_engine.found() - dependencies += fuzzing_engine - else - link_args += ['-fsanitize=fuzzer'] - endif - else - sources += files('src/fuzz/fuzz-main.c') - endif - sources += fuzz_generated_directives - - name = fs.stem(sources[0]) - - exe = executable( - name, - sources, - include_directories : [ - base.get('includes', []), - fuzzer.get('includes', includes), - include_directories('src/fuzz'), - ], - link_with : [base.get('link_with', []), fuzzer.get('link_with', libshared)], - dependencies : [ - dependencies, - userspace, - ], - c_args : [test_cflags, fuzzer.get('c_args', [])], - link_args: link_args, - install : false, - build_by_default : fuzzer_build) - fuzzer_exes += exe - - if want_tests != 'false' and name in fuzz_regression_tests - # Run the fuzz regression tests without any sanitizers enabled. - # Additional invocations with sanitizers may be added below. - foreach tuple : fuzz_regression_tests[name] - fuzz_dir = tuple[0] - fuzz_in = tuple[1] - test('@0@_@1@'.format(name, fuzz_in), - exe, - suite : 'fuzz', - args : [fuzz_dir != '' ? project_source_root / fuzz_dir / name / fuzz_in - : fuzz_generated_in_dir / '@0@_@1@'.format(name, fuzz_in)]) - endforeach - endif -endforeach - -alias_target('fuzzers', fuzzer_exes) - -############################################################ - subdir('docs/sysvinit') subdir('docs/var-log') subdir('hwdb.d') @@ -2841,24 +2836,28 @@ foreach tuple : fuzz_sanitizers exe = custom_target( name, output : name, - depends : [build] + fuzz_generated_directives, + depends : build, command : [ln, '-fs', build.full_path() / fuzzer, '@OUTPUT@'], build_by_default : true) - foreach tuple : fuzz_ins - fuzz_dir = tuple[0] - fuzz_in = tuple[1] - - test('@0@_@1@_@2@'.format(fuzzer, fuzz_in, sanitizer), + foreach directive : fuzz_ins.get('directives', []) + test('@0@_@1@_@2@'.format(fuzzer, fs.name(directive.full_path()), sanitizer), + env, + suite : 'fuzz+san', + env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'], + timeout : 60, + args : [exe.full_path(), directive.full_path()], + depends : directive) + endforeach + foreach file : fuzz_ins.get('files', []) + test('@0@_@1@_@2@'.format(fuzzer, fs.name(file), sanitizer), env, suite : 'fuzz+san', env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'], timeout : 60, - args : [exe.full_path(), - fuzz_dir != '' ? project_source_root / fuzz_dir / fuzzer / fuzz_in - : fuzz_generated_in_dir / '@0@_@1@'.format(fuzzer, fuzz_in)]) + args : [exe.full_path(), file]) endforeach endforeach endif diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build index 7adcc178a6..05997744df 100644 --- a/src/boot/efi/meson.build +++ b/src/boot/efi/meson.build @@ -24,6 +24,7 @@ if efi_arch != '' ], } efi_test_template = test_template + efitest_base + efi_fuzz_template = fuzz_template + efitest_base executables += [ efi_test_template + { @@ -34,19 +35,14 @@ if efi_arch != '' efi_test_template + { 'sources' : files('test-efi-string.c'), }, - ] - fuzzers += [ - { + efi_fuzz_template + { 'sources' : files('fuzz-bcd.c'), - 'base' : efitest_base, }, - { + efi_fuzz_template + { 'sources' : files('fuzz-efi-string.c'), - 'base' : efitest_base, }, - { + efi_fuzz_template + { 'sources' : files('fuzz-efi-printf.c'), - 'base' : efitest_base, }, ] endif diff --git a/src/core/meson.build b/src/core/meson.build index a99136be0f..395342d754 100644 --- a/src/core/meson.build +++ b/src/core/meson.build @@ -153,6 +153,21 @@ executables += [ ], 'dependencies' : libseccomp, }, + fuzz_template + { + 'sources' : files('fuzz-unit-file.c'), + 'link_with' : [ + libcore, + libshared + ], + 'dependencies' : libmount, + }, + fuzz_template + { + 'sources' : files('fuzz-manager-serialize.c'), + 'link_with' : [ + libcore, + libshared + ], + }, ] in_files = [['system.conf', pkgsysconfdir], @@ -211,21 +226,3 @@ core_test_template = test_template + { 'include_directories' : core_includes, 'suite' : 'core', } - -fuzzers += [ - { - 'sources' : files('fuzz-unit-file.c'), - 'link_with' : [ - libcore, - libshared - ], - 'dependencies' : libmount, - }, - { - 'sources' : files('fuzz-manager-serialize.c'), - 'link_with' : [ - libcore, - libshared - ], - }, -] diff --git a/src/journal-remote/meson.build b/src/journal-remote/meson.build index 89419f1de1..e5a37466db 100644 --- a/src/journal-remote/meson.build +++ b/src/journal-remote/meson.build @@ -81,6 +81,14 @@ executables += [ 'sources' : systemd_journal_gatewayd_sources, 'dependencies' : common_deps + [libmicrohttpd], }, + fuzz_template + { + 'sources' : files('fuzz-journal-remote.c'), + 'link_with' : [ + libshared, + libsystemd_journal_remote, + ], + 'include_directories' : journal_includes, + }, ] in_files = [ @@ -112,16 +120,3 @@ if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1 chmod 755 $DESTDIR/var/log/journal/remote || :''') endif endif - -############################################################ - -fuzzers += [ - { - 'sources' : files('fuzz-journal-remote.c'), - 'link_with' : [ - libshared, - libsystemd_journal_remote, - ], - 'includes' : journal_includes, - }, -] diff --git a/src/journal/meson.build b/src/journal/meson.build index 90170599a7..65adb2ccba 100644 --- a/src/journal/meson.build +++ b/src/journal/meson.build @@ -48,6 +48,14 @@ journal_test_template = test_template + { ], } +journal_fuzz_template = fuzz_template + { + 'link_with' : [ + libjournal_core, + libshared, + ], + 'dependencies' : libselinux, +} + executables += [ libexec_template + { 'name' : 'systemd-journald', @@ -124,81 +132,65 @@ executables += [ journal_test_template + { 'sources' : files('test-journal.c'), }, -] - -if install_sysconfdir_samples - install_data('journald.conf', - install_dir : pkgsysconfdir) -endif - -if get_option('create-log-dirs') - meson.add_install_script( - 'sh', '-c', - mkdir_p.format('/var/log/journal')) - meson.add_install_script( - 'sh', '-c', - '''chown 0:0 $DESTDIR/var/log/journal && - chmod 755 $DESTDIR/var/log/journal || :''') - if get_option('adm-group') - meson.add_install_script( - 'sh', '-c', - 'setfacl -nm g:adm:rx,d:g:adm:rx $DESTDIR/var/log/journal || :') - endif - if get_option('wheel-group') - meson.add_install_script( - 'sh', '-c', - 'setfacl -nm g:wheel:rx,d:g:wheel:rx $DESTDIR/var/log/journal || :') - endif -endif - -############################################################ - -fuzzer_journald_base = { - 'link_with' : [libjournal_core, libshared], - 'dependencies' : [libselinux], -} - -fuzzers += [ - { + journal_fuzz_template + { 'sources' : files( 'fuzz-journald-audit.c', 'fuzz-journald.c', ), - 'base' : fuzzer_journald_base, }, - { + journal_fuzz_template + { 'sources' : files( 'fuzz-journald-kmsg.c', 'fuzz-journald.c', ), - 'base' : fuzzer_journald_base, }, - { + journal_fuzz_template + { 'sources' : files( 'fuzz-journald-native.c', 'fuzz-journald.c', ), - 'base' : fuzzer_journald_base, }, - { + journal_fuzz_template + { 'sources' : files( 'fuzz-journald-native-fd.c', 'fuzz-journald.c', ), - 'base' : fuzzer_journald_base, }, - { + journal_fuzz_template + { 'sources' : files( 'fuzz-journald-stream.c', 'fuzz-journald.c', ), - 'base' : fuzzer_journald_base, }, - { + journal_fuzz_template + { 'sources' : files( 'fuzz-journald-syslog.c', 'fuzz-journald.c', ), - 'base' : fuzzer_journald_base, }, ] + +if install_sysconfdir_samples + install_data('journald.conf', + install_dir : pkgsysconfdir) +endif + +if get_option('create-log-dirs') + meson.add_install_script( + 'sh', '-c', + mkdir_p.format('/var/log/journal')) + meson.add_install_script( + 'sh', '-c', + '''chown 0:0 $DESTDIR/var/log/journal && + chmod 755 $DESTDIR/var/log/journal || :''') + if get_option('adm-group') + meson.add_install_script( + 'sh', '-c', + 'setfacl -nm g:adm:rx,d:g:adm:rx $DESTDIR/var/log/journal || :') + endif + if get_option('wheel-group') + meson.add_install_script( + 'sh', '-c', + 'setfacl -nm g:wheel:rx,d:g:wheel:rx $DESTDIR/var/log/journal || :') + endif +endif diff --git a/src/libsystemd-network/meson.build b/src/libsystemd-network/meson.build index 74041f6abd..043d3bc254 100644 --- a/src/libsystemd-network/meson.build +++ b/src/libsystemd-network/meson.build @@ -47,6 +47,13 @@ network_test_template = test_template + { 'suite' : 'network', } +network_fuzz_template = fuzz_template + { + 'link_with' : [ + libshared, + libsystemd_network, + ], +} + executables += [ network_test_template + { 'sources' : files('test-acd.c'), @@ -83,35 +90,22 @@ executables += [ network_test_template + { 'sources' : files('test-sd-dhcp-lease.c'), }, -] - -fuzzer_network_base = { - 'link_with' : [libshared, libsystemd_network], -} - -fuzzers += [ - { + network_fuzz_template + { 'sources' : files('fuzz-dhcp-client.c'), - 'base' : fuzzer_network_base, }, - { + network_fuzz_template + { 'sources' : files('fuzz-dhcp6-client.c'), - 'base' : fuzzer_network_base, }, - { + network_fuzz_template + { 'sources' : files('fuzz-dhcp-server.c'), - 'base' : fuzzer_network_base, }, - { + network_fuzz_template + { 'sources' : files('fuzz-dhcp-server-relay.c'), - 'base' : fuzzer_network_base, }, - { + network_fuzz_template + { 'sources' : files('fuzz-lldp-rx.c'), - 'base' : fuzzer_network_base, }, - { + network_fuzz_template + { 'sources' : files('fuzz-ndisc-rs.c'), - 'base' : fuzzer_network_base, }, ] diff --git a/src/network/meson.build b/src/network/meson.build index c5607a9b31..7d0e5d6345 100644 --- a/src/network/meson.build +++ b/src/network/meson.build @@ -114,6 +114,9 @@ network_generator_sources = files( 'generator/network-generator.c', ) +networkd_network_gperf_gperf = files('networkd-network-gperf.gperf') +networkd_netdev_gperf_gperf = files('netdev/netdev-gperf.gperf') + sources += custom_target( 'networkd-gperf.c', input : 'networkd-gperf.gperf', @@ -122,13 +125,13 @@ sources += custom_target( sources += custom_target( 'networkd-network-gperf.c', - input : 'networkd-network-gperf.gperf', + input : networkd_network_gperf_gperf, output : 'networkd-network-gperf.c', command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@']) sources += custom_target( 'netdev-gperf.c', - input : 'netdev/netdev-gperf.gperf', + input : networkd_netdev_gperf_gperf, output : 'netdev-gperf.c', command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@']) @@ -158,6 +161,15 @@ network_test_template = test_template + { 'include_directories' : network_includes, } +network_fuzz_template = fuzz_template + { + 'link_with' : [ + libnetworkd_core, + libsystemd_network, + ], + 'dependencies' : threads, + 'include_directories' : network_includes, +} + executables += [ libexec_template + { 'name' : 'systemd-networkd', @@ -221,6 +233,12 @@ executables += [ network_test_template + { 'sources' : files('test-networkd-util.c'), }, + network_fuzz_template + { + 'sources' : files('fuzz-netdev-parser.c'), + }, + network_fuzz_template + { + 'sources' : files('fuzz-network-parser.c'), + }, ] if conf.get('ENABLE_NETWORKD') == 1 @@ -244,20 +262,3 @@ if conf.get('ENABLE_NETWORKD') == 1 install_dir : pkgsysconfdir) endif endif - -fuzzer_network_base = { - 'link_with' : [libnetworkd_core, libsystemd_network, networkd_link_with], - 'dependencies' : threads, - 'includes' : network_includes, -} - -fuzzers += [ - { - 'sources' : files('fuzz-netdev-parser.c'), - 'base' : fuzzer_network_base, - }, - { - 'sources' : files('fuzz-network-parser.c'), - 'base' : fuzzer_network_base, - }, -] diff --git a/src/nspawn/meson.build b/src/nspawn/meson.build index b6628c6751..e2605f895b 100644 --- a/src/nspawn/meson.build +++ b/src/nspawn/meson.build @@ -45,6 +45,7 @@ nspawn_common_template = { 'dependencies' : libseccomp, } nspawn_test_template = test_template + nspawn_common_template +nspawn_fuzz_template = fuzz_template + nspawn_common_template executables += [ executable_template + { @@ -69,20 +70,10 @@ executables += [ 'dependencies' : libacl, 'type' : 'manual', }, -] - -fuzzer_nspawn_base = { - 'link_with' : [libshared, libnspawn_core], - 'dependencies' : libseccomp -} - -fuzzers += [ - { + nspawn_fuzz_template + { 'sources' : files('fuzz-nspawn-settings.c'), - 'base' : fuzzer_nspawn_base, }, - { + nspawn_fuzz_template + { 'sources' : files('fuzz-nspawn-oci.c'), - 'base' : fuzzer_nspawn_base, }, ] diff --git a/src/resolve/meson.build b/src/resolve/meson.build index e8881fb3b3..5b4e583501 100644 --- a/src/resolve/meson.build +++ b/src/resolve/meson.build @@ -134,6 +134,7 @@ resolve_common_template = { ], } resolve_test_template = test_template + resolve_common_template +resolve_fuzz_template = fuzz_template + resolve_common_template executables += [ libexec_template + { @@ -195,6 +196,18 @@ executables += [ ], 'include_directories' : resolve_includes, }, + resolve_fuzz_template + { + 'sources' : files('fuzz-dns-packet.c'), + }, + resolve_fuzz_template + { + 'sources' : files( + 'fuzz-etc-hosts.c', + 'resolved-etc-hosts.c', + ), + }, + resolve_fuzz_template + { + 'sources' : files('fuzz-resource-record.c'), + }, ] if conf.get('ENABLE_RESOLVE') == 1 @@ -223,28 +236,3 @@ custom_target( command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'], install : conf.get('ENABLE_RESOLVE') == 1 and install_sysconfdir_samples, install_dir : pkgsysconfdir) - -############################################################ - -fuzzer_resolve_base = { - 'link_with' : [libsystemd_resolve_core, libshared], - 'dependencies' : [lib_openssl_or_gcrypt, libm], -} - -fuzzers += [ - { - 'sources' : files('fuzz-dns-packet.c'), - 'base' : fuzzer_resolve_base, - }, - { - 'sources' : files( - 'fuzz-etc-hosts.c', - 'resolved-etc-hosts.c', - ), - 'base' : fuzzer_resolve_base, - }, - { - 'sources' : files('fuzz-resource-record.c'), - 'base' : fuzzer_resolve_base, - }, -] diff --git a/src/systemctl/meson.build b/src/systemctl/meson.build index e7e1a1964b..bc08b8672f 100644 --- a/src/systemctl/meson.build +++ b/src/systemctl/meson.build @@ -63,6 +63,14 @@ executables += [ threads, ], }, + fuzz_template + { + 'sources' : [ + files('fuzz-systemctl-parse-argv.c'), + systemctl_sources, + ], + 'link_with' : systemctl_link_with, + 'c_args' : ['-DFUZZ_SYSTEMCTL_PARSE_ARGV'], + }, ] foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] + @@ -71,14 +79,3 @@ foreach alias : (['halt', 'poweroff', 'reboot', 'shutdown'] + bindir / 'systemctl', sbindir / alias) endforeach - -fuzzers += [ - { - 'sources' : [ - files('fuzz-systemctl-parse-argv.c'), - systemctl_sources, - ], - 'link_with' : systemctl_link_with, - 'c_args' : '-DFUZZ_SYSTEMCTL_PARSE_ARGV', - }, -] diff --git a/src/udev/meson.build b/src/udev/meson.build index b99e313722..200cc05546 100644 --- a/src/udev/meson.build +++ b/src/udev/meson.build @@ -84,9 +84,11 @@ keyboard_keys_from_name_h = custom_target( ############################################################ +udev_link_gperf_gperf = files('net/link-config-gperf.gperf') + link_config_gperf_c = custom_target( 'link-config-gperf.c', - input : 'net/link-config-gperf.gperf', + input : udev_link_gperf_gperf, output : 'link-config-gperf.c', command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@']) @@ -142,6 +144,7 @@ udev_common_template = { ], } udev_test_template = test_template + udev_common_template +udev_fuzz_template = fuzz_template + udev_common_template executables += [ executable_template + { @@ -226,6 +229,22 @@ executables += [ udev_test_template + { 'sources' : files('test-udev-spawn.c'), }, + fuzz_template + { + 'sources' : files( + 'fido_id/fuzz-fido-id-desc.c', + 'fido_id/fido_id_desc.c', + ), + }, + udev_fuzz_template + { + 'sources' : files('net/fuzz-link-parser.c'), + 'include_directories' : udev_includes, + }, + udev_fuzz_template + { + 'sources' : files('fuzz-udev-rule-parse-value.c'), + }, + udev_fuzz_template + { + 'sources' : files('fuzz-udev-rules.c'), + }, ] meson.add_install_script(meson_make_symlink, @@ -252,30 +271,3 @@ if install_sysconfdir meson.add_install_script('sh', '-c', mkdir_p.format(sysconfdir / 'udev/rules.d')) endif - -fuzzer_udev_base = { - 'link_with' : [libudevd_core, libshared], - 'dependencies' : [threads, libacl], -} - -fuzzers += [ - { - 'sources' : files('net/fuzz-link-parser.c'), - 'includes' : udev_includes, - 'base' : fuzzer_udev_base, - }, - { - 'sources' : files('fuzz-udev-rule-parse-value.c'), - 'base' : fuzzer_udev_base, - }, - { - 'sources' : files('fuzz-udev-rules.c'), - 'base' : fuzzer_udev_base, - }, - { - 'sources' : files( - 'fido_id/fuzz-fido-id-desc.c', - 'fido_id/fido_id_desc.c', - ), - }, -] diff --git a/src/xdg-autostart-generator/meson.build b/src/xdg-autostart-generator/meson.build index 238dde8fd0..c938932c62 100644 --- a/src/xdg-autostart-generator/meson.build +++ b/src/xdg-autostart-generator/meson.build @@ -23,10 +23,7 @@ executables += [ 'xdg-autostart-service.c', ), }, -] - -fuzzers += [ - { + fuzz_template + { 'sources' : files( 'fuzz-xdg-desktop.c', 'xdg-autostart-service.c', diff --git a/test/fuzz/meson.build b/test/fuzz/meson.build index 5e8481354c..11b91e30bb 100644 --- a/test/fuzz/meson.build +++ b/test/fuzz/meson.build @@ -1,32 +1,38 @@ # SPDX-License-Identifier: LGPL-2.1-or-later generate_directives_py = find_program('generate-directives.py') -fuzz_generated_in_dir = meson.current_build_dir() -fuzz_generated_directives = [] +fuzz_regression_tests = {} -directives = [['fuzz-network-parser_directives', 'src/network/networkd-network-gperf.gperf'], - ['fuzz-netdev-parser_directives.netdev', 'src/network/netdev/netdev-gperf.gperf'], - ['fuzz-link-parser_directives.link', 'src/udev/net/link-config-gperf.gperf'], +directives = [['fuzz-network-parser', 'directives.network', networkd_network_gperf_gperf], + ['fuzz-netdev-parser', 'directives.netdev', networkd_netdev_gperf_gperf], + ['fuzz-link-parser', 'directives.link', udev_link_gperf_gperf], ] foreach tuple : directives - fuzz_generated_directives += custom_target( - tuple[0], - output: tuple[0], - command: [generate_directives_py, files(project_source_root / tuple[1])], + directive = custom_target( + tuple[1], + output: tuple[1], + command: [generate_directives_py, tuple[2]], capture: true) + + dict = { 'directives' : [directive] } + fuzz_regression_tests += { tuple[0] : dict } endforeach +unit_directives = [] foreach section : ['Automount', 'Mount', 'Path', 'Scope', 'Service', 'Slice', 'Socket', 'Swap', 'Timer'] unit_type = section.to_lower() sec_rx = section == 'Service' ? '(Service|Unit|Install)' : section - fuzz_generated_directives += custom_target( - 'fuzz-unit-file_directives.@0@'.format(unit_type), - output: 'fuzz-unit-file_directives.@0@'.format(unit_type), + name = 'directives.@0@'.format(unit_type) + unit_directives += custom_target( + name, + output: name, command: [generate_directives_py, load_fragment_gperf_gperf, sec_rx, unit_type], capture: true) endforeach +dict = { 'directives' : unit_directives } +fuzz_regression_tests += { 'fuzz-unit-file' : dict } ############################################################ @@ -58,21 +64,6 @@ else out = run_command(sh, '-c', 'cd "@0@"; echo @1@/*/*'.format(project_source_root, fuzz_testsdir), check: true) endif -# Fuzz inputs that we generate (see above fuzz_generated_directives) -fuzz_regression_tests = { - 'fuzz-link-parser': [['', 'directives.link']], - 'fuzz-netdev-parser': [['', 'directives.netdev']], - 'fuzz-network-parser': [['', 'directives']], - 'fuzz-unit-file': [['', 'directives.automount'], - ['', 'directives.mount'], - ['', 'directives.path'], - ['', 'directives.scope'], - ['', 'directives.service'], - ['', 'directives.slice'], - ['', 'directives.socket'], - ['', 'directives.swap'], - ['', 'directives.timer']]} - # Add crafted fuzz inputs we have in the repo foreach p : out.stdout().split() # Remove the last entry which is ''. @@ -84,11 +75,8 @@ foreach p : out.stdout().split() endif fuzzer = fs.name(fs.parent(p)) fuzz_in = fs.name(p) - if fuzzer not in fuzz_regression_tests - fuzz_regression_tests += {fuzzer: []} - endif - # Meson parser provision for: fuzz_regression_tests[fuzzer] += [fuzz_in] - l = fuzz_regression_tests[fuzzer] - l += [[fuzz_testsdir, fuzz_in]] - fuzz_regression_tests += {fuzzer: l} + + dict = fuzz_regression_tests.get(fuzzer, {}) + dict += { 'files' : dict.get('files', []) + files(fuzzer / fuzz_in) } + fuzz_regression_tests += { fuzzer : dict } endforeach diff --git a/test/meson.build b/test/meson.build index a5bcc128cc..59d9a63a11 100644 --- a/test/meson.build +++ b/test/meson.build @@ -309,7 +309,3 @@ if want_tests != 'false' and conf.get('ENABLE_KERNEL_INSTALL') == 1 args : args, depends : deps) endif - -############################################################ - -subdir('fuzz') |