This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy] Add few file processing directives
ClosedPublic

Authored by evgeny777 on Feb 7 2019, 12:02 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

evgeny777 created this revision.Feb 7 2019, 12:02 AM
jhenderson added inline comments.Feb 7 2019, 1:20 AM
test/tools/llvm-objcopy/ELF/globalize.test
11 ↗(On Diff #185712)

--regex here and in the other test cases you added below should be tested in addition to the basic behaviour of --globalize-symbols (i.e. --globalize-symbols should be the only switch for some tests). In particular, what you are testing is that --regex causes pattern matching, but not that no --regex doesn't cause pattern matching. That may actually be an issue with --regex in general, not specific to this test.

test/tools/llvm-objcopy/ELF/strip-symbol.test
9 ↗(On Diff #185712)

Why is this tested under strip-symbol and not the other cases?

Related aside: this is a good example of where unit testing should be present because really we're testing the symbol reading from file function not the switch behaviour.

evgeny777 marked an inline comment as done.Feb 7 2019, 1:32 AM
evgeny777 added inline comments.
test/tools/llvm-objcopy/ELF/strip-symbol.test
9 ↗(On Diff #185712)

Why is this tested under strip-symbol and not the other cases?

What's the point of doing this everywhere? We're using the same file parser for all cases

jhenderson added inline comments.Feb 7 2019, 1:55 AM
test/tools/llvm-objcopy/ELF/strip-symbol.test
9 ↗(On Diff #185712)

My point is more that we are testing a detail of the parser in a test that doesn't obviously have anything to do with that parser. Tests should test one feature or behaviour or it becomes hard to determine at a glance why a test is failing, or what behaviours or features are under test. I would deem that the parser is itself a feature, and should be tested separately (with separate tests to show that clients use it correctly).

Let's imagine the (admittedly somewhat contrived case) that we decide that the behaviour of --strip-symbols should change, e.g. to not allow comments any more. That would imply that this particular case should be removed from this test. However, given the current state of this patch, that would mean that we don't have any testing for comments in the normal parser.

Two options would be either to add the comment behaviour testing to each user of the parser or to write a test that tests comment handling explicitly. As noted above, this would naturally be a unit test, but given the current state of llvm-objcopy that is not possible. An alternative would be one or more lit tests called something like "symbols-from-file.test" or whatever.

evgeny777 updated this revision to Diff 185923.Feb 8 2019, 1:04 AM

Better tests

jhenderson added inline comments.Feb 8 2019, 1:28 AM
test/tools/llvm-objcopy/ELF/globalize.test
14 ↗(On Diff #185923)

This one still has --regex in, which I assume wasn't intentional?

evgeny777 updated this revision to Diff 185927.Feb 8 2019, 1:33 AM
evgeny777 marked an inline comment as done.

Test case fix

This revision is now accepted and ready to land.Feb 8 2019, 1:35 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2019, 6:38 AM