]> git.proxmox.com Git - qemu-server.git/commitdiff
tests: cfg2cmd: check also warnings
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 21 Aug 2020 08:38:27 +0000 (10:38 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 21 Aug 2020 08:38:27 +0000 (10:38 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
test/cfg2cmd/custom-cpu-model-host-phys-bits.conf
test/cfg2cmd/custom-cpu-model.conf
test/run_config2command_tests.pl

index a770d933580d609a3c5fdb2799945fcf4ab4e033..76abef6450659743f17adfcba204d5d83d7391cb 100644 (file)
@@ -1,4 +1,5 @@
 # TEST: Check if custom CPU models are resolved correctly
+# EXPECT_WARN: warning: CPU flag/setting '-kvm_pv_unhalt' (set by custom CPU model) overwrites '+kvm_pv_unhalt' (set by PVE; to improve Linux guest spinlock performance)
 cores: 3
 cpu: custom-qemu64,phys-bits=host
 name: customcpu
index f1fa6caab2e2994c5f7bfccad34c6191e973ac29..f4df6eb51f154bdd4c5ea8570085250e7cd4213f 100644 (file)
@@ -1,4 +1,5 @@
 # TEST: Check if custom CPU models are resolved correctly
+# EXPECT_WARN: warning: CPU flag/setting '-kvm_pv_unhalt' (set by custom CPU model) overwrites '+kvm_pv_unhalt' (set by PVE; to improve Linux guest spinlock performance)
 cores: 3
 cpu: custom-qemu64,flags=+virt-ssbd
 name: customcpu
index 7a4c0eb2423eb637857aaf9bcc88dcccaf914500..2ea6f83771a4879bca5abeb0d45d1d25d5b441a6 100755 (executable)
@@ -84,6 +84,8 @@ my $current_test; # = {
 #   description => 'Test description', # if available
 #   qemu_version => '2.12',
 #   host_arch => 'HOST_ARCH',
+#   expected_error => 'error message',
+#   expected_warning => 'warning message',
 #   config => { config hash },
 #   expected => [ expected outcome cmd line array ],
 # };
@@ -92,6 +94,7 @@ my $current_test; # = {
 #   TEST: A single line describing the test, gets outputted
 #   QEMU_VERSION: \d+\.\d+(\.\d+)? (defaults to current version)
 #   HOST_ARCH: x86_64 | aarch64 (default to x86_64, to make tests stable)
+#   EXPECT_ERROR: <error message> For negative tests
 # all fields are optional
 sub parse_test($) {
     my ($config_fn) = @_;
@@ -120,6 +123,8 @@ sub parse_test($) {
            $current_test->{host_arch} = "$1";
        } elsif ($line =~ /^EXPECT_ERROR:\s*(.*)\s*$/) {
            $current_test->{expect_error} = "$1";
+       } elsif ($line =~ /^EXPECT_WARN(?:ING)?:\s*(.*)\s*$/) {
+           $current_test->{expect_warning} = "$1";
        }
     }
 
@@ -306,6 +311,24 @@ sub diff($$) {
     die "files differ:\n$diff";
 }
 
+$SIG{__WARN__} = sub {
+    my $warning = shift;
+    chomp $warning;
+    if (my $warn_expect = $current_test->{expect_warning}) {
+       if ($warn_expect ne $warning) {
+           fail($current_test->{testname});
+           note("warning does not match expected error: '$warning' != '$warn_expect'");
+       } else {
+           note("got expected warning '$warning'");
+           return;
+       }
+    }
+
+    #warn "======= WARN ======\n= ". $_[0] . "===================\n";
+    fail($current_test->{testname});
+    note("got unexpected expected warning '$warning'");
+};
+
 sub do_test($) {
     my ($config_fn) = @_;