2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-04 20:17:55 +00:00

test(genesis): cover stale initramfs selection

Signed-off-by: Vinícius Ferrão <2031761+viniciusferrao@users.noreply.github.com>
This commit is contained in:
Vinícius Ferrão
2026-08-25 00:14:52 -03:00
parent 72a0cc9b58
commit 200302ca03
2 changed files with 67 additions and 0 deletions
+4
View File
@@ -106,6 +106,8 @@ my $tmpdir = tempdir(CLEANUP => 1);
my $export = "$tmpdir/export";
my $tftpdir = "$tmpdir/tftpboot";
prepare_export($export, 'new kernel', 'new initramfs');
make_path("$tftpdir/xcat");
write_file("$tftpdir/xcat/genesis.fs.x86_64.lzma", 'old initramfs');
ok(
xCAT_plugin::mknb::_prebuilt_genesis_requested($export),
@@ -124,6 +126,8 @@ my ($published_kernel, $published_initramfs) =
published_files($tftpdir, 'x86_64');
is(read_file($published_kernel), 'new kernel', 'the kernel is published');
is(read_file($published_initramfs), 'new initramfs', 'the initramfs is published');
ok(!-e "$tftpdir/xcat/genesis.fs.x86_64.lzma",
'installing an export removes the obsolete legacy initramfs');
is(
read_file("$tftpdir/xcat/genesis.exact-arch.x86_64"),
export_manifest('x86_64'),
+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/env perl
use strict;
use warnings;
use File::Path qw(make_path);
use File::Temp qw(tempdir);
use FindBin;
use Test::More;
BEGIN {
$ENV{XCATROOT} = "$FindBin::Bin/../../xCAT-server";
}
use lib "$FindBin::Bin/../../perl-xCAT";
use lib "$FindBin::Bin/../../xCAT-server/lib/perl";
use lib "$FindBin::Bin/../../xCAT-server/lib/xcat/plugins";
require sles;
sub write_file {
my ($path) = @_;
open(my $fh, '>', $path) or die "open $path: $!";
print {$fh} "test\n";
close($fh) or die "close $path: $!";
}
my $tftp = tempdir(CLEANUP => 1);
make_path("$tftp/xcat");
my $kernel = "$tftp/xcat/genesis.kernel.x86_64";
my $lzma = "$tftp/xcat/genesis.fs.x86_64.lzma";
my $gzip = "$tftp/xcat/genesis.fs.x86_64.gz";
write_file($_) for ($kernel, $lzma);
select(undef, undef, undef, 1.1);
write_file($gzip);
my ($selected_kernel, $selected_initrd) =
xCAT_plugin::sles::_find_genesis_boot_files($tftp, 'x86_64');
is($selected_kernel, 'genesis.kernel.x86_64',
'SLES selects the matching Genesis kernel');
is($selected_initrd, 'genesis.fs.x86_64.gz',
'SLES selects the newer gzip initramfs');
select(undef, undef, undef, 1.1);
write_file($lzma);
($selected_kernel, $selected_initrd) =
xCAT_plugin::sles::_find_genesis_boot_files($tftp, 'x86_64');
is($selected_initrd, 'genesis.fs.x86_64.lzma',
'SLES keeps a newer legacy initramfs usable');
unlink($gzip);
($selected_kernel, $selected_initrd) =
xCAT_plugin::sles::_find_genesis_boot_files($tftp, 'x86_64');
is($selected_initrd, 'genesis.fs.x86_64.lzma',
'SLES accepts the legacy initramfs by itself');
unlink($lzma);
($selected_kernel, $selected_initrd) =
xCAT_plugin::sles::_find_genesis_boot_files($tftp, 'x86_64');
is($selected_kernel, undef, 'a missing initramfs yields no partial boot selection');
is($selected_initrd, undef, 'a missing initramfs leaves both paths undefined');
done_testing();