From: Michael Ellerman <mpe@ellerman.id.au>
To: Sam Bobroff <sam.bobroff@au1.ibm.com>
Cc: mikey@neuling.org, matt@ozlabs.org, azanella@linux.vnet.ibm.com,
linuxppc-dev@lists.ozlabs.org,
Anshuman Khandual <khandual@linux.vnet.ibm.com>
Subject: Re: [PATCH 3/3] selftests/powerpc: Add transactional syscall test
Date: Tue, 24 Mar 2015 13:02:48 +1100 [thread overview]
Message-ID: <1427162568.28572.2.camel@ellerman.id.au> (raw)
In-Reply-To: <5510C352.9060302@au1.ibm.com>
On Tue, 2015-03-24 at 12:52 +1100, Sam Bobroff wrote:
> On 20/03/15 20:25, Anshuman Khandual wrote:
> > On 03/19/2015 10:13 AM, Sam Bobroff wrote:
> >> Check that a syscall made during an active transaction will fail with
> >> the correct failure code and that one made during a suspended
> >> transaction will succeed.
> >>
> >> Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
> >
> > The test works.
>
> Great :-)
>
> >> +
> >> +int tm_syscall(void)
> >> +{
> >> + SKIP_IF(!((long)get_auxv_entry(AT_HWCAP2) & PPC_FEATURE2_HTM));
> >> + setbuf(stdout, 0);
> >> + FAIL_IF(!t_active_getppid_test());
> >> + printf("%d active transactions correctly aborted.\n", TM_TEST_RUNS);
> >> + FAIL_IF(!t_suspended_getppid_test());
> >> + printf("%d suspended transactions succeeded.\n", TM_TEST_RUNS);
> >> + return 0;
> >> +}
> >> +
> >> +int main(void)
> >> +{
> >> + return test_harness(tm_syscall, "tm_syscall");
> >> +}
> >> +
> >
> > There is an extra blank line at the end of this file. Interchanging return
> > codes of 0 and 1 for various functions make it very confusing along with
> > negative FAIL_IF checks in the primary test function. Control flow structures
> > like these can use some in-code documentation for readability.
> >
> > + for (i = 0; i < TM_RETRIES; i++) {
> > + if (__builtin_tbegin(0)) {
> > + getppid();
> > + __builtin_tend(0);
> > + return 1;
> > + }
> > + if (t_failure_persistent())
> > + return 0;
> >
> > or
> >
> > + if (__builtin_tbegin(0)) {
> > + __builtin_tsuspend();
> > + getppid();
> > + __builtin_tresume();
> > + __builtin_tend(0);
> > + return 1;
> > + }
> > + if (t_failure_persistent())
> > + return 0;
> >
>
> Good points. I'll remove the blank line and comment the code.
>
> I'm not sure I can do any better with the FAIL_IF() macro: I wanted it
> to read "fail if the test failed", but I can see what you mean about a
> double negative. Maybe it would be better to introduce a different
> macro, more like a standard assert: TEST(XXX) which fails if XXX is
> false. However, I think "TEST" would be too generic a name and I'm not
> should what would be better. Any comments/suggestions?
FAIL_IF() is designed for things that return 0 for OK and !0 for failure. Like
most things in C.
So I think it would be improved if you inverted your return codes in your test
routines.
Even better to return ESOMETHING in the error cases, and zero otherwise.
cheers
next prev parent reply other threads:[~2015-03-24 2:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-19 4:43 [PATCH 0/3] powerpc/tm: Abort syscalls in active transactions Sam Bobroff
2015-03-19 4:43 ` [PATCH 1/3] " Sam Bobroff
2015-03-19 5:01 ` Michael Neuling
2015-03-20 9:04 ` Anshuman Khandual
2015-03-24 2:04 ` Michael Ellerman
2015-03-24 4:26 ` Anshuman Khandual
2015-03-24 13:02 ` Michael Ellerman
2015-03-19 4:43 ` [PATCH 2/3] selftests/powerpc: Move get_auxv_entry() to harness.c Sam Bobroff
2015-03-19 4:43 ` [PATCH 3/3] selftests/powerpc: Add transactional syscall test Sam Bobroff
2015-03-20 9:25 ` Anshuman Khandual
2015-03-24 1:52 ` Sam Bobroff
2015-03-24 2:02 ` Michael Ellerman [this message]
2015-03-30 0:06 ` Sam Bobroff
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=1427162568.28572.2.camel@ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=azanella@linux.vnet.ibm.com \
--cc=khandual@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=matt@ozlabs.org \
--cc=mikey@neuling.org \
--cc=sam.bobroff@au1.ibm.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;
as well as URLs for NNTP newsgroup(s).