Convert auth secret hal test to use VtsHalHidlTargetTestEnvBase
Test: make vts
vts-tradefed run vts-hal -m VtsHalAuthSecretV1_0Target
Change-Id: Ib66e101a78b4b6d66a426c36112b1cf0b95afda3
diff --git a/authsecret/1.0/vts/functional/VtsHalAuthSecretV1_0TargetTest.cpp b/authsecret/1.0/vts/functional/VtsHalAuthSecretV1_0TargetTest.cpp
index a610a75..255d4de 100644
--- a/authsecret/1.0/vts/functional/VtsHalAuthSecretV1_0TargetTest.cpp
+++ b/authsecret/1.0/vts/functional/VtsHalAuthSecretV1_0TargetTest.cpp
@@ -17,18 +17,35 @@
#include <android/hardware/authsecret/1.0/IAuthSecret.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
using ::android::hardware::hidl_vec;
using ::android::hardware::authsecret::V1_0::IAuthSecret;
using ::android::sp;
+// Test environment for Boot HIDL HAL.
+class AuthSecretHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static AuthSecretHidlEnvironment* Instance() {
+ static AuthSecretHidlEnvironment* instance = new AuthSecretHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IAuthSecret>(); }
+
+ private:
+ AuthSecretHidlEnvironment() {}
+};
+
/**
* There is no expected behaviour that can be tested so these tests check the
* HAL doesn't crash with different execution orders.
*/
struct AuthSecretHidlTest : public ::testing::VtsHalHidlTargetTestBase {
virtual void SetUp() override {
- authsecret = ::testing::VtsHalHidlTargetTestBase::getService<IAuthSecret>();
+ authsecret = ::testing::VtsHalHidlTargetTestBase::getService<IAuthSecret>(
+ AuthSecretHidlEnvironment::Instance()->getServiceName<IAuthSecret>());
ASSERT_NE(authsecret, nullptr);
// All tests must enroll the correct secret first as this cannot be changed
@@ -69,3 +86,12 @@
// Secret provisioned by SetUp()
authsecret->primaryUserCredential(WRONG_SECRET);
}
+
+int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(AuthSecretHidlEnvironment::Instance());
+ ::testing::InitGoogleTest(&argc, argv);
+ AuthSecretHidlEnvironment::Instance()->init(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ return status;
+}