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:
@@ -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'),
|
||||
|
||||
@@ -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();
|
||||
Reference in New Issue
Block a user