Signed-off-by: Thomas Lamprecht <t.lampre...@proxmox.com>
---
 .../minimal-defaults-to-new-machine.conf      |  5 ++++
 test/run_config2command_tests.pl              | 25 ++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 test/cfg2cmd/minimal-defaults-to-new-machine.conf

diff --git a/test/cfg2cmd/minimal-defaults-to-new-machine.conf 
b/test/cfg2cmd/minimal-defaults-to-new-machine.conf
new file mode 100644
index 0000000..5c0486b
--- /dev/null
+++ b/test/cfg2cmd/minimal-defaults-to-new-machine.conf
@@ -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
diff --git a/test/run_config2command_tests.pl b/test/run_config2command_tests.pl
index c75be53..bad6501 100755
--- a/test/run_config2command_tests.pl
+++ b/test/run_config2command_tests.pl
@@ -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/\..*$//;
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to