Skip to contentSkip to conversation

waitid10: Set the core dump file location to temporary directory

PATCH Superseded Hui Min Mina Chou via ltp 2 participants 3 messages Mar 28, 2024 – Apr 3, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 waitid10: Set the core dump file location to temporary directory

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)
---
 testcases/kernel/syscalls/waitid/waitid10.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/waitid/waitid10.c +15 -1
index e55e88c2325e..3e48f52d0ea8 100644
@@ -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);
 
 	if (rlim.rlim_cur)
 		return;
@@ -76,4 +85,9 @@ static struct tst_test test = {
 		{&infop, .size = sizeof(*infop)},
 		{},
 	},
+	.needs_tmpdir = 1,
+	.save_restore = (const struct tst_path_val[]) {
+		{CORE_PATTERN, NULL, TST_SR_TCONF},
+		{}
+	},
 };
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi!

Quoted 14 lines

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.

Quoted 23 lines
---
 testcases/kernel/syscalls/waitid/waitid10.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/waitid/waitid10.c +3 -0
index e55e88c2325e..3e48f52d0ea8 100644
@@ -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];

testcases/kernel/syscalls/waitid/waitid10.c static void setup(void) · line 62

Quoted 10 lines
testcases/kernel/syscalls/waitid/waitid10.c +7 -1
+	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.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
Quoted 64 lines · Cyril Hrubis

Hi!

Quoted 14 lines

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.

Quoted 23 lines
---
 testcases/kernel/syscalls/waitid/waitid10.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/waitid/waitid10.c +3 -0
index e55e88c2325e..3e48f52d0ea8 100644
@@ -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];

testcases/kernel/syscalls/waitid/waitid10.c static void setup(void) · line 62

Quoted 10 lines
testcases/kernel/syscalls/waitid/waitid10.c +7 -1
+     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},
                {}
        },
Quoted 4 lines

And be done with it.

--
Cyril Hrubis

Hi Cyril,

Thank you for your suggestions. I'll submit another patch with more explanations.

Thanks,
Mina

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp