This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Add unit tests for Distro detection
ClosedPublic

Authored by mgorny on Oct 21 2016, 6:57 AM.

Details

Summary

Add a set of unit tests for the distro detection code. The tests use an
in-memory virtual filesystems resembling release files for various
distributions supported. All release files are provided (not only the
ones directly used) in order to guarantee that one of the rules will not
mistakenly recognize the distribution incorrectly due to the additional
files (e.g. Ubuntu as Debian).

Diff Detail

Repository
rL LLVM

Event Timeline

mgorny updated this revision to Diff 75418.Oct 21 2016, 6:57 AM
mgorny retitled this revision from to [Driver] Add unit tests for DetectDistro().
mgorny updated this object.
mgorny added reviewers: bruno, bkramer, rafael.
mgorny added a subscriber: cfe-commits.
bkramer edited edge metadata.Oct 25 2016, 2:27 AM

Very nice.

unittests/Driver/ToolChainsTest.cpp
15 ↗(On Diff #75418)

Yeah. It's better to hoist the enum + the decl for detectDistro into a public header under include/clang/Driver and include it from here.

mgorny planned changes to this revision.Oct 25 2016, 7:58 AM
mgorny added inline comments.
unittests/Driver/ToolChainsTest.cpp
15 ↗(On Diff #75418)

Ok. Then I'll probably refactor the whole thing into a nicer API anyway ;-).

bruno edited edge metadata.Oct 25 2016, 8:28 AM

This is great!

unittests/Driver/ToolChainsTest.cpp
154 ↗(On Diff #75418)

Can you add the tests for /etc/SuSE-release here as well?

mgorny added inline comments.Oct 25 2016, 8:45 AM
unittests/Driver/ToolChainsTest.cpp
154 ↗(On Diff #75418)

Yes, that is a goal. I didn't add all distros yet because I wanted to see if I'm doing it right first ;-).

mgorny updated this revision to Diff 78494.Nov 18 2016, 3:31 AM
mgorny retitled this revision from [Driver] Add unit tests for DetectDistro() to [Driver] Add unit tests for Distro detection.
mgorny updated this object.
mgorny edited edge metadata.

Ok, here are the tests updated for the new API. I'll try to look into adding more distributions later today.

mgorny updated this revision to Diff 78506.Nov 18 2016, 6:00 AM

Added tests for SUSE and Arch Linux (and found a bug for the former, D26850).

bruno added a comment.Nov 18 2016, 9:54 AM

LGTM! Please add this before D26850, which should contain a testcase on top of this!

Thanks

bruno accepted this revision.Nov 18 2016, 9:55 AM
bruno edited edge metadata.
This revision is now accepted and ready to land.Nov 18 2016, 9:55 AM

LGTM! Please add this before D26850, which should contain a testcase on top of this!

I should probably also copy here that as I've mentioned on D26850, this already contains a test case erroring out due to the OpenSUSE parsing bug. I originally intended to commit the fix before the test case included here but I can move that around if you insist.

mgorny updated this revision to Diff 78625.Nov 19 2016, 4:56 AM
mgorny edited edge metadata.

Added a test for Exherbo.

This revision was automatically updated to reflect the committed changes.