Added VK_KHR_driver_properties test
- Convert FunctionalTest into a DeviceSuite to organize tests better.
- Added gson for parsing cmd gpu vkjson
- Added truth for better assert
- Added truth and other missing files to gamecore.zip
Test: added VkjsonTests
Change-Id: I3223b5f9d9610312bedc3afb8f35ca0a9d268365
diff --git a/Android.mk b/Android.mk
index ca29ddc..9923f4a 100644
--- a/Android.mk
+++ b/Android.mk
@@ -16,10 +16,13 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
-gamecore_dist_host_jar := GameQualificationHelperHost GameQualificationHost
+gamecore_dist_host_jar := GameQualificationHelperHost GameQualificationHost truth-prebuilt
gamecore_dist_host_jar_files := $(foreach m, $(gamecore_dist_host_jar), $(HOST_OUT_JAVA_LIBRARIES)/$(m).jar)
-gamecore_dist_test_apk := GameQualificationDevice GameQualificationSampleApp GameQualificationJavaTestCases
+gamecore_dist_test_exe := GameQualificationNativeTestCases
+gamecore_dist_test_exe_files := $(foreach m, $(gamecore_dist_test_exe), $(TARGET_OUT_TESTCASES)/$(m)/$(TARGET_ARCH)/$(m))
+
+gamecore_dist_test_apk := GameQualificationDevice GameQualificationSampleApp GameQualificationJavaTestCases GameQualificationAllocstress
gamecore_dist_test_apk_files := $(foreach m, $(gamecore_dist_test_apk), $(TARGET_OUT_DATA_APPS)/$(m)/$(m).apk)
gamecore_dist_intermediates := $(call intermediates-dir-for,PACKAGING,gamecore_dist,HOST,COMMON)
@@ -36,6 +39,7 @@
$(LOCAL_PATH)/AndroidTest.xml \
$(gamecore_dist_host_jar_files) \
$(gamecore_dist_test_apk_files) \
+ $(gamecore_dist_test_exe_files) \
$(tradefed_files)
$(gamecore_dist_zip) : $(gamecore_dist_files)
diff --git a/AndroidTest.xml b/AndroidTest.xml
index 98945b9..ced190e 100644
--- a/AndroidTest.xml
+++ b/AndroidTest.xml
@@ -25,8 +25,9 @@
<test class="com.android.tradefed.testtype.InstrumentationTest" >
<option name="package" value="com.android.game.qualification.tests" />
</test>
+
<test class="com.android.tradefed.testtype.HostTest" >
- <option name="class" value="com.android.game.qualification.test.FunctionalTests" />
+ <option name="class" value="com.android.game.qualification.test.FunctionalTestSuite" />
</test>
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
diff --git a/hostside/Android.mk b/hostside/Android.mk
index 2d503f3..23a845e 100644
--- a/hostside/Android.mk
+++ b/hostside/Android.mk
@@ -24,7 +24,9 @@
LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := tradefed GameQualificationHelperHost
+LOCAL_JAVA_LIBRARIES := tradefed GameQualificationHelperHost truth-prebuilt
+
+LOCAL_STATIC_JAVA_LIBARIES = gson-prebuilt-jar
LOCAL_COMPATIBILITY_SUITE := general-tests
diff --git a/hostside/src/com/android/game/qualification/test/FunctionalTests.java b/hostside/src/com/android/game/qualification/test/DeviceConfigurationTest.java
similarity index 75%
rename from hostside/src/com/android/game/qualification/test/FunctionalTests.java
rename to hostside/src/com/android/game/qualification/test/DeviceConfigurationTest.java
index e469c2e..0f6d118 100644
--- a/hostside/src/com/android/game/qualification/test/FunctionalTests.java
+++ b/hostside/src/com/android/game/qualification/test/DeviceConfigurationTest.java
@@ -15,27 +15,18 @@
*/
package com.android.game.qualification.test;
-import org.junit.runner.RunWith;
-import org.junit.Test;
-import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
-import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import static org.junit.Assert.assertEquals;
+
import static org.junit.Assert.assertTrue;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
@RunWith(DeviceJUnit4ClassRunner.class)
-public class FunctionalTests extends BaseHostJUnit4Test {
-
- private final String GOOGLE_DISPLAY_TIMING_EXTENSION_NAME = "VK_GOOGLE_display_timing";
-
- @Test
- public void testExposesDisplayTimingExtension()
- throws DeviceNotAvailableException {
- String vulkanCapabilities = getDevice().executeShellCommand("cmd gpu vkjson");
-
- assertTrue(vulkanCapabilities.contains(GOOGLE_DISPLAY_TIMING_EXTENSION_NAME));
- }
-
+public class DeviceConfigurationTest extends BaseHostJUnit4Test {
@Test
public void testConfigHzHighEnough()
throws DeviceNotAvailableException {
diff --git a/hostside/src/com/android/game/qualification/test/FunctionalTestSuite.java b/hostside/src/com/android/game/qualification/test/FunctionalTestSuite.java
new file mode 100644
index 0000000..ba8613c
--- /dev/null
+++ b/hostside/src/com/android/game/qualification/test/FunctionalTestSuite.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+package com.android.game.qualification.test;
+
+import com.android.tradefed.testtype.DeviceSuite;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(DeviceSuite.class)
+@SuiteClasses({
+ DeviceConfigurationTest.class,
+ VkJsonTests.class
+})
+public class FunctionalTestSuite {
+ // empty on purpose
+}
diff --git a/hostside/src/com/android/game/qualification/test/VkJsonTests.java b/hostside/src/com/android/game/qualification/test/VkJsonTests.java
new file mode 100644
index 0000000..7741fa7
--- /dev/null
+++ b/hostside/src/com/android/game/qualification/test/VkJsonTests.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+package com.android.game.qualification.test;
+
+import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
+
+import com.google.gson.Gson;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class VkJsonTests extends BaseHostJUnit4Test {
+ // *** BEGIN CLASSES FOR GSON ***
+ // Classes to be used with GSON. The structure follows the output of 'cmd gpu vkjson', which is
+ // format is defined in /frameworks/native/vulkan/vkjson/vkjson.cc
+ private static class VkJson {
+ List<VkJsonDevice> devices;
+ }
+
+ private static class VkJsonDevice {
+ VkJsonExtDriverProperties VK_KHR_driver_properties;
+ List<VkExtension> extensions;
+ }
+
+ private static class VkJsonExtDriverProperties {
+ VkPhysicalDeviceDriverPropertiesKHR driverPropertiesKHR;
+ }
+
+ private static class VkPhysicalDeviceDriverPropertiesKHR {
+ Long driverID;
+ String driverName;
+ String driverInfo;
+ VkConformanceVersionKHR conformanceVersion;
+ }
+
+ private static class VkConformanceVersionKHR {
+ Short major;
+ Short minor;
+ Short subminor;
+ Short patch;
+ }
+
+ private static class VkExtension {
+ String extensionName;
+ Integer specVersion;
+ }
+ // *** END CLASSES FOR GSON ***
+
+ private VkJson mVkJson;
+
+ @Before
+ public void setUp() throws DeviceNotAvailableException {
+ String cmdString = getDevice().executeShellCommand("cmd gpu vkjson");
+ Gson gson = new Gson();
+ mVkJson = gson.fromJson(cmdString, VkJson.class);
+
+ assertThat(mVkJson.devices).isNotNull();
+ assertThat(mVkJson.devices).isNotEmpty();
+ }
+
+ @Test
+ public void checkRequiredExtensions() {
+ final Collection<String> REQUIRED_EXTENSIONS = Arrays.asList(
+ "VK_GOOGLE_display_timing",
+ "VK_KHR_driver_properties");
+
+ List<String> extensions = mVkJson.devices.get(0).extensions.stream()
+ .map(it -> it.extensionName)
+ .collect(Collectors.toList());
+ assertWithMessage("Required Vulkan extensions are not supported")
+ .that(extensions)
+ .named("supported extensions")
+ .containsAllIn(REQUIRED_EXTENSIONS);
+ }
+
+ @Test
+ public void checkKHRDriverProperties() {
+ // Check driver conformance version is at least 1.1.2.
+ final short MAJOR = 1;
+ final short MINOR = 1;
+ final short SUBMINOR = 2;
+ final String DRIVER_CONFORMANCE_VERSION = MAJOR + "." + MINOR + "." + SUBMINOR;
+
+ assertWithMessage("VK_KHR_driver_properties is not supported")
+ .that(mVkJson.devices.get(0).VK_KHR_driver_properties)
+ .named("VK_KHR_driver_properties")
+ .isNotNull();
+
+ VkPhysicalDeviceDriverPropertiesKHR properties =
+ mVkJson.devices.get(0).VK_KHR_driver_properties.driverPropertiesKHR;
+ assertWithMessage("VK_KHR_driver_properties is not supported")
+ .that(properties).named("driverPropertiesKHR").isNotNull();
+
+ VkConformanceVersionKHR version = properties.conformanceVersion;
+ assertThat(version).named("driverPropertiesKHR.conformanceVersion").isNotNull();
+
+ String msg = "Driver conformance version must be at least " + DRIVER_CONFORMANCE_VERSION;
+ assertWithMessage(msg).that(version.major).named("major version").isAtLeast(MAJOR);
+ if (version.major == MAJOR) {
+ assertWithMessage(msg).that(version.minor).named("minor version").isAtLeast(MINOR);
+ if (version.minor == MINOR) {
+ assertWithMessage(msg).that(version.subminor).named("subminor version")
+ .isAtLeast(SUBMINOR);
+ }
+ }
+ }
+}