This is an archive of the discontinued LLVM Phabricator instance.

[unittests/Object] - Add testing for missing ELF formats.
ClosedPublic

Authored by grimar on Aug 26 2020, 7:50 AM.

Details

Summary

This adds all missing format values that are defined in
ELFObjectFile<ELFT>::getFileFormatName().

Diff Detail

Event Timeline

grimar created this revision.Aug 26 2020, 7:50 AM
grimar requested review of this revision.Aug 26 2020, 7:50 AM
grimar edited the summary of this revision. (Show Details)

llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test contains some tests as well, e.g. sparc. Should we remove some redundant targets there?

jhenderson added inline comments.Aug 27 2020, 12:15 AM
llvm/unittests/Object/ELFObjectFileTest.cpp
84–90

Maybe it's worth showing that an unused machine value also produces this result? Seems like an easy mistake would be to handle all the known machine types (including EM_NONE) and then put an llvm_unreachable or something at the end which is caught if an undefined value is used.

97–102

Optional, but it might be worth having versions that test the unknown paths for situations like this where one of the classes is unsupported and therefore you get something like "elf32-unknown".

grimar added a comment.EditedAug 27 2020, 2:36 AM

llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test contains some tests as well, e.g. sparc. Should we remove some redundant targets there?

llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test tests -O (--output-format) option of llvm-objcopy.

I probably do not see why any of those tests are really redundant. I think it is not the same as D86350 for llvm-readobj, where we are really able to test
just a few values printed for "Format" field, because it is directly related with the getFileFormatName result, which is tested here.

grimar updated this revision to Diff 288277.Aug 27 2020, 4:35 AM
grimar marked 2 inline comments as done.
grimar edited the summary of this revision. (Show Details)
  • Addressed review comments.
llvm/unittests/Object/ELFObjectFileTest.cpp
84–90

Reasonable, I think. Done.

97–102

Done.

jhenderson accepted this revision.Aug 27 2020, 4:48 AM

LGTM, thanks!

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