Allow VTS to load test HALs from data.
* This uses the TREBLE_TESTING_OVERRIDE flag which was previously only set by hidl-gen code.
b/63707685 is filed for this coupling.
* Lookup additional directory VTS_ROOT_PATH/system/lib(64) to search for -impl.so where
VTS_ROOT_PATH is an enviroment variable.
Test: make vts
vts-tradefed run vts -m VtsHidlUniTest.
Bug: 63707685
Bug: 63704014
Change-Id: Icdc486cc862adb2d93c4916f1cdf3bcafa971c69
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index 8be2c76..663c6b5 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -271,9 +271,21 @@
dlerror(); // clear
- for (const std::string &path : {
- HAL_LIBRARY_PATH_ODM, HAL_LIBRARY_PATH_VENDOR, HAL_LIBRARY_PATH_SYSTEM
- }) {
+ std::vector<std::string> paths = {HAL_LIBRARY_PATH_ODM, HAL_LIBRARY_PATH_VENDOR,
+ 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) {
+ 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);
+ }
+ }
+#endif
+ for (const std::string& path : paths) {
std::vector<std::string> libs = search(path, prefix, ".so");
for (const std::string &lib : libs) {