1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.1 Module
3 * -------------------------------------------------
5 * Copyright 2015 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Info log query shared utilities
22 *//*--------------------------------------------------------------------*/
24 #include "es31fInfoLogQueryShared.hpp"
25 #include "glsStateQueryUtil.hpp"
26 #include "tcuTestLog.hpp"
27 #include "glwEnums.hpp"
28 #include "gluStrUtil.hpp"
39 void verifyInfoLogQuery (tcu::ResultCollector& result,
40 glu::CallLogWrapper& gl,
43 void (glu::CallLogWrapper::* getInfoLog)(glw::GLuint, glw::GLsizei, glw::GLsizei*, glw::GLchar*),
44 const char* getterName)
47 const tcu::ScopedLogSection section (gl.getLog(), "QueryAll", "Query all");
48 std::string buf (logLen + 2, 'X');
50 buf[logLen + 1] = '\0';
51 (gl.*getInfoLog)(object, logLen, DE_NULL, &buf[0]);
52 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), getterName);
54 if (logLen > 0 && buf[logLen-1] != '\0')
55 result.fail("Return buffer was not INFO_LOG_LENGTH sized and null-terminated");
56 else if (buf[logLen] != 'X' && buf[logLen+1] != '\0')
57 result.fail("Buffer end guard modified, query wrote over the end of the buffer.");
61 const tcu::ScopedLogSection section (gl.getLog(), "QueryMore", "Query more");
62 std::string buf (logLen + 4, 'X');
65 buf[logLen + 3] = '\0';
66 (gl.*getInfoLog)(object, logLen+2, &written, &buf[0]);
67 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), getterName);
70 result.fail("'length' was not written to");
71 else if (buf[written] != '\0')
72 result.fail("Either length was incorrect or result was not null-terminated");
73 else if (logLen != 0 && (written + 1) > logLen)
74 result.fail("'length' characters + null terminator is larger than INFO_LOG_LENGTH");
75 else if ((written + 1) < logLen)
76 result.fail("'length' is not consistent with INFO_LOG_LENGTH");
77 else if (buf[logLen+2] != 'X' && buf[logLen+3] != '\0')
78 result.fail("Buffer end guard modified, query wrote over the end of the buffer.");
79 else if (written != (int)strlen(&buf[0]))
80 result.fail("'length' and written string length do not match");
85 const tcu::ScopedLogSection section (gl.getLog(), "QueryLess", "Query less");
86 std::string buf (logLen + 2, 'X');
89 (gl.*getInfoLog)(object, 2, &written, &buf[0]);
90 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), getterName);
93 result.fail("'length' was not written to");
94 else if (written != 1)
95 result.fail("Expected 'length' = 1");
96 else if (buf[1] != '\0')
97 result.fail("Expected null terminator at index 1");
102 const tcu::ScopedLogSection section (gl.getLog(), "QueryOne", "Query one character");
103 std::string buf (logLen + 2, 'X');
106 (gl.*getInfoLog)(object, 1, &written, &buf[0]);
107 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), getterName);
110 result.fail("'length' was not written to");
111 else if (written != 0)
112 result.fail("Expected 'length' = 0");
113 else if (buf[0] != '\0')
114 result.fail("Expected null terminator at index 0");
118 const tcu::ScopedLogSection section (gl.getLog(), "QueryNone", "Query to zero-sized buffer");
119 std::string buf (logLen + 2, 'X');
122 (gl.*getInfoLog)(object, 0, &written, &buf[0]);
123 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), getterName);
126 result.fail("'length' was not written to");
127 else if (written != 0)
128 result.fail("Expected 'length' = 0");
129 else if (buf[0] != 'X')
130 result.fail("Unexpected buffer mutation at index 0");