Add new --deqp-log-flush command line option
authorPiers Daniell <pdaniell@nvidia.com>
Thu, 18 Feb 2016 18:54:23 +0000 (11:54 -0700)
committerPiers Daniell <pdaniell@nvidia.com>
Mon, 22 Feb 2016 21:06:37 +0000 (14:06 -0700)
It defaults to enabled. When disabled it skips calling fflush() for
every XML token and line of log.

external/vulkancts/README.md
framework/common/tcuCommandLine.cpp
framework/common/tcuTestHierarchyUtil.cpp
framework/qphelper/qpTestLog.c
framework/qphelper/qpTestLog.h
framework/qphelper/qpXmlWriter.c
framework/qphelper/qpXmlWriter.h

index 65561e9..7985148 100644 (file)
@@ -134,6 +134,11 @@ can be selected with:
 
        --deqp-vk-device-id=<value>
 
+To speed up the conformance run on some platforms the following command line
+option may be used to disable frequent fflush() calls to the output logs:
+
+       --deqp-log-flush=disable
+
 No other command line options are allowed.
 
 ### Win32
index b41ef7b..ba267d5 100644 (file)
@@ -84,6 +84,7 @@ DE_DECLARE_COMMAND_LINE_OPT(LogImages,                                        bool);
 DE_DECLARE_COMMAND_LINE_OPT(LogShaderSources,                  bool);
 DE_DECLARE_COMMAND_LINE_OPT(TestOOM,                                   bool);
 DE_DECLARE_COMMAND_LINE_OPT(VKDeviceID,                                        int);
+DE_DECLARE_COMMAND_LINE_OPT(LogFlush,                                  bool);
 
 static void parseIntList (const char* src, std::vector<int>* dst)
 {
@@ -168,7 +169,8 @@ void registerOptions (de::cmdline::Parser& parser)
                << Option<VKDeviceID>                   (DE_NULL,       "deqp-vk-device-id",                    "Vulkan device ID (IDs start from 1)",                                                                  "1")
                << Option<LogImages>                    (DE_NULL,       "deqp-log-images",                              "Enable or disable logging of result images",           s_enableNames,          "enable")
                << Option<LogShaderSources>             (DE_NULL,       "deqp-log-shader-sources",              "Enable or disable logging of shader sources",          s_enableNames,          "enable")
-               << Option<TestOOM>                              (DE_NULL,       "deqp-test-oom",                                "Run tests that exhaust memory on purpose",                     s_enableNames,          TEST_OOM_DEFAULT);
+               << Option<TestOOM>                              (DE_NULL,       "deqp-test-oom",                                "Run tests that exhaust memory on purpose",                     s_enableNames,          TEST_OOM_DEFAULT)
+               << Option<LogFlush>             (DE_NULL,   "deqp-log-flush",               "Enable or disable log file fflush",                s_enableNames,      "enable");
 }
 
 void registerLegacyOptions (de::cmdline::Parser& parser)
@@ -725,6 +727,9 @@ bool CommandLine::parse (int argc, const char* const* argv)
        if (!m_cmdLine.getOption<opt::LogShaderSources>())
                m_logFlags |= QP_TEST_LOG_EXCLUDE_SHADER_SOURCES;
 
+       if (!m_cmdLine.getOption<opt::LogFlush>())
+               m_logFlags |= QP_TEST_LOG_NO_FLUSH;
+
        if ((m_cmdLine.hasOption<opt::CasePath>()?1:0) +
                (m_cmdLine.hasOption<opt::CaseList>()?1:0) +
                (m_cmdLine.hasOption<opt::CaseListFile>()?1:0) +
index dc21619..34882eb 100644 (file)
@@ -146,7 +146,7 @@ void writeXmlCaselistsToFiles (TestPackageRoot& root, TestContext& testCtx, cons
                        if (!file)
                                throw Exception("Failed to open " + filename);
 
-                       writer = qpXmlWriter_createFileWriter(file, DE_FALSE);
+                       writer = qpXmlWriter_createFileWriter(file, DE_FALSE, DE_FALSE);
                        if (!writer)
                                throw Exception("XML writer creation failed");
 
index 77e182a..45cacb9 100644 (file)
@@ -350,7 +350,7 @@ qpTestLog* qpTestLog_createFileLog (const char* fileName, deUint32 flags)
        }
 
        log->flags                      = flags;
-       log->writer                     = qpXmlWriter_createFileWriter(log->outputFile, 0);
+       log->writer                     = qpXmlWriter_createFileWriter(log->outputFile, 0, !(flags & QP_TEST_LOG_NO_FLUSH));
        log->lock                       = deMutex_create(DE_NULL);
        log->isSessionOpen      = DE_FALSE;
        log->isCaseOpen         = DE_FALSE;
@@ -419,7 +419,8 @@ deBool qpTestLog_startCase (qpTestLog* log, const char* testCasePath, qpTestCase
        /* Flush XML and write out #beginTestCaseResult. */
        qpXmlWriter_flush(log->writer);
        fprintf(log->outputFile, "\n#beginTestCaseResult %s\n", testCasePath);
-       qpTestLog_flushFile(log);
+       if (!(log->flags & QP_TEST_LOG_NO_FLUSH))
+               qpTestLog_flushFile(log);
 
        log->isCaseOpen = DE_TRUE;
 
@@ -473,7 +474,8 @@ deBool qpTestLog_endCase (qpTestLog* log, qpTestResult result, const char* resul
        /* Flush XML and write #endTestCaseResult. */
        qpXmlWriter_flush(log->writer);
        fprintf(log->outputFile, "\n#endTestCaseResult\n");
-       qpTestLog_flushFile(log);
+       if (!(log->flags & QP_TEST_LOG_NO_FLUSH))
+               qpTestLog_flushFile(log);
 
        log->isCaseOpen = DE_FALSE;
 
index d03dfdd..19b8a38 100644 (file)
@@ -133,7 +133,8 @@ typedef enum qpImageFormat_e
 typedef enum qpTestLogFlag_e
 {
        QP_TEST_LOG_EXCLUDE_IMAGES                      = (1<<0),               /*!< Do not log images. This reduces log size considerably.                     */
-       QP_TEST_LOG_EXCLUDE_SHADER_SOURCES      = (1<<1)                /*!< Do not log shader sources. Helps to reduce log size further.       */
+       QP_TEST_LOG_EXCLUDE_SHADER_SOURCES      = (1<<1),               /*!< Do not log shader sources. Helps to reduce log size further.       */
+       QP_TEST_LOG_NO_FLUSH                            = (1<<2)                /*!< Do not do a fflush after writing the log.                                          */
 } qpTestLogFlag;
 
 /* Shader type. */
index 6921dab..97ee987 100644 (file)
@@ -36,6 +36,7 @@
 struct qpXmlWriter_s
 {
        FILE*                           outputFile;
+       deBool                          flushAfterWrite;
 
        deBool                          xmlPrevIsStartElement;
        deBool                          xmlIsWriting;
@@ -114,12 +115,13 @@ static deBool writeEscaped (qpXmlWriter* writer, const char* str)
                }
        } while (!isEOS);
 
-       fflush(writer->outputFile);
+       if (writer->flushAfterWrite)
+               fflush(writer->outputFile);
        DE_ASSERT(d == &buf[0]); /* buffer must be empty */
        return DE_TRUE;
 }
 
-qpXmlWriter* qpXmlWriter_createFileWriter (FILE* outputFile, deBool useCompression)
+qpXmlWriter* qpXmlWriter_createFileWriter (FILE* outputFile, deBool useCompression, deBool flushAfterWrite)
 {
        qpXmlWriter* writer = (qpXmlWriter*)deCalloc(sizeof(qpXmlWriter));
        if (!writer)
@@ -128,6 +130,7 @@ qpXmlWriter* qpXmlWriter_createFileWriter (FILE* outputFile, deBool useCompressi
        DE_UNREF(useCompression); /* no compression supported. */
 
        writer->outputFile = outputFile;
+       writer->flushAfterWrite = flushAfterWrite;
 
        return writer;
 }
index ebba428..bb63bde 100644 (file)
@@ -85,9 +85,10 @@ DE_INLINE qpXmlAttribute qpSetBoolAttrib (const char* name, deBool value)
  * \brief Create a file based XML Writer instance
  * \param fileName Name of the file
  * \param useCompression Set to DE_TRUE to use compression, if supported by implementation
+ * \param flushAfterWrite Set to DE_TRUE to call fflush after writing each XML token
  * \return qpXmlWriter instance, or DE_NULL if cannot create file
  *//*--------------------------------------------------------------------*/
-qpXmlWriter*   qpXmlWriter_createFileWriter (FILE* outFile, deBool useCompression);
+qpXmlWriter*   qpXmlWriter_createFileWriter (FILE* outFile, deBool useCompression, deBool flushAfterWrite);
 
 /*--------------------------------------------------------------------*//*!
  * \brief XML Writer instance