nxdk_pgraph_tests
A collection of tests for the Xbox nv2a graphics processor
 
Loading...
Searching...
No Matches
test_suite.h
1#ifndef NXDK_PGRAPH_TESTS_TEST_SUITE_H
2#define NXDK_PGRAPH_TESTS_TEST_SUITE_H
3
4#include <ftp_logger.h>
5#include <test_host.h>
6
7#include <chrono>
8#include <functional>
9#include <map>
10#include <set>
11#include <string>
12#include <vector>
13
14#include "pgraph_diff_token.h"
15
16class TestHost;
17
21class TestSuite {
22 public:
24 struct Config {
27
28 // !Enables a diff of the nv2a PGRAPH registers before and after each test case.
29 bool enable_pgraph_region_diff;
30
33
34 // Optional FTPLogger used to transfer test artifacts to a remote host.
35 std::shared_ptr<FTPLogger> ftp_logger;
36 };
37
38 public:
39 TestSuite() = delete;
40 TestSuite(TestHost &host, std::string output_dir, std::string suite_name, const Config &config,
41 bool interactive_only = false);
42 virtual ~TestSuite() = default;
43
44 [[nodiscard]] const std::string &Name() const { return suite_name_; };
45
47 virtual void Initialize();
48
50 virtual void Deinitialize();
51
53 virtual void SetupTest();
54
56 virtual void TearDownTest();
57
58 void DisableTests(const std::set<std::string> &tests_to_skip);
59
60 [[nodiscard]] std::vector<std::string> TestNames() const;
61 [[nodiscard]] bool HasEnabledTests() const { return !tests_.empty(); };
62
63 void Run(const std::string &test_name);
64
69 void RunAll(bool inclue_interactive);
70
71 [[nodiscard]] bool IsInteractiveOnly() const { return interactive_only_; }
72 void SetSavingAllowed(bool enable = true) { allow_saving_ = enable; }
73
75 static void TagNV2ATrace(uint32_t num_nops);
76
77 protected:
78 void SetDefaultTextureFormat() const;
79
82 void FinishDraw(const std::string &name, bool save_zbuffer = false) {
83 host_.FinishDraw(allow_saving_, output_dir_, suite_name_, name, save_zbuffer);
84 }
85
86 void FinishDrawNoSave(const std::string &name, bool save_zbuffer = false) {
87 host_.FinishDraw(false, output_dir_, suite_name_, name, save_zbuffer);
88 }
89
90 private:
91 std::chrono::steady_clock::time_point LogTestStart(const std::string &test_name);
92 long LogTestEnd(const std::string &test_name, const std::chrono::steady_clock::time_point &start_time) const;
93
94 protected:
95 TestHost &host_;
96 std::string output_dir_;
97 std::string suite_name_;
98
99 // Flag indicating that suite should be skipped if not directly invoked by the user.
100 bool interactive_only_;
101
102 // Flag to forcibly disallow saving of output (e.g., when in multiframe test mode for debugging).
103 bool allow_saving_{true};
104
105 // Map of `test_name` to `void test()`
106 std::map<std::string, std::function<void()>> tests_{};
107 std::set<std::string> interactive_only_tests_{};
108
109 PGRAPHDiffToken pgraph_diff_;
110
111 bool enable_progress_log_;
112 bool enable_pgraph_region_diff_;
113 uint32_t delay_milliseconds_between_tests_;
114
115 std::shared_ptr<FTPLogger> ftp_logger_;
116};
117
118#endif // NXDK_PGRAPH_TESTS_TEST_SUITE_H
Definition test_host.h:33
void FinishDraw(bool allow_saving, const std::string &output_directory, const std::string &suite_name, const std::string &name, bool save_zbuffer=false)
Marks drawing as completed, potentially causing artifacts (framebuffer, z/stencil-buffer) to be saved...
Definition test_host.cpp:200
Definition test_suite.h:21
virtual void Initialize()
Called to initialize the test suite.
Definition test_suite.cpp:122
virtual void Deinitialize()
Called to tear down the test suite.
Definition test_suite.cpp:344
void RunAll(bool inclue_interactive)
Definition test_suite.cpp:101
virtual void TearDownTest()
Called after running an individual test within this suite.
Definition test_suite.cpp:352
static void TagNV2ATrace(uint32_t num_nops)
Inserts a pattern of NV097_NO_OPERATION's into the pushbuffer to allow identification when viewing nv...
Definition test_suite.cpp:335
void FinishDraw(const std::string &name, bool save_zbuffer=false)
Definition test_suite.h:82
virtual void SetupTest()
Called before running an individual test within this suite.
Definition test_suite.cpp:350
Definition pgraph_diff_token.h:6
Runtime configuration for TestSuites.
Definition test_suite.h:24
bool enable_progress_log
Enable logging of test progress to file.
Definition test_suite.h:26
uint32_t delay_milliseconds_between_tests
Artificial delay before starting each test.
Definition test_suite.h:32