From f78d2849cb39eadf3149710a15f90c787c8af14d Mon Sep 17 00:00:00 2001 From: Piotr Byszewski Date: Mon, 30 Mar 2020 18:47:30 +0200 Subject: [PATCH] Add waiver info to log sessionInfo Writing of session info was separated from log constructor. It is now possible for test package to specify additional session info content. Components: Framework, OpenGL, Vulkan VK-GL-CTS issue: 2222 Affects: dEQP-VK.* cts-runner Change-Id: Id03855a72a0690fcac2eaff645abf04893ad80f6 --- .../openglcts/modules/common/glcTestPackage.cpp | 8 +- .../openglcts/modules/runner/glcTestRunner.cpp | 4 +- .../vulkancts/modules/vulkan/vktBuildPrograms.cpp | 4 +- .../vulkancts/modules/vulkan/vktTestPackage.cpp | 11 ++- framework/common/tcuCommandLine.cpp | 18 +++++ framework/common/tcuCommandLine.hpp | 4 + framework/common/tcuTestContext.cpp | 8 +- framework/common/tcuTestContext.hpp | 2 + framework/common/tcuTestHierarchyIterator.cpp | 3 + framework/common/tcuTestLog.cpp | 17 +--- framework/common/tcuTestLog.hpp | 5 +- framework/common/tcuWaiverUtil.cpp | 92 ++++++++++++++++++---- framework/common/tcuWaiverUtil.hpp | 47 ++++++++++- .../platform/android/tcuAndroidTestActivity.cpp | 4 +- framework/platform/tcuMain.cpp | 4 +- framework/qphelper/qpTestLog.c | 68 ++++++++-------- framework/qphelper/qpTestLog.h | 3 +- modules/gles2/tes2TestPackage.cpp | 8 +- modules/gles3/tes3TestPackage.cpp | 10 ++- modules/gles31/tes31TestPackage.cpp | 10 ++- 20 files changed, 245 insertions(+), 85 deletions(-) diff --git a/external/openglcts/modules/common/glcTestPackage.cpp b/external/openglcts/modules/common/glcTestPackage.cpp index 5d2be56..ca7bb1f 100644 --- a/external/openglcts/modules/common/glcTestPackage.cpp +++ b/external/openglcts/modules/common/glcTestPackage.cpp @@ -71,8 +71,12 @@ void TestPackage::init(void) { Context& context = m_packageCtx->getContext(); const glu::ContextInfo& contextInfo = context.getContextInfo(); - m_waiverMechanism->setup(context.getTestContext().getCommandLine().getWaiverFileName(), m_name, - contextInfo.getString(GL_VENDOR), contextInfo.getString(GL_RENDERER)); + std::string vendor = contextInfo.getString(GL_VENDOR); + std::string renderer = contextInfo.getString(GL_RENDERER); + const tcu::CommandLine& commandLine = context.getTestContext().getCommandLine(); + tcu::SessionInfo sessionInfo (vendor, renderer, commandLine.getInitialCmdLine()); + m_waiverMechanism->setup(commandLine.getWaiverFileName(), m_name, vendor, renderer, sessionInfo); + context.getTestContext().getLog().writeSessionInfo(sessionInfo.get()); } } catch (...) diff --git a/external/openglcts/modules/runner/glcTestRunner.cpp b/external/openglcts/modules/runner/glcTestRunner.cpp index e5423d8..a151312 100644 --- a/external/openglcts/modules/runner/glcTestRunner.cpp +++ b/external/openglcts/modules/runner/glcTestRunner.cpp @@ -48,9 +48,11 @@ class RunSession public: RunSession(tcu::Platform& platform, tcu::Archive& archive, const int numArgs, const char* const* args) : m_cmdLine(numArgs, args) - , m_log(m_cmdLine.getLogFileName(), (numArgs - 1), (char**)(args + 1), m_cmdLine.getLogFlags()) + , m_log(m_cmdLine.getLogFileName(), m_cmdLine.getLogFlags()) , m_app(platform, archive, m_log, m_cmdLine) { + const std::string sessionInfo = "#sessionInfo commandLineParameters \""; + m_log.writeSessionInfo(sessionInfo + m_cmdLine.getInitialCmdLine() + "\"\n"); } inline bool iterate(void) diff --git a/external/vulkancts/modules/vulkan/vktBuildPrograms.cpp b/external/vulkancts/modules/vulkan/vktBuildPrograms.cpp index 5ff16ca..ed76356 100644 --- a/external/vulkancts/modules/vulkan/vktBuildPrograms.cpp +++ b/external/vulkancts/modules/vulkan/vktBuildPrograms.cpp @@ -674,12 +674,14 @@ int main (int argc, const char* argv[]) try { tcu::DirArchive archive ("."); - tcu::TestLog log (deqpCmdLine.getLogFileName(), (argc - 1), (char **)(argv + 1), deqpCmdLine.getLogFlags()); + tcu::TestLog log (deqpCmdLine.getLogFileName(), deqpCmdLine.getLogFlags()); tcu::Platform platform; tcu::TestContext testCtx (platform, archive, log, deqpCmdLine, DE_NULL); vk::SpirvVersion baselineSpirvVersion = vk::getBaselineSpirvVersion(cmdLine.getOption()); vk::SpirvVersion maxSpirvVersion = vk::getMaxSpirvVersionForGlsl(cmdLine.getOption()); + testCtx.writeSessionInfo(); + tcu::print("SPIR-V versions: baseline: %s, max supported: %s\n", getSpirvVersionName(baselineSpirvVersion).c_str(), getSpirvVersionName(maxSpirvVersion).c_str()); diff --git a/external/vulkancts/modules/vulkan/vktTestPackage.cpp b/external/vulkancts/modules/vulkan/vktTestPackage.cpp index 3040583..5a3ec6a 100644 --- a/external/vulkancts/modules/vulkan/vktTestPackage.cpp +++ b/external/vulkancts/modules/vulkan/vktTestPackage.cpp @@ -249,8 +249,15 @@ TestCaseExecutor::TestCaseExecutor (tcu::TestContext& testCtx) , m_deviceProperties (getPhysicalDeviceProperties(m_context)) , m_instance (DE_NULL) { - m_waiverMechanism.setup(testCtx.getCommandLine().getWaiverFileName(), "dEQP-VK", - m_deviceProperties.vendorID, m_deviceProperties.deviceID); + tcu::SessionInfo sessionInfo(m_deviceProperties.vendorID, + m_deviceProperties.deviceID, + testCtx.getCommandLine().getInitialCmdLine()); + m_waiverMechanism.setup(testCtx.getCommandLine().getWaiverFileName(), + "dEQP-VK", + m_deviceProperties.vendorID, + m_deviceProperties.deviceID, + sessionInfo); + testCtx.getLog().writeSessionInfo(sessionInfo.get()); } TestCaseExecutor::~TestCaseExecutor (void) diff --git a/framework/common/tcuCommandLine.cpp b/framework/common/tcuCommandLine.cpp index b94b6a5..707718c 100644 --- a/framework/common/tcuCommandLine.cpp +++ b/framework/common/tcuCommandLine.cpp @@ -687,6 +687,18 @@ CommandLine::CommandLine (void) CommandLine::CommandLine (int argc, const char* const* argv) : m_logFlags (0) { + if (argc > 1) + { + int loop = 1; // skip application name + while (true) + { + m_initialCmdLine += std::string(argv[loop++]); + if (loop >= argc) + break; + m_initialCmdLine += " "; + } + } + if (!parse(argc, argv)) throw Exception("Failed to parse command line"); } @@ -699,6 +711,7 @@ CommandLine::CommandLine (int argc, const char* const* argv) * \param cmdLine Full command line string. *//*--------------------------------------------------------------------*/ CommandLine::CommandLine (const std::string& cmdLine) + : m_initialCmdLine (cmdLine) { if (!parse(cmdLine)) throw Exception("Failed to parse command line"); @@ -719,6 +732,11 @@ const de::cmdline::CommandLine& CommandLine::getCommandLine (void) const return m_cmdLine; } +const std::string& CommandLine::getInitialCmdLine(void) const +{ + return m_initialCmdLine; +} + void CommandLine::registerExtendedOptions (de::cmdline::Parser& parser) { DE_UNREF(parser); diff --git a/framework/common/tcuCommandLine.hpp b/framework/common/tcuCommandLine.hpp index fbef41d..f5b8f65 100644 --- a/framework/common/tcuCommandLine.hpp +++ b/framework/common/tcuCommandLine.hpp @@ -141,6 +141,8 @@ public: bool parse (int argc, const char* const* argv); bool parse (const std::string& cmdLine); + const std::string& getInitialCmdLine (void) const; + //! Get log file name (--deqp-log-filename) const char* getLogFileName (void) const; @@ -282,6 +284,8 @@ private: de::cmdline::CommandLine m_cmdLine; deUint32 m_logFlags; + + std::string m_initialCmdLine; }; } // tcu diff --git a/framework/common/tcuTestContext.cpp b/framework/common/tcuTestContext.cpp index 965d918..94f4f79 100644 --- a/framework/common/tcuTestContext.cpp +++ b/framework/common/tcuTestContext.cpp @@ -22,7 +22,7 @@ *//*--------------------------------------------------------------------*/ #include "tcuTestContext.hpp" - +#include "tcuCommandLine.hpp" #include "tcuTestLog.hpp" namespace tcu @@ -46,6 +46,12 @@ TestContext::TestContext ( setCurrentArchive(m_rootArchive); } +void TestContext::writeSessionInfo(void) +{ + const std::string sessionInfo = "#sessionInfo commandLineParameters \""; + m_log.writeSessionInfo(sessionInfo + m_cmdLine.getInitialCmdLine() + "\"\n"); +} + void TestContext::touchWatchdog (void) { if (m_watchDog) diff --git a/framework/common/tcuTestContext.hpp b/framework/common/tcuTestContext.hpp index 0a8bddc..060a261 100644 --- a/framework/common/tcuTestContext.hpp +++ b/framework/common/tcuTestContext.hpp @@ -51,6 +51,8 @@ public: TestContext (Platform& platform, Archive& rootArchive, TestLog& log, const CommandLine& cmdLine, qpWatchDog* watchDog); ~TestContext (void) {} + void writeSessionInfo (void); + // API for test cases TestLog& getLog (void) { return m_log; } Archive& getArchive (void) { return *m_curArchive; } //!< \note Do not access in TestNode constructors. diff --git a/framework/common/tcuTestHierarchyIterator.cpp b/framework/common/tcuTestHierarchyIterator.cpp index 1fbb662..5c4ba63 100644 --- a/framework/common/tcuTestHierarchyIterator.cpp +++ b/framework/common/tcuTestHierarchyIterator.cpp @@ -64,6 +64,9 @@ void DefaultHierarchyInflater::enterTestPackage (TestPackage* testPackage, vecto testPackage->init(); testPackage->getChildren(children); + + // write default session info if it was not done by package + m_testCtx.writeSessionInfo(); } void DefaultHierarchyInflater::leaveTestPackage (TestPackage* testPackage) diff --git a/framework/common/tcuTestLog.cpp b/framework/common/tcuTestLog.cpp index 3c84ebb..16e2d2d 100644 --- a/framework/common/tcuTestLog.cpp +++ b/framework/common/tcuTestLog.cpp @@ -181,25 +181,16 @@ TestLog& SampleBuilder::operator<< (const TestLog::EndSampleToken&) // TestLog -TestLog::TestLog (const char* fileName, int argc, char** argv, deUint32 flags) - : m_log(qpTestLog_createFileLog(fileName, argc, argv, flags)) +TestLog::TestLog (const char* fileName, deUint32 flags) + : m_log(qpTestLog_createFileLog(fileName, flags)) { if (!m_log) throw ResourceError(std::string("Failed to open test log file '") + fileName + "'"); } -TestLog::TestLog (const char* fileName, const std::string& cmdLine, deUint32 flags) +void TestLog::writeSessionInfo(std::string additionalInfo) { - - deCommandLine* parsedCmdLine = deCommandLine_parse(cmdLine.c_str()); - if (!parsedCmdLine) - throw std::bad_alloc(); - - m_log = qpTestLog_createFileLog(fileName, parsedCmdLine->numArgs, parsedCmdLine->args, flags); - deCommandLine_destroy(parsedCmdLine); - - if (!m_log) - throw ResourceError(std::string("Failed to open test log file '") + fileName + "'"); + qpTestLog_beginSession(m_log, additionalInfo.c_str()); } TestLog::~TestLog (void) diff --git a/framework/common/tcuTestLog.hpp b/framework/common/tcuTestLog.hpp index 8323a8b..ab08573 100644 --- a/framework/common/tcuTestLog.hpp +++ b/framework/common/tcuTestLog.hpp @@ -102,10 +102,11 @@ public: typedef LogNumber Float; typedef LogNumber Integer; - explicit TestLog (const char* fileName, int argc = 0, char** argv = DE_NULL, deUint32 flags = 0); - explicit TestLog (const char* fileName, const std::string& cmdLine, deUint32 flags = 0); + explicit TestLog (const char* fileName, deUint32 flags = 0); ~TestLog (void); + void writeSessionInfo (std::string additionalInfo = ""); + MessageBuilder operator<< (const BeginMessageToken&); MessageBuilder message (void); diff --git a/framework/common/tcuWaiverUtil.cpp b/framework/common/tcuWaiverUtil.cpp index a35e79d..facaffe 100644 --- a/framework/common/tcuWaiverUtil.cpp +++ b/framework/common/tcuWaiverUtil.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "deString.h" #include "deStringUtil.hpp" #include "xeXMLParser.hpp" @@ -33,6 +34,40 @@ namespace tcu { +SessionInfo::SessionInfo(deUint32 vendorId, + deUint32 deviceId, + const std::string& cmdLine) + : m_cmdLine (cmdLine) +{ + m_info << std::hex + << "#sessionInfo vendorID 0x" << vendorId << "\n" + << "#sessionInfo deviceID 0x" << deviceId << "\n"; +} + +SessionInfo::SessionInfo(std::string vendor, + std::string renderer, + const std::string& cmdLine) + : m_cmdLine (cmdLine) +{ + m_info << "#sessionInfo vendor \"" << vendor << "\"\n" + << "#sessionInfo renderer \"" << renderer << "\"\n"; +} + +std::string SessionInfo::get() +{ + if (!m_waiverUrls.empty()) + { + m_info << "#sessionInfo waiverUrls \"" << m_waiverUrls << "\"\n"; + m_waiverUrls.clear(); + } + if (!m_cmdLine.empty()) + { + m_info << "#sessionInfo commandLineParameters \"" << m_cmdLine << "\"\n"; + m_cmdLine.clear(); + } + return m_info.str(); +} + // Base class for GL and VK waiver tree builders class WaiverTreeBuilder { @@ -45,6 +80,7 @@ public: const std::string& packageName, const char* vendorTag, const char* deviceTag, + SessionInfo& sessionInfo, std::vector& waiverTree); virtual ~WaiverTreeBuilder(); @@ -68,27 +104,27 @@ protected: // parse waiver.xml and read list of waived tests defined // specificly for current device id and current vendor id - void readWaivedTestsFromXML (void); + void readWaivedTestsFromXML (void); // use list of paths to build a temporary tree which // consists of BuilComponents that help with tree construction - void buildTreeFromPathList (void); + void buildTreeFromPathList (void); // use temporary tree to create final tree containing // only things that are needed during searches - void constructFinalTree (void); + void constructFinalTree (void); // helper methods used to identify if proper waiver for vendor was found - virtual bool matchVendor (const std::string& vendor) const = 0; + virtual bool matchVendor (const std::string& vendor) const = 0; // helper methods used after waiver for current vendor was found to check // if it is defined also for currend deviceId/renderer - virtual bool matchDevice (const std::string& device) const = 0; + virtual bool matchDevice (const std::string& device) const = 0; // helper method used in buildTreeFromPathList; returns index // of component having same ancestors as the component specified // in the argument or 0 when build tree does not include this component - deUint32 findComponentInBuildTree(const std::vector& pathComponents, deUint32 index) const; + deUint32 findComponentInBuildTree(const std::vector& pathComponents, deUint32 index) const; private: const std::string& m_waiverFile; @@ -101,6 +137,9 @@ private: std::vector m_testList; std::vector m_buildTree; + // reference to object containing information about used waivers + SessionInfo& m_sessionInfo; + // reference to vector containing final tree std::vector& m_finalTree; }; @@ -109,11 +148,13 @@ WaiverTreeBuilder::WaiverTreeBuilder(const std::string& waiverFile, const std::string& packageName, const char* vendorTag, const char* deviceTag, + SessionInfo& sessionInfo, std::vector& waiverTree) : m_waiverFile (waiverFile) , m_packageName (packageName) , m_vendorTag (vendorTag) , m_deviceTag (deviceTag) + , m_sessionInfo (sessionInfo) , m_finalTree (waiverTree) { } @@ -150,6 +191,7 @@ void WaiverTreeBuilder::readWaivedTestsFromXML() bool deviceFound = false; bool scanDevice = false; bool memorizeCase = false; + std::string waiverUrl; std::vector waiverTestList; while (true) @@ -190,7 +232,13 @@ void WaiverTreeBuilder::readWaivedTestsFromXML() // we found waiver tag, check if it is deffined for current vendor waiverTestList.clear(); if (xmlParser.hasAttribute(m_vendorTag)) + { vendorFound = matchVendor(xmlParser.getAttribute(m_vendorTag)); + // if waiver vendor matches current one then memorize waiver url + // it will be needed when deviceId/renderer will match current one + if (vendorFound) + waiverUrl = xmlParser.getAttribute("url"); + } break; case xe::xml::ELEMENT_DATA: @@ -217,9 +265,21 @@ void WaiverTreeBuilder::readWaivedTestsFromXML() scanDevice = false; if (deStringEqual(elemName, "waiver")) { - // when we found proper waiver we can copy memorized cases - if(vendorFound && deviceFound) + // when we found proper waiver we can copy memorized cases and update waiver info + if (vendorFound && deviceFound) + { + DE_ASSERT(m_testList.empty() || waiverUrl.empty()); + + std::string& urls = m_sessionInfo.m_waiverUrls; m_testList.insert(m_testList.end(), waiverTestList.begin(), waiverTestList.end()); + + // if m_waiverUrls is not empty then we found another waiver + // definition that should be applyed for this device; we need to + // add space to urls attribute to separate new url from previous one + if (!urls.empty()) + urls.append(" "); + urls.append(waiverUrl); + } vendorFound = false; deviceFound = false; } @@ -352,6 +412,7 @@ public: const std::string& packageName, const std::string& currentVendor, const std::string& currentRenderer, + SessionInfo& sessionInfo, std::vector& waiverTree); bool matchVendor (const std::string& vendor) const override; @@ -367,8 +428,9 @@ GLWaiverTreeBuilder::GLWaiverTreeBuilder(const std::string& waiverFile, const std::string& packageName, const std::string& currentVendor, const std::string& currentRenderer, + SessionInfo& sessionInfo, std::vector& waiverTree) - : WaiverTreeBuilder (waiverFile, packageName, "vendor", "r", waiverTree) + : WaiverTreeBuilder (waiverFile, packageName, "vendor", "r", sessionInfo, waiverTree) , m_currentVendor (currentVendor) , m_currentRenderer (currentRenderer) { @@ -401,6 +463,7 @@ public: const std::string& packageName, const deUint32 currentVendor, const deUint32 currentRenderer, + SessionInfo& sessionInfo, std::vector& waiverTree); bool matchVendor (const std::string& vendor) const override; @@ -416,8 +479,9 @@ VKWaiverTreeBuilder::VKWaiverTreeBuilder(const std::string& waiverFile, const std::string& packageName, const deUint32 currentVendor, const deUint32 currentRenderer, + SessionInfo& sessionInfo, std::vector& waiverTree) - : WaiverTreeBuilder(waiverFile, packageName, "vendorId", "d", waiverTree) + : WaiverTreeBuilder(waiverFile, packageName, "vendorId", "d", sessionInfo, waiverTree) , m_currentVendorId(currentVendor) , m_currentDeviceId(currentRenderer) { @@ -433,14 +497,14 @@ bool VKWaiverTreeBuilder::matchDevice(const std::string& device) const return (m_currentDeviceId == static_cast(std::stoul(device, 0, 0))); } -void WaiverUtil::setup(const std::string waiverFile, std::string packageName, deUint32 vendorId, deUint32 deviceId) +void WaiverUtil::setup(const std::string waiverFile, std::string packageName, deUint32 vendorId, deUint32 deviceId, SessionInfo& sessionInfo) { - VKWaiverTreeBuilder(waiverFile, packageName, vendorId, deviceId, m_waiverTree).build(); + VKWaiverTreeBuilder(waiverFile, packageName, vendorId, deviceId, sessionInfo, m_waiverTree).build(); } -void WaiverUtil::setup(const std::string waiverFile, std::string packageName, std::string vendor, std::string renderer) +void WaiverUtil::setup(const std::string waiverFile, std::string packageName, std::string vendor, std::string renderer, SessionInfo& sessionInfo) { - GLWaiverTreeBuilder(waiverFile, packageName, vendor, renderer, m_waiverTree).build(); + GLWaiverTreeBuilder(waiverFile, packageName, vendor, renderer, sessionInfo, m_waiverTree).build(); } bool WaiverUtil::isOnWaiverList(const std::string& casePath) const diff --git a/framework/common/tcuWaiverUtil.hpp b/framework/common/tcuWaiverUtil.hpp index d59bdfd..7c805d7 100644 --- a/framework/common/tcuWaiverUtil.hpp +++ b/framework/common/tcuWaiverUtil.hpp @@ -24,19 +24,60 @@ *//*--------------------------------------------------------------------*/ #include "deDefs.h" -#include +#include #include namespace tcu { +// Class containing information about session that are printed at the beginning of log. +class SessionInfo +{ +public: + + SessionInfo (deUint32 vendorId, + deUint32 deviceId, + const std::string& cmdLine); + SessionInfo (std::string vendor, + std::string renderer, + const std::string& cmdLine); + + std::string get (); + +private: + + // WaiverTreeBuilder fills private fields of this class. + friend class WaiverTreeBuilder; + + // String containing urls to gitlab issues + // that enable currently used waivers + std::string m_waiverUrls; + + // String containing command line + std::string m_cmdLine; + + // Stream containing all info + std::stringstream m_info; +}; + +// Class that uses paths to waived tests represented in a form of tree. +// Main functionality of this class is to quickly test test paths in +// order to verify if it is on waived tests list that was read from xml. class WaiverUtil { public: WaiverUtil () = default; - void setup (const std::string waiverFile, std::string packageName, deUint32 vendorId, deUint32 deviceId); - void setup (const std::string waiverFile, std::string packageName, std::string vendor, std::string renderer); + void setup (const std::string waiverFile, + std::string packageName, + deUint32 vendorId, + deUint32 deviceId, + SessionInfo& sessionInfo); + void setup (const std::string waiverFile, + std::string packageName, + std::string vendor, + std::string renderer, + SessionInfo& sessionInfo); bool isOnWaiverList (const std::string& casePath) const; diff --git a/framework/platform/android/tcuAndroidTestActivity.cpp b/framework/platform/android/tcuAndroidTestActivity.cpp index cfe53cb..10f21ec 100644 --- a/framework/platform/android/tcuAndroidTestActivity.cpp +++ b/framework/platform/android/tcuAndroidTestActivity.cpp @@ -43,10 +43,12 @@ TestThread::TestThread (NativeActivity& activity, const std::string& cmdLineStri , m_cmdLine (cmdLine) , m_platform (activity) , m_archive (activity.getNativeActivity()->assetManager) - , m_log (m_cmdLine.getLogFileName(), cmdLineString, m_cmdLine.getLogFlags()) + , m_log (m_cmdLine.getLogFileName(), m_cmdLine.getLogFlags()) , m_app (m_platform, m_archive, m_log, m_cmdLine) , m_finished (false) { + const std::string sessionInfo = "#sessionInfo commandLineParameters \""; + m_log.writeSessionInfo(sessionInfo + cmdLineString + "\"\n"); } TestThread::~TestThread (void) diff --git a/framework/platform/tcuMain.cpp b/framework/platform/tcuMain.cpp index 57d62e8..ede44b4 100644 --- a/framework/platform/tcuMain.cpp +++ b/framework/platform/tcuMain.cpp @@ -37,7 +37,7 @@ tcu::Platform* createPlatform (void); int main (int argc, char** argv) { - int exitStatus = EXIT_SUCCESS; + int exitStatus = EXIT_SUCCESS; #if (DE_OS != DE_OS_WIN32) // Set stdout to line-buffered mode (will be fully buffered by default if stdout is pipe). @@ -48,7 +48,7 @@ int main (int argc, char** argv) { tcu::CommandLine cmdLine (argc, argv); tcu::DirArchive archive (cmdLine.getArchiveDir()); - tcu::TestLog log (cmdLine.getLogFileName(), argc-1, argv+1, cmdLine.getLogFlags()); + tcu::TestLog log (cmdLine.getLogFileName(), cmdLine.getLogFlags()); de::UniquePtr platform (createPlatform()); de::UniquePtr app (new tcu::App(*platform, archive, log, cmdLine)); diff --git a/framework/qphelper/qpTestLog.c b/framework/qphelper/qpTestLog.c index 3b1f488..0ffceb9 100644 --- a/framework/qphelper/qpTestLog.c +++ b/framework/qphelper/qpTestLog.c @@ -297,40 +297,14 @@ DE_INLINE void doubleToString (double value, char* buf, size_t bufSize) deSprintf(buf, bufSize, "%f", value); } -static deBool beginSession (qpTestLog* log, int argc, char** argv) -{ - DE_ASSERT(log && !log->isSessionOpen); - - /* Write session info. */ - fprintf(log->outputFile, "#sessionInfo releaseName %s\n", qpGetReleaseName()); - fprintf(log->outputFile, "#sessionInfo releaseId 0x%08x\n", qpGetReleaseId()); - fprintf(log->outputFile, "#sessionInfo targetName \"%s\"\n", qpGetTargetName()); - fprintf(log->outputFile, "#sessionInfo commandLineParameters \""); - for (int i = 0; i < argc && argv != NULL; ++i) - { - fprintf(log->outputFile, "%s", argv[i]); - if (i < argc-1) - fprintf(log->outputFile, " "); - } - fprintf(log->outputFile, "\"\n"); - - /* Write out #beginSession. */ - fprintf(log->outputFile, "#beginSession\n"); - qpTestLog_flushFile(log); - - log->isSessionOpen = DE_TRUE; - - return DE_TRUE; -} - static deBool endSession (qpTestLog* log) { DE_ASSERT(log && log->isSessionOpen); - /* Make sure xml is flushed. */ - qpXmlWriter_flush(log->writer); + /* Make sure xml is flushed. */ + qpXmlWriter_flush(log->writer); - /* Write out #endSession. */ + /* Write out #endSession. */ fprintf(log->outputFile, "\n#endSession\n"); qpTestLog_flushFile(log); @@ -344,7 +318,7 @@ static deBool endSession (qpTestLog* log) * \param fileName Name of the file where to put logs * \return qpTestLog instance, or DE_NULL if cannot create file *//*--------------------------------------------------------------------*/ -qpTestLog* qpTestLog_createFileLog (const char* fileName, int argc, char** argv, deUint32 flags) +qpTestLog* qpTestLog_createFileLog (const char* fileName, deUint32 flags) { qpTestLog* log = (qpTestLog*)deCalloc(sizeof(qpTestLog)); if (!log) @@ -387,14 +361,42 @@ qpTestLog* qpTestLog_createFileLog (const char* fileName, int argc, char** argv, return DE_NULL; } - beginSession(log, argc, argv); - return log; } /*--------------------------------------------------------------------*//*! + * \brief Log information about test session + * \param log qpTestLog instance + * \param additionalSessionInfo string contatining additional sessionInfo data + *//*--------------------------------------------------------------------*/ +deBool qpTestLog_beginSession(qpTestLog* log, const char* additionalSessionInfo) +{ + DE_ASSERT(log); + + /* Make sure this function is called once*/ + if (log->isSessionOpen) + return DE_TRUE; + + /* Write session info. */ + fprintf(log->outputFile, "#sessionInfo releaseName %s\n", qpGetReleaseName()); + fprintf(log->outputFile, "#sessionInfo releaseId 0x%08x\n", qpGetReleaseId()); + fprintf(log->outputFile, "#sessionInfo targetName \"%s\"\n", qpGetTargetName()); + + if (strlen(additionalSessionInfo) > 1) + fprintf(log->outputFile, "%s\n", additionalSessionInfo); + + /* Write out #beginSession. */ + fprintf(log->outputFile, "#beginSession\n"); + qpTestLog_flushFile(log); + + log->isSessionOpen = DE_TRUE; + + return DE_TRUE; +} + +/*--------------------------------------------------------------------*//*! * \brief Destroy a logger instance - * \param a qpTestLog instance + * \param log qpTestLog instance *//*--------------------------------------------------------------------*/ void qpTestLog_destroy (qpTestLog* log) { diff --git a/framework/qphelper/qpTestLog.h b/framework/qphelper/qpTestLog.h index a5c8c6e..76d9693 100644 --- a/framework/qphelper/qpTestLog.h +++ b/framework/qphelper/qpTestLog.h @@ -195,7 +195,8 @@ typedef struct qpEglConfigInfo_s } qpEglConfigInfo; -qpTestLog* qpTestLog_createFileLog (const char* fileName, int argc, char** argv, deUint32 flags); +qpTestLog* qpTestLog_createFileLog (const char* fileName, deUint32 flags); +deBool qpTestLog_beginSession (qpTestLog* log, const char* additionalSessionInfo); void qpTestLog_destroy (qpTestLog* log); deBool qpTestLog_startCase (qpTestLog* log, const char* testCasePath, qpTestCaseType testCaseType); diff --git a/modules/gles2/tes2TestPackage.cpp b/modules/gles2/tes2TestPackage.cpp index bab00dc..3b3f2ac 100644 --- a/modules/gles2/tes2TestPackage.cpp +++ b/modules/gles2/tes2TestPackage.cpp @@ -146,8 +146,12 @@ void TestPackage::init (void) if (m_testCtx.getCommandLine().getRunMode() == tcu::RUNMODE_EXECUTE) { const glu::ContextInfo& contextInfo = m_context->getContextInfo(); - m_waiverMechanism->setup(m_context->getTestContext().getCommandLine().getWaiverFileName(), m_name, - contextInfo.getString(GL_VENDOR), contextInfo.getString(GL_RENDERER)); + std::string vendor = contextInfo.getString(GL_VENDOR); + std::string renderer = contextInfo.getString(GL_RENDERER); + const tcu::CommandLine& commandLine = m_context->getTestContext().getCommandLine(); + tcu::SessionInfo sessionInfo (vendor, renderer, commandLine.getInitialCmdLine()); + m_waiverMechanism->setup(commandLine.getWaiverFileName(), m_name, vendor, renderer, sessionInfo); + m_context->getTestContext().getLog().writeSessionInfo(sessionInfo.get()); } // Add main test groups diff --git a/modules/gles3/tes3TestPackage.cpp b/modules/gles3/tes3TestPackage.cpp index 9caafae..ba7e166 100644 --- a/modules/gles3/tes3TestPackage.cpp +++ b/modules/gles3/tes3TestPackage.cpp @@ -142,9 +142,13 @@ void TestPackage::init (void) // Setup waiver mechanism if (m_testCtx.getCommandLine().getRunMode() == tcu::RUNMODE_EXECUTE) { - const glu::ContextInfo& contextInfo = m_context->getContextInfo(); - m_waiverMechanism->setup(m_context->getTestContext().getCommandLine().getWaiverFileName(), m_name, - contextInfo.getString(GL_VENDOR), contextInfo.getString(GL_RENDERER)); + const glu::ContextInfo& contextInfo = m_context->getContextInfo(); + std::string vendor = contextInfo.getString(GL_VENDOR); + std::string renderer = contextInfo.getString(GL_RENDERER); + const tcu::CommandLine& commandLine = m_context->getTestContext().getCommandLine(); + tcu::SessionInfo sessionInfo (vendor, renderer, commandLine.getInitialCmdLine()); + m_waiverMechanism->setup(commandLine.getWaiverFileName(), m_name, vendor, renderer, sessionInfo); + m_context->getTestContext().getLog().writeSessionInfo(sessionInfo.get()); } // Add main test groups diff --git a/modules/gles31/tes31TestPackage.cpp b/modules/gles31/tes31TestPackage.cpp index c618795..40aa24e 100644 --- a/modules/gles31/tes31TestPackage.cpp +++ b/modules/gles31/tes31TestPackage.cpp @@ -131,10 +131,12 @@ void TestPackage::init (void) if (m_testCtx.getCommandLine().getRunMode() == tcu::RUNMODE_EXECUTE) { const glu::ContextInfo& contextInfo = m_context->getContextInfo(); - m_waiverMechanism->setup(m_context->getTestContext().getCommandLine().getWaiverFileName(), - m_name, - contextInfo.getString(GL_VENDOR), - contextInfo.getString(GL_RENDERER)); + std::string vendor = contextInfo.getString(GL_VENDOR); + std::string renderer = contextInfo.getString(GL_RENDERER); + const tcu::CommandLine& commandLine = m_context->getTestContext().getCommandLine(); + tcu::SessionInfo sessionInfo (vendor, renderer, commandLine.getInitialCmdLine()); + m_waiverMechanism->setup(commandLine.getWaiverFileName(), m_name, vendor, renderer, sessionInfo); + m_context->getTestContext().getLog().writeSessionInfo(sessionInfo.get()); } // Add main test groups -- 2.7.4