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 <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Martin Renvoize 2026-05-22 10:46:10 +01:00 committed by Pedro Amorim
parent 445b955b78
commit 71f9a68679
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 7 additions and 3 deletions

View File

@ -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);