public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Avinesh Kumar <akumar@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v4] syscalls/mmap01: Rewrite the test using new LTP API
Date: Tue, 5 Mar 2024 23:00:13 +0100	[thread overview]
Message-ID: <20240305220013.GC44833@pevik> (raw)
In-Reply-To: <20240130122540.13215-1-akumar@suse.de>

HI Avinesh,

> - use SAFE_MSYNC() macro
> - fixed the test for iterations > 1
> - enable test for all filesystems
+1

> Signed-off-by: Avinesh Kumar <akumar@suse.de>
> ---

> Changes v3->v4:
> * Changed the logic to verify that mapped file has not been changed.
> * Enabled all filesystems.


>  testcases/kernel/syscalls/mmap/mmap01.c | 223 +++++++-----------------
>  1 file changed, 61 insertions(+), 162 deletions(-)

> diff --git a/testcases/kernel/syscalls/mmap/mmap01.c b/testcases/kernel/syscalls/mmap/mmap01.c
...
> +static char *addr;
> +static char *dummy;
> +static struct stat stat_buf;
nit: struct stat stat_buf is used just in the setup, it could defined just
there. It can be changed before merge.

> +static const char write_buf[] = "HelloWorld!";

> -int main(int ac, char **av)
> +static void setup(void)
>  {
...
> +	fd = SAFE_OPEN(TEMPFILE, O_RDWR | O_CREAT, 0666);

> -	cleanup();
> -	tst_exit();
> -}
> +	SAFE_WRITE(SAFE_WRITE_ALL, fd, write_buf, strlen(write_buf));
> +	SAFE_LSEEK(fd, 0, SEEK_SET);
> +	SAFE_STAT(TEMPFILE, &stat_buf);

> -static void setup(void)
> -{
> -	struct stat stat_buf;
> -	char Path_name[PATH_MAX];
> -	char write_buf[] = "hello world\n";
> +	file_sz = stat_buf.st_size;
> +	page_sz = getpagesize();

> -	tst_sig(FORK, DEF_HANDLER, cleanup);
> +	dummy = SAFE_MALLOC(page_sz);
> +	memset(dummy, 0, page_sz);
> +}

> -	TEST_PAUSE;
> +static void run(void)
> +{
> +	char buf[20];

> -	tst_tmpdir();
> +	addr = SAFE_MMAP(NULL, page_sz, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0);
...
> +	addr[file_sz] = 'X';
> +	addr[file_sz + 1] = 'Y';
> +	addr[file_sz + 2] = 'Z';
...
> +	SAFE_MSYNC(addr, page_sz, MS_SYNC);
...
> +	SAFE_FILE_SCANF(TEMPFILE, "%s", buf);

> -	page_sz = getpagesize();
> +	if (strcmp(write_buf, buf))
> +		tst_res(TFAIL, "File data has changed");
> +	else
> +		tst_res(TPASS, "mmap() functionality successful");
nit: I would prefer something more descriptive (what mmap() actually did, e.g.
"mapped file has not been changed"), but I guess it's ok to keep it as is.

The rest LGTM.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

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

  reply	other threads:[~2024-03-05 22:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30 12:23 [LTP] [PATCH v4] syscalls/mmap01: Rewrite the test using new LTP API Avinesh Kumar
2024-03-05 22:00 ` Petr Vorel [this message]
2024-03-06 14:55 ` Cyril Hrubis
2024-03-20 10:56   ` Avinesh Kumar
2024-03-20 16:02     ` Petr Vorel

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=20240305220013.GC44833@pevik \
    --to=pvorel@suse.cz \
    --cc=akumar@suse.de \
    --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