Skip API and time rollback tests with GTEST_SKIP

Bug: 251240681
Change-Id: Ie1cee828f239ddca03ad18aac4139e2e42038df3
This commit is contained in:
Vicky Min
2023-09-01 19:06:25 +00:00
committed by Robert Shih
parent 065d4d151e
commit b04fda2908
7 changed files with 110 additions and 12 deletions

View File

@@ -13,6 +13,9 @@ namespace wvoec {
// Test that successive calls to PrepAndSignProvisioningRequest only increase
// the provisioning count in the ODK message
TEST_F(OEMCryptoSessionTests, Provisioning_IncrementCounterAPI18) {
if (wvoec::global_features.api_version < 18) {
GTEST_SKIP() << "Test for versions 18 and up only.";
}
// local struct to hold count values from core message
typedef struct counts {
uint32_t prov;
@@ -90,6 +93,9 @@ TEST_F(OEMCryptoSessionTests, Provisioning_IncrementCounterAPI18) {
// Test that successive calls to PrepAndSignLicenseRequest only increase
// the license count in the ODK message
TEST_F(OEMCryptoSessionTests, License_IncrementCounterAPI18) {
if (wvoec::global_features.api_version < 18) {
GTEST_SKIP() << "Test for versions 18 and up only.";
}
Session s;
s.open();
LicenseRoundTrip license_messages(&s);
@@ -128,6 +134,9 @@ TEST_F(OEMCryptoSessionTests, License_IncrementCounterAPI18) {
// it is incremented correctly after usage table modification (save offline
// license) and decrypt. Also test that decrypt count increments.
TEST_F(OEMCryptoSessionTests, MasterGeneration_IncrementCounterAPI18) {
if (wvoec::global_features.api_version < 18) {
GTEST_SKIP() << "Test for versions 18 and up only.";
}
if (!OEMCrypto_SupportsUsageTable()) {
GTEST_SKIP() << "Usage table not supported, so master generation number "
"does not need to be checked.";
@@ -1235,6 +1244,9 @@ TEST_P(OEMCryptoUsageTableDefragTest, ManyUsageEntries) {
// Verify that usage entries can be created in the position of existing entry
// indexes.
TEST_P(OEMCryptoUsageTableDefragTest, ReuseUsageEntryAPI17) {
if (wvoec::global_features.api_version < 17) {
GTEST_SKIP() << "Test for versions 17 and up only.";
}
LicenseWithUsageEntry entry0;
entry0.set_pst("pst 0");
LicenseWithUsageEntry entry1;
@@ -1252,6 +1264,9 @@ TEST_P(OEMCryptoUsageTableDefragTest, ReuseUsageEntryAPI17) {
// Verify that usage entries cannot replace an entry that is currently in
// use by a session.
TEST_P(OEMCryptoUsageTableDefragTest, ReuseUsageEntryIndexInUseAPI17) {
if (wvoec::global_features.api_version < 17) {
GTEST_SKIP() << "Test for versions 17 and up only.";
}
LicenseWithUsageEntry entry0;
entry0.set_pst("pst 0");
LicenseWithUsageEntry entry1;
@@ -1268,6 +1283,9 @@ TEST_P(OEMCryptoUsageTableDefragTest, ReuseUsageEntryIndexInUseAPI17) {
// Verify that usage entries cannot be created if the usage entry index is
// too large.
TEST_P(OEMCryptoUsageTableDefragTest, ReuseUsageEntryWithInvalidIndexAPI17) {
if (wvoec::global_features.api_version < 17) {
GTEST_SKIP() << "Test for versions 17 and up only.";
}
LicenseWithUsageEntry entry0;
entry0.set_pst("pst 0");
LicenseWithUsageEntry entry1;
@@ -1287,6 +1305,9 @@ TEST_P(OEMCryptoUsageTableDefragTest, ReuseUsageEntryWithInvalidIndexAPI17) {
// entry.
TEST_P(OEMCryptoUsageTableDefragTest,
ReuseUsageEntrySessionAlreadyHasEntryAPI17) {
if (wvoec::global_features.api_version < 17) {
GTEST_SKIP() << "Test for versions 17 and up only.";
}
LicenseWithUsageEntry entry;
entry.set_pst("pst 0");
@@ -1620,6 +1641,13 @@ class OEMCryptoUsageTableTestWallClock : public OEMCryptoUsageTableTest {
// clang-format on
TEST_P(OEMCryptoUsageTableTestWallClock, TimeRollbackPrevention) {
// This test may require root access. If user is not root, filter this test
// out.
if (!wvutil::TestSleep::CanChangeSystemTime()) {
GTEST_SKIP() << "Filtering out TimeRollbackPrevention.";
} else {
printf("Can change time. I will run TimeRollbackPrevention.\n");
}
cout << "This test temporarily rolls back the system time in order to "
"verify "
<< "that the usage report accounts for the change. After the test, it "
@@ -1729,6 +1757,9 @@ TEST_P(OEMCryptoUsageTableTest, UsageEntryWithInvalidSession) {
// Verify that a usage entry with an invalid session cannot be used.
TEST_P(OEMCryptoUsageTableTest, ReuseUsageEntryWithInvalidSessionAPI17) {
if (wvoec::global_features.api_version < 17) {
GTEST_SKIP() << "Test for versions 17 and up only.";
}
std::string pst("pst");
LicenseWithUsageEntry entry;
entry.license_messages().set_pst(pst);