2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-09 14:36:43 +00:00

test(xCAT-test): cover the install architectures debian.pm accepts

The plugin is loaded and install_darch is called for the architectures
xCAT installs Ubuntu on and two it does not. Against the previous plugin the
test fails on the missing function: the mapping was inline in mkinstall.

Signed-off-by: Vinícius Ferrão <2031761+viniciusferrao@users.noreply.github.com>
This commit is contained in:
Vinícius Ferrão
2026-09-08 17:00:42 -03:00
parent a6e69e88a4
commit 166da7c1b6
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env perl
use strict;
use warnings;
use File::Path qw(make_path);
use File::Temp qw(tempdir);
use FindBin;
use Test::More;
# mkinstall logged "Unknown arch" for every architecture other than x86_64, x86, ppc64le and
# ppc64el, so each diskful riscv64 install produced a false message. install_darch names the
# architectures xCAT installs Ubuntu on and the Debian name each one maps to.
# xCAT modules put $::XCATROOT/lib/perl ahead of @INC as they compile, so on a host with xCAT
# installed the modules loaded after the first one would come from /opt/xcat. XCATROOT points
# at this checkout before any of them compiles.
BEGIN {
my $root = tempdir( CLEANUP => 1 );
make_path("$root/lib");
symlink( "$FindBin::Bin/../../perl-xCAT", "$root/lib/perl" ) or die "symlink: $!";
$ENV{XCATROOT} = $root;
}
BEGIN {
package xCAT::TableUtils;
our $tftpdir;
sub getTftpDir { return $tftpdir; }
$INC{'xCAT/TableUtils.pm'} = __FILE__;
}
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";
require $plugin;
my @cases = (
# arch Debian name installs Ubuntu
[ 'x86_64', 'amd64', 1 ],
[ 'x86', 'i386', 1 ],
[ 'ppc64le', 'ppc64le', 1 ],
[ 'ppc64el', 'ppc64el', 1 ],
[ 'riscv64', 'riscv64', 1 ],
[ 'aarch64', 'aarch64', 0 ],
[ 'sparc', 'sparc', 0 ],
);
foreach my $case (@cases) {
my ( $arch, $darch, $known ) = @$case;
my ( $got_darch, $got_known ) = xCAT_plugin::debian::install_darch($arch);
is( $got_darch, $darch, "$arch installs from the $darch tree" );
is( $got_known, $known, $known ? "... and is an architecture xCAT installs Ubuntu on" : "... and is reported as unknown" );
}
done_testing();