Re: [PATCH for_v23 10/16] selftests/x86/sgx: Handle setup failures via test assertions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 15, 2019 at 01:25:55PM +0300, Jarkko Sakkinen wrote:
> On Tue, Oct 15, 2019 at 01:24:08PM +0300, Jarkko Sakkinen wrote:
> > On Tue, Oct 15, 2019 at 01:16:35PM +0300, Jarkko Sakkinen wrote:
> > > On Mon, Oct 07, 2019 at 09:46:07PM -0700, Sean Christopherson wrote:
> > > > Use the recently added assertion framework to report errors and exit
> > > > instead of propagating the error back up the stack.  Using assertions
> > > > reduces code and provides more detailed error messages, and has no
> > > > downsides as all errors lead to exit(1) anyways, i.e. an assertion
> > > > isn't blocking forward progress.
> > > > 
> > > > Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
> > > 
> > > I'm also dropping all of this. Was too hazy with it because of rush last
> > > week.
> > > 
> > > You shoud use EXCEPT_* macros instead of your home baked ones:
> > > 
> > > https://www.kernel.org/doc/html/v4.15/dev-tools/kselftest.html
> > > 
> > > I don't know what you are talking about in this commit message.
> > > "Recently added" tells me absolutely nothing. All I see that you
> > > are adding your own ad hoc crap.
> > 
> > E.g.
> > 
> > 1. WTH the new thing is.
> > 2. Why is it overriding the macros already defined for kselftest
> >    (see the documentation).
> > 3. Before vDSO commits please provide a patch set that does the
> >    migration with clear explanation what is going on.
> 
> See kselftest_harness.h.

I spent a bit of time looking at kselftest_harness.h.  It's simply not
designed to handle testing things like SGX and KVM where the nature of the
thing being tested requires a substantial amount of setup, or where a
non-trivial amount of work is done in a callback, e.g. the guest in KVM
and the vDSO callback in SGX.

And IMO "designed" is a strong word.  The macros are just someone else's
ad hoc code that got hoisted into the top-level selftests directory.

  commit 0b40808a10842131742b1646a465b877a277168a
  Author: Mickaël Salaün <mic@xxxxxxxxxxx>
  Date:   Fri May 26 20:43:56 2017 +0200

    selftests: Make test_harness.h more generally available

    The seccomp/test_harness.h file contains useful helpers to build tests.
    Moving it to the selftest directory should benefit to other test
    components.

    Keep seccomp maintainers for this file.

It's gained two non-seccomp users in the 2+ years since being hoisted, so
it's not exactly a kernel-wide standard.

  seccomp/seccomp_bpf.c:TEST_HARNESS_MAIN
  uevent/uevent_filtering.c:TEST_HARNESS_MAIN
  net/tls.c:TEST_HARNESS_MAIN

The SGX selftest can be massaged/butchered to work with kselftest_harness,
but the error messages are still unhelpful and the resulting code is a
mess.

What I do think makes sense is to use the ksft_test_* helpers that are
provided by kselftest.h.  I'd still like to add ASSERT_* macros to cut
down on the amount of boilerplate code, but the result should be much less
ad hoc than this version.



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux