include/SDL_test_harness.h
author David Ludwig <dludwig@pobox.com>
Mon, 01 Apr 2013 21:33:06 -0400
changeset 8453 499aa167ea79
parent 6885 700f1b25f77f
child 7189 414be1d64060
permissions -rw-r--r--
WinRT: made WinRT path retrieval be available in both UCS-2 and UTF-8 flavors
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2013 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  *  \file SDL_test_harness.h
    24  *  
    25  *  Include file for SDL test framework.
    26  *
    27  *  This code is a part of the SDL2_test library, not the main SDL library.
    28  */
    29 
    30 /*
    31   Defines types for test case definitions and the test execution harness API.
    32   
    33   Based on original GSOC code by Markus Kauppila <markus.kauppila@gmail.com>
    34 */
    35 
    36 #ifndef _SDL_test_harness_h
    37 #define _SDL_test_harness_h
    38 
    39 #include "begin_code.h"
    40 /* Set up for C function definitions, even when using C++ */
    41 #ifdef __cplusplus
    42 /* *INDENT-OFF* */
    43 extern "C" {
    44 /* *INDENT-ON* */
    45 #endif
    46 
    47 
    48 //! Definitions for test case structures
    49 #define TEST_ENABLED  1
    50 #define TEST_DISABLED 0
    51 
    52 //! Definition of all the possible test return values of the test case method
    53 #define TEST_ABORTED		-1
    54 #define TEST_COMPLETED		 0
    55 #define TEST_SKIPPED		 1
    56 
    57 //! Definition of all the possible test results for the harness
    58 #define TEST_RESULT_PASSED				0
    59 #define TEST_RESULT_FAILED				1
    60 #define TEST_RESULT_NO_ASSERT			2
    61 #define TEST_RESULT_SKIPPED				3
    62 #define TEST_RESULT_SETUP_FAILURE		4
    63 
    64 //!< Function pointer to a test case setup function (run before every test)
    65 typedef void (*SDLTest_TestCaseSetUpFp)(void *arg);
    66 
    67 //!< Function pointer to a test case function
    68 typedef void (*SDLTest_TestCaseFp)(void *arg);
    69 
    70 //!< Function pointer to a test case teardown function (run after every test)
    71 typedef void  (*SDLTest_TestCaseTearDownFp)(void *arg);
    72 
    73 /**
    74  * Holds information about a single test case.
    75  */
    76 typedef struct SDLTest_TestCaseReference {
    77 	/*!< Func2Stress */
    78 	SDLTest_TestCaseFp testCase;
    79 	/*!< Short name (or function name) "Func2Stress" */
    80 	char *name;
    81 	/*!< Long name or full description "This test pushes func2() to the limit." */
    82 	char *description;
    83 	/*!< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */
    84 	int enabled;
    85 } SDLTest_TestCaseReference;
    86 
    87 /**
    88  * Holds information about a test suite (multiple test cases).
    89  */
    90 typedef struct SDLTest_TestSuiteReference {
    91 	/*!< "PlatformSuite" */
    92 	char *name;
    93 	/*!< The function that is run before each test. NULL skips. */
    94 	SDLTest_TestCaseSetUpFp testSetUp;
    95 	/*!< The test cases that are run as part of the suite. Last item should be NULL. */
    96 	const SDLTest_TestCaseReference **testCases;
    97 	/*!< The function that is run after each test. NULL skips. */
    98 	SDLTest_TestCaseTearDownFp testTearDown;
    99 } SDLTest_TestSuiteReference;
   100 
   101 
   102 /**
   103  * \brief Execute a test suite using the given run seed and execution key.
   104  *
   105  * \param testSuites Suites containing the test case.
   106  * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one.
   107  * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one.
   108  * \param filter Filter specification. NULL disables. Case sensitive.
   109  * \param testIterations Number of iterations to run each test case.
   110  *
   111  * \returns Test run result; 0 when all tests passed, 1 if any tests failed.
   112  */
   113 int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations);
   114          
   115 
   116 /* Ends C function definitions when using C++ */
   117 #ifdef __cplusplus
   118 /* *INDENT-OFF* */
   119 }
   120 /* *INDENT-ON* */
   121 #endif
   122 #include "close_code.h"
   123 
   124 #endif /* _SDL_test_harness_h */
   125 
   126 /* vi: set ts=4 sw=4 expandtab: */