Linux Test Project
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] Refactoring aiodio_append.c using LTP API
Date: Thu, 2 Dec 2021 21:49:37 +0100	[thread overview]
Message-ID: <YakxYTtUs+tWyLj8@pevik> (raw)
In-Reply-To: <20211201160954.16442-1-andrea.cervesato@suse.com>

Hi Andrea,

...
> +static void run(void)
> +{
> +	char *filename = "file";
You decided to remove file as first parameter.
That's fine ($TMPDIR/aiodio.$$/file2 as parameter used $$ to get unique
directory, but new API uses unique directory anyway), but then you should update
runtest/ltp-aiodio.part4 - remove $TMPDIR/aiodio.$$/file2.
nit: I'd just define that name with preprocessor #define.

> +	int filesize = FILE_SIZE;
> +	int num_children = NUM_CHILDREN;
> +	int status;
>  	int i;
> -	char *filename = argv[1];

> -	printf("Starting aio/dio append test...\n");
> +	*run_child = 1;

>  	for (i = 0; i < num_children; i++) {
nit: I'd use directly NUM_CHILDREN
> -		if ((pid[i] = fork()) == 0) {
> -			/* child */
> -			return read_eof(filename);
> -		} else if (pid[i] < 0) {
> -			/* error */
> -			perror("fork error");
> -			break;
> -		} else {
> -			/* Parent */
> -			continue;
> +		if (!SAFE_FORK()) {
> +			read_eof(filename, filesize);
... and here FILE_SIZE
> +			return;
>  		}
>  	}
...

> +static struct tst_test test = {
> +	.test_all = run,
> +	.setup = setup,
> +	.cleanup = cleanup,
> +	.needs_tmpdir = 1,
> +	.forks_child = 1,
> +};
>  #else
> -int main(void)
> +static void run(void)
>  {
> -	tst_brkm(TCONF, NULL, "test requires libaio and it's development packages");
> +	tst_res(TCONF, "test requires libaio and it's development packages");
>  }
> +
> +static struct tst_test test = {
> +	.test_all = run,
> +};
>  #endif

New API has shorter variant when need to quit due missing dependencies:
TST_TEST_TCONF(), e.g.:

#else
	TST_TEST_TCONF("test requires libaio and it's development packages");
#endif

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2021-12-02 20:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-01 16:09 [LTP] [PATCH v1] Refactoring aiodio_append.c using LTP API Andrea Cervesato via ltp
2021-12-02 20:49 ` Petr Vorel [this message]
2021-12-06 14:49 ` 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=YakxYTtUs+tWyLj8@pevik \
    --to=pvorel@suse.cz \
    --cc=andrea.cervesato@suse.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox