🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
4.5 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
  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. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_test_harness.h
  20. *
  21. * Include file for SDL test framework.
  22. *
  23. * This code is a part of the SDL2_test library, not the main SDL library.
  24. */
  25. /*
  26. Defines types for test case definitions and the test execution harness API.
  27. Based on original GSOC code by Markus Kauppila <markus.kauppila@gmail.com>
  28. */
  29. #ifndef SDL_test_h_arness_h
  30. #define SDL_test_h_arness_h
  31. #include "begin_code.h"
  32. /* Set up for C function definitions, even when using C++ */
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* ! Definitions for test case structures */
  37. #define TEST_ENABLED 1
  38. #define TEST_DISABLED 0
  39. /* ! Definition of all the possible test return values of the test case method */
  40. #define TEST_ABORTED -1
  41. #define TEST_STARTED 0
  42. #define TEST_COMPLETED 1
  43. #define TEST_SKIPPED 2
  44. /* ! Definition of all the possible test results for the harness */
  45. #define TEST_RESULT_PASSED 0
  46. #define TEST_RESULT_FAILED 1
  47. #define TEST_RESULT_NO_ASSERT 2
  48. #define TEST_RESULT_SKIPPED 3
  49. #define TEST_RESULT_SETUP_FAILURE 4
  50. /* !< Function pointer to a test case setup function (run before every test) */
  51. typedef void (*SDLTest_TestCaseSetUpFp)(void *arg);
  52. /* !< Function pointer to a test case function */
  53. typedef int (*SDLTest_TestCaseFp)(void *arg);
  54. /* !< Function pointer to a test case teardown function (run after every test) */
  55. typedef void (*SDLTest_TestCaseTearDownFp)(void *arg);
  56. /**
  57. * Holds information about a single test case.
  58. */
  59. typedef struct SDLTest_TestCaseReference {
  60. /* !< Func2Stress */
  61. SDLTest_TestCaseFp testCase;
  62. /* !< Short name (or function name) "Func2Stress" */
  63. char *name;
  64. /* !< Long name or full description "This test pushes func2() to the limit." */
  65. char *description;
  66. /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */
  67. int enabled;
  68. } SDLTest_TestCaseReference;
  69. /**
  70. * Holds information about a test suite (multiple test cases).
  71. */
  72. typedef struct SDLTest_TestSuiteReference {
  73. /* !< "PlatformSuite" */
  74. char *name;
  75. /* !< The function that is run before each test. NULL skips. */
  76. SDLTest_TestCaseSetUpFp testSetUp;
  77. /* !< The test cases that are run as part of the suite. Last item should be NULL. */
  78. const SDLTest_TestCaseReference **testCases;
  79. /* !< The function that is run after each test. NULL skips. */
  80. SDLTest_TestCaseTearDownFp testTearDown;
  81. } SDLTest_TestSuiteReference;
  82. /**
  83. * \brief Generates a random run seed string for the harness. The generated seed will contain alphanumeric characters (0-9A-Z).
  84. *
  85. * Note: The returned string needs to be deallocated by the caller.
  86. *
  87. * \param length The length of the seed string to generate
  88. *
  89. * \returns The generated seed string
  90. */
  91. char *SDLTest_GenerateRunSeed(const int length);
  92. /**
  93. * \brief Execute a test suite using the given run seed and execution key.
  94. *
  95. * \param testSuites Suites containing the test case.
  96. * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one.
  97. * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one.
  98. * \param filter Filter specification. NULL disables. Case sensitive.
  99. * \param testIterations Number of iterations to run each test case.
  100. *
  101. * \returns Test run result; 0 when all tests passed, 1 if any tests failed.
  102. */
  103. int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations);
  104. /* Ends C function definitions when using C++ */
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #include "close_code.h"
  109. #endif /* SDL_test_h_arness_h */
  110. /* vi: set ts=4 sw=4 expandtab: */