5
0
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:
Thomas Lamprecht 2019-12-10 11:07:00 +01:00
parent 38277afcd4
commit a546da0319
2 changed files with 29 additions and 1 deletions

View 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

View File

@ -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/\..*$//;