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 virtual ~TestSuite() = default;
41
42 [[nodiscard]] const std::string &Name() const { return suite_name_; };
43
45 virtual void Initialize();
46
48 virtual void Deinitialize();
49
51 virtual void SetupTest();
52
54 virtual void TearDownTest();
55
56 void DisableTests(const std::set<std::string> &tests_to_skip);
57
58 [[nodiscard]] std::vector<std::string> TestNames() const;
59 [[nodiscard]] bool HasEnabledTests() const { return !tests_.empty(); };
60
61 void Run(const std::string &test_name);
62
63 void RunAll();
64
65 void SetSavingAllowed(bool enable = true) { allow_saving_ = enable; }
66
68 static void TagNV2ATrace(uint32_t num_nops);
69
70 protected:
71 void SetDefaultTextureFormat() const;
72
73 private:
74 std::chrono::steady_clock::time_point LogTestStart(const std::string &test_name);
75 long LogTestEnd(const std::string &test_name, const std::chrono::steady_clock::time_point &start_time) const;
76
77 protected:
78 TestHost &host_;
79 std::string output_dir_;
80 std::string suite_name_;
81
82 // Flag to forcibly disallow saving of output (e.g., when in multiframe test mode for debugging).
83 bool allow_saving_{true};
84
85 // Map of `test_name` to `void test()`
86 std::map<std::string, std::function<void()>> tests_{};
87
88 PGRAPHDiffToken pgraph_diff_;
89
90 bool enable_progress_log_;
91 bool enable_pgraph_region_diff_;
92 uint32_t delay_milliseconds_between_tests_;
93
94 std::shared_ptr<FTPLogger> ftp_logger_;
95};
96
97#endif // NXDK_PGRAPH_TESTS_TEST_SUITE_H
Definition test_host.h:47
Definition test_suite.h:20
virtual void Initialize()
Called to initialize the test suite.
Definition test_suite.cpp:117
virtual void Deinitialize()
Called to tear down the test suite.
Definition test_suite.cpp:340
virtual void TearDownTest()
Called after running an individual test within this suite.
Definition test_suite.cpp:348
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:346
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