This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj][test] - Stop using binaries in gnu-phdrs.test, split and refine it.
ClosedPublic

Authored by grimar on Apr 24 2020, 5:05 AM.

Details

Summary

gnu-phdrs.test uses 2 precompiled objects and has issues:

  • It does not test all possible program headers.
  • It does not test target-specific headers (arm, mips).
  • It does not use --strict-whitespace --match-full-line to check the format of the output.
  • It is possible to check things better/nicer.
  • It also tests --section-mapping.

This patch makes gnu-phdrs.test to stop using binaries and addresses issues above.
It splits --section-mapping testing to gnu-section-mapping.test

I am going to use it as a base for a follow-up patch that should also test
section to segment mapping conditions that we currently have
(see the discussion in D78709)

Diff Detail

Event Timeline

grimar created this revision.Apr 24 2020, 5:05 AM
MaskRay accepted this revision.Apr 24 2020, 9:38 AM

BTW, when FileCheck --match-full-lines --strict-whitespace reports a space issue, it is sometimes difficult to figure out how to fix the test... I usually have to use tmux copy-mode to copy the updated output (note: scanning from here) and paste that to the test file.

This revision is now accepted and ready to land.Apr 24 2020, 9:38 AM
grimar added a comment.EditedApr 26 2020, 11:44 PM

BTW, when FileCheck --match-full-lines --strict-whitespace reports a space issue, it is sometimes difficult to figure out how to fix the test

Very true. There is one gereral rule though: "when you do not see what is wrong, it is a missing space at the EOL" :)

(I am a windows console user, at least for my use cases it works).

Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2020, 11:44 PM
jhenderson added inline comments.Apr 27 2020, 1:41 AM
llvm/test/tools/llvm-readobj/ELF/gnu-phdrs.test
304

Space after "-l,".

Also "is the same" -> "are the same"

306

readobj -> readelf here and below?

320–321

I think these two lines are not needed - they aren't part of the program header dumping, right? Same goes for ELF64.

453

arbitraty -> arbitrary

Too many full stops.

595

Perhaps section mapping should be split into its own test, since most of the testing here isn't needed for it? It would be clear what test to look in for that option's testing then.

Also --section-mapping (similar comments below).

609

Arm -> ARM

Could we just fix the ARM header printing so that you don't need "document" in the comment?

626

What's the reasoning from removing this from its separate test? I don't think that gives us anything.

grimar marked 2 inline comments as done.Apr 27 2020, 2:15 AM
grimar added inline comments.
llvm/test/tools/llvm-readobj/ELF/gnu-phdrs.test
609

To fix ARM we need to add/change a test. This patch introduces a proper place for it (gnu-phdrs.test)

626

The original test uses phdrs-elf.exe-x86_64 which is removed with this patch.
Also I probably see no reason for testing it separatelly either: it is not a large/complex feature.

Want me to restore phdrs-elf.exe-x86_64 and keep gnu-section-mapping-no-shdrs.test unchanged?

jhenderson added inline comments.Apr 27 2020, 3:28 AM
llvm/test/tools/llvm-readobj/ELF/gnu-phdrs.test
609

Right, what I meant was fix it in a child commit, and not bother with the "document" part of the comment. Sorry I wasn't clear.

626

I guess it would be okay to fold it into a dedicated test for --section-mapping, but I think there should be a minimum of one test per user-visible option, unless two options are intricately connected. Whilst related, the --section-mapping option is not intricately tied into the --program-header option, so it makes sense to test them separately.

grimar marked an inline comment as done.Apr 27 2020, 3:54 AM
grimar added inline comments.
llvm/test/tools/llvm-readobj/ELF/gnu-phdrs.test
626

I see. Makes sense to me, will do.

grimar updated this revision to Diff 260579.Apr 28 2020, 3:28 AM
grimar marked 9 inline comments as done.
grimar retitled this revision from [llvm-readobj][test] - Stop using binaries in gnu-phdrs.test and refine it. to [llvm-readobj][test] - Stop using binaries in gnu-phdrs.test, split and refine it..
grimar edited the summary of this revision. (Show Details)
  • Addressed review comments.
llvm/test/tools/llvm-readobj/ELF/gnu-phdrs.test
595

Done.

609

I've tested GNU readelf 2.31.1, it prints:

LOPROC+0       0x0000000000000548 0x0000000000001000 0x0000000000001000
               0x0000000000000003 0x0000000000000003         0x1
EXIDX          0x0000000000000548 0x0000000000001000 0x0000000000001000
               0x0000000000000003 0x0000000000000003         0x1
LOPROC+0x2     0x0000000000000548 0x0000000000001000 0x0000000000001000
               0x0000000000000003 0x0000000000000003         0x1

We kind of follow GNU, so I think we can leave it as is for now. I am not sure if we want to follow more
and print "LOPROC+X" instead of "<unknown>: X", anyways it would be something related to tool general
behavior, not ARM specific. I've changed "Document/check" to "Check".

jhenderson added inline comments.Apr 29 2020, 1:00 AM
llvm/test/tools/llvm-readobj/ELF/gnu-phdrs.test
290–293

I'd be inclined to move this case into the section mapping test, and then simplify it down to show that program headers are emitted (but no need to check the full output). That way, the "Section to Segment mapping:" implicit-check-not is going to be closer to the true case, and less likely to get broken at some future point.

llvm/test/tools/llvm-readobj/ELF/gnu-section-mapping.test
12–13

I suspect we might want a few more test-cases here. Some examples off the top of my head:

  • Sections in segments which are themselves inside other segments.
  • TLS segment + trailing .tbss
  • Other nobits sections (both in middle and at end of segments).
  • Empty sections at start/middle/ends of segments
  • Sections that only partly overlap a segment (i.e. their start is before the start of a segment and/or their end is after the end of a segment).
  • Sections in a segment by address but not offset.
  • Sections in a segment by offset but not address.

There may well be others that I haven't thought of.

grimar marked an inline comment as done.Apr 29 2020, 1:07 AM
grimar added inline comments.
llvm/test/tools/llvm-readobj/ELF/gnu-section-mapping.test
12–13

The original test also did not test all of that.

I mentioned it in the description:

I am going to use it as a base for a follow-up patch that should also test
section to segment mapping conditions that we currently have
(see the discussion in D78709)
grimar updated this revision to Diff 260869.Apr 29 2020, 2:38 AM
grimar marked an inline comment as done.
  • Addressed review comments.
grimar edited the summary of this revision. (Show Details)Apr 29 2020, 2:38 AM
grimar closed this revision.May 1 2020, 11:51 AM

Was committed as 07d448135f328d040e51f49541467004643525ea, phab did not close it for some reason.

llvm/test/tools/llvm-readobj/ELF/gnu-phdrs.test