From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id BCE54626D5 for ; Fri, 21 Aug 2020 10:40:24 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A869AB009 for ; Fri, 21 Aug 2020 10:39:54 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 01D6DB001 for ; Fri, 21 Aug 2020 10:39:54 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id BB45F4477C for ; Fri, 21 Aug 2020 10:39:53 +0200 (CEST) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Date: Fri, 21 Aug 2020 10:39:40 +0200 Message-Id: <20200821083940.3048576-1-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.081 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] applied: [PATCH qemu-server] tests: cfg2cmd: check also warnings X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Aug 2020 08:40:24 -0000 Signed-off-by: Thomas Lamprecht --- As this would have caught a recent regression from commit 789fe8e8188521d55044d37c055d5d2cabbd5cfd .../custom-cpu-model-host-phys-bits.conf | 1 + test/cfg2cmd/custom-cpu-model.conf | 1 + test/run_config2command_tests.pl | 23 +++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/test/cfg2cmd/custom-cpu-model-host-phys-bits.conf b/test/cfg2cmd/custom-cpu-model-host-phys-bits.conf index a770d93..76abef6 100644 --- a/test/cfg2cmd/custom-cpu-model-host-phys-bits.conf +++ b/test/cfg2cmd/custom-cpu-model-host-phys-bits.conf @@ -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 diff --git a/test/cfg2cmd/custom-cpu-model.conf b/test/cfg2cmd/custom-cpu-model.conf index f1fa6ca..f4df6eb 100644 --- a/test/cfg2cmd/custom-cpu-model.conf +++ b/test/cfg2cmd/custom-cpu-model.conf @@ -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 diff --git a/test/run_config2command_tests.pl b/test/run_config2command_tests.pl index 7a4c0eb..2ea6f83 100755 --- a/test/run_config2command_tests.pl +++ b/test/run_config2command_tests.pl @@ -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: 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) = @_; -- 2.20.1