Merge in first OpenGL ES 3.2 tests
[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  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and/or associated documentation files (the
9  * "Materials"), to deal in the Materials without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Materials, and to
12  * permit persons to whom the Materials are furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice(s) and this permission notice shall be
16  * included in all copies or substantial portions of the Materials.
17  *
18  * The Materials are Confidential Information as defined by the
19  * Khronos Membership Agreement until designated non-confidential by
20  * Khronos, at which point this condition clause shall be removed.
21  *
22  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
26  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
29  *
30  *//*!
31  * \file
32  * \brief Build and Device Tests
33  *//*--------------------------------------------------------------------*/
34
35 #include "vktInfoTests.hpp"
36 #include "vktTestCaseUtil.hpp"
37 #include "vkPlatform.hpp"
38 #include "vkApiVersion.hpp"
39 #include "tcuTestLog.hpp"
40 #include "tcuFormatUtil.hpp"
41 #include "tcuCommandLine.hpp"
42 #include "tcuPlatform.hpp"
43 #include "deStringUtil.hpp"
44
45 namespace vkt
46 {
47
48 namespace
49 {
50
51 using tcu::TestLog;
52 using std::string;
53
54 std::string getOsName (int os)
55 {
56         switch (os)
57         {
58                 case DE_OS_VANILLA:             return "DE_OS_VANILLA";
59                 case DE_OS_WIN32:               return "DE_OS_WIN32";
60                 case DE_OS_UNIX:                return "DE_OS_UNIX";
61                 case DE_OS_WINCE:               return "DE_OS_WINCE";
62                 case DE_OS_OSX:                 return "DE_OS_OSX";
63                 case DE_OS_ANDROID:             return "DE_OS_ANDROID";
64                 case DE_OS_SYMBIAN:             return "DE_OS_SYMBIAN";
65                 case DE_OS_IOS:                 return "DE_OS_IOS";
66                 default:
67                         return de::toString(os);
68         }
69 }
70
71 std::string getCompilerName (int compiler)
72 {
73         switch (compiler)
74         {
75                 case DE_COMPILER_VANILLA:       return "DE_COMPILER_VANILLA";
76                 case DE_COMPILER_MSC:           return "DE_COMPILER_MSC";
77                 case DE_COMPILER_GCC:           return "DE_COMPILER_GCC";
78                 case DE_COMPILER_CLANG:         return "DE_COMPILER_CLANG";
79                 default:
80                         return de::toString(compiler);
81         }
82 }
83
84 std::string getCpuName (int cpu)
85 {
86         switch (cpu)
87         {
88                 case DE_CPU_VANILLA:    return "DE_CPU_VANILLA";
89                 case DE_CPU_ARM:                return "DE_CPU_ARM";
90                 case DE_CPU_X86:                return "DE_CPU_X86";
91                 case DE_CPU_X86_64:             return "DE_CPU_X86_64";
92                 case DE_CPU_ARM_64:             return "DE_CPU_ARM_64";
93                 case DE_CPU_MIPS:               return "DE_CPU_MIPS";
94                 case DE_CPU_MIPS_64:    return "DE_CPU_MIPS_64";
95                 default:
96                         return de::toString(cpu);
97         }
98 }
99
100 std::string getEndiannessName (int endianness)
101 {
102         switch (endianness)
103         {
104                 case DE_BIG_ENDIAN:             return "DE_BIG_ENDIAN";
105                 case DE_LITTLE_ENDIAN:  return "DE_LITTLE_ENDIAN";
106                 default:
107                         return de::toString(endianness);
108         }
109 }
110
111 tcu::TestStatus logBuildInfo (Context& context)
112 {
113 #if defined(DE_DEBUG)
114         const bool      isDebug = true;
115 #else
116         const bool      isDebug = false;
117 #endif
118
119         context.getTestContext().getLog()
120                 << TestLog::Message
121                 << "DE_OS: " << getOsName(DE_OS) << "\n"
122                 << "DE_CPU: " << getCpuName(DE_CPU) << "\n"
123                 << "DE_PTR_SIZE: " << DE_PTR_SIZE << "\n"
124                 << "DE_ENDIANNESS: " << getEndiannessName(DE_ENDIANNESS) << "\n"
125                 << "DE_COMPILER: " << getCompilerName(DE_COMPILER) << "\n"
126                 << "DE_DEBUG: " << (isDebug ? "true" : "false") << "\n"
127                 << TestLog::EndMessage;
128
129         return tcu::TestStatus::pass("Not validated");
130 }
131
132 tcu::TestStatus logDeviceInfo (Context& context)
133 {
134         TestLog&                                                                log                     = context.getTestContext().getLog();
135         const vk::VkPhysicalDeviceProperties&   properties      = context.getDeviceProperties();
136
137         log << TestLog::Message
138                 << "Using --deqp-vk-device-id="
139                 << context.getTestContext().getCommandLine().getVKDeviceId()
140                 << TestLog::EndMessage;
141
142         log << TestLog::Message
143                 << "apiVersion: " << vk::unpackVersion(properties.apiVersion) << "\n"
144                 << "driverVersion: " << tcu::toHex(properties.driverVersion) << "\n"
145                 << "deviceName: " << (const char*)properties.deviceName << "\n"
146                 << "vendorID: " << tcu::toHex(properties.vendorID) << "\n"
147                 << "deviceID: " << tcu::toHex(properties.deviceID) << "\n"
148                 << TestLog::EndMessage;
149
150         return tcu::TestStatus::pass("Not validated");
151 }
152
153 tcu::TestStatus logPlatformInfo (Context& context)
154 {
155         std::ostringstream details;
156
157         context.getTestContext().getPlatform().getVulkanPlatform().describePlatform(details);
158
159         context.getTestContext().getLog()
160                 << TestLog::Message
161                 << details.str()
162                 << TestLog::EndMessage;
163
164         return tcu::TestStatus::pass("Not validated");
165 }
166
167 } // anonymous
168
169 void createInfoTests (tcu::TestCaseGroup* testGroup)
170 {
171         addFunctionCase(testGroup, "build",             "Build Info",           logBuildInfo);
172         addFunctionCase(testGroup, "device",    "Device Info",          logDeviceInfo);
173         addFunctionCase(testGroup, "platform",  "Platform Info",        logPlatformInfo);
174 }
175
176 } // vkt