diff --git a/authsecret/1.0/vts/functional/Android.bp b/authsecret/1.0/vts/functional/Android.bp index f2b3a8a53a..9ce9cda2f9 100644 --- a/authsecret/1.0/vts/functional/Android.bp +++ b/authsecret/1.0/vts/functional/Android.bp @@ -19,5 +19,9 @@ cc_test { defaults: ["VtsHalTargetTestDefaults"], srcs: ["VtsHalAuthSecretV1_0TargetTest.cpp"], static_libs: ["android.hardware.authsecret@1.0"], - test_suites: ["general-tests"], + test_suites: [ + "general-tests", + "vts-core", + ], + require_root: true, } diff --git a/authsecret/1.0/vts/functional/VtsHalAuthSecretV1_0TargetTest.cpp b/authsecret/1.0/vts/functional/VtsHalAuthSecretV1_0TargetTest.cpp index 255d4de3f5..0bff9df7dd 100644 --- a/authsecret/1.0/vts/functional/VtsHalAuthSecretV1_0TargetTest.cpp +++ b/authsecret/1.0/vts/functional/VtsHalAuthSecretV1_0TargetTest.cpp @@ -16,36 +16,22 @@ #include -#include -#include +#include +#include +#include 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(); } - - 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 { +class AuthSecretHidlTest : public testing::TestWithParam { + public: virtual void SetUp() override { - authsecret = ::testing::VtsHalHidlTargetTestBase::getService( - AuthSecretHidlEnvironment::Instance()->getServiceName()); + authsecret = IAuthSecret::getService(GetParam()); ASSERT_NE(authsecret, nullptr); // All tests must enroll the correct secret first as this cannot be changed @@ -59,18 +45,18 @@ struct AuthSecretHidlTest : public ::testing::VtsHalHidlTargetTestBase { }; /* Provision the primary user with a secret. */ -TEST_F(AuthSecretHidlTest, provisionPrimaryUserCredential) { +TEST_P(AuthSecretHidlTest, provisionPrimaryUserCredential) { // Secret provisioned by SetUp() } /* Provision the primary user with a secret and pass the secret again. */ -TEST_F(AuthSecretHidlTest, provisionPrimaryUserCredentialAndPassAgain) { +TEST_P(AuthSecretHidlTest, provisionPrimaryUserCredentialAndPassAgain) { // Secret provisioned by SetUp() authsecret->primaryUserCredential(CORRECT_SECRET); } /* Provision the primary user with a secret and pass the secret again repeatedly. */ -TEST_F(AuthSecretHidlTest, provisionPrimaryUserCredentialAndPassAgainMultipleTimes) { +TEST_P(AuthSecretHidlTest, provisionPrimaryUserCredentialAndPassAgainMultipleTimes) { // Secret provisioned by SetUp() constexpr int N = 5; for (int i = 0; i < N; ++i) { @@ -82,16 +68,12 @@ TEST_F(AuthSecretHidlTest, provisionPrimaryUserCredentialAndPassAgainMultipleTim * should never happen and is an framework bug if it does. As the secret is * wrong, the HAL implementation may not be able to function correctly but it * should fail gracefully. */ -TEST_F(AuthSecretHidlTest, provisionPrimaryUserCredentialAndWrongSecret) { +TEST_P(AuthSecretHidlTest, provisionPrimaryUserCredentialAndWrongSecret) { // 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; -} +INSTANTIATE_TEST_SUITE_P( + PerInstance, AuthSecretHidlTest, + testing::ValuesIn(android::hardware::getAllHalInstanceNames(IAuthSecret::descriptor)), + android::hardware::PrintInstanceNameToString);