From: Li Wang <li.wang@linux.dev>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v6 2/2] coredump02: Verify ELF structure and notes
Date: Fri, 4 Sep 2026 17:18:21 +0800 [thread overview]
Message-ID: <apqM3bxh26RrnN3g@linux.dev> (raw)
In-Reply-To: <20260904-coredump-v6-2-b8e3947cc646@suse.com>
Hi Andrea,
Overall the test methodology looks good, with just a few minor
code cleanup points below.
> +static void set_pattern(const char *fmt, ...)
> +{
> + char pattern[PATTERN_MAX];
> + char readback[PATTERN_MAX];
> + va_list va;
> + int len;
> +
> + va_start(va, fmt);
> + len = vsnprintf(pattern, sizeof(pattern), fmt, va);
> + va_end(va);
> +
> + if (len >= PATTERN_MAX)
> + tst_brk(TCONF, "core_pattern does not fit into %i bytes", PATTERN_MAX - 1);
> +
> + SAFE_FILE_PRINTF(PATH_KERN_CORE_PATTERN, "%s", pattern);
> + SAFE_FILE_LINES_SCANF(PATH_KERN_CORE_PATTERN, "%127[^\n]", readback);
> +
> + if (strcmp(pattern, readback))
> + tst_brk(TBROK, "core_pattern readback mismatch: wrote '%s', read '%s'",
> + pattern, readback);
> +
> + tst_res(TINFO, "core_pattern is '%s'", pattern);
> +}
> +
> +static pid_t crash_child(void)
> +{
> + int status;
> + pid_t pid;
> +
> + pid = SAFE_FORK();
> + if (!pid)
> + abort();
> +
> + SAFE_WAITPID(pid, &status, 0);
> +
> + if (!WIFSIGNALED(status) || !WCOREDUMP(status))
> + tst_brk(TFAIL, "Child did not dump core");
> +
> + return pid;
> +}
Splitting the core file parsing into a separate test is fine.
For the duplicated code, there are two approaches - I'm okay
with either.
1. create a seperate coredump_common.h
#cat coredump_common.h
...
#ifndef COREDUMP_COMMON_H
#define COREDUMP_COMMON_H
#include <elf.h>
#include <sys/wait.h>
#include "tst_test.h"
#include "lapi/prctl.h"
#define PATTERN_MAX 128
static char cwd[PATH_MAX];
static void set_pattern(const char *fmt, ...)
{
// ...
}
static pid_t crash_child(void)
{
// ...
}
static void coredump_setup(void)
{
struct rlimit rl = {RLIM_INFINITY, RLIM_INFINITY};
SAFE_SETRLIMIT(RLIMIT_CORE, &rl);
SAFE_PRCTL(PR_SET_DUMPABLE, 1, 0, 0, 0);
SAFE_GETCWD(cwd, sizeof(cwd));
}
#endif /* COREDUMP_COMMON_H */
2. Merge coredump02 method into coredump01 with use tcnt=3.
static void run(unsigned int n)
{
switch (n) {
case 0:
verify_file_pattern_specifiers();
break;
case 1:
verify_file_pattern_content();
break;
case 2:
verify_pipe_pattern();
break;
}
}
static struct tst_test test = {
.test = run,
.tcnt = 3,
// ...
};
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-09-04 9:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 7:15 [LTP] [PATCH v6 0/2] coredump testing suite Andrea Cervesato
2026-09-04 7:15 ` [LTP] [PATCH v6 1/2] coredump01: New core_pattern specifiers test Andrea Cervesato
2026-09-04 7:52 ` [LTP] " linuxtestproject.agent
2026-09-04 7:15 ` [LTP] [PATCH v6 2/2] coredump02: Verify ELF structure and notes Andrea Cervesato
2026-09-04 9:18 ` Li Wang [this message]
2026-09-04 10:49 ` 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=apqM3bxh26RrnN3g@linux.dev \
--to=li.wang@linux.dev \
--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