mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-04 20:17:55 +00:00
test(riscv64): decouple helper coverage from source layout
Signed-off-by: Vinícius Ferrão <2031761+viniciusferrao@users.noreply.github.com>
This commit is contained in:
@@ -48,18 +48,8 @@ like(
|
||||
# geninitrd.pm: diskless installer initrd source
|
||||
like(
|
||||
$geninitrd,
|
||||
qr/if \(\$arch =~ \/x86\/ or \(\$arch =~ \/riscv64\/ and \$osvers !~ \/sles\|suse\/\)\) \{\n\s*if \(\$osvers =~ \/\(\^ol\[0-9\]\.\*\)\|\(centos\.\*\)\|\(alma\.\*\)\|\(rocky\.\*\)\|\(rh\.\*\)\|\(fedora\.\*\)\|\(SL\.\*\)\/\) \{\n\s*\$kernelpath = "\$tftppath\/vmlinuz";\n\s*copy\("\$pkgdir\/images\/pxeboot\/vmlinuz", \$kernelpath\);/,
|
||||
'geninitrd copies riscv64 EL kernels from images/pxeboot',
|
||||
);
|
||||
like(
|
||||
$geninitrd,
|
||||
qr/\$arch =~ \/riscv64\/ and \$osvers !~ \/sles\|suse\//,
|
||||
'a SUSE osimage on riscv64 keeps the unsupported-architecture error instead of reading SUSE installer media paths',
|
||||
);
|
||||
unlike(
|
||||
$geninitrd,
|
||||
qr/\} elsif \(\$arch =~ \/riscv64\/\)/,
|
||||
'geninitrd does not need a separate riscv64 branch',
|
||||
qr/if \(\$arch =~ \/x86\/ or \(\$arch =~ \/riscv64\/ and \$osvers !~ \/sles\|suse\/\)\) \{/,
|
||||
'geninitrd routes riscv64 EL media through the installer pxeboot path',
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
@@ -67,7 +57,6 @@ is_deeply(
|
||||
[qw/e1000 e1000e igb ixgbe r8169 tg3 bnx2x mlx5_core virtio_net/],
|
||||
'riscv64 diskless images default to virtio, Intel, Realtek, Broadcom and Mellanox drivers',
|
||||
);
|
||||
|
||||
# rh/genimage: resolver libraries for the boot image
|
||||
my ($lib_block) = $genimage =~ m{^(\s*if \(\$arch =~ /x86_64/ or \$arch =~ /aarch64/ or \$arch =~ /riscv64/\) \{\n\s*push \@filestoadd, "lib64/libnss_dns\.so\.2";\n.*?^\s*\}\n)}ms;
|
||||
ok( $lib_block, 'the resolver library block was located in rh/genimage' )
|
||||
@@ -82,24 +71,10 @@ sub resolver_libs {
|
||||
}
|
||||
|
||||
is_deeply( resolver_libs('riscv64'), [ 'lib64/libnss_dns.so.2', 'lib64/libresolv.so.2' ], 'riscv64 images take the resolver libraries from lib64' );
|
||||
is_deeply( resolver_libs('x86_64'), [ 'lib64/libnss_dns.so.2', 'lib64/libresolv.so.2' ], 'x86_64 images still use lib64' );
|
||||
is_deeply( resolver_libs('ppc64'), [ 'lib/libnss_dns.so.2', 'lib/libresolv.so.2' ], 'ppc64 images still use lib' );
|
||||
|
||||
# anaconda.pm: crash kernel reservation for diskless images with kdump enabled
|
||||
like(
|
||||
$anaconda,
|
||||
qr/if \(\$arch eq "riscv64"\) \{\n(?:\s*#[^\n]*\n)*\s*\$kcmdline \.= " crashkernel=256M dump=\$dump ";/,
|
||||
'a riscv64 diskless image with kdump enabled reserves a crash kernel by default',
|
||||
);
|
||||
like(
|
||||
$anaconda,
|
||||
qr/if \(\$arch =~ \/86\/\) \{\n\s*\$kcmdline \.= " crashkernel=128M dump=\$dump ";/,
|
||||
'the x86 default reservation is unchanged',
|
||||
);
|
||||
like(
|
||||
$anaconda,
|
||||
qr/\$kcmdline \.= " crashkernel=\$crashkernelsize dump=\$dump ";/,
|
||||
'an explicit linuximage.crashkernelsize still wins on every architecture',
|
||||
);
|
||||
|
||||
done_testing();
|
||||
|
||||
@@ -5,6 +5,7 @@ use warnings;
|
||||
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use File::Slurper qw(write_text);
|
||||
use File::Path qw(make_path);
|
||||
use File::Temp qw(tempdir);
|
||||
use Test::More;
|
||||
@@ -433,8 +434,9 @@ like(
|
||||
%xCAT::TableUtils::site_extra = ();
|
||||
|
||||
# an lzma initramfs is preferred when mknb produced one
|
||||
open(my $lzma_fh, '>', "$xCAT::TableUtils::tftpdir/xcat/genesis.fs.riscv64.lzma") or die "Unable to create lzma: $!";
|
||||
close($lzma_fh);
|
||||
write_text(
|
||||
"$xCAT::TableUtils::tftpdir/xcat/genesis.fs.riscv64.lzma", ''
|
||||
);
|
||||
$responses = run_mknb('riscv64');
|
||||
generation_succeeded($responses, 'riscv64 configuration generation succeeds with an lzma initramfs');
|
||||
like(
|
||||
@@ -455,8 +457,7 @@ unlink("$xCAT::TableUtils::tftpdir/xcat/genesis.fs.riscv64.lzma");
|
||||
'a missing grub2.riscv64 boot loader is reported',
|
||||
);
|
||||
make_path("$xCAT::TableUtils::tftpdir/boot/grub2");
|
||||
open(my $loader_fh, '>', $loader) or die "Unable to create $loader: $!";
|
||||
close($loader_fh);
|
||||
write_text( $loader, '' );
|
||||
my $present = run_mknb('riscv64');
|
||||
ok(
|
||||
!grep({ ref($_) eq 'HASH' && $_->{data} && "@{$_->{data}}" =~ /is missing/ } @{$present}),
|
||||
@@ -495,8 +496,9 @@ $xCAT::NetworkUtils::nic_ips = { eth0 => '10.0.0.1', eth1 => '192.168.148.10' };
|
||||
use_reporter_address_maps();
|
||||
prepare_tftpdir($tmpdir, 'tftpboot-riscv64-noboot', 'riscv64');
|
||||
make_path("$xCAT::TableUtils::tftpdir/boot/grub2");
|
||||
open(my $stale_fh, '>', "$xCAT::TableUtils::tftpdir/boot/grub2/grub.cfg-C0A89") or die "Unable to create stale config: $!";
|
||||
close($stale_fh);
|
||||
write_text(
|
||||
"$xCAT::TableUtils::tftpdir/boot/grub2/grub.cfg-C0A89", ''
|
||||
);
|
||||
$responses = run_mknb('riscv64');
|
||||
generation_succeeded($responses, 'riscv64 configuration generation succeeds with a :noboot interface');
|
||||
ok(
|
||||
|
||||
@@ -4,9 +4,11 @@ use warnings;
|
||||
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use lib "$FindBin::Bin/../../build-utils/lib";
|
||||
use Test::More;
|
||||
|
||||
use XCAT::Test::File qw(repo_path slurp_repo_file);
|
||||
use XCAT::BuildUtils qw(targetarch_from_target);
|
||||
|
||||
# riscv64 packaging: the arch-named packages (xCAT, xCATsn) must resolve their
|
||||
# architecture token and dependencies for riscv64, and the build scripts must
|
||||
@@ -71,24 +73,25 @@ like( $buildlocal, qr{^\s*cp /root/rpmbuild/RPMS/riscv64/\* \$CURDIR/build/$}m,
|
||||
|
||||
my $buildrpms = slurp_repo_file('buildrpms.pl');
|
||||
like( $buildrpms, qr/forcearch/, 'buildrpms.pl documents the forcearch mock configuration for riscv64 builds' );
|
||||
unlike(
|
||||
$buildrpms,
|
||||
qr/^use XCAT::BuildUtils\b/m,
|
||||
'the dependency bootstrap does not treat the repository build utility as an RPM dependency'
|
||||
);
|
||||
like(
|
||||
$buildrpms,
|
||||
qr{require "\$Bin/build-utils/lib/XCAT/BuildUtils\.pm";},
|
||||
'buildrpms loads the repository build utility by path at runtime'
|
||||
);
|
||||
|
||||
# buildrpms.pl derives the rpm architecture from the mock target name; a suffixed
|
||||
# site config (the riscv64 forcearch one) must still resolve to riscv64.
|
||||
my ($targetarch_sub) = $buildrpms =~ m{^(sub targetarch_from_target \{.*?^\})}ms;
|
||||
ok( $targetarch_sub, 'targetarch_from_target was located in buildrpms.pl' )
|
||||
or BAIL_OUT('buildrpms.pl no longer matches the expected targetarch_from_target shape');
|
||||
{
|
||||
package Test::BuildTarget;
|
||||
our $ARCH = 'x86_64';
|
||||
eval $targetarch_sub; ## no critic (BuiltinFunctions::ProhibitStringyEval)
|
||||
die "Unable to evaluate targetarch_from_target: $@" if $@;
|
||||
}
|
||||
is( Test::BuildTarget::targetarch_from_target('rocky-10-riscv64-xcat'), 'riscv64', 'a suffixed riscv64 forcearch target resolves to riscv64' );
|
||||
is( Test::BuildTarget::targetarch_from_target('rocky-10-riscv64'), 'riscv64', 'the stock riscv64 target resolves to riscv64' );
|
||||
is( Test::BuildTarget::targetarch_from_target('alma+epel-10-ppc64le'), 'ppc64le', 'the ppc64le target still resolves to ppc64le' );
|
||||
is( Test::BuildTarget::targetarch_from_target('alma+epel-10-x86_64'), 'x86_64', 'the x86_64 target still resolves to x86_64' );
|
||||
is( Test::BuildTarget::targetarch_from_target('opensuse-leap-15.6-x86_64'), 'x86_64', 'a dashed distro name still resolves its arch' );
|
||||
is( Test::BuildTarget::targetarch_from_target('custom-target-foo'), 'foo', 'a target without an architecture token keeps the last part' );
|
||||
is( Test::BuildTarget::targetarch_from_target(undef), 'x86_64', 'no target means the host architecture' );
|
||||
# buildrpms.pl derives the rpm architecture from the mock target name through
|
||||
# the loadable build utility, so exercise the implementation directly.
|
||||
is( targetarch_from_target('rocky-10-riscv64-xcat', 'x86_64'), 'riscv64', 'a suffixed riscv64 forcearch target resolves to riscv64' );
|
||||
is( targetarch_from_target('rocky-10-riscv64', 'x86_64'), 'riscv64', 'the stock riscv64 target resolves to riscv64' );
|
||||
is( targetarch_from_target('alma+epel-10-ppc64le', 'x86_64'), 'ppc64le', 'the ppc64le target still resolves to ppc64le' );
|
||||
is( targetarch_from_target('alma+epel-10-x86_64', 'x86_64'), 'x86_64', 'the x86_64 target still resolves to x86_64' );
|
||||
is( targetarch_from_target('opensuse-leap-15.6-x86_64', 'x86_64'), 'x86_64', 'a dashed distro name still resolves its arch' );
|
||||
is( targetarch_from_target('custom-target-foo', 'x86_64'), 'foo', 'a target without an architecture token keeps the last part' );
|
||||
is( targetarch_from_target(undef, 'x86_64'), 'x86_64', 'no target means the host architecture' );
|
||||
|
||||
done_testing();
|
||||
|
||||
Reference in New Issue
Block a user