Linux Test Project
 help / color / mirror / Atom feed
From: Andrea Cervesato via ltp <ltp@lists.linux.it>
To: "Li Wang" <li.wang@linux.dev>
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v5] coredump01: New core_pattern specifiers test
Date: Fri, 04 Sep 2026 06:25:44 +0000	[thread overview]
Message-ID: <6a9a6469.3d30ac2e.110181.4b84@mx.google.com> (raw)
In-Reply-To: <apo-YSqDGDNbrzcc@linux.dev>

Hi Li,

> > +	TST_EXP_PASS(access(dump, F_OK), "core.%%e.%%p.%%s expanded to core.coredump01.%d.%d",
> > +		     pid, SIGABRT);
> 
> Generally this checks is really nice, but it'd be better to
> add more checks for the core dump file?
> 
> e.g. file size > 0, ELF magic valid, and type == ET_CORE.

this is already done, but we can introduce ELF type check (read below).

> 
> FYI:
> 
> +static int verify_core_dump(const char *path, long long expected_size)
> +{
> +       int fd;
> +       struct stat st;
> +       unsigned char magic[SELFMAG];
> +       Elf64_Ehdr ehdr;

Ehdr is not portable on 32 bit systems breaking our testing, so I
wouldn't use it in this case. We need Elf32_Half which is in both
32bit and 64bit.

> +
> +       if (access(path, F_OK) != 0) {
> +               tst_res(TFAIL, "Core dump file %s does not exist", path);
> +               return -1;
> +       }
> +       tst_res(TPASS, "Core dump file %s exists", path);
> +
> +       SAFE_STAT(path, &st);
> +       TST_EXP_EXPR(st.st_size > 0, "core file size = %ld bytes", st.st_size);
> +
> +       if (expected_size > 0 && st.st_size != expected_size) {
> +               tst_res(TFAIL, "Core dump size mismatch: expected %lld bytes, got %ld",
> +                       expected_size, st.st_size);
> +               return -1;
> +       }
> +
> +       fd = SAFE_OPEN(path, O_RDONLY, 0);
> +       SAFE_READ(0, fd, magic, SELFMAG);
> +       SAFE_CLOSE(fd);
> +
> +       TST_EXP_EXPR(!memcmp(magic, ELFMAG, 4),
> +                       "core file has valid ELF magic");
> +
> +       fd = SAFE_OPEN(path, O_RDONLY, 0);
> +       SAFE_READ(0, fd, &ehdr, sizeof(ehdr));
> +       SAFE_READ(0, fd, &ehdr, sizeof(ehdr));

double read? I guess it's an error

I will send a new version with some of the proposed checks

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com

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

  reply	other threads:[~2026-09-04  6:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  7:21 [LTP] [PATCH v5] coredump01: New core_pattern specifiers test Andrea Cervesato
2026-09-03 12:01 ` [LTP] " linuxtestproject.agent
2026-09-04  3:43 ` [LTP] [PATCH v5] " Li Wang
2026-09-04  6:25   ` Andrea Cervesato via ltp [this message]
2026-09-04  6:52     ` Li Wang

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=6a9a6469.3d30ac2e.110181.4b84@mx.google.com \
    --to=ltp@lists.linux.it \
    --cc=andrea.cervesato@suse.com \
    --cc=li.wang@linux.dev \
    /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