From 71f9a686795303efb8cf08b3a12d544dd4e04a50 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 22 May 2026 10:46:10 +0100 Subject: [PATCH] Bug 40901: (QA follow-up) Fix systemd unit test for Test::NoWarnings and older systemd Add Test::NoWarnings and probe for --unit-path support, skipping on systemd versions that don't recognise the flag (e.g. KTD's Debian image). Signed-off-by: Martin Renvoize Signed-off-by: Pedro Amorim --- t/00-valid-systemd-units.t | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/t/00-valid-systemd-units.t b/t/00-valid-systemd-units.t index 3028955cdc..ec5c2a622d 100755 --- a/t/00-valid-systemd-units.t +++ b/t/00-valid-systemd-units.t @@ -18,6 +18,7 @@ use Modern::Perl; use Test::More; +use Test::NoWarnings; use Cwd qw( abs_path ); use FindBin qw( $Bin ); @@ -30,16 +31,19 @@ my $units_dir = abs_path("$Bin/../debian/systemd"); plan( skip_all => 'debian/systemd not found' ) unless $units_dir && -d $units_dir; +my $probe = qx(systemd-analyze verify --unit-path=/tmp /bin/true 2>&1); +plan( skip_all => 'systemd-analyze --unit-path not supported; upgrade systemd' ) + if $probe =~ /unrecognized option/; + opendir( my $dh, $units_dir ) or die "Cannot open $units_dir: $!"; my @units = sort - grep { /\.(service|target|socket|timer)$/ } - readdir $dh; + grep { /\.(service|target|socket|timer)$/ } readdir $dh; closedir $dh; plan( skip_all => 'No unit files found in debian/systemd' ) unless @units; -plan tests => scalar @units; +plan tests => scalar(@units) + 1; for my $unit (@units) { my $output = qx(systemd-analyze verify --no-pager "--unit-path=$units_dir" $unit 2>&1);