teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0059-meson-Use-files-for-fuzzers.patch

8d419f
From a21bc03df9504c7a9b0c8e0e894d94f226a7a038 Mon Sep 17 00:00:00 2001
8d419f
From: Jan Janssen <medhefgo@web.de>
8d419f
Date: Tue, 11 Jan 2022 10:47:01 +0100
8d419f
Subject: [PATCH] meson: Use files() for fuzzers
8d419f
8d419f
Not having to provide the full path in the source tree is much
8d419f
nicer and the produced lists can also be used anywhere in the source
8d419f
tree.
8d419f
8d419f
(cherry picked from commit bbec46c817951225f1e535d3df95b82a114e502a)
8d419f
8d419f
Related: #2017035
8d419f
---
8d419f
 meson.build                             |  3 ++-
8d419f
 src/boot/efi/meson.build                |  2 +-
8d419f
 src/core/meson.build                    |  2 +-
8d419f
 src/fuzz/meson.build                    | 20 ++++++++++----------
8d419f
 src/journal-remote/meson.build          |  2 +-
8d419f
 src/journal/meson.build                 | 24 ++++++++++++------------
8d419f
 src/libsystemd-network/meson.build      |  8 ++++----
8d419f
 src/libsystemd/meson.build              |  4 ++--
8d419f
 src/network/meson.build                 |  4 ++--
8d419f
 src/nspawn/meson.build                  |  4 ++--
8d419f
 src/resolve/meson.build                 |  2 +-
8d419f
 src/systemctl/meson.build               |  7 ++++---
8d419f
 src/udev/meson.build                    | 11 +++++------
8d419f
 src/xdg-autostart-generator/meson.build |  6 +++---
8d419f
 14 files changed, 50 insertions(+), 49 deletions(-)
8d419f
8d419f
diff --git a/meson.build b/meson.build
8d419f
index 35ba29aecf..fdf02b8110 100644
8d419f
--- a/meson.build
8d419f
+++ b/meson.build
8d419f
@@ -3677,7 +3677,8 @@ foreach tuple : fuzzers
8d419f
                 sources += 'src/fuzz/fuzz-main.c'
8d419f
         endif
8d419f
 
8d419f
-        name = sources[0].split('/')[-1].split('.')[0]
8d419f
+        # FIXME: Use fs.stem() with meson >= 0.54.0
8d419f
+        name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
8d419f
 
8d419f
         exe = executable(
8d419f
                 name,
8d419f
diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build
8d419f
index 229771026d..3e948281f2 100644
8d419f
--- a/src/boot/efi/meson.build
8d419f
+++ b/src/boot/efi/meson.build
8d419f
@@ -359,7 +359,7 @@ if efi_arch[1] in ['ia32', 'x86_64', 'arm', 'aarch64']
8d419f
                  'HAVE_ZSTD'],
8d419f
         ]
8d419f
         fuzzers += [
8d419f
-                [['src/boot/efi/fuzz-bcd.c']],
8d419f
+                [files('fuzz-bcd.c')],
8d419f
         ]
8d419f
 endif
8d419f
 
8d419f
diff --git a/src/core/meson.build b/src/core/meson.build
8d419f
index d229d46779..97ac431763 100644
8d419f
--- a/src/core/meson.build
8d419f
+++ b/src/core/meson.build
8d419f
@@ -228,7 +228,7 @@ endif
8d419f
 ############################################################
8d419f
 
8d419f
 fuzzers += [
8d419f
-        [['src/core/fuzz-unit-file.c'],
8d419f
+        [files('fuzz-unit-file.c'),
8d419f
          [libcore,
8d419f
           libshared],
8d419f
          [libmount]],
8d419f
diff --git a/src/fuzz/meson.build b/src/fuzz/meson.build
8d419f
index 1ed1dd8251..d987f32b08 100644
8d419f
--- a/src/fuzz/meson.build
8d419f
+++ b/src/fuzz/meson.build
8d419f
@@ -1,23 +1,23 @@
8d419f
 # SPDX-License-Identifier: LGPL-2.1-or-later
8d419f
 
8d419f
 fuzzers += [
8d419f
-        [['src/fuzz/fuzz-catalog.c']],
8d419f
+        [files('fuzz-catalog.c')],
8d419f
 
8d419f
-        [['src/fuzz/fuzz-json.c']],
8d419f
+        [files('fuzz-json.c')],
8d419f
 
8d419f
-        [['src/fuzz/fuzz-varlink.c']],
8d419f
+        [files('fuzz-varlink.c')],
8d419f
 
8d419f
-        [['src/fuzz/fuzz-udev-database.c']],
8d419f
+        [files('fuzz-udev-database.c')],
8d419f
 
8d419f
-        [['src/fuzz/fuzz-compress.c']],
8d419f
+        [files('fuzz-compress.c')],
8d419f
 
8d419f
-        [['src/fuzz/fuzz-bus-label.c']],
8d419f
+        [files('fuzz-bus-label.c')],
8d419f
 
8d419f
-        [['src/fuzz/fuzz-env-file.c']],
8d419f
+        [files('fuzz-env-file.c')],
8d419f
 
8d419f
-        [['src/fuzz/fuzz-hostname-setup.c']],
8d419f
+        [files('fuzz-hostname-setup.c')],
8d419f
 
8d419f
-        [['src/fuzz/fuzz-calendarspec.c']],
8d419f
+        [files('fuzz-calendarspec.c')],
8d419f
 
8d419f
-        [['src/fuzz/fuzz-time-util.c']],
8d419f
+        [files('fuzz-time-util.c')],
8d419f
 ]
8d419f
diff --git a/src/journal-remote/meson.build b/src/journal-remote/meson.build
8d419f
index 168d0ed6a3..1f3e0878ae 100644
8d419f
--- a/src/journal-remote/meson.build
8d419f
+++ b/src/journal-remote/meson.build
8d419f
@@ -76,7 +76,7 @@ endif
8d419f
 ############################################################
8d419f
 
8d419f
 fuzzers += [
8d419f
-        [['src/journal-remote/fuzz-journal-remote.c'],
8d419f
+        [files('fuzz-journal-remote.c'),
8d419f
          [libsystemd_journal_remote,
8d419f
           libshared],
8d419f
          [],
8d419f
diff --git a/src/journal/meson.build b/src/journal/meson.build
8d419f
index b9a63d5e2f..21c4d2561c 100644
8d419f
--- a/src/journal/meson.build
8d419f
+++ b/src/journal/meson.build
8d419f
@@ -116,38 +116,38 @@ tests += [
8d419f
 ]
8d419f
 
8d419f
 fuzzers += [
8d419f
-        [['src/journal/fuzz-journald-audit.c',
8d419f
-          'src/journal/fuzz-journald.c'],
8d419f
+        [files('fuzz-journald-audit.c',
8d419f
+               'fuzz-journald.c'),
8d419f
          [libjournal_core,
8d419f
           libshared],
8d419f
          [libselinux]],
8d419f
 
8d419f
-        [['src/journal/fuzz-journald-kmsg.c',
8d419f
-          'src/journal/fuzz-journald.c'],
8d419f
+        [files('fuzz-journald-kmsg.c',
8d419f
+               'fuzz-journald.c'),
8d419f
          [libjournal_core,
8d419f
           libshared],
8d419f
          [libselinux]],
8d419f
 
8d419f
-        [['src/journal/fuzz-journald-native.c',
8d419f
-          'src/journal/fuzz-journald.c'],
8d419f
+        [files('fuzz-journald-native.c',
8d419f
+               'fuzz-journald.c'),
8d419f
          [libjournal_core,
8d419f
           libshared],
8d419f
          [libselinux]],
8d419f
 
8d419f
-        [['src/journal/fuzz-journald-native-fd.c',
8d419f
-          'src/journal/fuzz-journald.c'],
8d419f
+        [files('fuzz-journald-native-fd.c',
8d419f
+               'fuzz-journald.c'),
8d419f
          [libjournal_core,
8d419f
           libshared],
8d419f
          [libselinux]],
8d419f
 
8d419f
-        [['src/journal/fuzz-journald-stream.c',
8d419f
-          'src/journal/fuzz-journald.c'],
8d419f
+        [files('fuzz-journald-stream.c',
8d419f
+               'fuzz-journald.c'),
8d419f
          [libjournal_core,
8d419f
           libshared],
8d419f
          [libselinux]],
8d419f
 
8d419f
-        [['src/journal/fuzz-journald-syslog.c',
8d419f
-          'src/journal/fuzz-journald.c'],
8d419f
+        [files('fuzz-journald-syslog.c',
8d419f
+               'fuzz-journald.c'),
8d419f
          [libjournal_core,
8d419f
           libshared],
8d419f
          [libselinux]],
8d419f
diff --git a/src/libsystemd-network/meson.build b/src/libsystemd-network/meson.build
8d419f
index 3923df48ea..6be409d8ad 100644
8d419f
--- a/src/libsystemd-network/meson.build
8d419f
+++ b/src/libsystemd-network/meson.build
8d419f
@@ -105,19 +105,19 @@ tests += [
8d419f
 ]
8d419f
 
8d419f
 fuzzers += [
8d419f
-        [['src/libsystemd-network/fuzz-dhcp6-client.c'],
8d419f
+        [files('fuzz-dhcp6-client.c'),
8d419f
          [libshared,
8d419f
           libsystemd_network]],
8d419f
 
8d419f
-        [['src/libsystemd-network/fuzz-dhcp-server.c'],
8d419f
+        [files('fuzz-dhcp-server.c'),
8d419f
          [libsystemd_network,
8d419f
           libshared]],
8d419f
 
8d419f
-        [['src/libsystemd-network/fuzz-lldp-rx.c'],
8d419f
+        [files('fuzz-lldp-rx.c'),
8d419f
          [libshared,
8d419f
           libsystemd_network]],
8d419f
 
8d419f
-        [['src/libsystemd-network/fuzz-ndisc-rs.c'],
8d419f
+        [files('fuzz-ndisc-rs.c'),
8d419f
          [libshared,
8d419f
           libsystemd_network]],
8d419f
 ]
8d419f
diff --git a/src/libsystemd/meson.build b/src/libsystemd/meson.build
8d419f
index 42746e560f..2e5255d479 100644
8d419f
--- a/src/libsystemd/meson.build
8d419f
+++ b/src/libsystemd/meson.build
8d419f
@@ -316,7 +316,7 @@ endif
8d419f
 ############################################################
8d419f
 
8d419f
 fuzzers += [
8d419f
-        [['src/libsystemd/sd-bus/fuzz-bus-message.c']],
8d419f
+        [files('sd-bus/fuzz-bus-message.c')],
8d419f
 
8d419f
-        [['src/libsystemd/sd-bus/fuzz-bus-match.c']],
8d419f
+        [files('sd-bus/fuzz-bus-match.c')],
8d419f
 ]
8d419f
diff --git a/src/network/meson.build b/src/network/meson.build
8d419f
index a598701e4f..23743233fa 100644
8d419f
--- a/src/network/meson.build
8d419f
+++ b/src/network/meson.build
8d419f
@@ -261,14 +261,14 @@ if conf.get('ENABLE_NETWORKD') == 1
8d419f
 endif
8d419f
 
8d419f
 fuzzers += [
8d419f
-        [['src/network/fuzz-netdev-parser.c'],
8d419f
+        [files('fuzz-netdev-parser.c'),
8d419f
          [libnetworkd_core,
8d419f
           libsystemd_network,
8d419f
           networkd_link_with],
8d419f
          [threads],
8d419f
          network_includes],
8d419f
 
8d419f
-        [['src/network/fuzz-network-parser.c'],
8d419f
+        [files('fuzz-network-parser.c'),
8d419f
          [libnetworkd_core,
8d419f
           libsystemd_network,
8d419f
           networkd_link_with],
8d419f
diff --git a/src/nspawn/meson.build b/src/nspawn/meson.build
8d419f
index 3c1a9c6182..2934672e9a 100644
8d419f
--- a/src/nspawn/meson.build
8d419f
+++ b/src/nspawn/meson.build
8d419f
@@ -66,12 +66,12 @@ tests += [
8d419f
 ]
8d419f
 
8d419f
 fuzzers += [
8d419f
-        [['src/nspawn/fuzz-nspawn-settings.c'],
8d419f
+        [files('fuzz-nspawn-settings.c'),
8d419f
          [libshared,
8d419f
           libnspawn_core],
8d419f
          [libseccomp]],
8d419f
 
8d419f
-        [['src/nspawn/fuzz-nspawn-oci.c'],
8d419f
+        [files('fuzz-nspawn-oci.c'),
8d419f
          [libshared,
8d419f
           libnspawn_core],
8d419f
          [libseccomp]],
8d419f
diff --git a/src/resolve/meson.build b/src/resolve/meson.build
8d419f
index 4de50c3d8e..1fee993d0a 100644
8d419f
--- a/src/resolve/meson.build
8d419f
+++ b/src/resolve/meson.build
8d419f
@@ -216,7 +216,7 @@ tests += [
8d419f
 ]
8d419f
 
8d419f
 fuzzers += [
8d419f
-        [['src/resolve/fuzz-dns-packet.c'],
8d419f
+        [files('fuzz-dns-packet.c'),
8d419f
          [libsystemd_resolve_core,
8d419f
           libshared],
8d419f
          [lib_openssl_or_gcrypt,
8d419f
diff --git a/src/systemctl/meson.build b/src/systemctl/meson.build
8d419f
index 38bf33d49a..f0d405bb58 100644
8d419f
--- a/src/systemctl/meson.build
8d419f
+++ b/src/systemctl/meson.build
8d419f
@@ -83,7 +83,8 @@ else
8d419f
 endif
8d419f
 
8d419f
 fuzzers += [
8d419f
-        [['src/systemctl/fuzz-systemctl-parse-argv.c',
8d419f
-          systemctl_sources],
8d419f
+        [files('fuzz-systemctl-parse-argv.c') +
8d419f
+         systemctl_sources,
8d419f
          systemctl_link_with,
8d419f
-         [], [], ['-DFUZZ_SYSTEMCTL_PARSE_ARGV']]]
8d419f
+         [], [], ['-DFUZZ_SYSTEMCTL_PARSE_ARGV']]
8d419f
+]
8d419f
diff --git a/src/udev/meson.build b/src/udev/meson.build
8d419f
index 57fbf8c8fc..9fd0bcdd0e 100644
8d419f
--- a/src/udev/meson.build
8d419f
+++ b/src/udev/meson.build
8d419f
@@ -174,24 +174,23 @@ if install_sysconfdir
8d419f
 endif
8d419f
 
8d419f
 fuzzers += [
8d419f
-        [['src/udev/net/fuzz-link-parser.c',
8d419f
-          'src/fuzz/fuzz.h'],
8d419f
+        [files('net/fuzz-link-parser.c'),
8d419f
          [libudevd_core,
8d419f
           libshared],
8d419f
          [threads,
8d419f
           libacl],
8d419f
          udev_includes],
8d419f
 
8d419f
-        [['src/udev/fuzz-udev-rules.c'],
8d419f
+        [files('fuzz-udev-rules.c'),
8d419f
          [libudevd_core,
8d419f
           libshared],
8d419f
          [threads,
8d419f
           libacl]],
8d419f
 
8d419f
-        [['src/udev/fuzz-udev-rule-parse-value.c']],
8d419f
+        [files('fuzz-udev-rule-parse-value.c')],
8d419f
 
8d419f
-        [['src/udev/fido_id/fuzz-fido-id-desc.c',
8d419f
-          'src/udev/fido_id/fido_id_desc.c']],
8d419f
+        [files('fido_id/fuzz-fido-id-desc.c',
8d419f
+               'fido_id/fido_id_desc.c')],
8d419f
 ]
8d419f
 
8d419f
 tests += [
8d419f
diff --git a/src/xdg-autostart-generator/meson.build b/src/xdg-autostart-generator/meson.build
8d419f
index 6418f57c40..cdce66b6fc 100644
8d419f
--- a/src/xdg-autostart-generator/meson.build
8d419f
+++ b/src/xdg-autostart-generator/meson.build
8d419f
@@ -12,7 +12,7 @@ tests += [
8d419f
 ]
8d419f
 
8d419f
 fuzzers += [
8d419f
-        [['src/xdg-autostart-generator/fuzz-xdg-desktop.c',
8d419f
-          'src/xdg-autostart-generator/xdg-autostart-service.c',
8d419f
-          'src/xdg-autostart-generator/xdg-autostart-service.h']],
8d419f
+        [files('fuzz-xdg-desktop.c',
8d419f
+               'xdg-autostart-service.c',
8d419f
+               'xdg-autostart-service.h')],
8d419f
 ]