2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-12-04 08:07:04 +00:00
Files
xcat-core/xCAT-test/unit/genesis_openembedded_duid.t
T
Daniel Hilst b62fd4cc8a test(xcat-core): genesis_openembedded_duid.t fails on a second enabled unit
genesis_openembedded_duid.t fails in the unit suite. The
xcat-genesis-network recipe enables xcat-genesis-duid.service and
xcat-genesis-bootnic.service, and the test matched SYSTEMD_SERVICE
against a list that holds the first unit alone.

The test now reads SYSTEMD_SERVICE as a list and asserts that it holds
xcat-genesis-duid.service. With that unit removed from the recipe the
assertion fails, and with the recipe as it is the test passes.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-11-09 18:18:28 -03:00

61 lines
2.3 KiB
Perl

#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use Test::More;
use XCAT::Test::File qw(repo_path slurp_repo_file);
# The systemd unit and the recipe are the artifact. genesis-duid is shell and is tested in
# xCAT-test/bats/genesis_openembedded_duid.bats.
my $META = 'xCAT-genesis-base/oe/meta-xcat-genesis';
my $NETWORK = "$META/recipes-connectivity/xcat-genesis-network";
#---
# =head3 contents_of
#
# Descriptions: Read a repository file, or return an empty string when it is absent.
#
# Arguments:
# $relative - the path of the file, relative to the checkout
#
# Returns: the contents of the file, or an empty string
#
# A missing file has to fail each assertion that names it. slurp_repo_file dies instead,
# which names no assertion at all.
#---
sub contents_of {
my ($relative) = @_;
return -f repo_path($relative) ? slurp_repo_file($relative) : '';
}
my $service_contents = contents_of("$NETWORK/files/xcat-genesis-duid.service");
like( $service_contents, qr/^ConditionKernelCommandLine=xcatd$/m,
'the client identifier service requires a Genesis boot' );
like( $service_contents, qr/^Before=.*\bNetworkManager\.service\b/m,
'the client identifier is written before NetworkManager reads conf.d' );
like( $service_contents, qr/^Before=.*\bxcat-genesis-network-state\.service\b/m,
'the client identifier is written before management network selection' );
like( $service_contents, qr{^ExecStart=/usr/libexec/xcat/genesis-duid$}m,
'the service runs the client identifier script' );
like( $service_contents, qr/^Type=oneshot$/m,
'the client identifier is written once per boot' );
my $recipe_contents = contents_of("$NETWORK/xcat-genesis-network_1.0.bb");
# The recipe enables more than one unit, so the list is read as a list.
my ($enabled) = $recipe_contents =~ /^SYSTEMD_SERVICE:\$\{PN\} = "([^"]*)"$/m;
my %enabled = map { $_ => 1 } split( ' ', $enabled // '' );
ok( $enabled{'xcat-genesis-duid.service'}, 'the recipe enables the client identifier service' )
or diag( 'SYSTEMD_SERVICE: ' . ( $enabled // 'absent' ) );
like( $recipe_contents, qr{\$\{D\}\$\{libexecdir\}/xcat/genesis-duid$}m,
'the recipe installs the client identifier script' );
ok( -f repo_path("$NETWORK/files/genesis-duid"),
'the client identifier script is in the OpenEmbedded layer' );
done_testing();