From 73b0f8fc0a4c4cf2f314877a23c85b181758c115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Tue, 13 Oct 2026 23:03:39 -0300 Subject: [PATCH] test(imgport): cover the bundle file check of an import Import bundles that lack the kernel, an extra file or a kit, and check that each is reported and changes nothing. --- xCAT-test/unit/imgport_rootimg_checksum.t | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/xCAT-test/unit/imgport_rootimg_checksum.t b/xCAT-test/unit/imgport_rootimg_checksum.t index dece63cd4..23d863f8e 100644 --- a/xCAT-test/unit/imgport_rootimg_checksum.t +++ b/xCAT-test/unit/imgport_rootimg_checksum.t @@ -81,7 +81,7 @@ sub import_image { rootimg => "$dest/$archive_name", kernel => "$dest/kernel", ramdisk => "$dest/initrd-stateless.gz", - (map { ($_ => $manifest{$_} =~ s/DEST/$dest/r) } keys %manifest), + (map { ($_ => ref($manifest{$_}) ? $manifest{$_} : $manifest{$_} =~ s/DEST/$dest/r) } keys %manifest), (defined $checksum ? (linuximage => { rootimgchecksum => $checksum }) : ()), osimage => { imagename => $name, osvers => 'rhels9.6', osarch => 'x86_64', profile => 'compute', provmethod => 'netboot' }, }; @@ -191,4 +191,19 @@ for my $nodes (qw(psnode undefined-node)) { is(definition($dest), 'rhels9.5', 'the image definition stays for an undefined node'); } +for my $case ([ kernel => 'kernel' ], [ 'extra/missing.conf' => extra => { src => '/etc/missing.conf', dest => "$fixture/extra" } ], + [ missingkit => kit => { missingkit => { kitname => 'missingkit', kitdir => "$fixture/kits/missingkit" } } ]) +{ + # The bundle lacks a file that its manifest names. + my ($lacks, $key, $value) = @$case; + my ($placed, $errors, $dest, $archive) = import_image('rootimg.cpio.gz', sub { + unlink("$fixture/bundle-$sequence/kernel") or die $! if $key eq 'kernel'; + }, (defined $value ? ($key => $value) : ())); + ok(!$placed, "an import fails when the bundle lacks $lacks"); + like($errors, qr/The image bundle lacks \Q$lacks\E\./, "the missing $lacks is reported"); + is(read_binary($archive), $published, "the published image stays when the bundle lacks $lacks"); + is(-e "$dest/kernel" ? read_binary("$dest/kernel") : undef, "published kernel\n", "the published kernel stays when the bundle lacks $lacks"); + is(definition($dest), 'rhels9.5', "the image definition stays when the bundle lacks $lacks"); +} + done_testing();