KeyMint VTS: fix flipped error messages
Also make main() shorter by `using`.
Bug: 317693523
Test: VtsAidlKeyMintTargetTest
Change-Id: Ife6048001a003e387927338dfcf7a4b2293576c7
diff --git a/security/keymint/aidl/vts/functional/KeyBlobUpgradeTest.cpp b/security/keymint/aidl/vts/functional/KeyBlobUpgradeTest.cpp
index 7ccd246..c2509b8 100644
--- a/security/keymint/aidl/vts/functional/KeyBlobUpgradeTest.cpp
+++ b/security/keymint/aidl/vts/functional/KeyBlobUpgradeTest.cpp
@@ -258,7 +258,8 @@
if (upgraded_keyblob.empty()) {
std::cerr << "Keyblob '" << name << "' did not require upgrade\n";
- EXPECT_TRUE(!expectUpgrade) << "Keyblob '" << name << "' unexpectedly upgraded";
+ EXPECT_FALSE(expectUpgrade)
+ << "Keyblob '" << name << "' unexpectedly left as-is";
} else {
// Ensure the old format keyblob is deleted (so any secure deletion data is
// cleaned up).
@@ -275,8 +276,7 @@
save_keyblob(subdir, name, upgraded_keyblob, key_characteristics);
// Cert file is left unchanged.
std::cerr << "Keyblob '" << name << "' upgraded\n";
- EXPECT_TRUE(expectUpgrade)
- << "Keyblob '" << name << "' unexpectedly left as-is";
+ EXPECT_TRUE(expectUpgrade) << "Keyblob '" << name << "' unexpectedly upgraded";
}
}
}
diff --git a/security/keymint/aidl/vts/functional/KeyMintTest.cpp b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
index d4adab5..a2e20dc 100644
--- a/security/keymint/aidl/vts/functional/KeyMintTest.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
@@ -8796,10 +8796,11 @@
} // namespace aidl::android::hardware::security::keymint::test
+using aidl::android::hardware::security::keymint::test::KeyMintAidlTestBase;
+
int main(int argc, char** argv) {
std::cout << "Testing ";
- auto halInstances =
- aidl::android::hardware::security::keymint::test::KeyMintAidlTestBase::build_params();
+ auto halInstances = KeyMintAidlTestBase::build_params();
std::cout << "HAL instances:\n";
for (auto& entry : halInstances) {
std::cout << " " << entry << '\n';
@@ -8809,12 +8810,10 @@
for (int i = 1; i < argc; ++i) {
if (argv[i][0] == '-') {
if (std::string(argv[i]) == "--arm_deleteAllKeys") {
- aidl::android::hardware::security::keymint::test::KeyMintAidlTestBase::
- arm_deleteAllKeys = true;
+ KeyMintAidlTestBase::arm_deleteAllKeys = true;
}
if (std::string(argv[i]) == "--dump_attestations") {
- aidl::android::hardware::security::keymint::test::KeyMintAidlTestBase::
- dump_Attestations = true;
+ KeyMintAidlTestBase::dump_Attestations = true;
} else {
std::cout << "NOT dumping attestations" << std::endl;
}
@@ -8829,8 +8828,7 @@
std::cerr << "Missing argument for --keyblob_dir\n";
return 1;
}
- aidl::android::hardware::security::keymint::test::KeyMintAidlTestBase::keyblob_dir =
- std::string(argv[i + 1]);
+ KeyMintAidlTestBase::keyblob_dir = std::string(argv[i + 1]);
++i;
}
if (std::string(argv[i]) == "--expect_upgrade") {
@@ -8839,11 +8837,17 @@
return 1;
}
std::string arg = argv[i + 1];
- aidl::android::hardware::security::keymint::test::KeyMintAidlTestBase::
- expect_upgrade =
- arg == "yes"
- ? true
- : (arg == "no" ? false : std::optional<bool>(std::nullopt));
+ KeyMintAidlTestBase::expect_upgrade =
+ arg == "yes" ? true
+ : (arg == "no" ? false : std::optional<bool>(std::nullopt));
+ if (KeyMintAidlTestBase::expect_upgrade.has_value()) {
+ std::cout << "expect_upgrade = "
+ << (KeyMintAidlTestBase::expect_upgrade.value() ? "true" : "false")
+ << std::endl;
+ } else {
+ std::cerr << "Error! Option --expect_upgrade " << arg << " unrecognized"
+ << std::endl;
+ }
++i;
}
}