Linux Test Project
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v3 1/8] Refactor mmap03 test
Date: Thu, 13 Mar 2025 10:58:37 +0100	[thread overview]
Message-ID: <20250313095837.GC135222@pevik> (raw)
In-Reply-To: <20250313-mmap_suite_refactoring-v3-1-eb9172686230@suse.com>

Hi Andrea, Cyril,

...
> +++ b/testcases/kernel/syscalls/mmap/mmap03.c
> -		/*
> -		 * Check whether the mapped memory region
> -		 * has the file contents.
> -		 *
> -		 * with ia64 and PARISC/hppa, this should
> -		 * generate a SIGSEGV which will be caught below.
> -		 *
> -		 */
> -
> -		if (sigsetjmp(env, 1) == 0) {
> -			if (memcmp(dummy, addr, page_sz)) {
> -				tst_resm(TFAIL,
> -					 "mapped memory region "
> -					 "contains invalid data");
> -			} else {
> -				tst_resm(TPASS,
> -					 "mmap() functionality is "
> -					 "correct");
> -			}
> -		}
> -#if defined(__ia64__) || defined(__hppa__) || defined(__mips__)
> -		if (pass) {
> -			tst_resm(TPASS, "Got SIGSEGV as expected");
> -		} else {
> -			tst_resm(TFAIL, "Mapped memory region with NO "
> -				 "access is accessible");
> -		}
...

> +#if defined(__ia64__) || defined(__hppa__) || defined(__mips__)
> +	if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
> +		tst_res(TPASS, "SIGSEGV has been received");

In the previous discussion [1] Cyril noted:

	The fact that memory mapped with PROT_EXEC is readable is an
	implementation detail for an architecture and not guaranteed. So the
	best result is either to expect that the child returns with 0 or dies
	with SIGSEGV, either one is correct behavior.

Therefore we don't need to check this for *any* specific architecture (e.g.
remove #if defined preprocessor wrap. And we should check either for 0 or
SIGSEGV, many tests do this, e.g. fstatfs/fstatfs02.c, clone/clone07.c.

> +	} else {
> +		tst_res(TFAIL, "Mapped memory region with NO "
> +			"access is accessible");
nit: Please no split strings (when they are reasonable long).

Kind regards,
Petr

[1] https://lore.kernel.org/ltp/Z7ykr8it7KmHjWsY@yuki.lan/

...
> +static struct tst_test test = {
> +	.test_all = run,
> +	.setup = setup,
> +	.cleanup = cleanup,
> +	.needs_tmpdir = 1,
> +	.forks_child = 1,
> +};

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

  reply	other threads:[~2025-03-13  9:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-13  9:15 [LTP] [PATCH v3 0/8] Cleanup the mmap testing suite Andrea Cervesato
2025-03-13  9:15 ` [LTP] [PATCH v3 1/8] Refactor mmap03 test Andrea Cervesato
2025-03-13  9:58   ` Petr Vorel [this message]
2025-03-13  9:15 ` [LTP] [PATCH v3 2/8] Refactor mmap10 test Andrea Cervesato
2025-03-13  9:15 ` [LTP] [PATCH v3 3/8] Cleanup mmap12 test Andrea Cervesato
2025-03-13  9:15 ` [LTP] [PATCH v3 4/8] Cleanup mmap17 test Andrea Cervesato
2025-03-13  9:15 ` [LTP] [PATCH v3 5/8] Cleanup mmap18 test Andrea Cervesato
2025-03-13  9:15 ` [LTP] [PATCH v3 6/8] Cleanup mmap19 test Andrea Cervesato
2025-03-13  9:15 ` [LTP] [PATCH v3 7/8] Cleanup mmap20 test Andrea Cervesato
2025-03-13  9:15 ` [LTP] [PATCH v3 8/8] Refactor mmap001 test and move it to mmap21 Andrea Cervesato
2025-03-13  9:22 ` [LTP] [PATCH v3 0/8] Cleanup the mmap testing suite Andrea Cervesato via ltp

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=20250313095837.GC135222@pevik \
    --to=pvorel@suse.cz \
    --cc=andrea.cervesato@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