Atlas - testautomation.c

Home / ext / SDL / test Lines: 1 | Size: 3962 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* 2 Copyright (C) 1997-2025 Sam Lantinga <[email protected]> 3 4 This software is provided 'as-is', without any express or implied 5 warranty. In no event will the authors be held liable for any damages 6 arising from the use of this software. 7 8 Permission is granted to anyone to use this software for any purpose, 9 including commercial applications, and to alter it and redistribute it 10 freely. 11*/ 12 13#include <stdlib.h> 14 15#include <SDL3/SDL.h> 16#include <SDL3/SDL_main.h> 17#include <SDL3/SDL_test.h> 18 19#include "testautomation_suites.h" 20 21static SDLTest_CommonState *state; 22static SDLTest_TestSuiteRunner *runner; 23 24/* All test suites */ 25static SDLTest_TestSuiteReference *testSuites[] = { 26 &audioTestSuite, 27 &clipboardTestSuite, 28 &eventsTestSuite, 29 &guidTestSuite, 30 &hintsTestSuite, 31 &intrinsicsTestSuite, 32 &joystickTestSuite, 33 &keyboardTestSuite, 34 &logTestSuite, 35 &mainTestSuite, 36 &mathTestSuite, 37 &mouseTestSuite, 38 &pixelsTestSuite, 39 &platformTestSuite, 40 &propertiesTestSuite, 41 &rectTestSuite, 42 &renderTestSuite, 43 &iostrmTestSuite, 44 &sdltestTestSuite, 45 &stdlibTestSuite, 46 &surfaceTestSuite, 47 &timeTestSuite, 48 &timerTestSuite, 49 &videoTestSuite, 50 &blitTestSuite, 51 &subsystemsTestSuite, /* run last, not interfere with other test environment */ 52 NULL 53}; 54 55/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ 56static void 57quit(int rc) 58{ 59 SDLTest_DestroyTestSuiteRunner(runner); 60 SDLTest_CommonQuit(state); 61 /* Let 'main()' return normally */ 62 if (rc != 0) { 63 exit(rc); 64 } 65} 66 67int main(int argc, char *argv[]) 68{ 69 int result; 70 int i, done; 71 SDL_Event event; 72 int list = 0; 73 74 /* Initialize test framework */ 75 state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO); 76 if (!state) { 77 return 1; 78 } 79 80 /* No need of windows (or update testautomation_mouse.c:mouse_getMouseFocus() */ 81 state->num_windows = 0; 82 83 runner = SDLTest_CreateTestSuiteRunner(state, testSuites); 84 85 /* Parse commandline */ 86 for (i = 1; i < argc;) { 87 int consumed; 88 89 consumed = SDLTest_CommonArg(state, i); 90 if (consumed == 0) { 91 consumed = -1; 92 93 if (SDL_strcasecmp(argv[i], "--list") == 0) { 94 consumed = 1; 95 list = 1; 96 } 97 } 98 if (consumed < 0) { 99 static const char *options[] = { 100 "[--list]", 101 NULL }; 102 SDLTest_CommonLogUsage(state, argv[0], options); 103 quit(1); 104 } 105 106 i += consumed; 107 } 108 109 /* List all suites. */ 110 if (list) { 111 int suiteCounter; 112 for (suiteCounter = 0; testSuites[suiteCounter]; ++suiteCounter) { 113 int testCounter; 114 SDLTest_TestSuiteReference *testSuite = testSuites[suiteCounter]; 115 SDL_Log("Test suite: %s", testSuite->name); 116 for (testCounter = 0; testSuite->testCases[testCounter]; ++testCounter) { 117 const SDLTest_TestCaseReference *testCase = testSuite->testCases[testCounter]; 118 SDL_Log(" test: %s%s", testCase->name, testCase->enabled ? "" : " (disabled)"); 119 } 120 } 121 return 0; 122 } 123 124 /* Initialize common state */ 125 if (!SDLTest_CommonInit(state)) { 126 quit(2); 127 } 128 129 /* Create the windows, initialize the renderers */ 130 for (i = 0; i < state->num_windows; ++i) { 131 SDL_Renderer *renderer = state->renderers[i]; 132 SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF); 133 SDL_RenderClear(renderer); 134 } 135 136 /* Call Harness */ 137 result = SDLTest_ExecuteTestSuiteRunner(runner); 138 139 /* Empty event queue */ 140 done = 0; 141 for (i = 0; i < 100; i++) { 142 while (SDL_PollEvent(&event)) { 143 SDLTest_CommonEvent(state, &event, &done); 144 } 145 SDL_Delay(10); 146 } 147 148 /* Shutdown everything */ 149 quit(0); 150 return result; 151} 152
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.