Fix bionic-unit-tests-glibc
Also add another test for dlsym(RTLD_NEXT, ..)
Bug: http://b/33106624
Test: run bionic-unit-tests-glibc and bionic-unit-tests
Change-Id: I340165d66bf2360b0e3273d3561a08cb5e7bd025
diff --git a/tests/gtest_main.cpp b/tests/gtest_main.cpp
index aacf9ae..b12c28f 100644
--- a/tests/gtest_main.cpp
+++ b/tests/gtest_main.cpp
@@ -20,6 +20,7 @@
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
+#include <libgen.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
@@ -65,6 +66,15 @@
return true;
}
+std::string get_dirname(const char* path) {
+#if defined(__BIONIC__)
+ return dirname(path);
+#else
+ // GLIBC does not have const char* dirname
+ return dirname(const_cast<char*>(path));
+#endif
+}
+
int get_argc() {
return g_argc;
}