xref: /aosp_15_r20/external/deqp/modules/gles3/functional/es3fApiCase.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.0 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
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 API test case.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es3fApiCase.hpp"
25 #include "gluStrUtil.hpp"
26 #include "gluRenderContext.hpp"
27 
28 #include <algorithm>
29 
30 using std::string;
31 using std::vector;
32 
33 namespace deqp
34 {
35 namespace gles3
36 {
37 namespace Functional
38 {
39 
40 using tcu::TestLog;
41 
ApiCase(Context & context,const char * name,const char * description)42 ApiCase::ApiCase(Context &context, const char *name, const char *description)
43     : TestCase(context, name, description)
44     , CallLogWrapper(context.getRenderContext().getFunctions(), context.getTestContext().getLog())
45     , m_log(getLog())
46 {
47 }
48 
~ApiCase(void)49 ApiCase::~ApiCase(void)
50 {
51 }
52 
iterate(void)53 ApiCase::IterateResult ApiCase::iterate(void)
54 {
55     // Initialize result to pass.
56     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
57 
58     // Enable call logging.
59     enableLogging(true);
60 
61     // Run test.
62     test();
63 
64     return STOP;
65 }
66 
expectError(uint32_t expected)67 void ApiCase::expectError(uint32_t expected)
68 {
69     uint32_t err = glGetError();
70     if (err != expected)
71     {
72         m_log << TestLog::Message << "// ERROR: expected " << glu::getErrorStr(expected) << TestLog::EndMessage;
73         if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
74             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid error");
75     }
76 }
77 
expectError(uint32_t expected0,uint32_t expected1)78 void ApiCase::expectError(uint32_t expected0, uint32_t expected1)
79 {
80     uint32_t err = glGetError();
81     if (err != expected0 && err != expected1)
82     {
83         m_log << TestLog::Message << "// ERROR: expected " << glu::getErrorStr(expected0) << " or "
84               << glu::getErrorStr(expected1) << TestLog::EndMessage;
85         if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
86             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid error");
87     }
88 }
89 
checkBooleans(uint8_t value,uint8_t expected)90 void ApiCase::checkBooleans(uint8_t value, uint8_t expected)
91 {
92     checkBooleans((int32_t)value, expected);
93 }
94 
checkBooleans(int32_t value,uint8_t expected)95 void ApiCase::checkBooleans(int32_t value, uint8_t expected)
96 {
97     if (value != (int32_t)expected)
98     {
99         m_log << TestLog::Message << "// ERROR: expected " << (expected ? "GL_TRUE" : "GL_FALSE")
100               << TestLog::EndMessage;
101         if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
102             m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
103     }
104 }
105 
getSupportedExtensions(const uint32_t numSupportedValues,const uint32_t extension,std::vector<int> & values)106 void ApiCase::getSupportedExtensions(const uint32_t numSupportedValues, const uint32_t extension,
107                                      std::vector<int> &values)
108 {
109     int32_t numFormats;
110     GLU_CHECK_CALL(glGetIntegerv(numSupportedValues, &numFormats));
111     if (numFormats == 0)
112     {
113         m_log << TestLog::Message << "// No supported extensions available." << TestLog::EndMessage;
114         return;
115     }
116     values.resize(numFormats);
117     GLU_CHECK_CALL(glGetIntegerv(extension, &values[0]));
118 }
119 
120 } // namespace Functional
121 } // namespace gles3
122 } // namespace deqp
123