This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj][test] - Test "Format" values.
ClosedPublic

Authored by grimar on Aug 21 2020, 7:11 AM.

Details

Summary

This adds testing for the "Format" field printed with --file-headers.

llvm-readelf doesn't use them, so only llvm-readobj needs to be tested.

All possible values are defined in ELFObjectFile<ELFT>::getFileFormatName().
and tested by D86625. Here we test just a few arbitrary ones.

Diff Detail

Event Timeline

grimar created this revision.Aug 21 2020, 7:11 AM
grimar requested review of this revision.Aug 21 2020, 7:11 AM

This is essentially testing the getFileFormatName function in ELFObjectFile.h, which is part of the Object library, not part of llvm-readobj. I'm not sure exhaustively testing all the possible values should be done in an llvm-readobj test. There should be an llvm-readobj test that shows that the Format is printed for one or two given values, but the getFileFormatName function should be tested in Object tests (probably best in gtest unit tests), in my opinion.

grimar planned changes to this revision.Aug 26 2020, 5:56 AM

OK. I'll prepare a different patch and update this later.

grimar updated this revision to Diff 287978.Aug 26 2020, 8:08 AM
grimar retitled this revision from [llvm-readobj][test] - Test all possible "Format" values. to [llvm-readobj][test] - Test "Format" values..
grimar edited the summary of this revision. (Show Details)
  • Addressed review comment.
jhenderson accepted this revision.Aug 27 2020, 12:05 AM

LGTM.

llvm/test/tools/llvm-readobj/ELF/file-header-format.test
2
28

If you're going to use the default for CLASS and DATA, I'd do the same for MACHINE too, with EM_NONE as the default. Up to you though.

This revision is now accepted and ready to land.Aug 27 2020, 12:05 AM
This revision was automatically updated to reflect the committed changes.