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
6#include <chrono>
7#include <functional>
8#include <map>
9#include <set>
10#include <string>
11#include <vector>
12
13#include "pgraph_diff_token.h"
14
15class TestHost;
16
20class TestSuite {
21 public:
23 struct Config {
26
27 // !Enables a diff of the nv2a PGRAPH registers before and after each test case.
28 bool enable_pgraph_region_diff;
29
32
33 // Optional FTPLogger used to transfer test artifacts to a remote host.
34 std::shared_ptr<FTPLogger> ftp_logger;
35 };
36
37 public:
38 TestSuite() = delete;
39 TestSuite(TestHost &host, std::string output_dir, std::string suite_name, const Config &config,
40 bool interactive_only = false);
41 virtual ~TestSuite() = default;
42
43 [[nodiscard]] const std::string &Name() const { return suite_name_; };
44
46 virtual void Initialize();
47
49 virtual void Deinitialize();
50
52 virtual void SetupTest();
53
55 virtual void TearDownTest();
56
57 void DisableTests(const std::set<std::string> &tests_to_skip);
58
59 [[nodiscard]] std::vector<std::string> TestNames() const;
60 [[nodiscard]] bool HasEnabledTests() const { return !tests_.empty(); };
61
62 void Run(const std::string &test_name);
63
64 void RunAll();
65
66 bool IsInteractiveOnly() const { return interactive_only_; }
67 void SetSavingAllowed(bool enable = true) { allow_saving_ = enable; }
68
70 static void TagNV2ATrace(uint32_t num_nops);
71
72 protected:
73 void SetDefaultTextureFormat() const;
74
75 private:
76 std::chrono::steady_clock::time_point LogTestStart(const std::string &test_name);
77 long LogTestEnd(const std::string &test_name, const std::chrono::steady_clock::time_point &start_time) const;
78
79 protected:
80 TestHost &host_;
81 std::string output_dir_;
82 std::string suite_name_;
83
84 // Flag indicating that suite should be skipped if not directly invoked by the user.
85 bool interactive_only_;
86
87 // Flag to forcibly disallow saving of output (e.g., when in multiframe test mode for debugging).
88 bool allow_saving_{true};
89
90 // Map of `test_name` to `void test()`
91 std::map<std::string, std::function<void()>> tests_{};
92
93 PGRAPHDiffToken pgraph_diff_;
94
95 bool enable_progress_log_;
96 bool enable_pgraph_region_diff_;
97 uint32_t delay_milliseconds_between_tests_;
98
99 std::shared_ptr<FTPLogger> ftp_logger_;
100};
101
102#endif // NXDK_PGRAPH_TESTS_TEST_SUITE_H
Definition test_host.h:33
Definition test_suite.h:20
virtual void Initialize()
Called to initialize the test suite.
Definition test_suite.cpp:120
virtual void Deinitialize()
Called to tear down the test suite.
Definition test_suite.cpp:342
virtual void TearDownTest()
Called after running an individual test within this suite.
Definition test_suite.cpp:350
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:333
virtual void SetupTest()
Called before running an individual test within this suite.
Definition test_suite.cpp:348
Definition pgraph_diff_token.h:6
Runtime configuration for TestSuites.
Definition test_suite.h:23
bool enable_progress_log
Enable logging of test progress to file.
Definition test_suite.h:25
uint32_t delay_milliseconds_between_tests
Artificial delay before starting each test.
Definition test_suite.h:31