/*--------------------------------------------------------------------*//*! * \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; }
/*--------------------------------------------------------------------*//*! * \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; }
/*--------------------------------------------------------------------*//*! * \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; }
static deBool endSession (qpTestLog* log) { DE_ASSERT(log && log->isSessionOpen); /* Make sure xml is flushed. */ qpXmlWriter_flush(log->writer); /* Write out #endSession. */ fprintf(log->outputFile, "\n#endSession\n"); qpTestLog_flushFile(log); log->isSessionOpen = DE_FALSE; return DE_TRUE; }