summaryrefslogtreecommitdiff
path: root/security/keymint/aidl/vts/functional/SecureElementProvisioningTest.cpp
diff options
context:
space:
mode:
authorDavid Drysdale <drysdale@google.com>2022-03-08 08:07:02 +0000
committerDavid Drysdale <drysdale@google.com>2022-03-08 08:07:02 +0000
commit1585fdceb5c5ee8556017e2221dc3f2683f9b2e3 (patch)
tree024bad0fc2c35c06ad83a9ab1c9a5b056cf39f7b /security/keymint/aidl/vts/functional/SecureElementProvisioningTest.cpp
parentcbc6a3305ea12a2afe30e30469693fe24067e86f (diff)
KeyMint VTS: check for relevant devices
Don't run tests if the appropriate KeyMint device is not available (e.g. on something that only has Keymaster). Move to use GTEST_SKIP consistently. Bug: 221909227 Test: VtsAidlKeyMintTargetTest Change-Id: I5dab238519e57e6752b795f3a983681cf4337bdd
Diffstat (limited to 'security/keymint/aidl/vts/functional/SecureElementProvisioningTest.cpp')
-rw-r--r--security/keymint/aidl/vts/functional/SecureElementProvisioningTest.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/security/keymint/aidl/vts/functional/SecureElementProvisioningTest.cpp b/security/keymint/aidl/vts/functional/SecureElementProvisioningTest.cpp
index 83ee188ad6..6f138672ba 100644
--- a/security/keymint/aidl/vts/functional/SecureElementProvisioningTest.cpp
+++ b/security/keymint/aidl/vts/functional/SecureElementProvisioningTest.cpp
@@ -63,6 +63,9 @@ class SecureElementProvisioningTest : public testing::Test {
map<SecurityLevel, shared_ptr<IKeyMintDevice>> SecureElementProvisioningTest::keymints_;
TEST_F(SecureElementProvisioningTest, ValidConfigurations) {
+ if (keymints_.empty()) {
+ GTEST_SKIP() << "Test not applicable to device with no KeyMint devices";
+ }
// TEE is required
ASSERT_EQ(keymints_.count(SecurityLevel::TRUSTED_ENVIRONMENT), 1);
// StrongBox is optional
@@ -70,6 +73,9 @@ TEST_F(SecureElementProvisioningTest, ValidConfigurations) {
}
TEST_F(SecureElementProvisioningTest, TeeOnly) {
+ if (keymints_.empty()) {
+ GTEST_SKIP() << "Test not applicable to device with no KeyMint devices";
+ }
ASSERT_EQ(keymints_.count(SecurityLevel::TRUSTED_ENVIRONMENT), 1);
auto tee = keymints_.find(SecurityLevel::TRUSTED_ENVIRONMENT)->second;
ASSERT_NE(tee, nullptr);
@@ -105,6 +111,9 @@ TEST_F(SecureElementProvisioningTest, TeeOnly) {
}
TEST_F(SecureElementProvisioningTest, TeeDoesNotImplementStrongBoxMethods) {
+ if (keymints_.empty()) {
+ GTEST_SKIP() << "Test not applicable to device with no KeyMint devices";
+ }
ASSERT_EQ(keymints_.count(SecurityLevel::TRUSTED_ENVIRONMENT), 1);
auto tee = keymints_.find(SecurityLevel::TRUSTED_ENVIRONMENT)->second;
ASSERT_NE(tee, nullptr);
@@ -122,7 +131,10 @@ TEST_F(SecureElementProvisioningTest, TeeDoesNotImplementStrongBoxMethods) {
}
TEST_F(SecureElementProvisioningTest, StrongBoxDoesNotImplementTeeMethods) {
- if (keymints_.count(SecurityLevel::STRONGBOX) == 0) return;
+ if (keymints_.count(SecurityLevel::STRONGBOX) == 0) {
+ // Need a StrongBox to provision.
+ GTEST_SKIP() << "Test not applicable to device with no StrongBox KeyMint device";
+ }
auto sb = keymints_.find(SecurityLevel::STRONGBOX)->second;
ASSERT_NE(sb, nullptr);
@@ -135,7 +147,10 @@ TEST_F(SecureElementProvisioningTest, StrongBoxDoesNotImplementTeeMethods) {
}
TEST_F(SecureElementProvisioningTest, UnimplementedTest) {
- if (keymints_.count(SecurityLevel::STRONGBOX) == 0) return; // Need a StrongBox to provision.
+ if (keymints_.count(SecurityLevel::STRONGBOX) == 0) {
+ // Need a StrongBox to provision.
+ GTEST_SKIP() << "Test not applicable to device with no StrongBox KeyMint device";
+ }
ASSERT_EQ(keymints_.count(SecurityLevel::TRUSTED_ENVIRONMENT), 1);
auto tee = keymints_.find(SecurityLevel::TRUSTED_ENVIRONMENT)->second;
@@ -166,7 +181,10 @@ TEST_F(SecureElementProvisioningTest, UnimplementedTest) {
}
TEST_F(SecureElementProvisioningTest, ChallengeQualityTest) {
- if (keymints_.count(SecurityLevel::STRONGBOX) == 0) return; // Need a StrongBox to provision.
+ if (keymints_.count(SecurityLevel::STRONGBOX) == 0) {
+ // Need a StrongBox to provision.
+ GTEST_SKIP() << "Test not applicable to device with no StrongBox KeyMint device";
+ }
ASSERT_EQ(keymints_.count(SecurityLevel::STRONGBOX), 1);
auto sb = keymints_.find(SecurityLevel::STRONGBOX)->second;
@@ -186,7 +204,10 @@ TEST_F(SecureElementProvisioningTest, ChallengeQualityTest) {
}
TEST_F(SecureElementProvisioningTest, ProvisioningTest) {
- if (keymints_.count(SecurityLevel::STRONGBOX) == 0) return; // Need a StrongBox to provision.
+ if (keymints_.count(SecurityLevel::STRONGBOX) == 0) {
+ // Need a StrongBox to provision.
+ GTEST_SKIP() << "Test not applicable to device with no StrongBox KeyMint device";
+ }
ASSERT_EQ(keymints_.count(SecurityLevel::TRUSTED_ENVIRONMENT), 1);
auto tee = keymints_.find(SecurityLevel::TRUSTED_ENVIRONMENT)->second;
@@ -215,7 +236,10 @@ TEST_F(SecureElementProvisioningTest, ProvisioningTest) {
}
TEST_F(SecureElementProvisioningTest, InvalidProvisioningTest) {
- if (keymints_.count(SecurityLevel::STRONGBOX) == 0) return; // Need a StrongBox to provision.
+ if (keymints_.count(SecurityLevel::STRONGBOX) == 0) {
+ // Need a StrongBox to provision.
+ GTEST_SKIP() << "Test not applicable to device with no StrongBox KeyMint device";
+ }
ASSERT_EQ(keymints_.count(SecurityLevel::TRUSTED_ENVIRONMENT), 1);
auto tee = keymints_.find(SecurityLevel::TRUSTED_ENVIRONMENT)->second;