Merge "[vts-core] add VtsHalAuthSecretV1_0TargetTest to vts-core"
This commit is contained in:
commit
2217b5ccd3
2 changed files with 19 additions and 33 deletions
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue