1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
4 *
5 * Copyright (c) 2016 Google Inc.
6 * Copyright (c) 2016 The Khronos Group Inc.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */ /*!
21 * \file
22 * \brief Test config list case.
23 */ /*-------------------------------------------------------------------*/
24
25 #include "glcConfigListCase.hpp"
26 #include "glcConfigList.hpp"
27 #include "tcuTestLog.hpp"
28
29 namespace glcts
30 {
31
32 using std::vector;
33 using tcu::TestLog;
34
getConfigTypeName(ConfigType type)35 static const char *getConfigTypeName(ConfigType type)
36 {
37 switch (type)
38 {
39 case CONFIGTYPE_DEFAULT:
40 return "default";
41 case CONFIGTYPE_EGL:
42 return "EGL";
43 case CONFIGTYPE_WGL:
44 return "WGL";
45 default:
46 throw tcu::Exception("Unknown config type");
47 }
48 }
49
getExcludeReasonName(ExcludeReason reason)50 static const char *getExcludeReasonName(ExcludeReason reason)
51 {
52 switch (reason)
53 {
54 case EXCLUDEREASON_NOT_COMPATIBLE:
55 return "Not compatible";
56 case EXCLUDEREASON_NOT_CONFORMANT:
57 return "Not conformant";
58 case EXCLUDEREASON_MSAA:
59 return "Multisampled: Not testable";
60 case EXCLUDEREASON_FLOAT:
61 return "Float configs: Not testable";
62 case EXCLUDEREASON_YUV:
63 return "YUV: Not testable";
64 default:
65 throw tcu::Exception("Unknown exclude reason");
66 }
67 }
68
getSurfaceTypeName(tcu::SurfaceType type)69 static const char *getSurfaceTypeName(tcu::SurfaceType type)
70 {
71 switch (type)
72 {
73 case tcu::SURFACETYPE_WINDOW:
74 return "window";
75 case tcu::SURFACETYPE_OFFSCREEN_NATIVE:
76 return "pixmap";
77 case tcu::SURFACETYPE_OFFSCREEN_GENERIC:
78 return "pbuffer";
79 default:
80 throw tcu::Exception("Unknown surface type");
81 }
82 }
83
84 struct SurfaceBitsFmt
85 {
86 uint32_t bits;
87
SurfaceBitsFmtglcts::SurfaceBitsFmt88 SurfaceBitsFmt(uint32_t bits_) : bits(bits_)
89 {
90 }
91 };
92
operator <<(std::ostream & str,const SurfaceBitsFmt & bits)93 std::ostream &operator<<(std::ostream &str, const SurfaceBitsFmt &bits)
94 {
95 static const tcu::SurfaceType s_types[] = {tcu::SURFACETYPE_WINDOW, tcu::SURFACETYPE_OFFSCREEN_NATIVE,
96 tcu::SURFACETYPE_OFFSCREEN_GENERIC};
97
98 bool isFirst = true;
99 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_types); ndx++)
100 {
101 if (bits.bits & (1 << s_types[ndx]))
102 {
103 if (!isFirst)
104 str << ", ";
105 str << getSurfaceTypeName(s_types[ndx]);
106 isFirst = false;
107 }
108 }
109
110 return str;
111 }
112
ConfigListCase(tcu::TestContext & testCtx,const char * name,const char * description,glu::ApiType type)113 ConfigListCase::ConfigListCase(tcu::TestContext &testCtx, const char *name, const char *description, glu::ApiType type)
114 : TestCase(testCtx, name, description)
115 , m_ctxType(type)
116 {
117 }
118
~ConfigListCase(void)119 ConfigListCase::~ConfigListCase(void)
120 {
121 }
122
iterate(void)123 ConfigListCase::IterateResult ConfigListCase::iterate(void)
124 {
125 TestLog &log = m_testCtx.getLog();
126 ConfigList configs;
127
128 getDefaultConfigList(m_testCtx.getPlatform(), m_ctxType, configs);
129
130 // Valid configs.
131 {
132 tcu::ScopedLogSection configSection(log, "Configs", "Configs");
133
134 for (vector<Config>::const_iterator cfgIter = configs.configs.begin(); cfgIter != configs.configs.end();
135 cfgIter++)
136 log << TestLog::Message << getConfigTypeName(cfgIter->type) << "(" << cfgIter->id
137 << "): " << SurfaceBitsFmt(cfgIter->surfaceTypes) << TestLog::EndMessage;
138 }
139
140 // Excluded configs.
141 {
142 tcu::ScopedLogSection excludedSection(log, "ExcludedConfigs", "Excluded configs");
143
144 for (vector<ExcludedConfig>::const_iterator cfgIter = configs.excludedConfigs.begin();
145 cfgIter != configs.excludedConfigs.end(); cfgIter++)
146 log << TestLog::Message << getConfigTypeName(cfgIter->type) << "(" << cfgIter->id
147 << "): " << getExcludeReasonName(cfgIter->reason) << TestLog::EndMessage;
148 }
149
150 // Totals.
151 int numValid = (int)configs.configs.size();
152 int numNotCompatible = 0;
153 int numNotConformant = 0;
154
155 for (vector<ExcludedConfig>::const_iterator cfgIter = configs.excludedConfigs.begin();
156 cfgIter != configs.excludedConfigs.end(); cfgIter++)
157 (cfgIter->reason == EXCLUDEREASON_NOT_CONFORMANT ? numNotConformant : numNotCompatible) += 1;
158
159 log << TestLog::Message << numValid << " valid, " << numNotConformant << " non-conformant and " << numNotCompatible
160 << " non-compatible configs" << TestLog::EndMessage;
161
162 bool configCountOk = numValid >= numNotConformant;
163 m_testCtx.setTestResult(configCountOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
164 configCountOk ? "Pass" : "Too many non-conformant configs");
165
166 return STOP;
167 }
168
169 } // namespace glcts
170