SDL Library

Dependents:   H261_decoder

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SDL_test_harness.h Source File

SDL_test_harness.h

Go to the documentation of this file.
00001 /*
00002   Simple DirectMedia Layer
00003   Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
00004 
00005   This software is provided 'as-is', without any express or implied
00006   warranty.  In no event will the authors be held liable for any damages
00007   arising from the use of this software.
00008 
00009   Permission is granted to anyone to use this software for any purpose,
00010   including commercial applications, and to alter it and redistribute it
00011   freely, subject to the following restrictions:
00012 
00013   1. The origin of this software must not be misrepresented; you must not
00014      claim that you wrote the original software. If you use this software
00015      in a product, an acknowledgment in the product documentation would be
00016      appreciated but is not required.
00017   2. Altered source versions must be plainly marked as such, and must not be
00018      misrepresented as being the original software.
00019   3. This notice may not be removed or altered from any source distribution.
00020 */
00021 
00022 /**
00023  *  \file SDL_test_harness.h
00024  *
00025  *  Include file for SDL test framework.
00026  *
00027  *  This code is a part of the SDL2_test library, not the main SDL library.
00028  */
00029 
00030 /*
00031   Defines types for test case definitions and the test execution harness API.
00032 
00033   Based on original GSOC code by Markus Kauppila <markus.kauppila@gmail.com>
00034 */
00035 
00036 #ifndef _SDL_test_harness_h
00037 #define _SDL_test_harness_h
00038 
00039 #include "begin_code.h"
00040 /* Set up for C function definitions, even when using C++ */
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 
00045 
00046 /* ! Definitions for test case structures */
00047 #define TEST_ENABLED  1
00048 #define TEST_DISABLED 0
00049 
00050 /* ! Definition of all the possible test return values of the test case method */
00051 #define TEST_ABORTED        -1
00052 #define TEST_STARTED         0
00053 #define TEST_COMPLETED       1
00054 #define TEST_SKIPPED         2
00055 
00056 /* ! Definition of all the possible test results for the harness */
00057 #define TEST_RESULT_PASSED              0
00058 #define TEST_RESULT_FAILED              1
00059 #define TEST_RESULT_NO_ASSERT           2
00060 #define TEST_RESULT_SKIPPED             3
00061 #define TEST_RESULT_SETUP_FAILURE       4
00062 
00063 /* !< Function pointer to a test case setup function (run before every test) */
00064 typedef void (*SDLTest_TestCaseSetUpFp)(void *arg);
00065 
00066 /* !< Function pointer to a test case function */
00067 typedef int (*SDLTest_TestCaseFp)(void *arg);
00068 
00069 /* !< Function pointer to a test case teardown function (run after every test) */
00070 typedef void  (*SDLTest_TestCaseTearDownFp)(void *arg);
00071 
00072 /**
00073  * Holds information about a single test case.
00074  */
00075 typedef struct SDLTest_TestCaseReference {
00076     /* !< Func2Stress */
00077     SDLTest_TestCaseFp testCase;
00078     /* !< Short name (or function name) "Func2Stress" */
00079     char *name;
00080     /* !< Long name or full description "This test pushes func2() to the limit." */
00081     char *description;
00082     /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */
00083     int enabled;
00084 } SDLTest_TestCaseReference;
00085 
00086 /**
00087  * Holds information about a test suite (multiple test cases).
00088  */
00089 typedef struct SDLTest_TestSuiteReference {
00090     /* !< "PlatformSuite" */
00091     char *name;
00092     /* !< The function that is run before each test. NULL skips. */
00093     SDLTest_TestCaseSetUpFp testSetUp;
00094     /* !< The test cases that are run as part of the suite. Last item should be NULL. */
00095     const SDLTest_TestCaseReference **testCases;
00096     /* !< The function that is run after each test. NULL skips. */
00097     SDLTest_TestCaseTearDownFp testTearDown;
00098 } SDLTest_TestSuiteReference;
00099 
00100 
00101 /**
00102  * \brief Execute a test suite using the given run seed and execution key.
00103  *
00104  * \param testSuites Suites containing the test case.
00105  * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one.
00106  * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one.
00107  * \param filter Filter specification. NULL disables. Case sensitive.
00108  * \param testIterations Number of iterations to run each test case.
00109  *
00110  * \returns Test run result; 0 when all tests passed, 1 if any tests failed.
00111  */
00112 int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations);
00113 
00114 
00115 /* Ends C function definitions when using C++ */
00116 #ifdef __cplusplus
00117 }
00118 #endif
00119 #include "close_code.h"
00120 
00121 #endif /* _SDL_test_harness_h */
00122 
00123 /* vi: set ts=4 sw=4 expandtab: */