mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-10-21 15:18:19 +00:00
e9ff86126c
The kvm unit tests loaded xCAT-server/lib/xcat/plugins/kvm.pm with a fake Sys::Virt and monitorctrl in %INC, an XCATROOT redirect, and package variables made public only so that a test could set them. Add xCAT::KVMUtils, a module that loads no xCAT module and no libvirt binding. It holds the guest architecture profile, the CPU, emulator and video model choices, and the disk model, prefix and bus choices, each as a sub that takes its inputs and returns its answer. The three tests call these subs directly and assert that the module loads no other xCAT module. XCAT::Test::KvmPlugin is deleted. A new case covers the video model of an aarch64 guest on an aarch64 hypervisor. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
30 lines
1.3 KiB
Perl
30 lines
1.3 KiB
Perl
#!/usr/bin/env perl
|
|
use strict;
|
|
use warnings;
|
|
|
|
use FindBin;
|
|
use lib "$FindBin::Bin/../../perl-xCAT";
|
|
use Test::More;
|
|
|
|
my %before = %INC;
|
|
require xCAT::KVMUtils;
|
|
my @xcat_loaded = sort grep { m{^xCAT} and !exists $before{$_} } keys %INC;
|
|
is_deeply(\@xcat_loaded, ['xCAT/KVMUtils.pm'], 'xCAT::KVMUtils loads no other xCAT module');
|
|
|
|
# A disk on a libvirt storage pool states the bus of the device name it is given. libvirt
|
|
# reads the same names the same way: hd* is ide, sd* is scsi, vd* is virtio.
|
|
is(xCAT::KVMUtils::pool_disk_bus('hda'), 'ide', 'an hd* disk on a storage pool is ide');
|
|
is(xCAT::KVMUtils::pool_disk_bus('sda'), 'scsi', 'an sd* disk on a storage pool is scsi');
|
|
is(xCAT::KVMUtils::pool_disk_bus('vda'), 'virtio', 'a vd* disk on a storage pool is virtio');
|
|
is(xCAT::KVMUtils::pool_disk_bus('xvda'), undef,
|
|
'a pool disk with any other name states no bus, and libvirt chooses one');
|
|
|
|
# The riscv64 virt machine has no IDE controller, so a riscv64 node depends on its volume
|
|
# name being sd*, and on its optical drive being sd* too.
|
|
my $riscv = xCAT::KVMUtils::guest_arch_profile('riscv64', 'x86_64');
|
|
is(xCAT::KVMUtils::pool_disk_bus('sda'), 'scsi', 'a riscv64 pool disk is scsi, not ide');
|
|
is(xCAT::KVMUtils::cdrom_prefix($riscv, 'scsi'), 'sd',
|
|
'the riscv64 optical drive is named sd*, not hd*');
|
|
|
|
done_testing();
|