[LTP] [PATCH v5] coredump01: New core_pattern specifiers test
Li Wang
li.wang@linux.dev
Fri Sep 4 08:52:36 CEST 2026
> > 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).
+1
> > +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.
+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
Oh sorry, that's a duplicate from the vim y&p.
> I will send a new version with some of the proposed checks
Thanks!
--
Regards,
Li Wang
More information about the ltp
mailing list