mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-26 01:34:05 +00:00
test(xcat-core): the initrd firmware step ignores custom drivers and firmware overrides
ubuntu_genimage_initrd_firmware.t drove the firmware step over a root image that holds every module and every firmware file. It covered neither of the two places genimage reads from beside the root image. The test now puts a driver in the custom directory, with its firmware in the root image, and a firmware override under lib/firmware/updates/<kernel>. Both are red: the step asks modinfo about the module under the root image, where a custom driver is not, and it looks for a firmware name under lib/firmware only, where an override is not. The five assertions that were there stay green. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -54,6 +54,7 @@ case "$*" in
|
||||
*mlx5_core*) echo mellanox/fw-a.mfa2 ;;
|
||||
*bnx2x*) echo bnx2x/bnx2x-e2.fw ;;
|
||||
*e1000e*) echo intel/absent-from-this-image.bin ;;
|
||||
*custom_nic*) echo custom/custom-nic.bin ;;
|
||||
*virtio_net*) : ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
@@ -64,6 +65,8 @@ $ENV{PATH} = "$bin:$ENV{PATH}";
|
||||
|
||||
foreach my $file (
|
||||
'lib/firmware/mellanox/fw-a.mfa2',
|
||||
'lib/firmware/updates/7.0.0/mellanox/fw-a.mfa2',
|
||||
'lib/firmware/custom/custom-nic.bin',
|
||||
'lib/firmware/bnx2x/bnx2x-e2.fw.zst',
|
||||
'lib/firmware/amdgpu/never-asked-for.bin',
|
||||
'lib/firmware/qcom/never-asked-for-either.bin',
|
||||
@@ -82,6 +85,16 @@ foreach my $file (
|
||||
}
|
||||
make_path("$initrd_dir/lib/firmware");
|
||||
|
||||
# A driver the administrator put in the custom directory. genimage takes the module from there
|
||||
# and not from the root image, so that is the file its firmware has to be read from.
|
||||
my $customdir = "$scratch/custom";
|
||||
my $pathtofiles = "$scratch/pathtofiles";
|
||||
make_path("$customdir/lib/modules/7.0.0/kernel/drivers/net");
|
||||
make_path($pathtofiles);
|
||||
open(my $custom, '>', "$customdir/lib/modules/7.0.0/kernel/drivers/net/custom_nic.ko") or die $!;
|
||||
print $custom "content of a custom driver\n";
|
||||
close($custom);
|
||||
|
||||
{
|
||||
package Scratch;
|
||||
use strict;
|
||||
@@ -101,11 +114,15 @@ if (defined $helper) {
|
||||
}
|
||||
|
||||
$Scratch::rootimg_dir = $rootimg;
|
||||
$Scratch::customdir = $customdir;
|
||||
$Scratch::pathtofiles = $pathtofiles;
|
||||
$Scratch::kernelver = '7.0.0';
|
||||
@Scratch::filestoadd = (
|
||||
[ 'lib/modules/7.0.0/kernel/drivers/net/virtio_net.ko', 'lib/virtio_net.ko' ],
|
||||
[ 'lib/modules/7.0.0/kernel/drivers/net/mlx5_core.ko', 'lib/mlx5_core.ko' ],
|
||||
[ 'lib/modules/7.0.0/kernel/drivers/net/bnx2x.ko.zst', 'lib/bnx2x.ko' ],
|
||||
[ 'lib/modules/7.0.0/kernel/drivers/net/e1000e.ko', 'lib/e1000e.ko' ],
|
||||
[ 'lib/modules/7.0.0/kernel/drivers/net/custom_nic.ko', 'lib/custom_nic.ko' ],
|
||||
[ 'bin/busybox', 'bin/busybox' ],
|
||||
);
|
||||
eval "package Scratch;\nno strict 'vars';\n$step\n1" or die $@;
|
||||
@@ -120,5 +137,9 @@ ok(!-e "$initrd_dir/lib/firmware/qcom/never-asked-for-either.bin",
|
||||
'the whole firmware tree does not reach the initrd');
|
||||
ok(!-e "$initrd_dir/lib/firmware/intel/absent-from-this-image.bin",
|
||||
'a firmware name the root image does not have is left out');
|
||||
ok(-e "$initrd_dir/lib/firmware/custom/custom-nic.bin",
|
||||
'the firmware of a driver taken from the custom directory reaches the initrd');
|
||||
ok(-e "$initrd_dir/lib/firmware/updates/7.0.0/mellanox/fw-a.mfa2",
|
||||
'a firmware override under updates/<kernel> reaches the initrd');
|
||||
|
||||
done_testing();
|
||||
|
||||
Reference in New Issue
Block a user