From c4cd8ed446dbde39df701dab0525e5ef5b9824ec Mon Sep 17 00:00:00 2001 From: Branden Archer Date: Mon, 1 Jul 2019 10:43:52 -0700 Subject: Relax testing under GSI VTS testing on GSI images will no longer occur on userdebug builds. Instead, a user build is used with a boot image containing a rootable adb. There is a change in Keystore that allows root to create test keys on debuggable builds specifically for this VTS test. Without that change the positive test cases will fail, as the test keys cannot be generated. To allow this test to continue working when run against GSI builds, the parts of the test which require debuggable builds are skipped. Test: build/test VtsHalWifiKeystoreV1_0TargetTest on a GSI user build with rootable adb Bug: 135421408 Change-Id: I4f7d29389dc170966e76a6661854cc92d0ea6e7f Merged-In: Ie52e916a658b09eea66ffd9c5f2ac704656f4f3f --- .../VtsHalWifiKeystoreV1_0TargetTest.cpp | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/wifi/keystore/1.0/vts/functional/VtsHalWifiKeystoreV1_0TargetTest.cpp b/wifi/keystore/1.0/vts/functional/VtsHalWifiKeystoreV1_0TargetTest.cpp index 53b6dd01..13a07f89 100644 --- a/wifi/keystore/1.0/vts/functional/VtsHalWifiKeystoreV1_0TargetTest.cpp +++ b/wifi/keystore/1.0/vts/functional/VtsHalWifiKeystoreV1_0TargetTest.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -70,6 +71,18 @@ class WifiKeystoreHalTest : public Test { void TearDown() override { resetState(); } + bool isDebuggableBuild() { + char value[PROPERTY_VALUE_MAX] = {0}; + property_get("ro.system.build.type", value, ""); + if (strcmp(value, "userdebug") == 0) { + return true; + } + if (strcmp(value, "eng") == 0) { + return true; + } + return false; + } + /** * Resets the relevant state of the system between tests */ @@ -237,6 +250,10 @@ TEST_F(WifiKeystoreHalTest, Sign_empty_key_name) { } TEST_F(WifiKeystoreHalTest, Sign_empty_data) { + if (!isDebuggableBuild()) { + GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys"; + } + IKeystore::KeystoreStatusCode statusCode; auto callback = [&statusCode](IKeystore::KeystoreStatusCode status, @@ -255,6 +272,10 @@ TEST_F(WifiKeystoreHalTest, Sign_empty_data) { } TEST_F(WifiKeystoreHalTest, Sign_wrong_key_purpose) { + if (!isDebuggableBuild()) { + GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys"; + } + IKeystore::KeystoreStatusCode statusCode; auto callback = [&statusCode](IKeystore::KeystoreStatusCode status, @@ -274,6 +295,10 @@ TEST_F(WifiKeystoreHalTest, Sign_wrong_key_purpose) { } TEST_F(WifiKeystoreHalTest, Sign_wrong_key_type) { + if (!isDebuggableBuild()) { + GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys"; + } + IKeystore::KeystoreStatusCode statusCode; auto callback = [&statusCode](IKeystore::KeystoreStatusCode status, @@ -295,6 +320,10 @@ TEST_F(WifiKeystoreHalTest, Sign_wrong_key_type) { } TEST_F(WifiKeystoreHalTest, Sign_success) { + if (!isDebuggableBuild()) { + GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys"; + } + IKeystore::KeystoreStatusCode statusCode; auto callback = [&statusCode](IKeystore::KeystoreStatusCode status, @@ -364,6 +393,10 @@ TEST_F(WifiKeystoreHalTest, GetBlob_missing_key) { } TEST_F(WifiKeystoreHalTest, GetBlob_wrong_user) { + if (!isDebuggableBuild()) { + GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys"; + } + IKeystore::KeystoreStatusCode statusCode; auto callback = [&statusCode](IKeystore::KeystoreStatusCode status, @@ -383,6 +416,10 @@ TEST_F(WifiKeystoreHalTest, GetBlob_wrong_user) { } TEST_F(WifiKeystoreHalTest, GetBlob_success) { + if (!isDebuggableBuild()) { + GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys"; + } + IKeystore::KeystoreStatusCode statusCode; auto callback = [&statusCode](IKeystore::KeystoreStatusCode status, @@ -449,6 +486,10 @@ TEST_F(WifiKeystoreHalTest, GetPublicKey_wrong_key_name) { } TEST_F(WifiKeystoreHalTest, GetPublicKey_wrong_user) { + if (!isDebuggableBuild()) { + GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys"; + } + IKeystore::KeystoreStatusCode statusCode; auto callback = [&statusCode](IKeystore::KeystoreStatusCode status, @@ -472,6 +513,10 @@ TEST_F(WifiKeystoreHalTest, GetPublicKey_wrong_user) { } TEST_F(WifiKeystoreHalTest, GetPublicKey_wrong_key_type) { + if (!isDebuggableBuild()) { + GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys"; + } + IKeystore::KeystoreStatusCode statusCode; auto callback = [&statusCode](IKeystore::KeystoreStatusCode status, @@ -494,6 +539,10 @@ TEST_F(WifiKeystoreHalTest, GetPublicKey_wrong_key_type) { } TEST_F(WifiKeystoreHalTest, GetPublicKey_success) { + if (!isDebuggableBuild()) { + GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys"; + } + IKeystore::KeystoreStatusCode statusCode; auto callback = [&statusCode](IKeystore::KeystoreStatusCode status, -- cgit v1.2.3