Merge in changes from Khronos Vulkan CTS repository
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / vktInfoTests.cpp
1 /*-------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2016 Google Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Build and Device Tests
22  *//*--------------------------------------------------------------------*/
23
24 #include "vktInfoTests.hpp"
25 #include "vktTestCaseUtil.hpp"
26 #include "vkPlatform.hpp"
27 #include "vkApiVersion.hpp"
28 #include "tcuTestLog.hpp"
29 #include "tcuFormatUtil.hpp"
30 #include "tcuCommandLine.hpp"
31 #include "tcuPlatform.hpp"
32 #include "deStringUtil.hpp"
33
34 namespace vkt
35 {
36
37 namespace
38 {
39
40 using tcu::TestLog;
41 using std::string;
42
43 std::string getOsName (int os)
44 {
45         switch (os)
46         {
47                 case DE_OS_VANILLA:             return "DE_OS_VANILLA";
48                 case DE_OS_WIN32:               return "DE_OS_WIN32";
49                 case DE_OS_UNIX:                return "DE_OS_UNIX";
50                 case DE_OS_WINCE:               return "DE_OS_WINCE";
51                 case DE_OS_OSX:                 return "DE_OS_OSX";
52                 case DE_OS_ANDROID:             return "DE_OS_ANDROID";
53                 case DE_OS_SYMBIAN:             return "DE_OS_SYMBIAN";
54                 case DE_OS_IOS:                 return "DE_OS_IOS";
55                 default:
56                         return de::toString(os);
57         }
58 }
59
60 std::string getCompilerName (int compiler)
61 {
62         switch (compiler)
63         {
64                 case DE_COMPILER_VANILLA:       return "DE_COMPILER_VANILLA";
65                 case DE_COMPILER_MSC:           return "DE_COMPILER_MSC";
66                 case DE_COMPILER_GCC:           return "DE_COMPILER_GCC";
67                 case DE_COMPILER_CLANG:         return "DE_COMPILER_CLANG";
68                 default:
69                         return de::toString(compiler);
70         }
71 }
72
73 std::string getCpuName (int cpu)
74 {
75         switch (cpu)
76         {
77                 case DE_CPU_VANILLA:    return "DE_CPU_VANILLA";
78                 case DE_CPU_ARM:                return "DE_CPU_ARM";
79                 case DE_CPU_X86:                return "DE_CPU_X86";
80                 case DE_CPU_X86_64:             return "DE_CPU_X86_64";
81                 case DE_CPU_ARM_64:             return "DE_CPU_ARM_64";
82                 case DE_CPU_MIPS:               return "DE_CPU_MIPS";
83                 case DE_CPU_MIPS_64:    return "DE_CPU_MIPS_64";
84                 default:
85                         return de::toString(cpu);
86         }
87 }
88
89 std::string getEndiannessName (int endianness)
90 {
91         switch (endianness)
92         {
93                 case DE_BIG_ENDIAN:             return "DE_BIG_ENDIAN";
94                 case DE_LITTLE_ENDIAN:  return "DE_LITTLE_ENDIAN";
95                 default:
96                         return de::toString(endianness);
97         }
98 }
99
100 tcu::TestStatus logBuildInfo (Context& context)
101 {
102 #if defined(DE_DEBUG)
103         const bool      isDebug = true;
104 #else
105         const bool      isDebug = false;
106 #endif
107
108         context.getTestContext().getLog()
109                 << TestLog::Message
110                 << "DE_OS: " << getOsName(DE_OS) << "\n"
111                 << "DE_CPU: " << getCpuName(DE_CPU) << "\n"
112                 << "DE_PTR_SIZE: " << DE_PTR_SIZE << "\n"
113                 << "DE_ENDIANNESS: " << getEndiannessName(DE_ENDIANNESS) << "\n"
114                 << "DE_COMPILER: " << getCompilerName(DE_COMPILER) << "\n"
115                 << "DE_DEBUG: " << (isDebug ? "true" : "false") << "\n"
116                 << TestLog::EndMessage;
117
118         return tcu::TestStatus::pass("Not validated");
119 }
120
121 tcu::TestStatus logDeviceInfo (Context& context)
122 {
123         TestLog&                                                                log                     = context.getTestContext().getLog();
124         const vk::VkPhysicalDeviceProperties&   properties      = context.getDeviceProperties();
125
126         log << TestLog::Message
127                 << "Using --deqp-vk-device-id="
128                 << context.getTestContext().getCommandLine().getVKDeviceId()
129                 << TestLog::EndMessage;
130
131         log << TestLog::Message
132                 << "apiVersion: " << vk::unpackVersion(properties.apiVersion) << "\n"
133                 << "driverVersion: " << tcu::toHex(properties.driverVersion) << "\n"
134                 << "deviceName: " << (const char*)properties.deviceName << "\n"
135                 << "vendorID: " << tcu::toHex(properties.vendorID) << "\n"
136                 << "deviceID: " << tcu::toHex(properties.deviceID) << "\n"
137                 << TestLog::EndMessage;
138
139         return tcu::TestStatus::pass("Not validated");
140 }
141
142 tcu::TestStatus logPlatformInfo (Context& context)
143 {
144         std::ostringstream details;
145
146         context.getTestContext().getPlatform().getVulkanPlatform().describePlatform(details);
147
148         context.getTestContext().getLog()
149                 << TestLog::Message
150                 << details.str()
151                 << TestLog::EndMessage;
152
153         return tcu::TestStatus::pass("Not validated");
154 }
155
156 } // anonymous
157
158 void createInfoTests (tcu::TestCaseGroup* testGroup)
159 {
160         addFunctionCase(testGroup, "build",             "Build Info",           logBuildInfo);
161         addFunctionCase(testGroup, "device",    "Device Info",          logDeviceInfo);
162         addFunctionCase(testGroup, "platform",  "Platform Info",        logPlatformInfo);
163 }
164
165 } // vkt