All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/7] io_cancel02: Add io_cancel02 test for libaio
Date: Mon, 21 Jun 2021 11:01:33 +0200	[thread overview]
Message-ID: <YNBVbVGZ5QRJuOkH@yuki> (raw)
In-Reply-To: <YNBQ95gIlM9TTjpA@yuki>

Hi!
> > +#include "config.h"
> > +#include "tst_test.h"
> > +
> > +#ifdef HAVE_LIBAIO
> > +#define EXP_RET (-EFAULT)
> > +
> > +#include <libaio.h>
> > +
> > +static void run(void)
> > +{
> > +	io_context_t ctx;
> > +
> > +	memset(&ctx, 0, sizeof(ctx));
> > +	TEST(io_cancel(ctx, NULL, NULL));
> > +
> > +	if (TST_RET == 0)
> > +		tst_res(TFAIL, "call succeeded unexpectedly");

It's usually easier to read to use return instead of else if branches:

	if (TST_RET == 0) {
		tst_res(TFAIL, "io_cancel() succeeded unexpectedly");
		return;
	}

Also you should never use strerror() in tests, we do have tst_strerrno()
for that purpose, also if you have checked that TST_RET == EFAULT there
is no point in converting the value into a string and you can do:


	if (TST_RET == -EFAULT) {
		tst_res(TPASS, "io_cancel() failed with EFAULT");
		return;
	}


Followed by:

	tst_res(TFAIL, "io_cancel() failed unexpectedly %s (%d) expected EFAULT",
	        tst_strerrno(-TST_RET), -TST_RET);

> > +	else if (TST_RET == EXP_RET)
> > +		tst_res(TPASS, "io_cancel(ctx, NULL, NULL) returns %ld : %s",
> > +			TST_RET, strerror(-TST_RET));
> > +	else
> > +		tst_res(TFAIL, "io_cancel(ctx, NULL, NULL) returns %ld : %s, expected %d : %s",
> > +			TST_RET, strerror(-TST_RET), EXP_RET, strerror(-EXP_RET));
> 
> Please use TST_EXP_FAIL() instead.

Looking again, these calls do return -error on failure, we can't use
TST_EXP_FAIL() here.

But even then there are a couple of problems to fix (commented above).


-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2021-06-21  9:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-18  9:42 [LTP] [PATCH 0/7] syscalls/aio: Add tests for libaio and docparse formatting Xie Ziyao
2021-06-18  9:42 ` [LTP] [PATCH 1/7] io_cancel02: Add io_cancel02 test for libaio Xie Ziyao
2021-06-21  8:42   ` Cyril Hrubis
2021-06-21  9:01     ` Cyril Hrubis [this message]
2021-06-18  9:42 ` [LTP] [PATCH 2/7] io_cancel01: Add .needs_kconfigs and more detailed description Xie Ziyao
2021-06-21  8:46   ` Cyril Hrubis
2021-06-18  9:42 ` [LTP] [PATCH 3/7] io_destroy01: Add docparse formatting " Xie Ziyao
2021-06-21  8:52   ` Cyril Hrubis
2021-06-18  9:42 ` [LTP] [PATCH 4/7] io_getevents01: Add .needs_kconfigs " Xie Ziyao
2021-06-21  8:55   ` Cyril Hrubis
2021-06-18  9:42 ` [LTP] [PATCH 5/7] io_getevents02: Add io_getevents02 test for libaio Xie Ziyao
2021-06-21  9:02   ` Cyril Hrubis
2021-06-22  9:18     ` Xie Ziyao
2021-06-18  9:42 ` [LTP] [PATCH 6/7] io_setup: Add docparse formatting and more detailed description Xie Ziyao
2021-06-21 12:58   ` Cyril Hrubis
2021-06-18  9:42 ` [LTP] [PATCH 7/7] io_submit01: " Xie Ziyao
2021-06-21 13:17   ` Cyril Hrubis

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=YNBVbVGZ5QRJuOkH@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.