From d43c566fa29bbc0da1534aea236d54ee5ca104b8 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 14 Dec 2018 15:24:21 -0500 Subject: Fix memory leaks around slang-test (#757) * Remove circular reference to renderer on Vk & D3D12 DescriptorSetImpl * Refactor Stbi image loading such that memory is correctly freed when goes out of scope. Added Crt memory dump at termination. Reduced erroneous reporting by scoping TestContext. * Used capitalized acronym for STBImage to keep Tim happy. * Split out TestReporter - to just handle reporting test results Split out Options Made TestContext hold options, and the reporter Removed remaining memory leaks. * Small optimization for rawWrite, such that it directly writes over print.. * Improve comments on TestCategorySet * Fix typos in TestCategorySet --- tools/slang-test/options.h | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tools/slang-test/options.h (limited to 'tools/slang-test/options.h') diff --git a/tools/slang-test/options.h b/tools/slang-test/options.h new file mode 100644 index 000000000..ccbd9aede --- /dev/null +++ b/tools/slang-test/options.h @@ -0,0 +1,83 @@ +// options.h + +#ifndef OPTIONS_H_INCLUDED +#define OPTIONS_H_INCLUDED + +#include "../../source/core/dictionary.h" + +#include "test-reporter.h" +#include "render-api-util.h" +#include "../../source/core/smart-pointer.h" + +// A category that a test can be tagged with +struct TestCategory: public Slang::RefObject +{ + // The name of the category, from the user perspective + Slang::String name; + + // The logical "super-category" of this category + TestCategory* parent; +}; + +struct TestCategorySet +{ +public: + /// Find a category with the specified name. Returns nullptr if not found + TestCategory * find(Slang::String const& name); + /// Adds a category with the specified name, and parent. Returns the category object. + /// Parent can be nullptr + TestCategory* add(Slang::String const& name, TestCategory* parent); + /// Finds a category by name, else reports and writes an error + TestCategory* findOrError(Slang::String const& name); + + Slang::RefPtr defaultCategory; ///< The default category + +protected: + Slang::Dictionary > m_categoryMap; +}; + +struct Options +{ + char const* appName = "slang-test"; + + // Directory to use when looking for binaries to run + char const* binDir = ""; + + // only run test cases with names that have this prefix + char const* testPrefix = nullptr; + + // generate extra output (notably: command lines we run) + bool shouldBeVerbose = false; + + // force generation of baselines for HLSL tests + bool generateHLSLBaselines = false; + + // Dump expected/actual output on failures, for debugging. + // This is especially intended for use in continuous + // integration builds. + bool dumpOutputOnFailure = false; + + // If set, will force using of executables (not shared library) for tests + bool useExes = false; + + // kind of output to generate + TestOutputMode outputMode = TestOutputMode::Default; + + // Only run tests that match one of the given categories + Slang::Dictionary includeCategories; + + // Exclude test that match one these categories + Slang::Dictionary excludeCategories; + + // By default we can test against all apis + RenderApiFlags enabledApis = RenderApiFlag::AllOf; + + // By default we potentially synthesize test for all + // TODO: Vulkan is disabled by default for now as the majority as vulkan synthesized tests fail + RenderApiFlags synthesizedTestApis = RenderApiFlag::AllOf & ~RenderApiFlag::Vulkan; + + /// Parse the args, report any errors into stdError, and write the results into optionsOut + static SlangResult parse(int argc, char** argv, TestCategorySet* categorySet, Slang::WriterHelper stdError, Options* optionsOut); +}; + +#endif // OPTIONS_H_INCLUDED -- cgit v1.2.3