Merge "Update HIDL makefiles"
diff --git a/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp b/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp
index e501580..a1676be 100644
--- a/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp
+++ b/configstore/1.0/vts/functional/VtsHalConfigstoreV1_0TargetTest.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "ConfigstoreHidlHalTest"
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/logging.h>
#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
#include <android/hardware/configstore/1.0/types.h>
@@ -34,13 +35,25 @@
#define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
#define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk())
+// Test environment for Configstore HIDL HAL.
+class ConfigstoreHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static ConfigstoreHidlEnvironment* Instance() {
+ static ConfigstoreHidlEnvironment* instance = new ConfigstoreHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<ISurfaceFlingerConfigs>(); }
+};
+
class ConfigstoreHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
sp<ISurfaceFlingerConfigs> sfConfigs;
virtual void SetUp() override {
- sfConfigs = ::testing::VtsHalHidlTargetTestBase::getService<
- ISurfaceFlingerConfigs>();
+ sfConfigs = ::testing::VtsHalHidlTargetTestBase::getService<ISurfaceFlingerConfigs>(
+ ConfigstoreHidlEnvironment::Instance()->getServiceName<ISurfaceFlingerConfigs>());
ASSERT_NE(sfConfigs, nullptr);
}
@@ -119,7 +132,9 @@
}
int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(ConfigstoreHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ ConfigstoreHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;
diff --git a/gatekeeper/1.0/vts/functional/VtsHalGatekeeperV1_0TargetTest.cpp b/gatekeeper/1.0/vts/functional/VtsHalGatekeeperV1_0TargetTest.cpp
index e9a44eb..715e9fc 100644
--- a/gatekeeper/1.0/vts/functional/VtsHalGatekeeperV1_0TargetTest.cpp
+++ b/gatekeeper/1.0/vts/functional/VtsHalGatekeeperV1_0TargetTest.cpp
@@ -33,6 +33,7 @@
#include <log/log.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
@@ -77,6 +78,20 @@
return auth_token;
}
+// Test environment for Gatekeeper HIDL HAL.
+class GatekeeperHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static GatekeeperHidlEnvironment* Instance() {
+ static GatekeeperHidlEnvironment* instance = new GatekeeperHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IGatekeeper>(); }
+ private:
+ GatekeeperHidlEnvironment() {}
+};
+
// The main test class for Gatekeeper HIDL HAL.
class GatekeeperHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
@@ -189,7 +204,8 @@
GatekeeperHidlTest() : uid_(0) {}
virtual void SetUp() override {
GatekeeperResponse rsp;
- gatekeeper_ = ::testing::VtsHalHidlTargetTestBase::getService<IGatekeeper>();
+ gatekeeper_ = ::testing::VtsHalHidlTargetTestBase::getService<IGatekeeper>(
+ GatekeeperHidlEnvironment::Instance()->getServiceName<IGatekeeper>());
ASSERT_NE(nullptr, gatekeeper_.get());
doDeleteAllUsers(rsp);
}
@@ -433,7 +449,9 @@
}
int main(int argc, char **argv) {
+ ::testing::AddGlobalTestEnvironment(GatekeeperHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ GatekeeperHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
ALOGI("Test result = %d", status);
return status;
diff --git a/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp b/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
index a017404..5fd2dd4 100644
--- a/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
+++ b/ir/1.0/vts/functional/VtsHalIrV1_0TargetTest.cpp
@@ -22,6 +22,7 @@
#include <android/hardware/ir/1.0/types.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <algorithm>
using ::android::hardware::ir::V1_0::IConsumerIr;
@@ -30,11 +31,26 @@
using ::android::hardware::Return;
using ::android::sp;
+// Test environment for Ir
+class ConsumerIrHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static ConsumerIrHidlEnvironment* Instance() {
+ static ConsumerIrHidlEnvironment* instance = new ConsumerIrHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IConsumerIr>(); }
+ private:
+ ConsumerIrHidlEnvironment() {}
+};
+
// The main test class for IR HIDL HAL.
class ConsumerIrHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- ir = ::testing::VtsHalHidlTargetTestBase::getService<IConsumerIr>();
+ ir = ::testing::VtsHalHidlTargetTestBase::getService<IConsumerIr>(
+ ConsumerIrHidlEnvironment::Instance()->getServiceName<IConsumerIr>());
ASSERT_NE(ir, nullptr);
}
@@ -77,7 +93,9 @@
}
int main(int argc, char **argv) {
+ ::testing::AddGlobalTestEnvironment(ConsumerIrHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
+ ConsumerIrHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
LOG(INFO) << "Test result = " << status;
return status;
diff --git a/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp b/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
index e7b222a..d5c006e 100644
--- a/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
+++ b/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp
@@ -33,19 +33,14 @@
#include "key_param_output.h"
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include "attestation_record.h"
#include "openssl_utils.h"
using ::android::sp;
-
using ::std::string;
-// This service_name will be passed to getService when retrieving the keymaster service to test. To
-// change it from "default" specify the selected service name on the command line. The first
-// non-gtest argument will be used as the service name.
-string service_name = "default";
-
static bool arm_deleteAllKeys = false;
static bool dump_Attestations = false;
@@ -417,6 +412,20 @@
} // namespace
+// Test environment for Keymaster HIDL HAL.
+class KeymasterHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static KeymasterHidlEnvironment* Instance() {
+ static KeymasterHidlEnvironment* instance = new KeymasterHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IKeymasterDevice>(); }
+ private:
+ KeymasterHidlEnvironment() {}
+};
+
class KeymasterHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
void TearDown() override {
@@ -428,7 +437,8 @@
// SetUpTestCase runs only once per test case, not once per test.
static void SetUpTestCase() {
- keymaster_ = IKeymasterDevice::getService(service_name);
+ keymaster_ = ::testing::VtsHalHidlTargetTestBase::getService<IKeymasterDevice>(
+ KeymasterHidlEnvironment::Instance()->getServiceName<IKeymasterDevice>());
ASSERT_NE(keymaster_, nullptr);
ASSERT_TRUE(
@@ -4190,8 +4200,10 @@
} // namespace android
int main(int argc, char** argv) {
+ using android::hardware::keymaster::V3_0::test::KeymasterHidlEnvironment;
+ ::testing::AddGlobalTestEnvironment(KeymasterHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
- std::vector<std::string> positional_args;
+ KeymasterHidlEnvironment::Instance()->init(&argc, argv);
for (int i = 1; i < argc; ++i) {
if (argv[i][0] == '-') {
if (std::string(argv[i]) == "--arm_deleteAllKeys") {
@@ -4200,14 +4212,8 @@
if (std::string(argv[i]) == "--dump_attestations") {
dump_Attestations = true;
}
- } else {
- positional_args.push_back(argv[i]);
}
}
- if (positional_args.size()) {
- ALOGI("Running keymaster VTS against service \"%s\"", positional_args[0].c_str());
- service_name = positional_args[0];
- }
int status = RUN_ALL_TESTS();
ALOGI("Test result = %d", status);
return status;