diff options
author | nelsonli <nelsonli@google.com> | 2019-10-15 21:33:58 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-10-15 21:33:58 -0700 |
commit | 42987814c5d7786492031e57051a89d56271a065 (patch) | |
tree | 6183a6ccf46ea06ddfbe8a533e07c26a7a659fff | |
parent | e126b55e4cc342616db1f85f4420f55e0776ece2 (diff) | |
parent | 2217b5ccd3d39fcb11dd56a9d7a33d54659572e7 (diff) | |
download | platform_hardware_interfaces-42987814c5d7786492031e57051a89d56271a065.tar.gz platform_hardware_interfaces-42987814c5d7786492031e57051a89d56271a065.tar.bz2 platform_hardware_interfaces-42987814c5d7786492031e57051a89d56271a065.zip |
Merge "[vts-core] add VtsHalAuthSecretV1_0TargetTest to vts-core"
am: 2217b5ccd3
Change-Id: I3544473b241e96fc5dc0628b52be80af86b151d0
-rw-r--r-- | authsecret/1.0/vts/functional/Android.bp | 6 | ||||
-rw-r--r-- | authsecret/1.0/vts/functional/VtsHalAuthSecretV1_0TargetTest.cpp | 46 |
2 files changed, 19 insertions, 33 deletions
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 <android/hardware/authsecret/1.0/IAuthSecret.h> -#include <VtsHalHidlTargetTestBase.h> -#include <VtsHalHidlTargetTestEnvBase.h> +#include <gtest/gtest.h> +#include <hidl/GtestPrinter.h> +#include <hidl/ServiceManagement.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 { +class AuthSecretHidlTest : public testing::TestWithParam<std::string> { + public: virtual void SetUp() override { - authsecret = ::testing::VtsHalHidlTargetTestBase::getService<IAuthSecret>( - AuthSecretHidlEnvironment::Instance()->getServiceName<IAuthSecret>()); + 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); |