Lines Matching defs:log

266 static void qpTestLog_flushFile (qpTestLog* log)
268 DE_ASSERT(log && log->outputFile);
269 fflush(log->outputFile);
272 FlushFileBuffers((HANDLE)_get_osfhandle(_fileno(log->outputFile)));
308 static deBool endSession (qpTestLog* log)
310 DE_ASSERT(log && log->isSessionOpen);
313 qpXmlWriter_flush(log->writer);
317 fprintf(log->outputFile, "\nRun took %.2f seconds\n", (float)duration / 1000000.0f);
320 fprintf(log->outputFile, "\n#endSession\n");
321 qpTestLog_flushFile(log);
323 log->isSessionOpen = DE_FALSE;
335 qpTestLog* log = (qpTestLog*)deCalloc(sizeof(qpTestLog));
336 if (!log)
342 ContainerStack_reset(&log->containerStack);
346 qpPrintf("Writing test log into %s\n", fileName);
349 log->outputFile = fopen(fileName, "wb");
350 if (!log->outputFile)
352 qpPrintf("ERROR: Unable to open test log output file '%s'.\n", fileName);
353 qpTestLog_destroy(log);
357 log->flags = flags;
358 log->writer = qpXmlWriter_createFileWriter(log->outputFile, 0, !(flags & QP_TEST_LOG_NO_FLUSH));
359 log->lock = deMutex_create(DE_NULL);
360 log->isSessionOpen = DE_FALSE;
361 log->isCaseOpen = DE_FALSE;
363 if (!log->writer)
366 qpTestLog_destroy(log);
370 if (!log->lock)
373 qpTestLog_destroy(log);
377 return log;
382 * \param log qpTestLog instance
385 deBool qpTestLog_beginSession(qpTestLog* log, const char* additionalSessionInfo)
387 DE_ASSERT(log);
390 if (log->isSessionOpen)
394 fprintf(log->outputFile, "#sessionInfo releaseName %s\n", qpGetReleaseName());
395 fprintf(log->outputFile, "#sessionInfo releaseId 0x%08x\n", qpGetReleaseId());
396 fprintf(log->outputFile, "#sessionInfo targetName \"%s\"\n", qpGetTargetName());
398 if(qpTestLog_isCompact(log))
402 fprintf(log->outputFile, "#sessionInfo logFormatVersion \"%s%s\"\n", LOG_FORMAT_VERSION, compactStr);
405 fprintf(log->outputFile, "%s\n", additionalSessionInfo);
408 fprintf(log->outputFile, "#beginSession\n");
409 qpTestLog_flushFile(log);
412 log->isSessionOpen = DE_TRUE;
419 * \param log qpTestLog instance
421 void qpTestLog_destroy (qpTestLog* log)
423 DE_ASSERT(log);
425 if (log->isSessionOpen)
426 endSession(log);
428 if (log->writer)
429 qpXmlWriter_destroy(log->writer);
431 if (log->outputFile)
432 fclose(log->outputFile);
434 if (log->lock)
435 deMutex_destroy(log->lock);
437 deFree(log);
442 * \param log qpTestLog instance
447 deBool qpTestLog_startCase (qpTestLog* log, const char* testCasePath, qpTestCaseType testCaseType)
453 DE_ASSERT(log && testCasePath && (testCasePath[0] != 0));
454 deMutex_lock(log->lock);
456 DE_ASSERT(!log->isCaseOpen);
457 DE_ASSERT(ContainerStack_isEmpty(&log->containerStack));
460 qpXmlWriter_flush(log->writer);
461 if (!qpTestLog_isCompact(log))
463 fprintf(log->outputFile, "\n#beginTestCaseResult %s\n", testCasePath);
465 if (!(log->flags & QP_TEST_LOG_NO_FLUSH))
466 qpTestLog_flushFile(log);
468 log->isCaseOpen = DE_TRUE;
472 if (!qpTestLog_isCompact(log))
478 if (!qpXmlWriter_startDocument(log->writer, !qpTestLog_isCompact(log)) ||
479 !qpXmlWriter_startElement(log->writer, "TestCaseResult", numResultAttribs, resultAttribs))
482 deMutex_unlock(log->lock);
486 deMutex_unlock(log->lock);
492 * \param log qpTestLog instance
497 deBool qpTestLog_endCase (qpTestLog* log, qpTestResult result, const char* resultDetails)
502 deMutex_lock(log->lock);
504 DE_ASSERT(log->isCaseOpen);
505 DE_ASSERT(ContainerStack_isEmpty(&log->containerStack));
510 if (!qpXmlWriter_startElement(log->writer, "Result", 1, &statusAttrib) ||
511 (resultDetails && !qpXmlWriter_writeString(log->writer, resultDetails)) ||
512 !qpXmlWriter_endElement(log->writer, "Result") ||
513 !qpXmlWriter_endElement(log->writer, "TestCaseResult") ||
514 !qpXmlWriter_endDocument(log->writer)) /* Close any XML elements still open */
517 deMutex_unlock(log->lock);
522 qpXmlWriter_flush(log->writer);
523 if(!qpTestLog_isCompact(log))
525 fprintf(log->outputFile, "\n#endTestCaseResult\n");
527 if (!(log->flags & QP_TEST_LOG_NO_FLUSH))
528 qpTestLog_flushFile(log);
530 log->isCaseOpen = DE_FALSE;
532 deMutex_unlock(log->lock);
536 deBool qpTestLog_startTestsCasesTime (qpTestLog* log)
538 DE_ASSERT(log);
539 deMutex_lock(log->lock);
542 qpXmlWriter_flush(log->writer);
543 fprintf(log->outputFile, "\n#beginTestsCasesTime\n");
545 log->isCaseOpen = DE_TRUE;
547 if (!qpXmlWriter_startDocument(log->writer, !qpTestLog_isCompact(log)) ||
548 !qpXmlWriter_startElement(log->writer, "TestsCasesTime", 0, (const qpXmlAttribute*)DE_NULL))
551 deMutex_unlock(log->lock);
555 deMutex_unlock(log->lock);
559 deBool qpTestLog_endTestsCasesTime (qpTestLog* log)
561 DE_ASSERT(log);
562 deMutex_lock(log->lock);
564 DE_ASSERT(log->isCaseOpen);
566 if (!qpXmlWriter_endElement(log->writer, "TestsCasesTime") ||
567 !qpXmlWriter_endDocument(log->writer))
570 deMutex_unlock(log->lock);
574 qpXmlWriter_flush(log->writer);
576 fprintf(log->outputFile, "\n#endTestsCasesTime\n");
578 log->isCaseOpen = DE_FALSE;
580 deMutex_unlock(log->lock);
587 * \param log qpTestLog instance
591 deBool qpTestLog_terminateCase (qpTestLog* log, qpTestResult result)
595 DE_ASSERT(log);
598 deMutex_lock(log->lock);
600 if (!log->isCaseOpen)
602 deMutex_unlock(log->lock);
607 qpXmlWriter_flush(log->writer);
608 fprintf(log->outputFile, "\n#terminateTestCaseResult %s\n", resultStr);
609 qpTestLog_flushFile(log);
611 log->isCaseOpen = DE_FALSE;
614 ContainerStack_reset(&log->containerStack);
617 deMutex_unlock(log->lock);
621 static deBool qpTestLog_writeKeyValuePair (qpTestLog* log, const char* elementName, const char* name, const char* description, const char* unit, qpKeyValueTag tag, const char* text)
627 DE_ASSERT(log && elementName && text);
628 deMutex_lock(log->lock);
636 if (!qpXmlWriter_startElement(log->writer, elementName, numAttribs, attribs) ||
637 !qpXmlWriter_writeString(log->writer, text) ||
638 !qpXmlWriter_endElement(log->writer, elementName))
641 deMutex_unlock(log->lock);
645 deMutex_unlock(log->lock);
650 * \brief Write key-value-pair into log
651 * \param log qpTestLog instance
658 deBool qpTestLog_writeText (qpTestLog* log, const char* name, const char* description, qpKeyValueTag tag, const char* text)
661 return qpTestLog_writeKeyValuePair(log, "Text", name, description, DE_NULL, tag, text);
665 * \brief Write key-value-pair into log
666 * \param log qpTestLog instance
673 deBool qpTestLog_writeInteger (qpTestLog* log, const char* name, const char* description, const char* unit, qpKeyValueTag tag, deInt64 value)
679 return qpTestLog_writeKeyValuePair(log, "Number", name, description, unit, tag, tmpString);
683 * \brief Write key-value-pair into log
684 * \param log qpTestLog instance
691 deBool qpTestLog_writeFloat (qpTestLog* log, const char* name, const char* description, const char* unit, qpKeyValueTag tag, float value)
697 return qpTestLog_writeKeyValuePair(log, "Number", name, description, unit, tag, tmpString);
837 * \param log qpTestLog instance
842 deBool qpTestLog_startImageSet (qpTestLog* log, const char* name, const char* description)
847 DE_ASSERT(log && name);
848 deMutex_lock(log->lock);
855 if (!qpXmlWriter_startElement(log->writer, "ImageSet", numAttribs, attribs))
858 deMutex_unlock(log->lock);
862 DE_ASSERT(ContainerStack_push(&log->containerStack, CONTAINERTYPE_IMAGESET));
864 deMutex_unlock(log->lock);
870 * \param log qpTestLog instance
873 deBool qpTestLog_endImageSet (qpTestLog* log)
875 DE_ASSERT(log);
876 deMutex_lock(log->lock);
879 if (!qpXmlWriter_endElement(log->writer, "ImageSet"))
882 deMutex_unlock(log->lock);
886 DE_ASSERT(ContainerStack_pop(&log->containerStack) == CONTAINERTYPE_IMAGESET);
888 deMutex_unlock(log->lock);
893 * \brief Write base64 encoded raw image data into log
894 * \param log qpTestLog instance
906 qpTestLog* log,
924 DE_ASSERT(log && name);
929 if (log->flags & QP_TEST_LOG_EXCLUDE_IMAGES)
1017 deMutex_lock(log->lock);
1020 if (!qpXmlWriter_startElement(log->writer, "Image", numAttribs, attribs) ||
1021 !qpXmlWriter_writeBase64(log->writer, (const deUint8*)writeDataPtr, writeDataBytes) ||
1022 !qpXmlWriter_endElement(log->writer, "Image"))
1025 deMutex_unlock(log->lock);
1030 deMutex_unlock(log->lock);
1039 * \brief Writes infoLog into log. Might filter out empty infoLog.
1040 * \param log qpTestLog instance
1041 * \param infoLog Implementation provided shader compilation or linkage log
1044 deBool qpTestLog_writeInfoLog (qpTestLog* log, const char* infoLog)
1049 if (infoLog[0] == '\0' && (log->flags & QP_TEST_LOG_EXCLUDE_EMPTY_LOGINFO) != 0)
1052 return qpXmlWriter_writeStringElement(log->writer, "InfoLog", infoLog);
1056 * \brief Write a OpenGL ES shader program into the log.
1058 * \param linkInfoLog Implementation provided linkage log
1060 deBool qpTestLog_startShaderProgram (qpTestLog* log, deBool linkOk, const char* linkInfoLog)
1065 DE_ASSERT(log);
1066 deMutex_lock(log->lock);
1070 if (!qpXmlWriter_startElement(log->writer, "ShaderProgram", numProgramAttribs, programAttribs) ||
1071 !qpTestLog_writeInfoLog(log, linkInfoLog))
1074 deMutex_unlock(log->lock);
1078 DE_ASSERT(ContainerStack_push(&log->containerStack, CONTAINERTYPE_SHADERPROGRAM));
1080 deMutex_unlock(log->lock);
1086 * \param log qpTestLog instance
1089 deBool qpTestLog_endShaderProgram (qpTestLog* log)
1091 DE_ASSERT(log);
1092 deMutex_lock(log->lock);
1095 if (!qpXmlWriter_endElement(log->writer, "ShaderProgram"))
1098 deMutex_unlock(log->lock);
1102 DE_ASSERT(ContainerStack_pop(&log->containerStack) == CONTAINERTYPE_SHADERPROGRAM);
1104 deMutex_unlock(log->lock);
1109 * \brief Write a OpenGL ES shader into the log.
1113 * \param infoLog Implementation provided shader compilation log
1115 deBool qpTestLog_writeShader (qpTestLog* log, qpShaderType type, const char* source, deBool compileOk, const char* infoLog)
1118 const char* sourceStr = ((log->flags & QP_TEST_LOG_EXCLUDE_SHADER_SOURCES) == 0 || !compileOk) ? source : "";
1122 deMutex_lock(log->lock);
1125 DE_ASSERT(ContainerStack_getTop(&log->containerStack) == CONTAINERTYPE_SHADERPROGRAM);
1129 if (!qpXmlWriter_startElement(log->writer, tagName, numShaderAttribs, shaderAttribs) ||
1130 !qpXmlWriter_writeStringElement(log->writer, "ShaderSource", sourceStr) ||
1131 !qpTestLog_writeInfoLog(log, infoLog) ||
1132 !qpXmlWriter_endElement(log->writer, tagName))
1135 deMutex_unlock(log->lock);
1139 deMutex_unlock(log->lock);
1144 * \brief Start writing a set of EGL configurations into the log.
1146 deBool qpTestLog_startEglConfigSet (qpTestLog* log, const char* name, const char* description)
1151 DE_ASSERT(log && name);
1152 deMutex_lock(log->lock);
1159 if (!qpXmlWriter_startElement(log->writer, "EglConfigSet", numAttribs, attribs))
1162 deMutex_unlock(log->lock);
1166 DE_ASSERT(ContainerStack_push(&log->containerStack, CONTAINERTYPE_EGLCONFIGSET));
1168 deMutex_unlock(log->lock);
1175 deBool qpTestLog_endEglConfigSet (qpTestLog* log)
1177 DE_ASSERT(log);
1178 deMutex_lock(log->lock);
1181 if (!qpXmlWriter_endElement(log->writer, "EglConfigSet"))
1184 deMutex_unlock(log->lock);
1188 DE_ASSERT(ContainerStack_pop(&log->containerStack) == CONTAINERTYPE_EGLCONFIGSET);
1190 deMutex_unlock(log->lock);
1198 deBool qpTestLog_writeEglConfig (qpTestLog* log, const qpEglConfigInfo* config)
1203 DE_ASSERT(log && config);
1204 deMutex_lock(log->lock);
1238 if (!qpXmlWriter_startElement(log->writer, "EglConfig", numAttribs, attribs) ||
1239 !qpXmlWriter_endElement(log->writer, "EglConfig"))
1242 deMutex_unlock(log->lock);
1246 deMutex_unlock(log->lock);
1251 * \brief Start section in log.
1252 * \param log qpTestLog instance
1257 deBool qpTestLog_startSection (qpTestLog* log, const char* name, const char* description)
1262 DE_ASSERT(log && name);
1263 deMutex_lock(log->lock);
1270 if (!qpXmlWriter_startElement(log->writer, "Section", numAttribs, attribs))
1273 deMutex_unlock(log->lock);
1277 DE_ASSERT(ContainerStack_push(&log->containerStack, CONTAINERTYPE_SECTION));
1279 deMutex_unlock(log->lock);
1284 * \brief End section in log.
1285 * \param log qpTestLog instance
1288 deBool qpTestLog_endSection (qpTestLog* log)
1290 DE_ASSERT(log);
1291 deMutex_lock(log->lock);
1294 if (!qpXmlWriter_endElement(log->writer, "Section"))
1297 deMutex_unlock(log->lock);
1301 DE_ASSERT(ContainerStack_pop(&log->containerStack) == CONTAINERTYPE_SECTION);
1303 deMutex_unlock(log->lock);
1308 * \brief Write OpenCL compute kernel source into the log.
1310 deBool qpTestLog_writeKernelSource (qpTestLog* log, const char* source)
1312 const char* sourceStr = (log->flags & QP_TEST_LOG_EXCLUDE_SHADER_SOURCES) != 0 ? "" : source;
1314 DE_ASSERT(log);
1315 deMutex_lock(log->lock);
1317 if (!qpXmlWriter_writeStringElement(log->writer, "KernelSource", sourceStr))
1320 deMutex_unlock(log->lock);
1324 deMutex_unlock(log->lock);
1329 * \brief Write a SPIR-V module assembly source into the log.
1331 deBool qpTestLog_writeSpirVAssemblySource (qpTestLog* log, const char* source)
1333 const char* const sourceStr = (log->flags & QP_TEST_LOG_EXCLUDE_SHADER_SOURCES) != 0 ? "" : source;
1335 deMutex_lock(log->lock);
1337 DE_ASSERT(ContainerStack_getTop(&log->containerStack) == CONTAINERTYPE_SHADERPROGRAM);
1339 if (!qpXmlWriter_writeStringElement(log->writer, "SpirVAssemblySource", sourceStr))
1342 deMutex_unlock(log->lock);
1346 deMutex_unlock(log->lock);
1351 * \brief Write OpenCL kernel compilation results into the log
1353 deBool qpTestLog_writeCompileInfo (qpTestLog* log, const char* name, const char* description, deBool compileOk, const char* infoLog)
1358 DE_ASSERT(log && name && description && infoLog);
1359 deMutex_lock(log->lock);
1365 if (!qpXmlWriter_startElement(log->writer, "CompileInfo", numAttribs, attribs) ||
1366 !qpTestLog_writeInfoLog(log, infoLog) ||
1367 !qpXmlWriter_endElement(log->writer, "CompileInfo"))
1370 deMutex_unlock(log->lock);
1374 deMutex_unlock(log->lock);
1378 deBool qpTestLog_startSampleList (qpTestLog* log, const char* name, const char* description)
1383 DE_ASSERT(log && name && description);
1384 deMutex_lock(log->lock);
1389 if (!qpXmlWriter_startElement(log->writer, "SampleList", numAttribs, attribs))
1392 deMutex_unlock(log->lock);
1396 DE_ASSERT(ContainerStack_push(&log->containerStack, CONTAINERTYPE_SAMPLELIST));
1398 deMutex_unlock(log->lock);
1402 deBool qpTestLog_startSampleInfo (qpTestLog* log)
1404 DE_ASSERT(log);
1405 deMutex_lock(log->lock);
1407 if (!qpXmlWriter_startElement(log->writer, "SampleInfo", 0, DE_NULL))
1410 deMutex_unlock(log->lock);
1414 DE_ASSERT(ContainerStack_push(&log->containerStack, CONTAINERTYPE_SAMPLEINFO));
1416 deMutex_unlock(log->lock);
1420 deBool qpTestLog_writeValueInfo (qpTestLog* log, const char* name, const char* description, const char* unit, qpSampleValueTag tag)
1426 DE_ASSERT(log && name && description && tagName);
1427 deMutex_lock(log->lock);
1429 DE_ASSERT(ContainerStack_getTop(&log->containerStack) == CONTAINERTYPE_SAMPLEINFO);
1438 if (!qpXmlWriter_startElement(log->writer, "ValueInfo", numAttribs, attribs) ||
1439 !qpXmlWriter_endElement(log->writer, "ValueInfo"))
1442 deMutex_unlock(log->lock);
1446 deMutex_unlock(log->lock);
1450 deBool qpTestLog_endSampleInfo (qpTestLog* log)
1452 DE_ASSERT(log);
1453 deMutex_lock(log->lock);
1455 if (!qpXmlWriter_endElement(log->writer, "SampleInfo"))
1458 deMutex_unlock(log->lock);
1462 DE_ASSERT(ContainerStack_pop(&log->containerStack) == CONTAINERTYPE_SAMPLEINFO);
1464 deMutex_unlock(log->lock);
1468 deBool qpTestLog_startSample (qpTestLog* log)
1470 DE_ASSERT(log);
1471 deMutex_lock(log->lock);
1473 DE_ASSERT(ContainerStack_getTop(&log->containerStack) == CONTAINERTYPE_SAMPLELIST);
1475 if (!qpXmlWriter_startElement(log->writer, "Sample", 0, DE_NULL))
1478 deMutex_unlock(log->lock);
1482 DE_ASSERT(ContainerStack_push(&log->containerStack, CONTAINERTYPE_SAMPLE));
1484 deMutex_unlock(log->lock);
1488 deBool qpTestLog_writeValueFloat (qpTestLog* log, double value)
1493 deMutex_lock(log->lock);
1495 DE_ASSERT(ContainerStack_getTop(&log->containerStack) == CONTAINERTYPE_SAMPLE);
1497 if (!qpXmlWriter_writeStringElement(log->writer, "Value", &tmpString[0]))
1500 deMutex_unlock(log->lock);
1504 deMutex_unlock(log->lock);
1508 deBool qpTestLog_writeValueInteger (qpTestLog* log, deInt64 value)
1513 deMutex_lock(log->lock);
1515 DE_ASSERT(ContainerStack_getTop(&log->containerStack) == CONTAINERTYPE_SAMPLE);
1517 if (!qpXmlWriter_writeStringElement(log->writer, "Value", &tmpString[0]))
1520 deMutex_unlock(log->lock);
1524 deMutex_unlock(log->lock);
1528 deBool qpTestLog_endSample (qpTestLog* log)
1530 DE_ASSERT(log);
1531 deMutex_lock(log->lock);
1533 if (!qpXmlWriter_endElement(log->writer, "Sample"))
1536 deMutex_unlock(log->lock);
1540 DE_ASSERT(ContainerStack_pop(&log->containerStack) == CONTAINERTYPE_SAMPLE);
1542 deMutex_unlock(log->lock);
1546 deBool qpTestLog_endSampleList (qpTestLog* log)
1548 DE_ASSERT(log);
1549 deMutex_lock(log->lock);
1551 if (!qpXmlWriter_endElement(log->writer, "SampleList"))
1554 deMutex_unlock(log->lock);
1558 DE_ASSERT(ContainerStack_pop(&log->containerStack) == CONTAINERTYPE_SAMPLELIST);
1560 deMutex_unlock(log->lock);
1564 deBool qpTestLog_writeRaw(qpTestLog* log, const char* rawContents)
1566 DE_ASSERT(log);
1568 fseek(log->outputFile, 0, SEEK_END);
1569 fprintf(log->outputFile, "%s", rawContents);
1570 if (!(log->flags & QP_TEST_LOG_NO_FLUSH))
1571 qpTestLog_flushFile(log);
1576 deUint32 qpTestLog_getLogFlags (const qpTestLog* log)
1578 DE_ASSERT(log);
1579 return log->flags;
1587 deBool qpTestLog_isCompact(qpTestLog *log)
1589 return (log->flags & QP_TEST_LOG_COMPACT) != 0;