diff options
author | Steven Moreland <smoreland@google.com> | 2017-10-15 02:57:39 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-10-15 02:57:39 +0000 |
commit | 05535d6d3340d3b76e270c7fb19e9d38d4744360 (patch) | |
tree | 05e6460bd2af268e8a2858c7208b2263a5ff8bbb | |
parent | 8a951b9392d85080710146c3a45ae9008e07c946 (diff) | |
parent | 77f4c859c984264a232a6fa2617c0279be25a366 (diff) | |
download | libhidl-05535d6d3340d3b76e270c7fb19e9d38d4744360.tar.gz |
Statically load passthrough HALs for tests.
am: 77f4c859c9
Change-Id: Iac7bfa23df799f90a927a5bec1f18c36273ba7b4
-rw-r--r-- | transport/ServiceManagement.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp index 3f0ebc6..c6c43a7 100644 --- a/transport/ServiceManagement.cpp +++ b/transport/ServiceManagement.cpp @@ -273,25 +273,37 @@ struct PassthroughServiceManager : IServiceManager1_1 { const std::string prefix = packageAndVersion + "-impl"; const std::string sym = "HIDL_FETCH_" + ifaceName; - const int dlMode = RTLD_LAZY; - void *handle = nullptr; + constexpr int dlMode = RTLD_LAZY; + void* handle = nullptr; dlerror(); // clear std::vector<std::string> paths = {HAL_LIBRARY_PATH_ODM, HAL_LIBRARY_PATH_VENDOR, HAL_LIBRARY_PATH_VNDK_SP, HAL_LIBRARY_PATH_SYSTEM}; + #ifdef LIBHIDL_TARGET_DEBUGGABLE const char* env = std::getenv("TREBLE_TESTING_OVERRIDE"); const bool trebleTestingOverride = env && !strcmp(env, "true"); if (trebleTestingOverride) { + // Load HAL implementations that are statically linked + handle = dlopen(nullptr, dlMode); + if (handle == nullptr) { + const char* error = dlerror(); + LOG(ERROR) << "Failed to dlopen self: " + << (error == nullptr ? "unknown error" : error); + } else if (!eachLib(handle, "SELF", sym)) { + return; + } + const char* vtsRootPath = std::getenv("VTS_ROOT_PATH"); if (vtsRootPath && strlen(vtsRootPath) > 0) { const std::string halLibraryPathVtsOverride = std::string(vtsRootPath) + HAL_LIBRARY_PATH_SYSTEM; - paths.push_back(halLibraryPathVtsOverride); + paths.insert(paths.begin(), halLibraryPathVtsOverride); } } #endif + for (const std::string& path : paths) { std::vector<std::string> libs = search(path, prefix, ".so"); |