diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-04-02 09:22:13 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-02 09:22:13 -0400 |
| commit | 2896aa39a529a00673a30ef4a9c3ebe76f401fea (patch) | |
| tree | 3db2c41af598b3285c5313055d90dbf1a5cc06b6 /tools/slang-test/test-context.h | |
| parent | c21bffecd9da150576f62ecf8a73a1660717abe9 (diff) | |
Feature/test improvements (#934)
* First pass extract the test information by 'running tests'.
* * Checking renderer availablilty
* Using TestInfo to determine which tests are run and synthesized
* Display if test is synthesized and what render api it's targetting
* * Improved comments
* Removed some dead code
* Display ignored tests.
* TestInfo -> TestRequirements
* * Added DIAGNOSTIC_TEST type - test always runs (ie has no requirements).
* Made diagnostic tests use DIAGNOSTIC_TEST
* TestInfo -> TestRequirements
* TestDetails holds TestRequirements and TestOptions
* Fix debug typo.
Diffstat (limited to 'tools/slang-test/test-context.h')
| -rw-r--r-- | tools/slang-test/test-context.h | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/tools/slang-test/test-context.h b/tools/slang-test/test-context.h index b07ca94e6..95b46fe6e 100644 --- a/tools/slang-test/test-context.h +++ b/tools/slang-test/test-context.h @@ -8,16 +8,78 @@ #include "../../source/core/slang-std-writers.h" #include "../../source/core/dictionary.h" #include "../../source/core/slang-test-tool-util.h" +#include "../../source/core/slang-render-api-util.h" #include "options.h" +enum class BackendType +{ + Unknown = -1, + Dxc, + Fxc, + Glslang, + CountOf, +}; + +typedef uint32_t BackendFlags; +struct BackendFlag +{ + enum Enum : uint32_t + { + Dxc = 1 << int(BackendType::Dxc), + Fxc = 1 << int(BackendType::Fxc), + Glslang = 1 << int(BackendType::Glslang), + }; +}; + +/// Structure that describes requirements needs to run - such as rendering APIs or +/// back-end availability +struct TestRequirements +{ + TestRequirements& addUsed(BackendType type) + { + if (type != BackendType::Unknown) + { + usedBackendFlags |= BackendFlags(1) << int(type); + } + return *this; + } + TestRequirements& addUsed(Slang::RenderApiType type) + { + using namespace Slang; + if (type != RenderApiType::Unknown) + { + usedRenderApiFlags |=RenderApiFlags(1) << int(type); + } + return *this; + } + TestRequirements& addUsedBackends(BackendFlags flags) + { + usedBackendFlags |= flags; + return *this; + } + TestRequirements& addUsedRenderApis(Slang::RenderApiFlags flags) + { + usedRenderApiFlags |= flags; + return *this; + } + /// True if has this render api as used + bool isUsed(Slang::RenderApiType apiType) const + { + return (apiType != Slang::RenderApiType::Unknown) && ((usedRenderApiFlags & (Slang::RenderApiFlags(1) << int(apiType))) != 0); + } + + Slang::RenderApiType explicitRenderApi = Slang::RenderApiType::Unknown; ///< The render api explicitly specified + BackendFlags usedBackendFlags = 0; ///< Used backends + Slang::RenderApiFlags usedRenderApiFlags = 0; ///< Used render api flags (some might be implied) +}; + class TestContext { public: typedef Slang::TestToolUtil::InnerMainFunc InnerMainFunc; - /// Get the slang session SlangSession* getSession() const { return m_session; } @@ -28,6 +90,11 @@ class TestContext /// Set the function for the shared library void setInnerMainFunc(const Slang::String& name, InnerMainFunc func); + /// If true tests aren't being run just the information on testing is being accumulated + bool isCollectingRequirements() const { return testRequirements != nullptr; } + /// If set, then tests are executed + bool isExecuting() const { return testRequirements == nullptr; } + /// Ctor TestContext(); /// Dtor @@ -37,6 +104,13 @@ class TestContext TestReporter* reporter = nullptr; TestCategorySet categorySet; + /// If set then tests are not run, but their requirements are set + TestRequirements* testRequirements = nullptr; + + BackendFlags availableBackendFlags = 0; + Slang::RenderApiFlags availableRenderApiFlags = 0; + bool isAvailableRenderApiFlagsValid = false; + protected: struct SharedLibraryTool { |
