dcavalca / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone
Blob Blame History Raw
From a21bc03df9504c7a9b0c8e0e894d94f226a7a038 Mon Sep 17 00:00:00 2001
From: Jan Janssen <medhefgo@web.de>
Date: Tue, 11 Jan 2022 10:47:01 +0100
Subject: [PATCH] meson: Use files() for fuzzers

Not having to provide the full path in the source tree is much
nicer and the produced lists can also be used anywhere in the source
tree.

(cherry picked from commit bbec46c817951225f1e535d3df95b82a114e502a)

Related: #2017035
---
 meson.build                             |  3 ++-
 src/boot/efi/meson.build                |  2 +-
 src/core/meson.build                    |  2 +-
 src/fuzz/meson.build                    | 20 ++++++++++----------
 src/journal-remote/meson.build          |  2 +-
 src/journal/meson.build                 | 24 ++++++++++++------------
 src/libsystemd-network/meson.build      |  8 ++++----
 src/libsystemd/meson.build              |  4 ++--
 src/network/meson.build                 |  4 ++--
 src/nspawn/meson.build                  |  4 ++--
 src/resolve/meson.build                 |  2 +-
 src/systemctl/meson.build               |  7 ++++---
 src/udev/meson.build                    | 11 +++++------
 src/xdg-autostart-generator/meson.build |  6 +++---
 14 files changed, 50 insertions(+), 49 deletions(-)

diff --git a/meson.build b/meson.build
index 35ba29aecf..fdf02b8110 100644
--- a/meson.build
+++ b/meson.build
@@ -3677,7 +3677,8 @@ foreach tuple : fuzzers
                 sources += 'src/fuzz/fuzz-main.c'
         endif
 
-        name = sources[0].split('/')[-1].split('.')[0]
+        # FIXME: Use fs.stem() with meson >= 0.54.0
+        name = '@0@'.format(sources[0]).split('/')[-1].split('.')[0]
 
         exe = executable(
                 name,
diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build
index 229771026d..3e948281f2 100644
--- a/src/boot/efi/meson.build
+++ b/src/boot/efi/meson.build
@@ -359,7 +359,7 @@ if efi_arch[1] in ['ia32', 'x86_64', 'arm', 'aarch64']
                  'HAVE_ZSTD'],
         ]
         fuzzers += [
-                [['src/boot/efi/fuzz-bcd.c']],
+                [files('fuzz-bcd.c')],
         ]
 endif
 
diff --git a/src/core/meson.build b/src/core/meson.build
index d229d46779..97ac431763 100644
--- a/src/core/meson.build
+++ b/src/core/meson.build
@@ -228,7 +228,7 @@ endif
 ############################################################
 
 fuzzers += [
-        [['src/core/fuzz-unit-file.c'],
+        [files('fuzz-unit-file.c'),
          [libcore,
           libshared],
          [libmount]],
diff --git a/src/fuzz/meson.build b/src/fuzz/meson.build
index 1ed1dd8251..d987f32b08 100644
--- a/src/fuzz/meson.build
+++ b/src/fuzz/meson.build
@@ -1,23 +1,23 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 
 fuzzers += [
-        [['src/fuzz/fuzz-catalog.c']],
+        [files('fuzz-catalog.c')],
 
-        [['src/fuzz/fuzz-json.c']],
+        [files('fuzz-json.c')],
 
-        [['src/fuzz/fuzz-varlink.c']],
+        [files('fuzz-varlink.c')],
 
-        [['src/fuzz/fuzz-udev-database.c']],
+        [files('fuzz-udev-database.c')],
 
-        [['src/fuzz/fuzz-compress.c']],
+        [files('fuzz-compress.c')],
 
-        [['src/fuzz/fuzz-bus-label.c']],
+        [files('fuzz-bus-label.c')],
 
-        [['src/fuzz/fuzz-env-file.c']],
+        [files('fuzz-env-file.c')],
 
-        [['src/fuzz/fuzz-hostname-setup.c']],
+        [files('fuzz-hostname-setup.c')],
 
-        [['src/fuzz/fuzz-calendarspec.c']],
+        [files('fuzz-calendarspec.c')],
 
-        [['src/fuzz/fuzz-time-util.c']],
+        [files('fuzz-time-util.c')],
 ]
diff --git a/src/journal-remote/meson.build b/src/journal-remote/meson.build
index 168d0ed6a3..1f3e0878ae 100644
--- a/src/journal-remote/meson.build
+++ b/src/journal-remote/meson.build
@@ -76,7 +76,7 @@ endif
 ############################################################
 
 fuzzers += [
-        [['src/journal-remote/fuzz-journal-remote.c'],
+        [files('fuzz-journal-remote.c'),
          [libsystemd_journal_remote,
           libshared],
          [],
diff --git a/src/journal/meson.build b/src/journal/meson.build
index b9a63d5e2f..21c4d2561c 100644
--- a/src/journal/meson.build
+++ b/src/journal/meson.build
@@ -116,38 +116,38 @@ tests += [
 ]
 
 fuzzers += [
-        [['src/journal/fuzz-journald-audit.c',
-          'src/journal/fuzz-journald.c'],
+        [files('fuzz-journald-audit.c',
+               'fuzz-journald.c'),
          [libjournal_core,
           libshared],
          [libselinux]],
 
-        [['src/journal/fuzz-journald-kmsg.c',
-          'src/journal/fuzz-journald.c'],
+        [files('fuzz-journald-kmsg.c',
+               'fuzz-journald.c'),
          [libjournal_core,
           libshared],
          [libselinux]],
 
-        [['src/journal/fuzz-journald-native.c',
-          'src/journal/fuzz-journald.c'],
+        [files('fuzz-journald-native.c',
+               'fuzz-journald.c'),
          [libjournal_core,
           libshared],
          [libselinux]],
 
-        [['src/journal/fuzz-journald-native-fd.c',
-          'src/journal/fuzz-journald.c'],
+        [files('fuzz-journald-native-fd.c',
+               'fuzz-journald.c'),
          [libjournal_core,
           libshared],
          [libselinux]],
 
-        [['src/journal/fuzz-journald-stream.c',
-          'src/journal/fuzz-journald.c'],
+        [files('fuzz-journald-stream.c',
+               'fuzz-journald.c'),
          [libjournal_core,
           libshared],
          [libselinux]],
 
-        [['src/journal/fuzz-journald-syslog.c',
-          'src/journal/fuzz-journald.c'],
+        [files('fuzz-journald-syslog.c',
+               'fuzz-journald.c'),
          [libjournal_core,
           libshared],
          [libselinux]],
diff --git a/src/libsystemd-network/meson.build b/src/libsystemd-network/meson.build
index 3923df48ea..6be409d8ad 100644
--- a/src/libsystemd-network/meson.build
+++ b/src/libsystemd-network/meson.build
@@ -105,19 +105,19 @@ tests += [
 ]
 
 fuzzers += [
-        [['src/libsystemd-network/fuzz-dhcp6-client.c'],
+        [files('fuzz-dhcp6-client.c'),
          [libshared,
           libsystemd_network]],
 
-        [['src/libsystemd-network/fuzz-dhcp-server.c'],
+        [files('fuzz-dhcp-server.c'),
          [libsystemd_network,
           libshared]],
 
-        [['src/libsystemd-network/fuzz-lldp-rx.c'],
+        [files('fuzz-lldp-rx.c'),
          [libshared,
           libsystemd_network]],
 
-        [['src/libsystemd-network/fuzz-ndisc-rs.c'],
+        [files('fuzz-ndisc-rs.c'),
          [libshared,
           libsystemd_network]],
 ]
diff --git a/src/libsystemd/meson.build b/src/libsystemd/meson.build
index 42746e560f..2e5255d479 100644
--- a/src/libsystemd/meson.build
+++ b/src/libsystemd/meson.build
@@ -316,7 +316,7 @@ endif
 ############################################################
 
 fuzzers += [
-        [['src/libsystemd/sd-bus/fuzz-bus-message.c']],
+        [files('sd-bus/fuzz-bus-message.c')],
 
-        [['src/libsystemd/sd-bus/fuzz-bus-match.c']],
+        [files('sd-bus/fuzz-bus-match.c')],
 ]
diff --git a/src/network/meson.build b/src/network/meson.build
index a598701e4f..23743233fa 100644
--- a/src/network/meson.build
+++ b/src/network/meson.build
@@ -261,14 +261,14 @@ if conf.get('ENABLE_NETWORKD') == 1
 endif
 
 fuzzers += [
-        [['src/network/fuzz-netdev-parser.c'],
+        [files('fuzz-netdev-parser.c'),
          [libnetworkd_core,
           libsystemd_network,
           networkd_link_with],
          [threads],
          network_includes],
 
-        [['src/network/fuzz-network-parser.c'],
+        [files('fuzz-network-parser.c'),
          [libnetworkd_core,
           libsystemd_network,
           networkd_link_with],
diff --git a/src/nspawn/meson.build b/src/nspawn/meson.build
index 3c1a9c6182..2934672e9a 100644
--- a/src/nspawn/meson.build
+++ b/src/nspawn/meson.build
@@ -66,12 +66,12 @@ tests += [
 ]
 
 fuzzers += [
-        [['src/nspawn/fuzz-nspawn-settings.c'],
+        [files('fuzz-nspawn-settings.c'),
          [libshared,
           libnspawn_core],
          [libseccomp]],
 
-        [['src/nspawn/fuzz-nspawn-oci.c'],
+        [files('fuzz-nspawn-oci.c'),
          [libshared,
           libnspawn_core],
          [libseccomp]],
diff --git a/src/resolve/meson.build b/src/resolve/meson.build
index 4de50c3d8e..1fee993d0a 100644
--- a/src/resolve/meson.build
+++ b/src/resolve/meson.build
@@ -216,7 +216,7 @@ tests += [
 ]
 
 fuzzers += [
-        [['src/resolve/fuzz-dns-packet.c'],
+        [files('fuzz-dns-packet.c'),
          [libsystemd_resolve_core,
           libshared],
          [lib_openssl_or_gcrypt,
diff --git a/src/systemctl/meson.build b/src/systemctl/meson.build
index 38bf33d49a..f0d405bb58 100644
--- a/src/systemctl/meson.build
+++ b/src/systemctl/meson.build
@@ -83,7 +83,8 @@ else
 endif
 
 fuzzers += [
-        [['src/systemctl/fuzz-systemctl-parse-argv.c',
-          systemctl_sources],
+        [files('fuzz-systemctl-parse-argv.c') +
+         systemctl_sources,
          systemctl_link_with,
-         [], [], ['-DFUZZ_SYSTEMCTL_PARSE_ARGV']]]
+         [], [], ['-DFUZZ_SYSTEMCTL_PARSE_ARGV']]
+]
diff --git a/src/udev/meson.build b/src/udev/meson.build
index 57fbf8c8fc..9fd0bcdd0e 100644
--- a/src/udev/meson.build
+++ b/src/udev/meson.build
@@ -174,24 +174,23 @@ if install_sysconfdir
 endif
 
 fuzzers += [
-        [['src/udev/net/fuzz-link-parser.c',
-          'src/fuzz/fuzz.h'],
+        [files('net/fuzz-link-parser.c'),
          [libudevd_core,
           libshared],
          [threads,
           libacl],
          udev_includes],
 
-        [['src/udev/fuzz-udev-rules.c'],
+        [files('fuzz-udev-rules.c'),
          [libudevd_core,
           libshared],
          [threads,
           libacl]],
 
-        [['src/udev/fuzz-udev-rule-parse-value.c']],
+        [files('fuzz-udev-rule-parse-value.c')],
 
-        [['src/udev/fido_id/fuzz-fido-id-desc.c',
-          'src/udev/fido_id/fido_id_desc.c']],
+        [files('fido_id/fuzz-fido-id-desc.c',
+               'fido_id/fido_id_desc.c')],
 ]
 
 tests += [
diff --git a/src/xdg-autostart-generator/meson.build b/src/xdg-autostart-generator/meson.build
index 6418f57c40..cdce66b6fc 100644
--- a/src/xdg-autostart-generator/meson.build
+++ b/src/xdg-autostart-generator/meson.build
@@ -12,7 +12,7 @@ tests += [
 ]
 
 fuzzers += [
-        [['src/xdg-autostart-generator/fuzz-xdg-desktop.c',
-          'src/xdg-autostart-generator/xdg-autostart-service.c',
-          'src/xdg-autostart-generator/xdg-autostart-service.h']],
+        [files('fuzz-xdg-desktop.c',
+               'xdg-autostart-service.c',
+               'xdg-autostart-service.h')],
 ]