summaryrefslogtreecommitdiffstats
path: root/tools/slang-test/options.h
blob: a210a7558e4033be6f5c91f0d32e5b58e9cb73e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// options.h

#ifndef OPTIONS_H_INCLUDED
#define OPTIONS_H_INCLUDED

#include "../../source/core/slang-dictionary.h"

#include "test-reporter.h"
#include "../../source/core/slang-render-api-util.h"
#include "../../source/core/slang-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<TestCategory> defaultCategory;    ///< The default category

protected:
    Slang::Dictionary<Slang::String, Slang::RefPtr<TestCategory> > m_categoryMap;
};

struct Options
{
    char const* appName = "slang-test";

    // Directory to use when looking for binaries to run. If empty it's not set.
    Slang::String 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;

    // Use verbose paths
    bool verbosePaths = 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<TestCategory*, TestCategory*> includeCategories;

    // Exclude test that match one these categories
    Slang::Dictionary<TestCategory*, TestCategory*> excludeCategories;

    // By default we can test against all apis
    Slang::RenderApiFlags enabledApis = Slang::RenderApiFlag::AllOf;

    // The subCommand to execute. Will be empty if there is no subCommand 
    Slang::String subCommand;      

    // Arguments to the sub command. Note that if there is a subCommand the first parameter is always the subCommand itself.
    Slang::List<Slang::String> subCommandArgs;

    // By default we potentially synthesize test for all 
    // TODO: Vulkan is disabled by default for now as the majority as vulkan synthesized tests
    // OpenGL is disabled for now
    Slang::RenderApiFlags synthesizedTestApis = Slang::RenderApiFlag::AllOf & ~(Slang::RenderApiFlag::Vulkan | Slang::RenderApiFlag::OpenGl | Slang::RenderApiFlag::CPU);

    // The adapter to use. If empty will match first found adapter.
    Slang::String adapter;

        /// 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