mirror of
git://git.proxmox.com/git/qemu-server.git
synced 2025-01-11 05:17:57 +03:00
cfg2cmd: allow to test for expected error messages
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
38277afcd4
commit
a546da0319
5
test/cfg2cmd/minimal-defaults-to-new-machine.conf
Normal file
5
test/cfg2cmd/minimal-defaults-to-new-machine.conf
Normal file
@ -0,0 +1,5 @@
|
||||
# TEST: newer machine verison than QEMU version installed on node
|
||||
# QEMU_VERSION: 4.1.1
|
||||
# EXPECT_ERROR: Installed QEMU version '4.1.1' is too old to run machine type 'pc-q35-42.9', please upgrade node 'localhost'
|
||||
smbios1: uuid=6cf17dc3-8341-4ecc-aebd-7503f2583fb3
|
||||
machine: pc-q35-42.9
|
@ -117,6 +117,8 @@ sub parse_test($) {
|
||||
$current_test->{qemu_version} = "$1";
|
||||
} elsif ($line =~ /^HOST_ARCH:\s*(.*)\s*$/) {
|
||||
$current_test->{host_arch} = "$1";
|
||||
} elsif ($line =~ /^EXPECT_ERROR:\s*(.*)\s*$/) {
|
||||
$current_test->{expect_error} = "$1";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -280,7 +282,28 @@ sub do_test($) {
|
||||
|
||||
my ($vmid, $storecfg) = $base_env->@{qw(vmid storage_config)};
|
||||
|
||||
my $cmdline = PVE::QemuServer::vm_commandline($storecfg, $vmid);
|
||||
my $cmdline = eval { PVE::QemuServer::vm_commandline($storecfg, $vmid) };
|
||||
my $err = $@;
|
||||
|
||||
if (my $err_expect = $current_test->{expect_error}) {
|
||||
if (!$err) {
|
||||
fail("$testname");
|
||||
note("did NOT get any error, but expected error: $err_expect");
|
||||
return;
|
||||
}
|
||||
chomp $err;
|
||||
if ($err !~ /^\s*$err_expect\s*$/) {
|
||||
fail("$testname");
|
||||
note("error does not match expected error: '$err' !~ '$err_expect'");
|
||||
} else {
|
||||
pass("$testname");
|
||||
}
|
||||
return;
|
||||
} elsif ($err) {
|
||||
fail("$testname");
|
||||
note("got unexpected error: $err");
|
||||
return;
|
||||
}
|
||||
|
||||
# check if QEMU version set correctly and test version_cmp
|
||||
(my $qemu_major = get_test_qemu_version()) =~ s/\..*$//;
|
||||
|
Loading…
Reference in New Issue
Block a user