Fix DynamicLibraryTest.cpp on FreeBSD and NetBSD
authorDimitry Andric <dimitry@andric.com>
Sun, 14 May 2017 18:35:38 +0000 (18:35 +0000)
committerDimitry Andric <dimitry@andric.com>
Sun, 14 May 2017 18:35:38 +0000 (18:35 +0000)
commit4043373e840e6e635c27fa1d149653e574832e62
tree002618d5a13663b6e159c8dc59ebb4b465fbbefa
parentee97c5f0125e8f07ee53934bf607c5d518959cac
Fix DynamicLibraryTest.cpp on FreeBSD and NetBSD

Summary:

After rL301562, on FreeBSD the DynamicLibrary unittests fail, because
the test uses getMainExecutable("DynamicLibraryTests", Ptr), and since
the path does not contain any slashes, retrieving the main executable
will not work.

Reimplement getMainExecutable() for FreeBSD and NetBSD using sysctl(3),
which is more reliable than fiddling with relative or absolute paths.

Also add retrieval of the original argv[] from the GoogleTest framework,
to use as a fallback for other OSes.

Reviewers: emaste, marsupial, hans, krytarowski

Reviewed By: krytarowski

Subscribers: krytarowski, llvm-commits

Differential Revision: https://reviews.llvm.org/D33171

llvm-svn: 303015
llvm/lib/Support/Unix/Path.inc
llvm/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp