Convert VtsHalWifiKeystoreV1_0TargetTest to be gtest
am: 6ba3483656
Change-Id: I7b739bf49bc036d28f9a1644a6dbade5e5304a22
diff --git a/wifi/keystore/1.0/vts/functional/Android.bp b/wifi/keystore/1.0/vts/functional/Android.bp
index b0d398c..b817865 100644
--- a/wifi/keystore/1.0/vts/functional/Android.bp
+++ b/wifi/keystore/1.0/vts/functional/Android.bp
@@ -16,6 +16,7 @@
cc_test {
name: "VtsHalWifiKeystoreV1_0TargetTest",
+ defaults: ["VtsHalTargetTestDefaults"],
srcs: [
"VtsHalWifiKeystoreV1_0TargetTest.cpp",
],
@@ -43,4 +44,10 @@
"-Wall",
"-Werror",
],
+ test_suites: ["general-tests", "vts-core"],
+}
+
+vts_config {
+ name: "VtsHalWifiKeystoreV1_0Target",
+ test_config: "wifi_keystore_target.xml",
}
diff --git a/wifi/keystore/1.0/vts/functional/Android.mk b/wifi/keystore/1.0/vts/functional/Android.mk
deleted file mode 100644
index 7fe4d34..0000000
--- a/wifi/keystore/1.0/vts/functional/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Copyright (C) 2019 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := VtsHalWifiKeystoreV1_0TargetTest
-include test/vts/tools/build/Android.host_config.mk
diff --git a/wifi/keystore/1.0/vts/functional/VtsHalWifiKeystoreV1_0TargetTest.cpp b/wifi/keystore/1.0/vts/functional/VtsHalWifiKeystoreV1_0TargetTest.cpp
index 12096b4..9820a47 100644
--- a/wifi/keystore/1.0/vts/functional/VtsHalWifiKeystoreV1_0TargetTest.cpp
+++ b/wifi/keystore/1.0/vts/functional/VtsHalWifiKeystoreV1_0TargetTest.cpp
@@ -16,12 +16,14 @@
#include <android-base/logging.h>
-#include <VtsHalHidlTargetTestBase.h>
#include <android/security/keystore/IKeystoreService.h>
#include <android/system/wifi/keystore/1.0/IKeystore.h>
#include <binder/IServiceManager.h>
#include <binder/ProcessState.h>
#include <cutils/properties.h>
+#include <gtest/gtest.h>
+#include <hidl/GtestPrinter.h>
+#include <hidl/ServiceManagement.h>
#include <keymasterV4_0/authorization_set.h>
#include <keystore/keystore_promises.h>
#include <private/android_filesystem_config.h>
@@ -53,10 +55,10 @@
};
// The fixture for testing the Wifi Keystore HAL
-class WifiKeystoreHalTest : public Test {
+class WifiKeystoreHalTest : public TestWithParam<std::string> {
protected:
void SetUp() override {
- keystore = IKeystore::getService();
+ keystore = IKeystore::getService(GetParam());
ASSERT_TRUE(keystore);
sp<android::IServiceManager> service_manager = android::defaultServiceManager();
@@ -219,7 +221,7 @@
sp<IKeystoreService> service;
};
-TEST_F(WifiKeystoreHalTest, Sign_nullptr_key_name) {
+TEST_P(WifiKeystoreHalTest, Sign_nullptr_key_name) {
IKeystore::KeystoreStatusCode statusCode;
auto callback = [&statusCode](IKeystore::KeystoreStatusCode status,
@@ -234,7 +236,7 @@
EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
}
-TEST_F(WifiKeystoreHalTest, Sign_empty_key_name) {
+TEST_P(WifiKeystoreHalTest, Sign_empty_key_name) {
IKeystore::KeystoreStatusCode statusCode;
auto callback = [&statusCode](IKeystore::KeystoreStatusCode status,
@@ -249,7 +251,7 @@
EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
}
-TEST_F(WifiKeystoreHalTest, Sign_empty_data) {
+TEST_P(WifiKeystoreHalTest, Sign_empty_data) {
if (!isDebuggableBuild()) {
GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys";
}
@@ -274,7 +276,7 @@
EXPECT_EQ(true, callbackInvoked);
}
-TEST_F(WifiKeystoreHalTest, Sign_wrong_key_purpose) {
+TEST_P(WifiKeystoreHalTest, Sign_wrong_key_purpose) {
if (!isDebuggableBuild()) {
GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys";
}
@@ -297,7 +299,7 @@
EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
}
-TEST_F(WifiKeystoreHalTest, Sign_wrong_key_type) {
+TEST_P(WifiKeystoreHalTest, Sign_wrong_key_type) {
if (!isDebuggableBuild()) {
GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys";
}
@@ -322,7 +324,7 @@
EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
}
-TEST_F(WifiKeystoreHalTest, Sign_success) {
+TEST_P(WifiKeystoreHalTest, Sign_success) {
if (!isDebuggableBuild()) {
GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys";
}
@@ -350,7 +352,7 @@
EXPECT_EQ(result, true);
}
-TEST_F(WifiKeystoreHalTest, GetBlob_null_key_name) {
+TEST_P(WifiKeystoreHalTest, GetBlob_null_key_name) {
IKeystore::KeystoreStatusCode statusCode;
auto callback = [&statusCode](IKeystore::KeystoreStatusCode status,
@@ -365,7 +367,7 @@
EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
}
-TEST_F(WifiKeystoreHalTest, GetBlob_empty_key_name) {
+TEST_P(WifiKeystoreHalTest, GetBlob_empty_key_name) {
IKeystore::KeystoreStatusCode statusCode;
auto callback = [&statusCode](IKeystore::KeystoreStatusCode status,
@@ -380,7 +382,7 @@
EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
}
-TEST_F(WifiKeystoreHalTest, GetBlob_missing_key) {
+TEST_P(WifiKeystoreHalTest, GetBlob_missing_key) {
IKeystore::KeystoreStatusCode statusCode;
auto callback = [&statusCode](IKeystore::KeystoreStatusCode status,
@@ -395,7 +397,7 @@
EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
}
-TEST_F(WifiKeystoreHalTest, GetBlob_wrong_user) {
+TEST_P(WifiKeystoreHalTest, GetBlob_wrong_user) {
if (!isDebuggableBuild()) {
GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys";
}
@@ -418,7 +420,7 @@
EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
}
-TEST_F(WifiKeystoreHalTest, GetBlob_success) {
+TEST_P(WifiKeystoreHalTest, GetBlob_success) {
if (!isDebuggableBuild()) {
GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys";
}
@@ -443,7 +445,7 @@
EXPECT_EQ(result, true);
}
-TEST_F(WifiKeystoreHalTest, GetPublicKey_nullptr_key_name) {
+TEST_P(WifiKeystoreHalTest, GetPublicKey_nullptr_key_name) {
IKeystore::KeystoreStatusCode statusCode;
auto callback = [&statusCode](IKeystore::KeystoreStatusCode status,
@@ -458,7 +460,7 @@
EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
}
-TEST_F(WifiKeystoreHalTest, GetPublicKey_empty_key_name) {
+TEST_P(WifiKeystoreHalTest, GetPublicKey_empty_key_name) {
IKeystore::KeystoreStatusCode statusCode;
auto callback = [&statusCode](IKeystore::KeystoreStatusCode status,
@@ -473,7 +475,7 @@
EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
}
-TEST_F(WifiKeystoreHalTest, GetPublicKey_wrong_key_name) {
+TEST_P(WifiKeystoreHalTest, GetPublicKey_wrong_key_name) {
IKeystore::KeystoreStatusCode statusCode;
auto callback = [&statusCode](IKeystore::KeystoreStatusCode status,
@@ -488,7 +490,7 @@
EXPECT_EQ(IKeystore::KeystoreStatusCode::ERROR_UNKNOWN, statusCode);
}
-TEST_F(WifiKeystoreHalTest, GetPublicKey_wrong_user) {
+TEST_P(WifiKeystoreHalTest, GetPublicKey_wrong_user) {
if (!isDebuggableBuild()) {
GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys";
}
@@ -515,7 +517,7 @@
EXPECT_EQ(result, true);
}
-TEST_F(WifiKeystoreHalTest, GetPublicKey_wrong_key_type) {
+TEST_P(WifiKeystoreHalTest, GetPublicKey_wrong_key_type) {
if (!isDebuggableBuild()) {
GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys";
}
@@ -541,7 +543,7 @@
EXPECT_EQ(result, true);
}
-TEST_F(WifiKeystoreHalTest, GetPublicKey_success) {
+TEST_P(WifiKeystoreHalTest, GetPublicKey_success) {
if (!isDebuggableBuild()) {
GTEST_SKIP() << "Device not running a debuggable build, cannot make test keys";
}
@@ -566,4 +568,9 @@
EXPECT_EQ(result, true);
}
+INSTANTIATE_TEST_SUITE_P(
+ PerInstance, WifiKeystoreHalTest,
+ testing::ValuesIn(android::hardware::getAllHalInstanceNames(IKeystore::descriptor)),
+ android::hardware::PrintInstanceNameToString);
+
} // namespace
diff --git a/wifi/keystore/1.0/vts/functional/AndroidTest.xml b/wifi/keystore/1.0/vts/functional/wifi_keystore_target.xml
similarity index 94%
rename from wifi/keystore/1.0/vts/functional/AndroidTest.xml
rename to wifi/keystore/1.0/vts/functional/wifi_keystore_target.xml
index 1de6db9..6b3cd09 100644
--- a/wifi/keystore/1.0/vts/functional/AndroidTest.xml
+++ b/wifi/keystore/1.0/vts/functional/wifi_keystore_target.xml
@@ -20,10 +20,10 @@
<option name="push-group" value="HalHidlTargetTest.push"/>
</target_preparer>
<test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
- <option name="test-module-name" value="VtsHalWifiKeystoreV1_0TargetTest"/>
+ <option name="test-module-name" value="VtsHalWifiKeystoreV1_0Target"/>
<option name="binary-test-source" value="_32bit::DATA/nativetest/VtsHalWifiKeystoreV1_0TargetTest/VtsHalWifiKeystoreV1_0TargetTest"/>
<option name="binary-test-source" value="_64bit::DATA/nativetest64/VtsHalWifiKeystoreV1_0TargetTest/VtsHalWifiKeystoreV1_0TargetTest"/>
- <option name="binary-test-type" value="hal_hidl_gtest"/>
+ <option name="binary-test-type" value="gtest"/>
<option name="test-timeout" value="5m"/>
</test>
</configuration>