1 /*-------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 Google Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Vulkan Test Package
22 *//*--------------------------------------------------------------------*/
24 #include "vktTestPackage.hpp"
26 #include "qpDebugOut.h"
29 #include "tcuPlatform.hpp"
30 #include "tcuTestCase.hpp"
31 #include "tcuTestLog.hpp"
32 #include "tcuCommandLine.hpp"
33 #include "tcuWaiverUtil.hpp"
35 #include "vkPlatform.hpp"
36 #include "vkPrograms.hpp"
37 #include "vkBinaryRegistry.hpp"
38 #include "vkShaderToSpirV.hpp"
39 #include "vkDebugReportUtil.hpp"
40 #include "vkQueryUtil.hpp"
41 #include "vkApiVersion.hpp"
42 #include "vkRenderDocUtil.hpp"
43 #include "vkResourceInterface.hpp"
45 #include "deUniquePtr.hpp"
46 #include "deSharedPtr.hpp"
47 #ifdef CTS_USES_VULKANSC
48 #include "deProcess.h"
49 #include "vksClient.hpp"
51 #endif // CTS_USES_VULKANSC
53 #include "vktTestGroupUtil.hpp"
54 #include "vktApiTests.hpp"
55 #include "vktPipelineTests.hpp"
56 #include "vktBindingModelTests.hpp"
57 #include "vktSpvAsmTests.hpp"
58 #include "vktShaderLibrary.hpp"
59 #include "vktRenderPassTests.hpp"
60 #include "vktMemoryTests.hpp"
61 #include "vktShaderRenderBuiltinVarTests.hpp"
62 #include "vktShaderRenderDerivateTests.hpp"
63 #include "vktShaderRenderDiscardTests.hpp"
64 #include "vktShaderRenderIndexingTests.hpp"
65 #include "vktShaderRenderInvarianceTests.hpp"
66 #include "vktShaderRenderLimitTests.hpp"
67 #include "vktShaderRenderLoopTests.hpp"
68 #include "vktShaderRenderMatrixTests.hpp"
69 #include "vktShaderRenderOperatorTests.hpp"
70 #include "vktShaderRenderReturnTests.hpp"
71 #include "vktShaderRenderStructTests.hpp"
72 #include "vktShaderRenderSwitchTests.hpp"
73 #include "vktShaderRenderTextureFunctionTests.hpp"
74 #include "vktShaderRenderTextureGatherTests.hpp"
75 #include "vktShaderBuiltinTests.hpp"
76 #include "vktOpaqueTypeIndexingTests.hpp"
77 #include "vktAtomicOperationTests.hpp"
78 #include "vktUniformBlockTests.hpp"
79 #include "vktDynamicStateTests.hpp"
80 #include "vktSSBOLayoutTests.hpp"
81 #include "vktQueryPoolTests.hpp"
82 #include "vktDrawTests.hpp"
83 #include "vktComputeTests.hpp"
84 #include "vktConditionalTests.hpp"
85 #include "vktImageTests.hpp"
86 #include "vktInfoTests.hpp"
87 #include "vktWsiTests.hpp"
88 #include "vktSynchronizationTests.hpp"
89 #include "vktSparseResourcesTests.hpp"
90 #include "vktTessellationTests.hpp"
91 #include "vktRasterizationTests.hpp"
92 #include "vktClippingTests.hpp"
93 #include "vktFragmentOperationsTests.hpp"
94 #include "vktTextureTests.hpp"
95 #include "vktGeometryTests.hpp"
96 #include "vktRobustnessTests.hpp"
97 #include "vktMultiViewTests.hpp"
98 #include "vktSubgroupsTests.hpp"
99 #include "vktYCbCrTests.hpp"
100 #include "vktProtectedMemTests.hpp"
101 #include "vktDeviceGroupTests.hpp"
102 #include "vktMemoryModelTests.hpp"
103 #include "vktAmberGraphicsFuzzTests.hpp"
104 #include "vktAmberGlslTests.hpp"
105 #include "vktAmberDepthTests.hpp"
106 #include "vktImagelessFramebufferTests.hpp"
107 #include "vktTransformFeedbackTests.hpp"
108 #include "vktDescriptorIndexingTests.hpp"
109 #include "vktImagelessFramebufferTests.hpp"
110 #include "vktFragmentShaderInterlockTests.hpp"
111 #include "vktShaderClockTests.hpp"
112 #include "vktModifiersTests.hpp"
113 #include "vktRayTracingTests.hpp"
114 #include "vktRayQueryTests.hpp"
115 #include "vktPostmortemTests.hpp"
116 #include "vktFragmentShadingRateTests.hpp"
117 #include "vktReconvergenceTests.hpp"
118 #include "vktMeshShaderTests.hpp"
119 #include "vktFragmentShadingBarycentricTests.hpp"
120 #include "vktVideoTests.hpp"
121 #ifdef CTS_USES_VULKANSC
122 #include "vktSafetyCriticalTests.hpp"
123 #endif // CTS_USES_VULKANSC
141 #ifdef CTS_USES_VULKANSC
142 struct DetailedSubprocessTestCount
144 std::string testPattern;
147 #endif // CTS_USES_VULKANSC
149 class TestCaseExecutor : public tcu::TestCaseExecutor
152 TestCaseExecutor (tcu::TestContext& testCtx);
153 ~TestCaseExecutor (void);
155 void init (tcu::TestCase* testCase, const std::string& path) override;
156 void deinit (tcu::TestCase* testCase) override;
158 tcu::TestNode::IterateResult iterate (tcu::TestCase* testCase) override;
160 void deinitTestPackage (tcu::TestContext& testCtx) override;
161 bool usesLocalStatus () override;
162 void updateGlobalStatus (tcu::TestRunStatus& status) override;
163 void reportDurations (tcu::TestContext& testCtx, const std::string& packageName, const deInt64& duration, const std::map<std::string, deUint64>& groupsDurationTime) override;
164 int getCurrentSubprocessCount (const std::string& casePath, int defaultSubprocessCount);
167 void logUnusedShaders (tcu::TestCase* testCase);
169 void runTestsInSubprocess (tcu::TestContext& testCtx);
171 bool spirvVersionSupported (vk::SpirvVersion);
173 vk::BinaryCollection m_progCollection;
174 vk::BinaryRegistryReader m_prebuiltBinRegistry;
176 const UniquePtr<vk::Library> m_library;
177 MovePtr<Context> m_context;
179 const UniquePtr<vk::RenderDocUtil> m_renderDoc;
180 SharedPtr<vk::ResourceInterface> m_resourceInterface;
181 vk::VkPhysicalDeviceProperties m_deviceProperties;
182 tcu::WaiverUtil m_waiverMechanism;
184 TestInstance* m_instance; //!< Current test case instance
185 std::vector<std::string> m_testsForSubprocess;
186 tcu::TestRunStatus m_status;
188 #ifdef CTS_USES_VULKANSC
189 int m_subprocessCount;
191 std::unique_ptr<vksc_server::ipc::Parent> m_parentIPC;
192 std::vector<DetailedSubprocessTestCount> m_detailedSubprocessTestCount;
193 #endif // CTS_USES_VULKANSC
196 #ifdef CTS_USES_VULKANSC
197 static deBool supressedWrite (int, const char*) { return false; }
198 static deBool supressedWriteFtm (int, const char*, va_list) { return false; }
199 static deBool openWrite (int type, const char* message) { DE_UNREF(type); DE_UNREF(message); return true; }
200 static deBool openWriteFtm (int type, const char* format, va_list args) { DE_UNREF(type); DE_UNREF(format); DE_UNREF(args); return true; }
201 static void suppressStandardOutput () { qpRedirectOut(supressedWrite, supressedWriteFtm); }
202 static void restoreStandardOutput () { qpRedirectOut(openWrite, openWriteFtm); }
203 #endif // CTS_USES_VULKANSC
205 static MovePtr<vk::Library> createLibrary (tcu::TestContext& testCtx)
207 #ifdef DE_PLATFORM_USE_LIBRARY_TYPE
208 return MovePtr<vk::Library>(testCtx.getPlatform().getVulkanPlatform().createLibrary(vk::Platform::LIBRARY_TYPE_VULKAN, testCtx.getCommandLine().getVkLibraryPath()));
210 return MovePtr<vk::Library>(testCtx.getPlatform().getVulkanPlatform().createLibrary(testCtx.getCommandLine().getVkLibraryPath()));
214 static vk::VkPhysicalDeviceProperties getPhysicalDeviceProperties(vkt::Context& context)
216 const vk::InstanceInterface& vki = context.getInstanceInterface();
217 const vk::VkPhysicalDevice physicalDevice = context.getPhysicalDevice();
219 vk::VkPhysicalDeviceProperties properties;
220 vki.getPhysicalDeviceProperties(physicalDevice, &properties);
224 std::string trim (const std::string& original)
226 static const std::string whiteSigns = " \t";
227 const auto beg = original.find_first_not_of(whiteSigns);
228 if (beg == std::string::npos)
229 return std::string();
230 const auto end = original.find_last_not_of(whiteSigns);
231 return original.substr(beg, end - beg + 1);
234 TestCaseExecutor::TestCaseExecutor (tcu::TestContext& testCtx)
235 : m_prebuiltBinRegistry (testCtx.getArchive(), "vulkan/prebuilt")
236 , m_library (createLibrary(testCtx))
237 , m_renderDoc (testCtx.getCommandLine().isRenderDocEnabled()
238 ? MovePtr<vk::RenderDocUtil>(new vk::RenderDocUtil())
239 : MovePtr<vk::RenderDocUtil>(DE_NULL))
240 #if defined CTS_USES_VULKANSC
241 , m_resourceInterface (new vk::ResourceInterfaceVKSC(testCtx))
243 , m_resourceInterface (new vk::ResourceInterfaceStandard(testCtx))
244 #endif // CTS_USES_VULKANSC
245 , m_instance (DE_NULL)
246 #if defined CTS_USES_VULKANSC
247 , m_subprocessCount (0)
248 #endif // CTS_USES_VULKANSC
250 #ifdef CTS_USES_VULKANSC
251 std::vector<int> caseFraction = testCtx.getCommandLine().getCaseFraction();
252 std::string jsonFileName;
254 if (caseFraction.empty())
256 jsonFileName = "pipeline_data.txt";
261 jsonFileName = "pipeline_data_" + std::to_string(caseFraction[0]) + ".txt";
262 portOffset = caseFraction[0];
265 if (testCtx.getCommandLine().isSubProcess())
267 std::vector<deUint8> input = vksc_server::ipc::Child{portOffset}.GetFile(jsonFileName);
268 m_resourceInterface->importData(input);
272 m_parentIPC.reset( new vksc_server::ipc::Parent{portOffset} );
275 // Load information about test tree branches that use subprocess test count other than default
276 // Expected file format:
277 if (!testCtx.getCommandLine().isSubProcess() && !std::string(testCtx.getCommandLine().getSubprocessConfigFile()).empty())
279 std::ifstream iFile(testCtx.getCommandLine().getSubprocessConfigFile(), std::ios::in);
281 TCU_THROW(InternalError, (std::string("Missing config file defining number of tests: ") + testCtx.getCommandLine().getSubprocessConfigFile()).c_str());
283 while (std::getline(iFile, line))
287 std::size_t pos = line.find_first_of(',');
288 if (pos == std::string::npos)
290 std::string testPattern, testNumber;
291 std::copy(line.begin(), line.begin() + pos, std::back_inserter(testPattern));
292 testPattern = trim(testPattern);
293 std::copy(line.begin() + pos + 1, line.end(), std::back_inserter(testNumber));
294 testNumber = trim(testNumber);
295 if (testPattern.empty() || testNumber.empty())
297 std::istringstream is(testNumber);
299 if ((is >> testCount).fail())
301 m_detailedSubprocessTestCount.push_back(DetailedSubprocessTestCount{ testPattern, testCount });
303 // sort test patterns
304 std::sort(m_detailedSubprocessTestCount.begin(), m_detailedSubprocessTestCount.end(), [](const DetailedSubprocessTestCount& lhs, const DetailedSubprocessTestCount& rhs)
306 return lhs.testCount < rhs.testCount;
310 // If we are provided with remote location
311 if (!std::string(testCtx.getCommandLine().getServerAddress()).empty())
313 // Open connection with the server dedicated for standard output
314 vksc_server::OpenRemoteStandardOutput(testCtx.getCommandLine().getServerAddress());
315 restoreStandardOutput();
317 #endif // CTS_USES_VULKANSC
319 m_context = MovePtr<Context>(new Context(testCtx, m_library->getPlatformInterface(), m_progCollection, m_resourceInterface));
320 m_deviceProperties = getPhysicalDeviceProperties(*m_context);
322 tcu::SessionInfo sessionInfo(m_deviceProperties.vendorID,
323 m_deviceProperties.deviceID,
324 testCtx.getCommandLine().getInitialCmdLine());
325 m_waiverMechanism.setup(testCtx.getCommandLine().getWaiverFileName(),
327 m_deviceProperties.vendorID,
328 m_deviceProperties.deviceID,
331 #ifdef CTS_USES_VULKANSC
332 if (!std::string(testCtx.getCommandLine().getServerAddress()).empty())
334 vksc_server::AppendRequest request;
335 request.fileName = testCtx.getCommandLine().getLogFileName();
337 std::ostringstream str;
338 str << "#sessionInfo releaseName " << qpGetReleaseName() << std::endl;
339 str << "#sessionInfo releaseId 0x" << std::hex << std::setw(8) << std::setfill('0') << qpGetReleaseId() << std::endl;
340 str << "#sessionInfo targetName \"" << qpGetTargetName() << "\"" << std::endl;
341 str << sessionInfo.get() << std::endl;
342 str << "#beginSession" << std::endl;
344 std::string output = str.str();
345 request.data.assign(output.begin(), output.end());
346 request.clear = true;
347 vksc_server::StandardOutputServerSingleton()->SendRequest(request);
350 #endif // CTS_USES_VULKANSC
352 testCtx.getLog().writeSessionInfo(sessionInfo.get());
355 #ifdef CTS_USES_VULKANSC
356 m_resourceInterface->initApiVersion(m_context->getUsedApiVersion());
358 // Real Vulkan SC tests are performed in subprocess.
359 // Tests run in main process are only used to collect data required by Vulkan SC.
360 // That's why we turn off any output in main process and copy output from subprocess when subprocess tests are performed
361 if (!testCtx.getCommandLine().isSubProcess())
363 suppressStandardOutput();
364 m_context->getTestContext().getLog().supressLogging(true);
366 #endif // CTS_USES_VULKANSC
369 TestCaseExecutor::~TestCaseExecutor (void)
374 void TestCaseExecutor::init (tcu::TestCase* testCase, const std::string& casePath)
376 if (m_waiverMechanism.isOnWaiverList(casePath))
377 throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
379 TestCase* vktCase = dynamic_cast<TestCase*>(testCase);
380 tcu::TestLog& log = m_context->getTestContext().getLog();
381 const deUint32 usedVulkanVersion = m_context->getUsedApiVersion();
382 const vk::SpirvVersion baselineSpirvVersion = vk::getBaselineSpirvVersion(usedVulkanVersion);
383 vk::ShaderBuildOptions defaultGlslBuildOptions (usedVulkanVersion, baselineSpirvVersion, 0u);
384 vk::ShaderBuildOptions defaultHlslBuildOptions (usedVulkanVersion, baselineSpirvVersion, 0u);
385 vk::SpirVAsmBuildOptions defaultSpirvAsmBuildOptions (usedVulkanVersion, baselineSpirvVersion);
386 vk::SourceCollections sourceProgs (usedVulkanVersion, defaultGlslBuildOptions, defaultHlslBuildOptions, defaultSpirvAsmBuildOptions);
387 const tcu::CommandLine& commandLine = m_context->getTestContext().getCommandLine();
388 const bool doShaderLog = commandLine.isLogDecompiledSpirvEnabled() && log.isShaderLoggingEnabled();
391 TCU_THROW(InternalError, "Test node not an instance of vkt::TestCase");
394 #ifdef CTS_USES_VULKANSC
395 int currentSubprocessCount = getCurrentSubprocessCount(casePath, m_context->getTestContext().getCommandLine().getSubprocessTestCount());
396 if (m_subprocessCount && currentSubprocessCount != m_subprocessCount)
398 runTestsInSubprocess(m_context->getTestContext());
400 // Clean up data after performing tests in subprocess and prepare system for another batch of tests
401 m_testsForSubprocess.clear();
402 const vk::DeviceInterface& vkd = m_context->getDeviceInterface();
403 const vk::DeviceDriverSC* dds = dynamic_cast<const vk::DeviceDriverSC*>(&vkd);
405 TCU_THROW(InternalError, "Undefined device driver for Vulkan SC");
407 m_resourceInterface->resetObjects();
409 suppressStandardOutput();
410 m_context->getTestContext().getLog().supressLogging(true);
412 m_subprocessCount = currentSubprocessCount;
413 #endif // CTS_USES_VULKANSC
414 m_testsForSubprocess.push_back(casePath);
417 m_resourceInterface->initTestCase(casePath);
419 if (m_waiverMechanism.isOnWaiverList(casePath))
420 throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
422 vktCase->checkSupport(*m_context);
424 vktCase->delayedInit();
426 m_progCollection.clear();
427 vktCase->initPrograms(sourceProgs);
429 for (vk::GlslSourceCollection::Iterator progIter = sourceProgs.glslSources.begin(); progIter != sourceProgs.glslSources.end(); ++progIter)
431 if (!spirvVersionSupported(progIter.getProgram().buildOptions.targetVersion))
432 TCU_THROW(NotSupportedError, "Shader requires SPIR-V higher than available");
434 const vk::ProgramBinary* const binProg = m_resourceInterface->buildProgram<glu::ShaderProgramInfo, vk::GlslSourceCollection::Iterator>(casePath, progIter, m_prebuiltBinRegistry, &m_progCollection);
440 std::ostringstream disasm;
442 vk::disassembleProgram(*binProg, &disasm);
444 log << vk::SpirVAsmSource(disasm.str());
446 catch (const tcu::NotSupportedError& err)
453 for (vk::HlslSourceCollection::Iterator progIter = sourceProgs.hlslSources.begin(); progIter != sourceProgs.hlslSources.end(); ++progIter)
455 if (!spirvVersionSupported(progIter.getProgram().buildOptions.targetVersion))
456 TCU_THROW(NotSupportedError, "Shader requires SPIR-V higher than available");
458 const vk::ProgramBinary* const binProg = m_resourceInterface->buildProgram<glu::ShaderProgramInfo, vk::HlslSourceCollection::Iterator>(casePath, progIter, m_prebuiltBinRegistry, &m_progCollection);
464 std::ostringstream disasm;
466 vk::disassembleProgram(*binProg, &disasm);
468 log << vk::SpirVAsmSource(disasm.str());
470 catch (const tcu::NotSupportedError& err)
477 for (vk::SpirVAsmCollection::Iterator asmIterator = sourceProgs.spirvAsmSources.begin(); asmIterator != sourceProgs.spirvAsmSources.end(); ++asmIterator)
479 if (!spirvVersionSupported(asmIterator.getProgram().buildOptions.targetVersion))
480 TCU_THROW(NotSupportedError, "Shader requires SPIR-V higher than available");
482 m_resourceInterface->buildProgram<vk::SpirVProgramInfo, vk::SpirVAsmCollection::Iterator>(casePath, asmIterator, m_prebuiltBinRegistry, &m_progCollection);
485 if (m_renderDoc) m_renderDoc->startFrame(m_context->getInstance());
487 DE_ASSERT(!m_instance);
488 m_instance = vktCase->createInstance(*m_context);
489 m_context->resultSetOnValidation(false);
492 void TestCaseExecutor::deinit (tcu::TestCase* testCase)
495 m_instance = DE_NULL;
497 if (m_renderDoc) m_renderDoc->endFrame(m_context->getInstance());
499 // Collect and report any debug messages
500 #ifndef CTS_USES_VULKANSC
501 if (m_context->hasDebugReportRecorder())
502 collectAndReportDebugMessages(m_context->getDebugReportRecorder(), *m_context);
503 #endif // CTS_USES_VULKANSC
505 if (testCase != DE_NULL)
506 logUnusedShaders(testCase);
508 #ifdef CTS_USES_VULKANSC
509 if (!m_context->getTestContext().getCommandLine().isSubProcess())
511 int currentSubprocessCount = getCurrentSubprocessCount(m_context->getResourceInterface()->getCasePath(), m_context->getTestContext().getCommandLine().getSubprocessTestCount());
512 if (m_testsForSubprocess.size() >= std::size_t(currentSubprocessCount))
514 runTestsInSubprocess(m_context->getTestContext());
516 // Clean up data after performing tests in subprocess and prepare system for another batch of tests
517 m_testsForSubprocess.clear();
518 const vk::DeviceInterface& vkd = m_context->getDeviceInterface();
519 const vk::DeviceDriverSC* dds = dynamic_cast<const vk::DeviceDriverSC*>(&vkd);
521 TCU_THROW(InternalError, "Undefined device driver for Vulkan SC");
523 m_resourceInterface->resetObjects();
525 suppressStandardOutput();
526 m_context->getTestContext().getLog().supressLogging(true);
529 #endif // CTS_USES_VULKANSC
532 void TestCaseExecutor::logUnusedShaders (tcu::TestCase* testCase)
534 const qpTestResult testResult = testCase->getTestContext().getTestResult();
536 if (testResult == QP_TEST_RESULT_PASS || testResult == QP_TEST_RESULT_QUALITY_WARNING || testResult == QP_TEST_RESULT_COMPATIBILITY_WARNING)
538 bool unusedShaders = false;
540 for (vk::BinaryCollection::Iterator it = m_progCollection.begin(); it != m_progCollection.end(); ++it)
542 if (!it.getProgram().getUsed())
544 unusedShaders = true;
554 for (vk::BinaryCollection::Iterator it = m_progCollection.begin(); it != m_progCollection.end(); ++it)
556 if (!it.getProgram().getUsed())
557 message += it.getName() + ",";
560 message.resize(message.size() - 1);
562 message = std::string("Unused shaders: ") + message;
564 m_context->getTestContext().getLog() << TestLog::Message << message << TestLog::EndMessage;
569 tcu::TestNode::IterateResult TestCaseExecutor::iterate (tcu::TestCase*)
571 DE_ASSERT(m_instance);
573 const tcu::TestStatus result = m_instance->iterate();
575 if (result.isComplete())
577 // Vulkan tests shouldn't set result directly except when using a debug report messenger to catch validation errors.
578 DE_ASSERT(m_context->getTestContext().getTestResult() == QP_TEST_RESULT_LAST || m_context->resultSetOnValidation());
580 // Override result if not set previously by a debug report messenger.
581 if (!m_context->resultSetOnValidation())
582 m_context->getTestContext().setTestResult(result.getCode(), result.getDescription().c_str());
583 return tcu::TestNode::STOP;
586 return tcu::TestNode::CONTINUE;
589 void TestCaseExecutor::deinitTestPackage (tcu::TestContext& testCtx)
591 #ifdef CTS_USES_VULKANSC
592 if (!testCtx.getCommandLine().isSubProcess())
594 if (!m_testsForSubprocess.empty())
596 runTestsInSubprocess(testCtx);
598 // Clean up data after performing tests in subprocess and prepare system for another batch of tests
599 m_testsForSubprocess.clear();
600 const vk::DeviceInterface& vkd = m_context->getDeviceInterface();
601 const vk::DeviceDriverSC* dds = dynamic_cast<const vk::DeviceDriverSC*>(&vkd);
603 TCU_THROW(InternalError, "Undefined device driver for Vulkan SC");
605 m_resourceInterface->resetObjects();
608 // Tests are finished. Next tests ( if any ) will come from other test package and test executor
609 restoreStandardOutput();
610 m_context->getTestContext().getLog().supressLogging(false);
612 m_resourceInterface->resetPipelineCaches();
615 #endif // CTS_USES_VULKANSC
618 bool TestCaseExecutor::usesLocalStatus ()
620 #ifdef CTS_USES_VULKANSC
621 return !m_context->getTestContext().getCommandLine().isSubProcess();
627 void TestCaseExecutor::updateGlobalStatus (tcu::TestRunStatus& status)
629 status.numExecuted += m_status.numExecuted;
630 status.numPassed += m_status.numPassed;
631 status.numNotSupported += m_status.numNotSupported;
632 status.numWarnings += m_status.numWarnings;
633 status.numWaived += m_status.numWaived;
634 status.numFailed += m_status.numFailed;
638 void TestCaseExecutor::reportDurations(tcu::TestContext& testCtx, const std::string& packageName, const deInt64& duration, const std::map<std::string, deUint64>& groupsDurationTime)
640 #ifdef CTS_USES_VULKANSC
641 // Send it to server to append to its log
642 vksc_server::AppendRequest request;
643 request.fileName = testCtx.getCommandLine().getLogFileName();
645 std::ostringstream str;
648 str << "#beginTestsCasesTime" << std::endl;
650 str << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
651 str << "<TestsCasesTime>" << std::endl;
653 str << " <Number Name=\"" << packageName << "\" Description=\"Total tests case duration in microseconds\" Tag=\"Time\" Unit=\"us\">" << duration << "</Number>" << std::endl;
654 for (std::map<std::string, deUint64>::const_iterator it = groupsDurationTime.begin(); it != groupsDurationTime.end(); ++it)
655 str << " <Number Name=\"" << it->first << "\" Description=\"The test group case duration in microseconds\" Tag=\"Time\" Unit=\"us\">" << it->second << "</Number>" << std::endl;
656 str << "</TestsCasesTime>" << std::endl;
658 str << "#endTestsCasesTime" << std::endl;
660 str << "#endSession" << std::endl;
662 std::string output = str.str();
663 request.data.assign(output.begin(), output.end());
664 vksc_server::StandardOutputServerSingleton()->SendRequest(request);
667 DE_UNREF(packageName);
669 DE_UNREF(groupsDurationTime);
670 #endif // CTS_USES_VULKANSC
674 int TestCaseExecutor::getCurrentSubprocessCount(const std::string& casePath, int defaultSubprocessCount)
676 #ifdef CTS_USES_VULKANSC
677 for (const auto& detailed : m_detailedSubprocessTestCount)
678 if (tcu::matchWildcards(detailed.testPattern.begin(), detailed.testPattern.end(), casePath.begin(), casePath.end(), false))
679 return detailed.testCount;
682 #endif // CTS_USES_VULKANSC
683 return defaultSubprocessCount;
686 void TestCaseExecutor::runTestsInSubprocess (tcu::TestContext& testCtx)
688 #ifdef CTS_USES_VULKANSC
689 if (testCtx.getCommandLine().isSubProcess())
690 TCU_THROW(InternalError, "Cannot run subprocess inside subprocess : ");
692 if (m_testsForSubprocess.empty())
695 std::vector<int> caseFraction = testCtx.getCommandLine().getCaseFraction();
696 std::ostringstream jsonFileName, qpaFileName, pipelineCompilerOutFileName, pipelineCompilerLogFileName, pipelineCompilerPrefix;
697 if (caseFraction.empty())
699 jsonFileName << "pipeline_data.txt";
700 qpaFileName << "sub.qpa";
701 if (!std::string(testCtx.getCommandLine().getPipelineCompilerPath()).empty())
703 pipelineCompilerOutFileName << "pipeline_cache.bin";
704 pipelineCompilerLogFileName << "compiler.log";
705 pipelineCompilerPrefix << "";
710 jsonFileName << "pipeline_data_" << caseFraction[0] << ".txt";
711 qpaFileName << "sub_" << caseFraction[0] << ".qpa";
712 if (!std::string(testCtx.getCommandLine().getPipelineCompilerPath()).empty())
714 pipelineCompilerOutFileName << "pipeline_cache_" << caseFraction[0] <<".bin";
715 pipelineCompilerLogFileName << "compiler_" << caseFraction[0] << ".log";
716 pipelineCompilerPrefix << "sub_" << caseFraction[0] << "_";
720 // export data collected during statistics gathering to JSON file ( VkDeviceObjectReservationCreateInfo, SPIR-V shaders, pipelines )
722 m_resourceInterface->removeRedundantObjects();
723 m_resourceInterface->finalizeCommandBuffers();
724 std::vector<deUint8> data = m_resourceInterface->exportData();
725 m_parentIPC->SetFile(jsonFileName.str(), data);
728 // collect current application name, add it to new commandline with subprocess parameters
729 std::string newCmdLine;
731 std::string appName = testCtx.getCommandLine().getApplicationName();
733 TCU_THROW(InternalError, "Application name is not defined");
734 // add --deqp-subprocess option to inform deqp-vksc process that it works as slave process
735 newCmdLine = appName + " --deqp-subprocess=enable --deqp-log-filename=" + qpaFileName.str();
737 // add offline pipeline compiler parameters if present
738 if (!std::string(testCtx.getCommandLine().getPipelineCompilerPath()).empty())
740 newCmdLine += " --deqp-pipeline-compiler=" + std::string(testCtx.getCommandLine().getPipelineCompilerPath());
741 newCmdLine += " --deqp-pipeline-file=" + pipelineCompilerOutFileName.str();
742 if (!std::string(testCtx.getCommandLine().getPipelineCompilerDataDir()).empty())
743 newCmdLine += " --deqp-pipeline-dir=" + std::string(testCtx.getCommandLine().getPipelineCompilerDataDir());
744 newCmdLine += " --deqp-pipeline-logfile=" + pipelineCompilerLogFileName.str();
745 if(!pipelineCompilerPrefix.str().empty())
746 newCmdLine += " --deqp-pipeline-prefix=" + pipelineCompilerPrefix.str();
747 if (!std::string(testCtx.getCommandLine().getPipelineCompilerArgs()).empty())
748 newCmdLine += " --deqp-pipeline-args=\"" + std::string( testCtx.getCommandLine().getPipelineCompilerArgs() ) + "\"";
752 // collect parameters, remove parameters associated with case filter and case fraction. We will provide our own case list
754 std::string originalCmdLine = testCtx.getCommandLine().getInitialCmdLine();
756 // brave ( but working ) assumption that each CTS parameter starts with "--deqp"
758 std::string paramStr ("--deqp");
759 std::vector<std::string> skipElements =
762 "--deqp-stdin-caselist",
763 "--deqp-log-filename",
764 "--deqp-pipeline-compiler",
765 "--deqp-pipeline-dir",
766 "--deqp-pipeline-args",
767 "--deqp-pipeline-file",
768 "--deqp-pipeline-logfile",
769 "--deqp-pipeline-prefix"
773 std::vector<std::size_t> argPos;
774 while ((pos = originalCmdLine.find(paramStr, pos)) != std::string::npos)
775 argPos.push_back(pos++);
777 argPos.push_back(originalCmdLine.size());
779 std::vector<std::string> args;
780 for (std::size_t i = 0; i < argPos.size()-1; ++i)
782 std::string s = originalCmdLine.substr(argPos[i], argPos[i + 1] - argPos[i]);
783 std::size_t found = s.find_last_not_of(' ');
784 if (found != std::string::npos)
790 for (std::size_t i = 0; i < args.size(); ++i)
792 bool skipElement = false;
793 for (const auto& elem : skipElements)
794 if (args[i].find(elem) == 0)
801 newCmdLine = newCmdLine + " " + args[i];
805 // create --deqp-case list from tests collected in m_testsForSubprocess
806 std::string subprocessTestList;
807 for (auto it = begin(m_testsForSubprocess); it != end(m_testsForSubprocess); ++it)
809 auto nit = it; ++nit;
811 subprocessTestList += *it;
812 if (nit != end(m_testsForSubprocess))
813 subprocessTestList += "\n";
816 std::string caseListName = "subcaselist" + (caseFraction.empty() ? std::string("") : de::toString(caseFraction[0])) + ".txt";
818 deFile* exportFile = deFile_create(caseListName.c_str(), DE_FILEMODE_CREATE | DE_FILEMODE_OPEN | DE_FILEMODE_WRITE | DE_FILEMODE_TRUNCATE);
819 deInt64 numWritten = 0;
820 deFile_write(exportFile, subprocessTestList.c_str(), subprocessTestList.size(), &numWritten);
821 deFile_destroy(exportFile);
822 newCmdLine = newCmdLine + " --deqp-caselist-file=" + caseListName;
824 // restore cout and cerr
825 restoreStandardOutput();
827 // create subprocess which will perform real tests
828 std::string subProcessExitCodeInfo;
830 deProcess* process = deProcess_create();
831 if (deProcess_start(process, newCmdLine.c_str(), ".") != DE_TRUE)
833 std::string err = deProcess_getLastError(process);
834 deProcess_destroy(process);
836 TCU_THROW(InternalError, "Error while running subprocess : " + err);
839 whole.reserve(1024 * 4);
841 // create a separate thread that captures std::err output
842 de::MovePtr<std::thread> errThread(new std::thread([&process]
844 deFile* subErr = deProcess_getStdErr(process);
845 char errBuffer[128] = { 0 };
846 deInt64 errNumRead = 0;
847 while (deFile_read(subErr, errBuffer, sizeof(errBuffer) - 1, &errNumRead) == DE_FILERESULT_SUCCESS)
849 errBuffer[errNumRead] = 0;
853 deFile* subOutput = deProcess_getStdOut(process);
854 char outBuffer[128] = { 0 };
856 while (deFile_read(subOutput, outBuffer, sizeof(outBuffer) - 1, &numRead) == DE_FILERESULT_SUCCESS)
858 outBuffer[numRead] = 0;
863 if (deProcess_waitForFinish(process))
865 const int exitCode = deProcess_getExitCode(process);
868 s << " Subprocess failed with exit code " << exitCode << "(" << std::hex << exitCode << ")";
870 subProcessExitCodeInfo = s.str();
872 deProcess_destroy(process);
874 vksc_server::RemoteWrite(0, whole.c_str());
877 // copy test information from sub.qpa to main log
879 std::ifstream subQpa(qpaFileName.str(), std::ios::binary);
880 std::string subQpaText{std::istreambuf_iterator<char>(subQpa),
881 std::istreambuf_iterator<char>()};
883 std::string beginText ("#beginTestCaseResult");
884 std::string endText ("#endTestCaseResult");
885 std::size_t beginPos = subQpaText.find(beginText);
886 std::size_t endPos = subQpaText.rfind(endText);
887 if (beginPos == std::string::npos || endPos == std::string::npos)
888 TCU_THROW(InternalError, "Couldn't match tags from " + qpaFileName.str() + subProcessExitCodeInfo);
890 std::string subQpaCopy = "\n" + std::string(subQpaText.begin() + beginPos, subQpaText.begin() + endPos + endText.size()) + "\n";
892 if (!std::string(testCtx.getCommandLine().getServerAddress()).empty())
894 // Send it to server to append to its log
895 vksc_server::AppendRequest request;
896 request.fileName = testCtx.getCommandLine().getLogFileName();
897 request.data.assign(subQpaCopy.begin(), subQpaCopy.end());
898 vksc_server::StandardOutputServerSingleton()->SendRequest(request);
902 // Write it to parent's log
905 testCtx.getLog().supressLogging(false);
906 testCtx.getLog().writeRaw(subQpaCopy.c_str());
910 testCtx.getLog().supressLogging(true);
913 testCtx.getLog().supressLogging(true);
918 std::string beginStat ("#SubProcessStatus");
919 std::size_t beginPos = subQpaText.find(beginStat);
920 if (beginPos == std::string::npos)
921 TCU_THROW(InternalError, "Couldn't match #SubProcessStatus tag from " + qpaFileName.str() + subProcessExitCodeInfo);
923 std::string subQpaStat (subQpaText.begin() + beginPos + beginStat.size(), subQpaText.end());
925 std::istringstream str(subQpaStat);
926 int numExecuted, numPassed, numFailed, numNotSupported, numWarnings, numWaived;
927 str >> numExecuted >> numPassed >> numFailed >> numNotSupported >> numWarnings >> numWaived;
929 m_status.numExecuted += numExecuted;
930 m_status.numPassed += numPassed;
931 m_status.numNotSupported += numNotSupported;
932 m_status.numWarnings += numWarnings;
933 m_status.numWaived += numWaived;
934 m_status.numFailed += numFailed;
937 deDeleteFile(qpaFileName.str().c_str());
941 #endif // CTS_USES_VULKANSC
944 bool TestCaseExecutor::spirvVersionSupported (vk::SpirvVersion spirvVersion)
946 if (spirvVersion <= vk::getMaxSpirvVersionForVulkan(m_context->getUsedApiVersion()))
949 if (spirvVersion <= vk::SPIRV_VERSION_1_4)
950 return m_context->isDeviceFunctionalitySupported("VK_KHR_spirv_1_4");
957 void createGlslTests (tcu::TestCaseGroup* glslTests)
959 tcu::TestContext& testCtx = glslTests->getTestContext();
961 // ShaderLibrary-based tests
965 const char* description;
968 { "arrays", "Arrays" },
969 { "conditionals", "Conditional statements" },
970 { "constant_expressions", "Constant expressions" },
971 { "constants", "Constants" },
972 { "conversions", "Type conversions" },
973 { "functions", "Functions" },
974 { "linkage", "Linking" },
975 { "scoping", "Scoping" },
976 { "swizzles", "Swizzles" },
979 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_es310Tests); ndx++)
980 glslTests->addChild(createShaderLibraryGroup(testCtx,
981 s_es310Tests[ndx].name,
982 s_es310Tests[ndx].description,
983 std::string("vulkan/glsl/es310/") + s_es310Tests[ndx].name + ".test").release());
988 const char* description;
991 { "linkage", "Linking" },
994 de::MovePtr<tcu::TestCaseGroup> glsl440Tests = de::MovePtr<tcu::TestCaseGroup>(new tcu::TestCaseGroup(testCtx, "440", ""));
996 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_440Tests); ndx++)
997 glsl440Tests->addChild(createShaderLibraryGroup(testCtx,
998 s_440Tests[ndx].name,
999 s_440Tests[ndx].description,
1000 std::string("vulkan/glsl/440/") + s_440Tests[ndx].name + ".test").release());
1002 glslTests->addChild(glsl440Tests.release());
1004 // ShaderRenderCase-based tests
1005 glslTests->addChild(sr::createDerivateTests (testCtx));
1006 glslTests->addChild(sr::createDiscardTests (testCtx));
1007 #ifndef CTS_USES_VULKANSC
1008 glslTests->addChild(sr::createDemoteTests (testCtx));
1009 #endif // CTS_USES_VULKANSC
1010 glslTests->addChild(sr::createIndexingTests (testCtx));
1011 glslTests->addChild(sr::createShaderInvarianceTests (testCtx));
1012 glslTests->addChild(sr::createLimitTests (testCtx));
1013 glslTests->addChild(sr::createLoopTests (testCtx));
1014 glslTests->addChild(sr::createMatrixTests (testCtx));
1015 glslTests->addChild(sr::createOperatorTests (testCtx));
1016 glslTests->addChild(sr::createReturnTests (testCtx));
1017 glslTests->addChild(sr::createStructTests (testCtx));
1018 glslTests->addChild(sr::createSwitchTests (testCtx));
1019 glslTests->addChild(sr::createTextureFunctionTests (testCtx));
1020 glslTests->addChild(sr::createTextureGatherTests (testCtx));
1021 glslTests->addChild(sr::createBuiltinVarTests (testCtx));
1023 // ShaderExecutor-based tests
1024 glslTests->addChild(shaderexecutor::createBuiltinTests (testCtx));
1025 glslTests->addChild(shaderexecutor::createOpaqueTypeIndexingTests (testCtx));
1026 glslTests->addChild(shaderexecutor::createAtomicOperationTests (testCtx));
1027 glslTests->addChild(shaderexecutor::createShaderClockTests (testCtx));
1029 #ifndef CTS_USES_VULKANSC
1030 // Amber GLSL tests.
1031 glslTests->addChild(cts_amber::createCombinedOperationsGroup (testCtx));
1032 glslTests->addChild(cts_amber::createCrashTestGroup (testCtx));
1033 #endif // CTS_USES_VULKANSC
1038 BaseTestPackage::BaseTestPackage (tcu::TestContext& testCtx, const char* name, const char* desc)
1039 : tcu::TestPackage(testCtx, name, desc)
1043 BaseTestPackage::~BaseTestPackage (void)
1047 #ifdef CTS_USES_VULKAN
1049 TestPackage::TestPackage (tcu::TestContext& testCtx)
1050 : BaseTestPackage(testCtx, "dEQP-VK", "dEQP Vulkan Tests")
1054 TestPackage::~TestPackage (void)
1058 ExperimentalTestPackage::ExperimentalTestPackage (tcu::TestContext& testCtx)
1059 : BaseTestPackage(testCtx, "dEQP-VK-experimental", "dEQP Vulkan Experimental Tests")
1063 ExperimentalTestPackage::~ExperimentalTestPackage (void)
1069 #ifdef CTS_USES_VULKANSC
1071 TestPackageSC::TestPackageSC (tcu::TestContext& testCtx)
1072 : BaseTestPackage(testCtx, "dEQP-VKSC", "dEQP Vulkan SC Tests")
1076 TestPackageSC::~TestPackageSC (void)
1080 #endif // CTS_USES_VULKANSC
1082 tcu::TestCaseExecutor* BaseTestPackage::createExecutor (void) const
1084 return new TestCaseExecutor(m_testCtx);
1087 #ifdef CTS_USES_VULKAN
1089 void TestPackage::init (void)
1091 addChild(createTestGroup (m_testCtx, "info", "Build and Device Info Tests", createInfoTests));
1092 addChild(api::createTests (m_testCtx));
1093 addChild(memory::createTests (m_testCtx));
1094 addChild(pipeline::createTests (m_testCtx));
1095 addChild(BindingModel::createTests (m_testCtx));
1096 addChild(SpirVAssembly::createTests (m_testCtx));
1097 addChild(createTestGroup (m_testCtx, "glsl", "GLSL shader execution tests", createGlslTests));
1098 addChild(createRenderPassTests (m_testCtx));
1099 addChild(createRenderPass2Tests (m_testCtx));
1100 addChild(createDynamicRenderingTests (m_testCtx));
1101 addChild(ubo::createTests (m_testCtx));
1102 addChild(DynamicState::createTests (m_testCtx));
1103 addChild(ssbo::createTests (m_testCtx));
1104 addChild(QueryPool::createTests (m_testCtx));
1105 addChild(Draw::createTests (m_testCtx));
1106 addChild(compute::createTests (m_testCtx));
1107 addChild(image::createTests (m_testCtx));
1108 addChild(wsi::createTests (m_testCtx));
1109 addChild(createSynchronizationTests (m_testCtx));
1110 addChild(createSynchronization2Tests (m_testCtx));
1111 addChild(sparse::createTests (m_testCtx));
1112 addChild(tessellation::createTests (m_testCtx));
1113 addChild(rasterization::createTests (m_testCtx));
1114 addChild(clipping::createTests (m_testCtx));
1115 addChild(FragmentOperations::createTests (m_testCtx));
1116 addChild(texture::createTests (m_testCtx));
1117 addChild(geometry::createTests (m_testCtx));
1118 addChild(robustness::createTests (m_testCtx));
1119 addChild(MultiView::createTests (m_testCtx));
1120 addChild(subgroups::createTests (m_testCtx));
1121 addChild(ycbcr::createTests (m_testCtx));
1122 addChild(ProtectedMem::createTests (m_testCtx));
1123 addChild(DeviceGroup::createTests (m_testCtx));
1124 addChild(MemoryModel::createTests (m_testCtx));
1125 addChild(conditional::createTests (m_testCtx));
1126 addChild(cts_amber::createGraphicsFuzzTests (m_testCtx));
1127 addChild(imageless::createTests (m_testCtx));
1128 addChild(TransformFeedback::createTests (m_testCtx));
1129 addChild(DescriptorIndexing::createTests (m_testCtx));
1130 addChild(FragmentShaderInterlock::createTests(m_testCtx));
1131 addChild(modifiers::createTests (m_testCtx));
1132 addChild(RayTracing::createTests (m_testCtx));
1133 addChild(RayQuery::createTests (m_testCtx));
1134 addChild(FragmentShadingRate::createTests (m_testCtx));
1135 addChild(Reconvergence::createTests (m_testCtx, false));
1136 addChild(MeshShader::createTests (m_testCtx));
1137 addChild(FragmentShadingBarycentric::createTests(m_testCtx));
1138 // Amber depth pipeline tests
1139 addChild(cts_amber::createAmberDepthGroup (m_testCtx));
1140 addChild(video::createTests (m_testCtx));
1143 void ExperimentalTestPackage::init (void)
1145 addChild(postmortem::createTests (m_testCtx));
1146 addChild(Reconvergence::createTests (m_testCtx, true));
1151 #ifdef CTS_USES_VULKANSC
1153 void TestPackageSC::init (void)
1155 addChild(createTestGroup (m_testCtx, "info", "Build and Device Info Tests", createInfoTests));
1156 addChild(api::createTests (m_testCtx));
1157 addChild(memory::createTests (m_testCtx));
1158 addChild(pipeline::createTests (m_testCtx));
1159 addChild(BindingModel::createTests (m_testCtx));
1160 addChild(SpirVAssembly::createTests (m_testCtx));
1161 addChild(createTestGroup (m_testCtx, "glsl", "GLSL shader execution tests", createGlslTests));
1162 addChild(createRenderPassTests (m_testCtx));
1163 addChild(createRenderPass2Tests (m_testCtx));
1164 addChild(ubo::createTests (m_testCtx));
1165 addChild(DynamicState::createTests (m_testCtx));
1166 addChild(ssbo::createTests (m_testCtx));
1167 addChild(QueryPool::createTests (m_testCtx));
1168 addChild(Draw::createTests (m_testCtx));
1169 addChild(compute::createTests (m_testCtx));
1170 addChild(image::createTests (m_testCtx));
1171 // addChild(wsi::createTests (m_testCtx));
1172 addChild(createSynchronizationTests (m_testCtx));
1173 addChild(createSynchronization2Tests (m_testCtx));
1174 // addChild(sparse::createTests (m_testCtx));
1175 addChild(tessellation::createTests (m_testCtx));
1176 addChild(rasterization::createTests (m_testCtx));
1177 addChild(clipping::createTests (m_testCtx));
1178 addChild(FragmentOperations::createTests (m_testCtx));
1179 addChild(texture::createTests (m_testCtx));
1180 addChild(geometry::createTests (m_testCtx));
1181 addChild(robustness::createTests (m_testCtx));
1182 addChild(MultiView::createTests (m_testCtx));
1183 addChild(subgroups::createTests (m_testCtx));
1184 addChild(ycbcr::createTests (m_testCtx));
1185 addChild(ProtectedMem::createTests (m_testCtx));
1186 addChild(DeviceGroup::createTests (m_testCtx));
1187 addChild(MemoryModel::createTests (m_testCtx));
1188 // addChild(conditional::createTests (m_testCtx));
1189 // addChild(cts_amber::createGraphicsFuzzTests (m_testCtx));
1190 addChild(imageless::createTests (m_testCtx));
1191 // addChild(TransformFeedback::createTests (m_testCtx));
1192 addChild(DescriptorIndexing::createTests (m_testCtx));
1193 addChild(FragmentShaderInterlock::createTests(m_testCtx));
1194 // addChild(modifiers::createTests (m_testCtx));
1195 // addChild(RayTracing::createTests (m_testCtx));
1196 // addChild(RayQuery::createTests (m_testCtx));
1197 addChild(FragmentShadingRate::createTests(m_testCtx));
1198 addChild(sc::createTests(m_testCtx));
1201 #endif // CTS_USES_VULKANSC