Example #1
0
/*--------------------------------------------------------------------*//*!
 * \brief Write a OpenGL ES shader into the log.
 * \param type				Shader type
 * \param source			Shader source
 * \param compileOk			Shader compilation result, false on failure
 * \param infoLog			Implementation provided shader compilation log
 *//*--------------------------------------------------------------------*/
deBool qpTestLog_writeShader (qpTestLog* log, qpShaderType type, const char* source, deBool compileOk, const char* infoLog)
{
	const char*		tagName				= QP_LOOKUP_STRING(s_qpShaderTypeMap, type);
	const char*		sourceStr			= ((log->flags & QP_TEST_LOG_EXCLUDE_SHADER_SOURCES) == 0 || !compileOk) ? source : "";
	int				numShaderAttribs	= 0;
	qpXmlAttribute	shaderAttribs[4];

	deMutex_lock(log->lock);

	DE_ASSERT(source);
	DE_ASSERT(ContainerStack_getTop(&log->containerStack) == CONTAINERTYPE_SHADERPROGRAM);

	shaderAttribs[numShaderAttribs++]	= qpSetStringAttrib("CompileStatus", compileOk ? "OK" : "Fail");

	if (!qpXmlWriter_startElement(log->writer, tagName, numShaderAttribs, shaderAttribs) ||
		!qpXmlWriter_writeStringElement(log->writer, "ShaderSource", sourceStr) ||
		!qpXmlWriter_writeStringElement(log->writer, "InfoLog", infoLog) ||
		!qpXmlWriter_endElement(log->writer, tagName))
	{
		qpPrintf("qpTestLog_writeShader(): Writing XML failed\n");
		deMutex_unlock(log->lock);
		return DE_FALSE;
	}

	deMutex_unlock(log->lock);
	return DE_TRUE;
}
Example #2
0
static deBool qpTestLog_writeKeyValuePair (qpTestLog* log, const char* elementName, const char* name, const char* description, const char* unit, qpKeyValueTag tag, const char* text)
{
	const char*		tagString = QP_LOOKUP_STRING(s_qpTagMap, tag);
	qpXmlAttribute	attribs[8];
	int				numAttribs = 0;

	DE_ASSERT(log && elementName && text);
	deMutex_lock(log->lock);

	/* Fill in attributes. */
	if (name)			attribs[numAttribs++] = qpSetStringAttrib("Name", name);
	if (description)	attribs[numAttribs++] = qpSetStringAttrib("Description", description);
	if (tagString)		attribs[numAttribs++] = qpSetStringAttrib("Tag", tagString);
	if (unit)			attribs[numAttribs++] = qpSetStringAttrib("Unit", unit);

	if (!qpXmlWriter_startElement(log->writer, elementName, numAttribs, attribs) ||
		!qpXmlWriter_writeString(log->writer, text) ||
		!qpXmlWriter_endElement(log->writer, elementName))
	{
		qpPrintf("qpTestLog_writeKeyValuePair(): Writing XML failed\n");
		deMutex_unlock(log->lock);
		return DE_FALSE;
	}

	deMutex_unlock(log->lock);
	return DE_TRUE;
}
Example #3
0
/*--------------------------------------------------------------------*//*!
 * \brief Abrupt termination of logging.
 * \param log		qpTestLog instance
 * \param result	Result code, only Crash and Timeout are allowed.
 * \return true if ok, false otherwise
 *//*--------------------------------------------------------------------*/
deBool qpTestLog_terminateCase (qpTestLog* log, qpTestResult result)
{
	const char* resultStr = QP_LOOKUP_STRING(s_qpTestResultMap, result);

	DE_ASSERT(log);
	DE_ASSERT(result == QP_TEST_RESULT_CRASH || result == QP_TEST_RESULT_TIMEOUT);

	deMutex_lock(log->lock);

	if (!log->isCaseOpen)
	{
		deMutex_unlock(log->lock);
		return DE_FALSE; /* Soft error. This is called from error handler. */
	}

	/* Flush XML and write #terminateTestCaseResult. */
	qpXmlWriter_flush(log->writer);
	fprintf(log->outputFile, "\n#terminateTestCaseResult %s\n", resultStr);
	qpTestLog_flushFile(log);

	log->isCaseOpen = DE_FALSE;

#if defined(DE_DEBUG)
	ContainerStack_reset(&log->containerStack);
#endif

	deMutex_unlock(log->lock);
	return DE_TRUE;
}
Example #4
0
/*--------------------------------------------------------------------*//*!
 * \brief Log end of test case
 * \param log qpTestLog instance
 * \param result Test result
 * \param description Description of a problem in case of error
 * \return true if ok, false otherwise
 *//*--------------------------------------------------------------------*/
deBool qpTestLog_endCase (qpTestLog* log, qpTestResult result, const char* resultDetails)
{
	const char*		statusStr		= QP_LOOKUP_STRING(s_qpTestResultMap, result);
	qpXmlAttribute	statusAttrib	= qpSetStringAttrib("StatusCode", statusStr);

	deMutex_lock(log->lock);

	DE_ASSERT(log->isCaseOpen);
	DE_ASSERT(ContainerStack_isEmpty(&log->containerStack));

	/* <Result StatusCode="Pass">Result details</Result>
	 * </TestCaseResult>
	 */
	if (!qpXmlWriter_startElement(log->writer, "Result", 1, &statusAttrib) ||
		(resultDetails && !qpXmlWriter_writeString(log->writer, resultDetails)) ||
		!qpXmlWriter_endElement(log->writer, "Result") ||
		!qpXmlWriter_endElement(log->writer, "TestCaseResult") ||
		!qpXmlWriter_endDocument(log->writer))		/* Close any XML elements still open */
	{
		qpPrintf("qpTestLog_endCase(): Writing XML failed\n");
		deMutex_unlock(log->lock);
		return DE_FALSE;
	}

	/* Flush XML and write #endTestCaseResult. */
	qpXmlWriter_flush(log->writer);
	fprintf(log->outputFile, "\n#endTestCaseResult\n");
	if (!(log->flags & QP_TEST_LOG_NO_FLUSH))
		qpTestLog_flushFile(log);

	log->isCaseOpen = DE_FALSE;

	deMutex_unlock(log->lock);
	return DE_TRUE;
}
Example #5
0
deBool qpTestLog_writeValueInfo (qpTestLog* log, const char* name, const char* description, const char* unit, qpSampleValueTag tag)
{
	const char*		tagName		= QP_LOOKUP_STRING(s_qpSampleValueTagMap, tag);
	int				numAttribs	= 0;
	qpXmlAttribute	attribs[4];

	DE_ASSERT(log && name && description && tagName);
	deMutex_lock(log->lock);

	DE_ASSERT(ContainerStack_getTop(&log->containerStack) == CONTAINERTYPE_SAMPLEINFO);

	attribs[numAttribs++] = qpSetStringAttrib("Name", name);
	attribs[numAttribs++] = qpSetStringAttrib("Description", description);
	attribs[numAttribs++] = qpSetStringAttrib("Tag", tagName);

	if (unit)
		attribs[numAttribs++] = qpSetStringAttrib("Unit", unit);

	if (!qpXmlWriter_startElement(log->writer, "ValueInfo", numAttribs, attribs) ||
		!qpXmlWriter_endElement(log->writer, "ValueInfo"))
	{
		qpPrintf("qpTestLog_writeValueInfo(): Writing XML failed\n");
		deMutex_unlock(log->lock);
		return DE_FALSE;
	}

	deMutex_unlock(log->lock);
	return DE_TRUE;
}
Example #6
0
/*--------------------------------------------------------------------*//*!
 * \brief Log start of test case
 * \param log qpTestLog instance
 * \param testCasePath	Full test case path (as seen in Candy).
 * \param testCaseType	Test case type
 * \return true if ok, false otherwise
 *//*--------------------------------------------------------------------*/
deBool qpTestLog_startCase (qpTestLog* log, const char* testCasePath, qpTestCaseType testCaseType)
{
	const char*		typeStr				= QP_LOOKUP_STRING(s_qpTestTypeMap, testCaseType);
	int				numResultAttribs	= 0;
	qpXmlAttribute	resultAttribs[8];

	DE_ASSERT(log && testCasePath && (testCasePath[0] != 0));
	deMutex_lock(log->lock);

	DE_ASSERT(!log->isCaseOpen);
	DE_ASSERT(ContainerStack_isEmpty(&log->containerStack));

	/* Flush XML and write out #beginTestCaseResult. */
	qpXmlWriter_flush(log->writer);
	fprintf(log->outputFile, "\n#beginTestCaseResult %s\n", testCasePath);
	qpTestLog_flushFile(log);

	log->isCaseOpen = DE_TRUE;

	/* Fill in attributes. */
	resultAttribs[numResultAttribs++] = qpSetStringAttrib("Version", LOG_FORMAT_VERSION);
	resultAttribs[numResultAttribs++] = qpSetStringAttrib("CasePath", testCasePath);
	resultAttribs[numResultAttribs++] = qpSetStringAttrib("CaseType", typeStr);

	if (!qpXmlWriter_startDocument(log->writer) ||
		!qpXmlWriter_startElement(log->writer, "TestCaseResult", numResultAttribs, resultAttribs))
	{
		qpPrintf("qpTestLog_startCase(): Writing XML failed\n");
		deMutex_unlock(log->lock);
		return DE_FALSE;
	}

	deMutex_unlock(log->lock);
	return DE_TRUE;
}
Example #7
0
/*--------------------------------------------------------------------*//*!
 * \brief Write base64 encoded raw image data into log
 * \param log				qpTestLog instance
 * \param name				Unique name (matching names can be compared across BatchResults).
 * \param description		Textual description (shown in Candy).
 * \param compressionMode	Compression mode
 * \param imageFormat		Color format
 * \param width				Width in pixels
 * \param height			Height in pixels
 * \param stride			Data stride (offset between rows)
 * \param data				Pointer to pixel data
 * \return 0 if OK, otherwise <0
 *//*--------------------------------------------------------------------*/
deBool qpTestLog_writeImage	(
	qpTestLog*				log,
	const char*				name,
	const char*				description,
	qpImageCompressionMode	compressionMode,
	qpImageFormat			imageFormat,
	int						width,
	int						height,
	int						stride,
	const void*				data)
{
	char			widthStr[32];
	char			heightStr[32];
	qpXmlAttribute	attribs[8];
	int				numAttribs			= 0;
	Buffer			compressedBuffer;
	const void*		writeDataPtr		= DE_NULL;
	size_t			writeDataBytes		= ~(size_t)0;

	DE_ASSERT(log && name);
	DE_ASSERT(deInRange32(width, 1, 32768));
	DE_ASSERT(deInRange32(height, 1, 32768));
	DE_ASSERT(data);

	if (log->flags & QP_TEST_LOG_EXCLUDE_IMAGES)
		return DE_TRUE; /* Image not logged. */

	Buffer_init(&compressedBuffer);

	/* BEST compression mode defaults to PNG. */
	if (compressionMode == QP_IMAGE_COMPRESSION_MODE_BEST)
	{
#if defined(QP_SUPPORT_PNG)
		compressionMode = QP_IMAGE_COMPRESSION_MODE_PNG;
#else
		compressionMode = QP_IMAGE_COMPRESSION_MODE_NONE;
#endif
	}

#if defined(QP_SUPPORT_PNG)
	/* Try storing with PNG compression. */
	if (compressionMode == QP_IMAGE_COMPRESSION_MODE_PNG)
	{
		deBool compressOk = compressImagePNG(&compressedBuffer, imageFormat, width, height, stride, data);
		if (compressOk)
		{
			writeDataPtr	= compressedBuffer.data;
			writeDataBytes	= compressedBuffer.size;
		}
		else
		{
			/* Fall-back to default compression. */
			qpPrintf("WARNING: PNG compression failed -- storing image uncompressed.\n");
			compressionMode	= QP_IMAGE_COMPRESSION_MODE_NONE;
		}
	}
#endif

	/* Handle image compression. */
	switch (compressionMode)
	{
		case QP_IMAGE_COMPRESSION_MODE_NONE:
		{
			int pixelSize		= imageFormat == QP_IMAGE_FORMAT_RGB888 ? 3 : 4;
			int packedStride	= pixelSize*width;

			if (packedStride == stride)
				writeDataPtr = data;
			else
			{
				/* Need to re-pack pixels. */
				if (Buffer_resize(&compressedBuffer, (size_t)(packedStride*height)))
				{
					int row;
					for (row = 0; row < height; row++)
						memcpy(&compressedBuffer.data[packedStride*row], &((const deUint8*)data)[row*stride], (size_t)(pixelSize*width));
				}
				else
				{
					qpPrintf("ERROR: Failed to pack pixels for writing.\n");
					Buffer_deinit(&compressedBuffer);
					return DE_FALSE;
				}
			}

			writeDataBytes = (size_t)(packedStride*height);
			break;
		}

#if defined(QP_SUPPORT_PNG)
		case QP_IMAGE_COMPRESSION_MODE_PNG:
			DE_ASSERT(writeDataPtr); /* Already handled. */
			break;
#endif

		default:
			qpPrintf("qpTestLog_writeImage(): Unknown compression mode: %s\n", QP_LOOKUP_STRING(s_qpImageCompressionModeMap, compressionMode));
			Buffer_deinit(&compressedBuffer);
			return DE_FALSE;
	}

	/* Fill in attributes. */
	int32ToString(width, widthStr);
	int32ToString(height, heightStr);
	attribs[numAttribs++] = qpSetStringAttrib("Name", name);
	attribs[numAttribs++] = qpSetStringAttrib("Width", widthStr);
	attribs[numAttribs++] = qpSetStringAttrib("Height", heightStr);
	attribs[numAttribs++] = qpSetStringAttrib("Format", QP_LOOKUP_STRING(s_qpImageFormatMap, imageFormat));
	attribs[numAttribs++] = qpSetStringAttrib("CompressionMode", QP_LOOKUP_STRING(s_qpImageCompressionModeMap, compressionMode));
	if (description) attribs[numAttribs++] = qpSetStringAttrib("Description", description);

	/* \note Log lock is acquired after compression! */
	deMutex_lock(log->lock);

	/* <Image ID="result" Name="Foobar" Width="640" Height="480" Format="RGB888" CompressionMode="None">base64 data</Image> */
	if (!qpXmlWriter_startElement(log->writer, "Image", numAttribs, attribs) ||
		!qpXmlWriter_writeBase64(log->writer, (const deUint8*)writeDataPtr, writeDataBytes) ||
		!qpXmlWriter_endElement(log->writer, "Image"))
	{
		qpPrintf("qpTestLog_writeImage(): Writing XML failed\n");
		deMutex_unlock(log->lock);
		Buffer_deinit(&compressedBuffer);
		return DE_FALSE;
	}

	deMutex_unlock(log->lock);

	/* Free compressed data if allocated. */
	Buffer_deinit(&compressedBuffer);

	return DE_TRUE;
}
Example #8
0
const char* qpGetTestResultName (qpTestResult result)
{
	return QP_LOOKUP_STRING(s_qpTestResultMap, result);
}