diff options
author | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
commit | 6aaedb813fa11ba0679c3051bc2eb28646b9506c (patch) | |
tree | 34acbfc9840e02cb4753e6306ea7ce978bf8b58e /src/contrib/SDL-3.2.20/include/SDL3/SDL_test_harness.h | |
parent | 8f228ade99dd3d4c8da9b78ade1815c9adf85c8f (diff) |
Update to SDL3
Diffstat (limited to 'src/contrib/SDL-3.2.20/include/SDL3/SDL_test_harness.h')
-rw-r--r-- | src/contrib/SDL-3.2.20/include/SDL3/SDL_test_harness.h | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/include/SDL3/SDL_test_harness.h b/src/contrib/SDL-3.2.20/include/SDL3/SDL_test_harness.h new file mode 100644 index 0000000..5d4963e --- /dev/null +++ b/src/contrib/SDL-3.2.20/include/SDL3/SDL_test_harness.h | |||
@@ -0,0 +1,151 @@ | |||
1 | /* | ||
2 | Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
4 | |||
5 | This software is provided 'as-is', without any express or implied | ||
6 | warranty. In no event will the authors be held liable for any damages | ||
7 | arising from the use of this software. | ||
8 | |||
9 | Permission is granted to anyone to use this software for any purpose, | ||
10 | including commercial applications, and to alter it and redistribute it | ||
11 | freely, subject to the following restrictions: | ||
12 | |||
13 | 1. The origin of this software must not be misrepresented; you must not | ||
14 | claim that you wrote the original software. If you use this software | ||
15 | in a product, an acknowledgment in the product documentation would be | ||
16 | appreciated but is not required. | ||
17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
18 | misrepresented as being the original software. | ||
19 | 3. This notice may not be removed or altered from any source distribution. | ||
20 | */ | ||
21 | |||
22 | /** | ||
23 | * Test suite related functions of SDL test framework. | ||
24 | * | ||
25 | * This code is a part of the SDL test library, not the main SDL library. | ||
26 | */ | ||
27 | |||
28 | /* | ||
29 | Defines types for test case definitions and the test execution harness API. | ||
30 | |||
31 | Based on original GSOC code by Markus Kauppila <markus.kauppila@gmail.com> | ||
32 | */ | ||
33 | |||
34 | #ifndef SDL_test_h_arness_h | ||
35 | #define SDL_test_h_arness_h | ||
36 | |||
37 | #include <SDL3/SDL_stdinc.h> | ||
38 | #include <SDL3/SDL_test_common.h> /* SDLTest_CommonState */ | ||
39 | |||
40 | #include <SDL3/SDL_begin_code.h> | ||
41 | /* Set up for C function definitions, even when using C++ */ | ||
42 | #ifdef __cplusplus | ||
43 | extern "C" { | ||
44 | #endif | ||
45 | |||
46 | /* ! Definitions for test case structures */ | ||
47 | #define TEST_ENABLED 1 | ||
48 | #define TEST_DISABLED 0 | ||
49 | |||
50 | /* ! Definition of all the possible test return values of the test case method */ | ||
51 | #define TEST_ABORTED -1 | ||
52 | #define TEST_STARTED 0 | ||
53 | #define TEST_COMPLETED 1 | ||
54 | #define TEST_SKIPPED 2 | ||
55 | |||
56 | /* ! Definition of all the possible test results for the harness */ | ||
57 | #define TEST_RESULT_PASSED 0 | ||
58 | #define TEST_RESULT_FAILED 1 | ||
59 | #define TEST_RESULT_NO_ASSERT 2 | ||
60 | #define TEST_RESULT_SKIPPED 3 | ||
61 | #define TEST_RESULT_SETUP_FAILURE 4 | ||
62 | |||
63 | /* !< Function pointer to a test case setup function (run before every test) */ | ||
64 | typedef void (SDLCALL *SDLTest_TestCaseSetUpFp)(void **arg); | ||
65 | |||
66 | /* !< Function pointer to a test case function */ | ||
67 | typedef int (SDLCALL *SDLTest_TestCaseFp)(void *arg); | ||
68 | |||
69 | /* !< Function pointer to a test case teardown function (run after every test) */ | ||
70 | typedef void (SDLCALL *SDLTest_TestCaseTearDownFp)(void *arg); | ||
71 | |||
72 | /* | ||
73 | * Holds information about a single test case. | ||
74 | */ | ||
75 | typedef struct SDLTest_TestCaseReference { | ||
76 | /* !< Func2Stress */ | ||
77 | SDLTest_TestCaseFp testCase; | ||
78 | /* !< Short name (or function name) "Func2Stress" */ | ||
79 | const char *name; | ||
80 | /* !< Long name or full description "This test pushes func2() to the limit." */ | ||
81 | const char *description; | ||
82 | /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ | ||
83 | int enabled; | ||
84 | } SDLTest_TestCaseReference; | ||
85 | |||
86 | /* | ||
87 | * Holds information about a test suite (multiple test cases). | ||
88 | */ | ||
89 | typedef struct SDLTest_TestSuiteReference { | ||
90 | /* !< "PlatformSuite" */ | ||
91 | const char *name; | ||
92 | /* !< The function that is run before each test. NULL skips. */ | ||
93 | SDLTest_TestCaseSetUpFp testSetUp; | ||
94 | /* !< The test cases that are run as part of the suite. Last item should be NULL. */ | ||
95 | const SDLTest_TestCaseReference **testCases; | ||
96 | /* !< The function that is run after each test. NULL skips. */ | ||
97 | SDLTest_TestCaseTearDownFp testTearDown; | ||
98 | } SDLTest_TestSuiteReference; | ||
99 | |||
100 | |||
101 | /* | ||
102 | * Generates a random run seed string for the harness. The generated seed | ||
103 | * will contain alphanumeric characters (0-9A-Z). | ||
104 | * | ||
105 | * \param buffer Buffer in which to generate the random seed. Must have a capacity of at least length + 1 characters. | ||
106 | * \param length Number of alphanumeric characters to write to buffer, must be >0 | ||
107 | * | ||
108 | * \returns A null-terminated seed string and equal to the in put buffer on success, NULL on failure | ||
109 | */ | ||
110 | char * SDLCALL SDLTest_GenerateRunSeed(char *buffer, int length); | ||
111 | |||
112 | /* | ||
113 | * Holds information about the execution of test suites. | ||
114 | * */ | ||
115 | typedef struct SDLTest_TestSuiteRunner SDLTest_TestSuiteRunner; | ||
116 | |||
117 | /* | ||
118 | * Create a new test suite runner, that will execute the given test suites. | ||
119 | * It will register the harness cli arguments to the common SDL state. | ||
120 | * | ||
121 | * \param state Common SDL state on which to register CLI arguments. | ||
122 | * \param testSuites NULL-terminated test suites containing test cases. | ||
123 | * | ||
124 | * \returns the test run result: 0 when all tests passed, 1 if any tests failed. | ||
125 | */ | ||
126 | SDLTest_TestSuiteRunner * SDLCALL SDLTest_CreateTestSuiteRunner(SDLTest_CommonState *state, SDLTest_TestSuiteReference *testSuites[]); | ||
127 | |||
128 | /* | ||
129 | * Destroy a test suite runner. | ||
130 | * It will unregister the harness cli arguments to the common SDL state. | ||
131 | * | ||
132 | * \param runner The runner that should be destroyed. | ||
133 | */ | ||
134 | void SDLCALL SDLTest_DestroyTestSuiteRunner(SDLTest_TestSuiteRunner *runner); | ||
135 | |||
136 | /* | ||
137 | * Execute a test suite, using the configured run seed, execution key, filter, etc. | ||
138 | * | ||
139 | * \param runner The runner that should be executed. | ||
140 | * | ||
141 | * \returns the test run result: 0 when all tests passed, 1 if any tests failed. | ||
142 | */ | ||
143 | int SDLCALL SDLTest_ExecuteTestSuiteRunner(SDLTest_TestSuiteRunner *runner); | ||
144 | |||
145 | /* Ends C function definitions when using C++ */ | ||
146 | #ifdef __cplusplus | ||
147 | } | ||
148 | #endif | ||
149 | #include <SDL3/SDL_close_code.h> | ||
150 | |||
151 | #endif /* SDL_test_h_arness_h */ | ||