Clean up the <libgen.h> implementation a little, bring in tests.

Most of these tests were in system/extras, but I've added more to cover other
cases explicitly mentioned by POSIX.

Change-Id: I5e8d77e4179028d77306935cceadbb505515dcde
8 files changed