public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
From: Andrew Jones <ajones@ventanamicro.com>
To: "Xu, Haibo1" <haibo1.xu@intel.com>
Cc: "kvm-riscv@lists.infradead.org" <kvm-riscv@lists.infradead.org>,
	 "linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	"anup@brainfault.org" <anup@brainfault.org>,
	 "atishp@atishpatra.org" <atishp@atishpatra.org>,
	"paul.walmsley@sifive.com" <paul.walmsley@sifive.com>,
	 "palmer@dabbelt.com" <palmer@dabbelt.com>,
	"aou@eecs.berkeley.edu" <aou@eecs.berkeley.edu>
Subject: Re: [PATCH] KVM: riscv: selftests: get-reg-list print_reg should never fail
Date: Wed, 20 Sep 2023 17:28:00 +0200	[thread overview]
Message-ID: <20230920-326d0d84a57240dcebca6277@orel> (raw)
In-Reply-To: <BY5PR11MB3909D011A5633AF7496CFFDCB0F9A@BY5PR11MB3909.namprd11.prod.outlook.com>

On Wed, Sep 20, 2023 at 02:59:07PM +0000, Xu, Haibo1 wrote:
> > -----Original Message-----
> > From: Andrew Jones <ajones@ventanamicro.com>
> > Sent: Wednesday, September 20, 2023 10:37 PM
> > To: kvm-riscv@lists.infradead.org; linux-riscv@lists.infradead.org
> > Cc: anup@brainfault.org; atishp@atishpatra.org; Xu, Haibo1
> > <haibo1.xu@intel.com>; paul.walmsley@sifive.com; palmer@dabbelt.com;
> > aou@eecs.berkeley.edu
> > Subject: [PATCH] KVM: riscv: selftests: get-reg-list print_reg should never fail
> > 
> > When outputting the "new" register list we want to print all of the new
> > registers, decoding as much as possible of each of them. Also, we don't want
> > to assert while listing registers with '--list'. We output
> > "/* UNKNOWN */" after each new register (which we were already doing for
> > some), which should be enough.
> > 
> > Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
> > ---
> >  .../selftests/kvm/riscv/get-reg-list.c        | 93 +++++++++----------
> >  1 file changed, 42 insertions(+), 51 deletions(-)
> > 
> > diff --git a/tools/testing/selftests/kvm/riscv/get-reg-list.c
> > b/tools/testing/selftests/kvm/riscv/get-reg-list.c
> > index 85907c86b835..054706538b9e 100644
> > --- a/tools/testing/selftests/kvm/riscv/get-reg-list.c
> > +++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c
> > @@ -112,11 +112,13 @@ void finalize_vcpu(struct kvm_vcpu *vcpu, struct
> > vcpu_reg_list *c)
> >  	}
> >  }
> > 
> > -static const char *config_id_to_str(__u64 id)
> > +static const char *config_id_to_str(const char *prefix, __u64 id)
> >  {
> >  	/* reg_off is the offset into struct kvm_riscv_config */
> >  	__u64 reg_off = id & ~(REG_MASK | KVM_REG_RISCV_CONFIG);
> > 
> > +	assert((id & KVM_REG_RISCV_TYPE_MASK) ==
> > KVM_REG_RISCV_CONFIG);
> > +
> 
> I think we can skip this kind of assert test since the function was reached by:
> 
> switch (id & KVM_REG_RISCV_TYPE_MASK) {
>      case KVM_REG_RISCV_CONFIG:

The assert is to ensure developers don't call it from anywhere else, where
they may not have already confirmed the register type. And, that's why
it's an 'assert' instead of a 'TEST_ASSERT'. It's for developers, not test
results.

Thanks,
drew

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2023-09-20 15:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-20 14:37 [PATCH] KVM: riscv: selftests: get-reg-list print_reg should never fail Andrew Jones
2023-09-20 14:59 ` Xu, Haibo1
2023-09-20 15:28   ` Andrew Jones [this message]
2023-09-20 15:41     ` Xu, Haibo1
2023-10-10  5:59 ` Anup Patel

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=20230920-326d0d84a57240dcebca6277@orel \
    --to=ajones@ventanamicro.com \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atishp@atishpatra.org \
    --cc=haibo1.xu@intel.com \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    /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