2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-24 00:34:02 +00:00
Files
xcat-core/xCAT-test/unit/debian_install_prescript.t
T
Daniel Hilst 75c0af5373 fix(xcat-core): debian_install_prescript.t passes when the file it reads is missing
debian_install_prescript.t called plan skip_all when xCAT-server/lib/xcat/plugins/debian.pm was absent, so a checkout that lost
the file reported 0 tests and exit 0. A test that cannot fail measures nothing.

Die instead, which is what makentp_ntp_deps.t already does for setupntp.

With xCAT-server/lib/xcat/plugins/debian.pm moved aside the file now exits 2 and prints "debian.pm not found";
before this change it exited 0 and printed "1..0 # SKIP debian.pm not found". With the file
present the test passes either way.

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

56 lines
2.4 KiB
Perl

#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use Test::More;
# Ubuntu has two installers and two pre-install scripts that are not interchangeable.
# pre.ubuntu.subiquity writes a curtin "storage:" document that the autoinstall
# early-commands append to /autoinstall.yaml. pre.ubuntu.ppc64 writes a partman recipe
# for the debian-installer, which is not YAML at all.
#
# mkinstall chose the subiquity script, then overwrote that choice for every ppc64 node,
# so a ppc64el Subiquity install appended a partman recipe to its autoinstall.yaml. The
# ppc64 script belongs to the debian-installer path only.
use lib "$FindBin::Bin/../../perl-xCAT";
use lib "$FindBin::Bin/../../xCAT-server/lib/perl";
my $plugin = "$FindBin::Bin/../../xCAT-server/lib/xcat/plugins/debian.pm";
die "debian.pm not found\n" unless -r $plugin;
eval { require $plugin; 1 } or plan skip_all => "could not load debian.pm: $@";
can_ok('xCAT_plugin::debian', 'install_prescript')
or die('mkinstall still chooses the pre-install script inline, so nothing can drive it');
sub chosen {
my ($platform, $arch, $subiquity) = @_;
my $path = xCAT_plugin::debian::install_prescript($platform, $arch, $subiquity);
$path =~ s{.*/}{};
return $path;
}
# --- subiquity: the arch never changes the script -------------------------
is(chosen('ubuntu', 'x86_64', 1), 'pre.ubuntu.subiquity',
'an x86_64 subiquity install gets the subiquity pre-install script');
is(chosen('ubuntu', 'ppc64el', 1), 'pre.ubuntu.subiquity',
'a ppc64el subiquity install gets the subiquity pre-install script, not the partman one');
is(chosen('ubuntu', 'ppc64le', 1), 'pre.ubuntu.subiquity',
'the ppc64le spelling reaches the same script');
is(chosen('ubuntu', 'ppc64', 1), 'pre.ubuntu.subiquity',
'so does the bare ppc64 spelling');
# --- debian-installer: ppc64 keeps its own script -------------------------
is(chosen('ubuntu', 'ppc64el', 0), 'pre.ubuntu.ppc64',
'a ppc64el debian-installer install keeps the partman pre-install script');
is(chosen('ubuntu', 'ppc64', 0), 'pre.ubuntu.ppc64',
'and so does the bare ppc64 spelling');
is(chosen('ubuntu', 'x86_64', 0), 'pre.ubuntu',
'an x86_64 debian-installer install gets the plain script');
# --- the override is Ubuntu only -----------------------------------------
is(chosen('debian', 'ppc64el', 0), 'pre.debian',
'Debian on POWER has no ppc64 pre-install script to select');
done_testing();