Merge "Run full tests when AIDL HALs timeout." am: 1580e45020 am: ae8d650abb am: dc5f853332 am: 3326d25c30 am: d9f2f4de4e
Original change: https://android-review.googlesource.com/c/platform/test/vts-testcase/hal/+/1883568
Change-Id: I9c6cee25d1a778716e1389ac0628f6bebd2a4a67
diff --git a/treble/vintf/SingleManifestTest.cpp b/treble/vintf/SingleManifestTest.cpp
index 0f22e6c..da39b44 100644
--- a/treble/vintf/SingleManifestTest.cpp
+++ b/treble/vintf/SingleManifestTest.cpp
@@ -134,7 +134,7 @@
return nullptr;
}
- auto hal_service = VtsTrebleVintfTestBase::GetHalService(
+ auto hal_service = VtsTrebleVintfTestBase::GetHidlService(
interface.string(), fq_instance.getInstance(), Transport::PASSTHROUGH);
if (hal_service != nullptr) {
@@ -313,12 +313,12 @@
const FQName lowest_name =
fq_name.withVersion(fq_name.getPackageMajorVersion(), 0);
- hal_service = GetHalService(lowest_name, instance_name, transport);
+ hal_service = GetHidlService(lowest_name, instance_name, transport);
EXPECT_TRUE(
canCastInterface(hal_service.get(), fq_name.string().c_str()))
<< fq_name.string() << " is not on the device.";
} else {
- hal_service = GetHalService(fq_name, instance_name, transport);
+ hal_service = GetHidlService(fq_name, instance_name, transport);
}
if (hal_service == nullptr) {
@@ -363,10 +363,10 @@
EXPECT_TRUE(fqInstanceName.setTo(name));
auto service =
- GetHalService(toFQNameString(fqInstanceName.getPackage(),
- fqInstanceName.getVersion(),
- fqInstanceName.getInterface()),
- fqInstanceName.getInstance(), Transport::HWBINDER);
+ GetHidlService(toFQNameString(fqInstanceName.getPackage(),
+ fqInstanceName.getVersion(),
+ fqInstanceName.getInterface()),
+ fqInstanceName.getInstance(), Transport::HWBINDER);
ASSERT_NE(service, nullptr);
Partition partition = GetPartition(service);
@@ -404,7 +404,7 @@
const FQName lowest_name =
fq_name.withVersion(fq_name.getPackageMajorVersion(), 0);
sp<IBase> hal_service =
- GetHalService(lowest_name, instance_name, transport);
+ GetHidlService(lowest_name, instance_name, transport);
if (hal_service == nullptr) {
ADD_FAILURE() << "Could not get service " << fq_name.string() << "/"
<< instance_name;
@@ -444,7 +444,7 @@
return;
}
- sp<IBase> hal_service = GetHalService(fq_name, instance_name, transport);
+ sp<IBase> hal_service = GetHidlService(fq_name, instance_name, transport);
if (hal_service == nullptr) {
FailureHalMissing(fq_name, instance_name);
@@ -594,8 +594,9 @@
&updatable_via_apex) {
const std::string type = package + "." + interface;
const std::string name = type + "/" + instance;
- sp<IBinder> binder =
- defaultServiceManager()->waitForService(String16(name.c_str()));
+
+ sp<IBinder> binder = GetAidlService(name);
+
ASSERT_NE(binder, nullptr) << "Failed to get " << name;
// allow upgrade if updatable HAL's declared APEX is actually updated.
diff --git a/treble/vintf/VtsTrebleVintfTestBase.cpp b/treble/vintf/VtsTrebleVintfTestBase.cpp
index ddc358f..72ad095 100644
--- a/treble/vintf/VtsTrebleVintfTestBase.cpp
+++ b/treble/vintf/VtsTrebleVintfTestBase.cpp
@@ -16,6 +16,21 @@
#include "VtsTrebleVintfTestBase.h"
+#include <android-base/logging.h>
+#include <android-base/strings.h>
+#include <android/hidl/manager/1.0/IServiceManager.h>
+#include <binder/IServiceManager.h>
+#include <gtest/gtest.h>
+#include <hidl-hash/Hash.h>
+#include <hidl-util/FQName.h>
+#include <hidl-util/FqInstance.h>
+#include <hidl/HidlTransportUtils.h>
+#include <hidl/ServiceManagement.h>
+#include <procpartition/procpartition.h>
+#include <vintf/HalManifest.h>
+#include <vintf/VintfObject.h>
+#include <vintf/parse_string.h>
+
#include <chrono>
#include <condition_variable>
#include <functional>
@@ -29,20 +44,6 @@
#include <thread>
#include <vector>
-#include <android-base/logging.h>
-#include <android-base/strings.h>
-#include <android/hidl/manager/1.0/IServiceManager.h>
-#include <gtest/gtest.h>
-#include <hidl-hash/Hash.h>
-#include <hidl-util/FQName.h>
-#include <hidl-util/FqInstance.h>
-#include <hidl/HidlTransportUtils.h>
-#include <hidl/ServiceManagement.h>
-#include <procpartition/procpartition.h>
-#include <vintf/HalManifest.h>
-#include <vintf/VintfObject.h>
-#include <vintf/parse_string.h>
-
#include "SingleManifestTest.h"
#include "utils.h"
@@ -134,15 +135,17 @@
});
}
-sp<IBase> VtsTrebleVintfTestBase::GetHalService(const FQName &fq_name,
- const string &instance_name,
- Transport transport, bool log) {
- return GetHalService(fq_name.string(), instance_name, transport, log);
+sp<IBase> VtsTrebleVintfTestBase::GetHidlService(const FQName &fq_name,
+ const string &instance_name,
+ Transport transport,
+ bool log) {
+ return GetHidlService(fq_name.string(), instance_name, transport, log);
}
-sp<IBase> VtsTrebleVintfTestBase::GetHalService(const string &fq_name,
- const string &instance_name,
- Transport transport, bool log) {
+sp<IBase> VtsTrebleVintfTestBase::GetHidlService(const string &fq_name,
+ const string &instance_name,
+ Transport transport,
+ bool log) {
using android::hardware::details::getRawServiceInternal;
if (log) {
@@ -176,6 +179,19 @@
return base;
}
+sp<IBinder> VtsTrebleVintfTestBase::GetAidlService(const string &name) {
+ auto task = std::packaged_task<sp<IBinder>()>([name]() {
+ return defaultServiceManager()->waitForService(String16(name.c_str()));
+ });
+
+ auto max_time = std::chrono::seconds(2); // TODO(b/205347235)
+ auto future = task.get_future();
+ std::thread(std::move(task)).detach();
+ auto status = future.wait_for(max_time);
+
+ return status == std::future_status::ready ? future.get() : nullptr;
+}
+
vector<string> VtsTrebleVintfTestBase::GetInstanceNames(
const sp<IServiceManager> &manager, const FQName &fq_name) {
vector<string> ret;
diff --git a/treble/vintf/VtsTrebleVintfTestBase.h b/treble/vintf/VtsTrebleVintfTestBase.h
index 779e898..64d3ff9 100644
--- a/treble/vintf/VtsTrebleVintfTestBase.h
+++ b/treble/vintf/VtsTrebleVintfTestBase.h
@@ -17,13 +17,14 @@
#ifndef VTS_TREBLE_VINTF_TEST_BASE_H_
#define VTS_TREBLE_VINTF_TEST_BASE_H_
-#include <string>
-#include <vector>
-
#include <android/hidl/manager/1.0/IServiceManager.h>
+#include <binder/IBinder.h>
#include <gtest/gtest.h>
#include <vintf/VintfObject.h>
+#include <string>
+#include <vector>
+
#include "utils.h"
namespace android {
@@ -45,12 +46,13 @@
static void ForEachHidlHalInstance(const HalManifestPtr &, HidlVerifyFn);
// Retrieves an existing HAL service.
- static sp<IBase> GetHalService(const string &fq_name,
- const string &instance_name, Transport,
- bool log = true);
- static sp<IBase> GetHalService(const FQName &fq_name,
- const string &instance_name, Transport,
- bool log = true);
+ static sp<IBase> GetHidlService(const string &fq_name,
+ const string &instance_name, Transport,
+ bool log = true);
+ static sp<IBase> GetHidlService(const FQName &fq_name,
+ const string &instance_name, Transport,
+ bool log = true);
+ static sp<IBinder> GetAidlService(const std::string &name);
static vector<string> GetInstanceNames(const sp<IServiceManager> &manager,
const FQName &fq_name);