public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Hui Min Mina Chou <minachou@andestech.com>
Cc: tim609@andestech.com, cynthia@andestech.com, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] waitid10: Set the core dump file location to temporary directory
Date: Thu, 28 Mar 2024 18:22:48 +0100	[thread overview]
Message-ID: <ZgWnaDxy2JWU-gMB@yuki> (raw)
In-Reply-To: <20240328084000.320291-1-minachou@andestech.com>

Hi!
> Reference to madvise08, set the core dump file location to
> temporary directory, and restore default value after testing.
> 
>  # ./waitid10
>  tst_buffers.c:56: TINFO: Test is using guarded buffers
>  tst_test.c:1709: TINFO: LTP version: 20240129-45-g69537563d16a
>  tst_test.c:1593: TINFO: Timeout per run is 0h 05m 00s
>  waitid10.c:60: TINFO: Temporary core pattern is '/tmp/LTP_waiTF0QR3/core'
>  waitid10.c:73: TINFO: Raising RLIMIT_CORE rlim_cur=0 -> 0
>  waitid10.c:38: TPASS: waitid(P_ALL, 0, infop, WEXITED) passed
>  waitid10.c:39: TPASS: infop->si_pid == pidchild (304)
>  waitid10.c:40: TPASS: infop->si_status == SIGFPE (8)
>  waitid10.c:41: TPASS: infop->si_signo == SIGCHLD (17)
>  waitid10.c:44: TPASS: infop->si_code == CLD_DUMPED (3)

This description is missing the main point, that is why is this change
needed.

> Signed-off-by: Hui Min Mina Chou <minachou@andestech.com>
> ---
>  testcases/kernel/syscalls/waitid/waitid10.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/syscalls/waitid/waitid10.c b/testcases/kernel/syscalls/waitid/waitid10.c
> index e55e88c2325e..3e48f52d0ea8 100644
> --- a/testcases/kernel/syscalls/waitid/waitid10.c
> +++ b/testcases/kernel/syscalls/waitid/waitid10.c
> @@ -16,6 +16,8 @@
>  #include <sys/prctl.h>
>  #include "tst_test.h"
>  
> +#define CORE_PATTERN "/proc/sys/kernel/core_pattern"
> +
>  static siginfo_t *infop;
>  static int core_dumps = 1;
>  
> @@ -48,9 +50,16 @@ static void setup(void)
>  {
>  	struct rlimit rlim;
>  	char c;
> +	char cwd[1024];
> +	char tmpcpattern[1048];
>  
>  	SAFE_GETRLIMIT(RLIMIT_CORE, &rlim);
> -	SAFE_FILE_SCANF("/proc/sys/kernel/core_pattern", "%c", &c);
> +
> +	SAFE_GETCWD(cwd, sizeof(cwd));
> +	snprintf(tmpcpattern, sizeof(tmpcpattern), "%s/core", cwd);
> +	tst_res(TINFO, "Temporary core pattern is '%s'", tmpcpattern);
> +	SAFE_FILE_PRINTF(CORE_PATTERN, "%s", tmpcpattern);
> +	SAFE_FILE_SCANF(CORE_PATTERN, "%c", &c);

Also why has to be the pattern absolute path?

If this is really needed we can as well do:

	.needs_tmpdir = 1,
	.save_restore = (const struct tst_path_val[]) {
		{CORE_PATTERN, "./core", TST_SR_TCONF},
		{}
	},

And be done with it.

-- 
Cyril Hrubis
chrubis@suse.cz

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

  reply	other threads:[~2024-03-28 17:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28  8:40 [LTP] [PATCH] waitid10: Set the core dump file location to temporary directory Hui Min Mina Chou via ltp
2024-03-28 17:22 ` Cyril Hrubis [this message]
2024-04-03  3:35   ` Mina Chou 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=ZgWnaDxy2JWU-gMB@yuki \
    --to=chrubis@suse.cz \
    --cc=cynthia@andestech.com \
    --cc=ltp@lists.linux.it \
    --cc=minachou@andestech.com \
    --cc=tim609@andestech.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