From: Thomas Huth <thuth@redhat.com>
To: David Matlack <dmatlack@google.com>,
Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 0/3] Use TAP in some more KVM selftests
Date: Thu, 10 Nov 2022 08:45:11 +0100 [thread overview]
Message-ID: <060d927e-59f0-1e10-06ac-ed323b2a5433@redhat.com> (raw)
In-Reply-To: <Y2mrh7h1jrZSPU5l@google.com>
On 08/11/2022 02.06, David Matlack wrote:
> On Fri, Oct 14, 2022 at 09:03:59PM +0000, Sean Christopherson wrote:
>> On Tue, Oct 04, 2022, Thomas Huth wrote:
>>> Many KVM selftests are completely silent. This has the disadvantage
>>> for the users that they do not know what's going on here. For example,
>>> some time ago, a tester asked me how to know whether a certain new
>>> sub-test has been added to one of the s390x test binaries or not (which
>>> he didn't compile on his own), which is hard to judge when there is no
>>> output. So I finally went ahead and implemented TAP output in the
>>> s390x-specific tests some months ago.
>>>
>>> Now I wonder whether that could be a good strategy for the x86 and
>>> generic tests, too?
>>
>> Taking Andrew's thoughts a step further, I'm in favor of adding TAP output, but
>> only if we implement it in such a way that it reduces the burden on writing new
>> tests. I _really_ like that sync_regs_test's subtests are split into consumable
>> chunks, but I worry that the amount of boilerplate needed will deter test writes
>> and increase the maintenance cost.
>>
>> And my experience with KVM-unit-tests is that letting test writers specify strings
>> for test names is a bad idea, e.g. using an arbitrary string creates a disconnect
>> between what the user sees and what code is running, and makes it unnecessarily
>> difficult to connect a failure back to code. And if we ever support running
>> specific testcases by name (I'm still not sure this is a net positive), arbitrary
>> strings get really annoying because inevitably an arbitrary string will contain
>> characters that need to be escaped in the shell.
>>
>> Adding a macro or three to let tests define and run testscases with minimal effort
>> would more or less eliminate the boilerplate. And in theory providing semi-rigid
>> macros would help force simple tests to conform to standard patterns, which should
>> reduce the cost of someone new understanding the test, and would likely let us do
>> more automagic things in the future.
>>
>> E.g. something like this in the test:
>>
>> KVM_RUN_TESTCASES(vcpu,
>> test_clear_kvm_dirty_regs_bits,
>> test_set_invalid,
>> test_req_and_verify_all_valid_regs,
>> test_set_and_verify_various_reg_values,
>> test_clear_kvm_dirty_regs_bits,
>> );
>
> There is an existing framework in
> tools/testing/selftests/kselftest_harness.h that provides macros for
> setting up and running tests cases. I converted sync_regs_test to use it
> below as an example [1].
>
> The harness runs each subtest in a child process, so sharing a VM/VCPU
> across test cases is not possible. This means setting up and tearing
> down a VM for every test case, but the harness makes this pretty easy
> with FIXTURE_{SETUP,TEARDOWN}(). With this harness, we can keep using
> TEST_ASSERT() as-is, and still run all test cases even if one fails.
> Plus no need for the hard-coded ksft_*() calls in main().
Hi!
Sorry for not getting back to this earlier - I'm pretty much busy with other
stuff right now. But your suggestion looks really cool, I like it - so if
you've got some spare time to work on the conversion, please go ahead (I
won't have much time to work on this in the next weeks, I think)!
Thomas
prev parent reply other threads:[~2022-11-10 7:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-04 9:31 [RFC PATCH 0/3] Use TAP in some more KVM selftests Thomas Huth
2022-10-04 9:31 ` [PATCH 1/3] KVM: selftests: Use TAP interface in the kvm_binary_stats_test Thomas Huth
2022-10-05 8:33 ` Andrew Jones
2022-10-07 1:22 ` Sean Christopherson
2022-10-04 9:31 ` [PATCH 2/3] KVM: selftests: x86: Use TAP interface in the sync_regs test Thomas Huth
2022-10-04 9:31 ` [PATCH 3/3] KVM: selftests: x86: Use TAP interface in the tsc_msrs_test Thomas Huth
2022-10-14 21:03 ` [RFC PATCH 0/3] Use TAP in some more KVM selftests Sean Christopherson
2022-11-08 1:06 ` David Matlack
2022-11-09 19:22 ` Sean Christopherson
2022-11-10 7:45 ` Thomas Huth [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=060d927e-59f0-1e10-06ac-ed323b2a5433@redhat.com \
--to=thuth@redhat.com \
--cc=dmatlack@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox