Test lib updates: updated harness to support filtering, added surface comparer, updated interface to test images; added Render test suite from GSOC project

This commit is contained in:
Andreas Schiffler 2012-12-22 16:06:55 -08:00
parent f5af517cd2
commit 81eb615d45
17 changed files with 1739 additions and 184 deletions

View file

@ -162,6 +162,7 @@
<ClInclude Include="..\..\include\SDL_test_md5.h" /> <ClInclude Include="..\..\include\SDL_test_md5.h" />
<ClInclude Include="..\..\include\SDL_test_random.h" /> <ClInclude Include="..\..\include\SDL_test_random.h" />
<ClInclude Include="..\..\include\SDL_test_images.h" /> <ClInclude Include="..\..\include\SDL_test_images.h" />
<ClInclude Include="..\..\include\SDL_test_compare.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\test\SDL_test_assert.c" /> <ClCompile Include="..\..\src\test\SDL_test_assert.c" />
@ -178,6 +179,7 @@
<ClCompile Include="..\..\src\test\SDL_test_imageFace.c" /> <ClCompile Include="..\..\src\test\SDL_test_imageFace.c" />
<ClCompile Include="..\..\src\test\SDL_test_imagePrimitives.c" /> <ClCompile Include="..\..\src\test\SDL_test_imagePrimitives.c" />
<ClCompile Include="..\..\src\test\SDL_test_imagePrimitivesBlend.c" /> <ClCompile Include="..\..\src\test\SDL_test_imagePrimitivesBlend.c" />
<ClCompile Include="..\..\src\test\SDL_test_compare.c" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View file

@ -166,6 +166,7 @@
<ClInclude Include="..\..\include\SDL_test_md5.h" /> <ClInclude Include="..\..\include\SDL_test_md5.h" />
<ClInclude Include="..\..\include\SDL_test_random.h" /> <ClInclude Include="..\..\include\SDL_test_random.h" />
<ClInclude Include="..\..\include\SDL_test_images.h" /> <ClInclude Include="..\..\include\SDL_test_images.h" />
<ClInclude Include="..\..\include\SDL_test_compare.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\test\SDL_test_assert.c" /> <ClCompile Include="..\..\src\test\SDL_test_assert.c" />
@ -182,6 +183,7 @@
<ClCompile Include="..\..\src\test\SDL_test_imageFace.c" /> <ClCompile Include="..\..\src\test\SDL_test_imageFace.c" />
<ClCompile Include="..\..\src\test\SDL_test_imagePrimitives.c" /> <ClCompile Include="..\..\src\test\SDL_test_imagePrimitives.c" />
<ClCompile Include="..\..\src\test\SDL_test_imagePrimitivesBlend.c" /> <ClCompile Include="..\..\src\test\SDL_test_imagePrimitivesBlend.c" />
<ClCompile Include="..\..\src\test\SDL_test_compare.c" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View file

@ -41,6 +41,7 @@
#include "SDL_test_assert.h" #include "SDL_test_assert.h"
#include "SDL_test_harness.h" #include "SDL_test_harness.h"
#include "SDL_test_images.h" #include "SDL_test_images.h"
#include "SDL_test_compare.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */

View file

@ -0,0 +1,72 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/**
* \file SDL_test_compare.h
*
* Include file for SDL test framework.
*
* This code is a part of the SDL2_test library, not the main SDL library.
*/
/*
Defines comparison functions (i.e. for surfaces).
*/
#ifndef _SDL_test_compare_h
#define _SDL_test_compare_h
#include "SDL.h"
#include "SDL_test_images.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
extern "C" {
/* *INDENT-ON* */
#endif
/**
* \brief Compares a surface and with reference image data for equality
*
* \param sur Surface used in comparison
* \param img Test Surface used in comparison
* \param allowable_error Allowable difference in blending accuracy
*
* \returns 0 if comparison succeeded, >0 (=number of pixels where comparison failed) if comparison failed, <0 for any other error.
*/
int SDLTest_CompareSurfaces(SDL_Surface *sur, SDL_Surface *img, int allowable_error);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
/* *INDENT-OFF* */
}
/* *INDENT-ON* */
#endif
#include "close_code.h"
#endif /* _SDL_test_compare_h */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -105,11 +105,12 @@ typedef struct SDLTest_TestSuiteReference {
* \param testSuites Suites containing the test case. * \param testSuites Suites containing the test case.
* \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one. * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one.
* \param userExecKey Custom execution key provided by user, or 0 to autogenerate one. * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one.
* \param filter Filter specification. NULL disables. Case sensitive.
* \param testIterations Number of iterations to run each test case. * \param testIterations Number of iterations to run each test case.
* *
* \returns Test run result; 0 when all tests passed, 1 if any tests failed. * \returns Test run result; 0 when all tests passed, 1 if any tests failed.
*/ */
int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, Uint64 userExecKey, int testIterations); int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, Uint64 userExecKey, char *filter, int testIterations);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */

View file

@ -36,6 +36,8 @@
#ifndef _SDL_test_images_h #ifndef _SDL_test_images_h
#define _SDL_test_images_h #define _SDL_test_images_h
#include "SDL.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
@ -44,29 +46,28 @@ extern "C" {
/* *INDENT-ON* */ /* *INDENT-ON* */
#endif #endif
/** /**
*Type for test images. *Type for test images.
*/ */
typedef struct SDLTest_SurfaceImage_s { typedef struct SDLTest_SurfaceImage_s {
int width; int width;
int height; int height;
unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
const unsigned char pixel_data[]; const unsigned char pixel_data[];
} SDLTest_SurfaceImage_t; } SDLTest_SurfaceImage_t;
/* Test images */ /* Test images */
const SDLTest_SurfaceImage_t SDLTest_imageBlit; SDL_Surface *SDLTest_ImageBlit();
const SDLTest_SurfaceImage_t SDLTest_imageBlitColor; SDL_Surface *SDLTest_ImageBlitColor();
const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha; SDL_Surface *SDLTest_ImageBlitAlpha();
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd; SDL_Surface *SDLTest_ImageBlitBlendAdd();
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend; SDL_Surface *SDLTest_ImageBlitBlend();
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod; SDL_Surface *SDLTest_ImageBlitBlendMod();
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone; SDL_Surface *SDLTest_ImageBlitBlendNone();
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll; SDL_Surface *SDLTest_ImageBlitBlendAll();
const SDLTest_SurfaceImage_t SDLTest_ImageFace; SDL_Surface *SDLTest_ImageFace();
const SDLTest_SurfaceImage_t SDLTest_imagePrimitives; SDL_Surface *SDLTest_ImagePrimitives();
const SDLTest_SurfaceImage_t SDLTest_imagePrimitivesBlend; SDL_Surface *SDLTest_ImagePrimitivesBlend();
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -0,0 +1,83 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/*
Based on automated SDL_Surface tests originally written by Edgar Simo 'bobbens'.
Rewritten for test lib by Andreas Schiffler.
*/
#include "SDL_config.h"
#include "SDL_test.h"
int SDLTest_CompareSurfaces( SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error )
{
int ret;
int i,j;
int bpp, bpp_reference;
Uint8 *p, *p_reference;
int dist;
Uint8 R, G, B, A;
Uint8 Rd, Gd, Bd, Ad;
/* Make surfacee size is the same. */
if ((surface->w != referenceSurface->w) || (surface->h != referenceSurface->h))
{
return -1;
}
SDL_LockSurface( surface );
SDL_LockSurface( referenceSurface );
ret = 0;
bpp = surface->format->BytesPerPixel;
bpp_reference = referenceSurface->format->BytesPerPixel;
/* Compare image - should be same format. */
for (j=0; j<surface->h; j++) {
for (i=0; i<surface->w; i++) {
p = (Uint8 *)surface->pixels + j * surface->pitch + i * bpp;
p_reference = (Uint8 *)referenceSurface->pixels + j * referenceSurface->pitch + i * bpp_reference;
dist = 0;
SDL_GetRGBA(*(Uint32*)p, surface->format, &R, &G, &B, &A);
SDL_GetRGBA(*(Uint32*)p_reference, referenceSurface->format, &Rd, &Gd, &Bd, &Ad);
dist += (R-Rd)*(R-Rd);
dist += (G-Gd)*(G-Gd);
dist += (B-Bd)*(B-Bd);
/* Allow some difference in blending accuracy */
if (dist > allowable_error) {
ret++;
}
}
}
SDL_UnlockSurface( surface );
SDL_UnlockSurface( referenceSurface );
return ret;
}

View file

@ -116,8 +116,8 @@ SDLTest_RandomUint32()
Uint64 Uint64
SDLTest_RandomUint64() SDLTest_RandomUint64()
{ {
Uint64 value; Uint64 value = 0;
Uint32 *vp = (void*)&value; Uint32 *vp = (void *)&value;
fuzzerInvocationCounter++; fuzzerInvocationCounter++;
@ -130,8 +130,8 @@ SDLTest_RandomUint64()
Sint64 Sint64
SDLTest_RandomSint64() SDLTest_RandomSint64()
{ {
Uint64 value; Uint64 value = 0;
Uint32 *vp = (void*)&value; Uint32 *vp = (void *)&value;
fuzzerInvocationCounter++; fuzzerInvocationCounter++;

View file

@ -1,22 +1,22 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "SDL_config.h" #include "SDL_config.h"
@ -41,17 +41,17 @@ const char *SDLTest_FinalResultFormat = ">>> %s '%s': %s\n";
static Uint32 SDLTest_TestCaseTimeout = 3600; static Uint32 SDLTest_TestCaseTimeout = 3600;
/** /**
* Generates a random run seed string for the harness. The generated seed * Generates a random run seed string for the harness. The generated seed
* will contain alphanumeric characters (0-9A-Z). * will contain alphanumeric characters (0-9A-Z).
* *
* Note: The returned string needs to be deallocated by the caller. * Note: The returned string needs to be deallocated by the caller.
* *
* \param length The length of the seed string to generate * \param length The length of the seed string to generate
* *
* \returns The generated seed string * \returns The generated seed string
*/ */
char * char *
SDLTest_GenerateRunSeed(const int length) SDLTest_GenerateRunSeed(const int length)
{ {
char *seed = NULL; char *seed = NULL;
SDLTest_RandomContext randomContext; SDLTest_RandomContext randomContext;
@ -86,18 +86,18 @@ SDLTest_GenerateRunSeed(const int length)
} }
/** /**
* Generates an execution key for the fuzzer. * Generates an execution key for the fuzzer.
* *
* \param runSeed The run seed to use * \param runSeed The run seed to use
* \param suiteName The name of the test suite * \param suiteName The name of the test suite
* \param testName The name of the test * \param testName The name of the test
* \param iteration The iteration count * \param iteration The iteration count
* *
* \returns The generated execution key to initialize the fuzzer with. * \returns The generated execution key to initialize the fuzzer with.
* *
*/ */
Uint64 Uint64
SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iteration) SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iteration)
{ {
SDLTest_Md5Context md5Context; SDLTest_Md5Context md5Context;
Uint64 *keys; Uint64 *keys;
@ -157,17 +157,17 @@ SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iter
} }
/** /**
* \brief Set timeout handler for test. * \brief Set timeout handler for test.
* *
* Note: SDL_Init(SDL_INIT_TIMER) will be called if it wasn't done so before. * Note: SDL_Init(SDL_INIT_TIMER) will be called if it wasn't done so before.
* *
* \param timeout Timeout interval in seconds. * \param timeout Timeout interval in seconds.
* \param callback Function that will be called after timeout has elapsed. * \param callback Function that will be called after timeout has elapsed.
* *
* \return Timer id or -1 on failure. * \return Timer id or -1 on failure.
*/ */
SDL_TimerID SDL_TimerID
SDLTest_SetTestTimeout(int timeout, void (*callback)()) SDLTest_SetTestTimeout(int timeout, void (*callback)())
{ {
Uint32 timeoutInMilliseconds; Uint32 timeoutInMilliseconds;
SDL_TimerID timerID; SDL_TimerID timerID;
@ -201,24 +201,27 @@ SDLTest_SetTestTimeout(int timeout, void (*callback)())
return timerID; return timerID;
} }
/**
* \brief Timeout handler. Aborts test run and exits harness process.
*/
void void
SDLTest_BailOut() SDLTest_BailOut()
{ {
SDLTest_LogError("TestCaseTimeout timer expired. Aborting test run."); SDLTest_LogError("TestCaseTimeout timer expired. Aborting test run.");
exit(TEST_ABORTED); // bail out from the test exit(TEST_ABORTED); // bail out from the test
} }
/** /**
* \brief Execute a test using the given execution key. * \brief Execute a test using the given execution key.
* *
* \param testSuite Suite containing the test case. * \param testSuite Suite containing the test case.
* \param testCase Case to execute. * \param testCase Case to execute.
* \param execKey Execution key for the fuzzer. * \param execKey Execution key for the fuzzer.
* *
* \returns Test case result. * \returns Test case result.
*/ */
int int
SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, SDLTest_TestCaseReference *testCase, Uint64 execKey) SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, SDLTest_TestCaseReference *testCase, Uint64 execKey)
{ {
SDL_TimerID timer = 0; SDL_TimerID timer = 0;
int testResult = 0; int testResult = 0;
@ -232,11 +235,12 @@ SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, SDLTest_TestCaseReference
if (!testCase->enabled) if (!testCase->enabled)
{ {
SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Skipped"); SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", testCase->name, "Skipped (Disabled)");
return TEST_RESULT_SKIPPED; return TEST_RESULT_SKIPPED;
} }
// Initialize fuzzer
// Initialize fuzzer
SDLTest_FuzzerInit(execKey); SDLTest_FuzzerInit(execKey);
// Reset assert tracker // Reset assert tracker
@ -315,17 +319,21 @@ float GetClock()
} }
/** /**
* \brief Execute a test suite using the given run seend and execution key. * \brief Execute a test suite using the given run seend and execution key.
* *
* \param testSuites Suites containing the test case. * The filter string is matched to the suite name (full comparison) to select a single suite,
* \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one. * or if no suite matches, it is matched to the test names (full comparison) to select a single test.
* \param userExecKey Custom execution key provided by user, or 0 to autogenerate one. *
* \param testIterations Number of iterations to run each test case. * \param testSuites Suites containing the test case.
* * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one.
* \returns Test run result; 0 when all tests passed, 1 if any tests failed. * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one.
*/ * \param filter Filter specification. NULL disables. Case sensitive.
* \param testIterations Number of iterations to run each test case.
*
* \returns Test run result; 0 when all tests passed, 1 if any tests failed.
*/
int int
SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, Uint64 userExecKey, int testIterations) SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, Uint64 userExecKey, char *filter, int testIterations)
{ {
int suiteCounter; int suiteCounter;
int testCounter; int testCounter;
@ -343,6 +351,10 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
float suiteEndSeconds; float suiteEndSeconds;
float testEndSeconds; float testEndSeconds;
float runtime; float runtime;
int suiteFilter = 0;
char *suiteFilterName = NULL;
int testFilter = 0;
char *testFilterName = NULL;
int testResult = 0; int testResult = 0;
int runResult = 0; int runResult = 0;
Uint32 totalTestFailedCount = 0; Uint32 totalTestFailedCount = 0;
@ -370,6 +382,7 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
runSeed = userRunSeed; runSeed = userRunSeed;
} }
// Reset per-run counters // Reset per-run counters
totalTestFailedCount = 0; totalTestFailedCount = 0;
totalTestPassedCount = 0; totalTestPassedCount = 0;
@ -381,121 +394,184 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
// Log run with fuzzer parameters // Log run with fuzzer parameters
SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed); SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed);
// Initialize filtering
if (filter != NULL && SDL_strlen(filter) > 0) {
/* Loop over all suites to check if we have a filter match */
suiteCounter = 0;
while (testSuites[suiteCounter] && suiteFilter == 0) {
testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter];
suiteCounter++;
if (testSuite->name != NULL && SDL_strcmp(filter, testSuite->name) == 0) {
/* Matched a suite name */
suiteFilter = 1;
suiteFilterName = testSuite->name;
SDLTest_Log("Filtering: running only suite '%s'", suiteFilterName);
break;
}
/* Within each suite, loop over all test cases to check if we have a filter match */
testCounter = 0;
while (testSuite->testCases[testCounter] && testFilter == 0)
{
testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter];
testCounter++;
if (testCase->name != NULL && SDL_strcmp(filter, testCase->name) == 0) {
/* Matched a test name */
suiteFilter = 1;
suiteFilterName = testSuite->name;
testFilter = 1;
testFilterName = testCase->name;
SDLTest_Log("Filtering: running only test '%s' in suite '%s'", testFilterName, suiteFilterName);
break;
}
}
}
if (suiteFilter == 0 && testFilter == 0) {
SDLTest_LogError("Filter '%s' did not match any test suite/case.", filter);
SDLTest_Log("Exit code: 2");
return 2;
}
}
// Loop over all suites // Loop over all suites
suiteCounter = 0; suiteCounter = 0;
while(testSuites[suiteCounter]) { while(testSuites[suiteCounter]) {
testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter]; testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter];
currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat);
suiteCounter++; suiteCounter++;
// Reset per-suite counters // Filter suite if flag set and we have a name
testFailedCount = 0; if (suiteFilter == 1 && suiteFilterName != NULL && testSuite->name != NULL &&
testPassedCount = 0; SDL_strcmp(suiteFilterName, testSuite->name) != 0) {
testSkippedCount = 0; // Skip suite
SDLTest_Log("===== Test Suite %i: '%s' skipped\n",
suiteCounter,
currentSuiteName);
} else {
// Take time - suite start // Reset per-suite counters
suiteStartSeconds = GetClock(); testFailedCount = 0;
testPassedCount = 0;
testSkippedCount = 0;
// Log suite started // Take time - suite start
currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat); suiteStartSeconds = GetClock();
SDLTest_Log("===== Test Suite %i: '%s' started\n",
suiteCounter,
currentSuiteName);
// Loop over all test cases // Log suite started
testCounter = 0; SDLTest_Log("===== Test Suite %i: '%s' started\n",
while(testSuite->testCases[testCounter]) suiteCounter,
{ currentSuiteName);
testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter];
testCounter++;
// Take time - test start // Loop over all test cases
testStartSeconds = GetClock(); testCounter = 0;
while(testSuite->testCases[testCounter])
// Log test started
currentTestName = (char *)((testCase->name) ? testCase->name : SDLTest_InvalidNameFormat);
SDLTest_Log("----- Test Case %i.%i: '%s' started",
suiteCounter,
testCounter,
currentTestName);
if (testCase->description != NULL && strlen(testCase->description)>0) {
SDLTest_Log("Test Description: '%s'",
(testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);
}
// Loop over all iterations
iterationCounter = 0;
while(iterationCounter < testIterations)
{ {
iterationCounter++; testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter];
currentTestName = (char *)((testCase->name) ? testCase->name : SDLTest_InvalidNameFormat);
testCounter++;
if (userExecKey != 0) { // Filter tests if flag set and we have a name
execKey = userExecKey; if (testFilter == 1 && testFilterName != NULL && testCase->name != NULL &&
SDL_strcmp(testFilterName, testCase->name) != 0) {
// Skip test
SDLTest_Log("===== Test Case %i.%i: '%s' skipped\n",
suiteCounter,
testCounter,
currentTestName);
} else { } else {
execKey = SDLTest_GenerateExecKey(runSeed, testSuite->name, testCase->name, iterationCounter);
}
SDLTest_Log("Test Iteration %i: execKey %llu", iterationCounter, execKey); // Take time - test start
testResult = SDLTest_RunTest(testSuite, testCase, execKey); testStartSeconds = GetClock();
// Log test started
SDLTest_Log("----- Test Case %i.%i: '%s' started",
suiteCounter,
testCounter,
currentTestName);
if (testCase->description != NULL && strlen(testCase->description)>0) {
SDLTest_Log("Test Description: '%s'",
(testCase->description) ? testCase->description : SDLTest_InvalidNameFormat);
}
// Loop over all iterations
iterationCounter = 0;
while(iterationCounter < testIterations)
{
iterationCounter++;
if (userExecKey != 0) {
execKey = userExecKey;
} else {
execKey = SDLTest_GenerateExecKey(runSeed, testSuite->name, testCase->name, iterationCounter);
}
SDLTest_Log("Test Iteration %i: execKey %llu", iterationCounter, execKey);
testResult = SDLTest_RunTest(testSuite, testCase, execKey);
if (testResult == TEST_RESULT_PASSED) {
testPassedCount++;
totalTestPassedCount++;
} else if (testResult == TEST_RESULT_SKIPPED) {
testSkippedCount++;
totalTestSkippedCount++;
} else {
testFailedCount++;
totalTestFailedCount++;
}
}
// Take time - test end
testEndSeconds = GetClock();
runtime = testEndSeconds - testStartSeconds;
if (runtime < 0.0f) runtime = 0.0f;
if (testIterations > 1) {
// Log test runtime
SDLTest_Log("Runtime of %i iterations: %.1f sec", testIterations, runtime);
SDLTest_Log("Average Test runtime: %.5f sec", runtime / (float)testIterations);
} else {
// Log test runtime
SDLTest_Log("Total Test runtime: %.1f sec", runtime);
}
// Log final test result
switch (testResult) {
case TEST_RESULT_PASSED:
SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Passed");
break;
case TEST_RESULT_FAILED:
SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Failed");
break;
case TEST_RESULT_NO_ASSERT:
SDLTest_LogError((char *)SDLTest_FinalResultFormat,"Test", currentTestName, "No Asserts");
break;
}
if (testResult == TEST_RESULT_PASSED) {
testPassedCount++;
totalTestPassedCount++;
} else if (testResult == TEST_RESULT_SKIPPED) {
testSkippedCount++;
totalTestSkippedCount++;
} else {
testFailedCount++;
totalTestFailedCount++;
} }
} }
// Take time - test end // Take time - suite end
testEndSeconds = GetClock(); suiteEndSeconds = GetClock();
runtime = testEndSeconds - testStartSeconds; runtime = suiteEndSeconds - suiteStartSeconds;
if (runtime < 0.0f) runtime = 0.0f; if (runtime < 0.0f) runtime = 0.0f;
if (testIterations > 1) { // Log suite runtime
// Log test runtime SDLTest_Log("Total Suite runtime: %.1f sec", runtime);
SDLTest_Log("Runtime of %i iterations: %.1f sec", testIterations, runtime);
SDLTest_Log("Test runtime: %.5f sec", runtime / (float)testIterations);
} else {
// Log test runtime
SDLTest_Log("Test runtime: %.1f sec", runtime);
}
// Log final test result // Log summary and final Suite result
switch (testResult) { countSum = testPassedCount + testFailedCount + testSkippedCount;
case TEST_RESULT_PASSED: if (testFailedCount == 0)
SDLTest_Log((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Passed"); {
break; SDLTest_Log(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
case TEST_RESULT_FAILED: SDLTest_Log((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Passed");
SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Test", currentTestName, "Failed"); }
break; else
case TEST_RESULT_NO_ASSERT: {
SDLTest_LogError((char *)SDLTest_FinalResultFormat,"Test", currentTestName, "No Asserts"); SDLTest_LogError(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
break; SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Failed");
} }
}
// Take time - suite end
suiteEndSeconds = GetClock();
runtime = suiteEndSeconds - suiteStartSeconds;
if (runtime < 0.0f) runtime = 0.0f;
// Log suite runtime
SDLTest_Log("Suite runtime: %.1f sec", runtime);
// Log summary and final Suite result
countSum = testPassedCount + testFailedCount + testSkippedCount;
if (testFailedCount == 0)
{
SDLTest_Log(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
SDLTest_Log((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Passed");
}
else
{
SDLTest_LogError(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Failed");
} }
} }
@ -505,11 +581,11 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
if (runtime < 0.0f) runtime = 0.0f; if (runtime < 0.0f) runtime = 0.0f;
// Log total runtime // Log total runtime
SDLTest_Log("Total runtime: %.1f sec", runtime); SDLTest_Log("Total Run runtime: %.1f sec", runtime);
// Log summary and final run result // Log summary and final run result
countSum = totalTestPassedCount + totalTestFailedCount + totalTestSkippedCount; countSum = totalTestPassedCount + totalTestFailedCount + totalTestSkippedCount;
if (testFailedCount == 0) if (totalTestFailedCount == 0)
{ {
runResult = 0; runResult = 0;
SDLTest_Log(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount); SDLTest_Log(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);

View file

@ -535,6 +535,32 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlit = {
"\0\0", "\0\0",
}; };
/**
* \brief Returns the Blit test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlit()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
(void*)SDLTest_imageBlit.pixel_data,
SDLTest_imageBlit.width,
SDLTest_imageBlit.height,
SDLTest_imageBlit.bytes_per_pixel * 8,
SDLTest_imageBlit.width * SDLTest_imageBlit.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
return surface;
}
const SDLTest_SurfaceImage_t SDLTest_imageBlitColor = { const SDLTest_SurfaceImage_t SDLTest_imageBlitColor = {
80, 60, 3, 80, 60, 3,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
@ -992,6 +1018,32 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitColor = {
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
}; };
/**
* \brief Returns the BlitColor test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitColor()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
(void*)SDLTest_imageBlitColor.pixel_data,
SDLTest_imageBlitColor.width,
SDLTest_imageBlitColor.height,
SDLTest_imageBlitColor.bytes_per_pixel * 8,
SDLTest_imageBlitColor.width * SDLTest_imageBlitColor.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
return surface;
}
const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha = { const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha = {
80, 60, 3, 80, 60, 3,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
@ -1478,3 +1530,28 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha = {
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
}; };
/**
* \brief Returns the BlitAlpha test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitAlpha()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
(void*)SDLTest_imageBlitAlpha.pixel_data,
SDLTest_imageBlitAlpha.width,
SDLTest_imageBlitAlpha.height,
SDLTest_imageBlitAlpha.bytes_per_pixel * 8,
SDLTest_imageBlitAlpha.width * SDLTest_imageBlitAlpha.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
return surface;
}

View file

@ -575,6 +575,32 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd = {
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
}; };
/**
* \brief Returns the BlitBlendAdd test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitBlendAdd()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
(void*)SDLTest_imageBlitBlendAdd.pixel_data,
SDLTest_imageBlitBlendAdd.width,
SDLTest_imageBlitBlendAdd.height,
SDLTest_imageBlitBlendAdd.bytes_per_pixel * 8,
SDLTest_imageBlitBlendAdd.width * SDLTest_imageBlitBlendAdd.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
return surface;
}
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = { const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = {
80, 60, 3, 80, 60, 3,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
@ -1079,6 +1105,32 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = {
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
}; };
/**
* \brief Returns the BlitBlend test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitBlend()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
(void*)SDLTest_imageBlitBlend.pixel_data,
SDLTest_imageBlitBlend.width,
SDLTest_imageBlitBlend.height,
SDLTest_imageBlitBlend.bytes_per_pixel * 8,
SDLTest_imageBlitBlend.width * SDLTest_imageBlitBlend.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
return surface;
}
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod = { const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod = {
80, 60, 3, 80, 60, 3,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
@ -1483,6 +1535,32 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod = {
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
}; };
/**
* \brief Returns the BlitBlendMod test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitBlendMod()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
(void*)SDLTest_imageBlitBlendMod.pixel_data,
SDLTest_imageBlitBlendMod.width,
SDLTest_imageBlitBlendMod.height,
SDLTest_imageBlitBlendMod.bytes_per_pixel * 8,
SDLTest_imageBlitBlendMod.width * SDLTest_imageBlitBlendMod.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
return surface;
}
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone = { const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone = {
80, 60, 3, 80, 60, 3,
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
@ -2270,6 +2348,32 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone = {
"\377\377\377\377\377\377\377\377", "\377\377\377\377\377\377\377\377",
}; };
/**
* \brief Returns the BlitBlendNone test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitBlendNone()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
(void*)SDLTest_imageBlitBlendNone.pixel_data,
SDLTest_imageBlitBlendNone.width,
SDLTest_imageBlitBlendNone.height,
SDLTest_imageBlitBlendNone.bytes_per_pixel * 8,
SDLTest_imageBlitBlendNone.width * SDLTest_imageBlitBlendNone.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
return surface;
}
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll = { const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll = {
80, 60, 3, 80, 60, 3,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
@ -2712,3 +2816,28 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll = {
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
}; };
/**
* \brief Returns the BlitBlendAll test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageBlitBlendAll()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
(void*)SDLTest_imageBlitBlendAll.pixel_data,
SDLTest_imageBlitBlendAll.width,
SDLTest_imageBlitBlendAll.height,
SDLTest_imageBlitBlendAll.bytes_per_pixel * 8,
SDLTest_imageBlitBlendAll.width * SDLTest_imageBlitBlendAll.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
return surface;
}

View file

@ -24,7 +24,7 @@
/* GIMP RGBA C-Source image dump (face.c) */ /* GIMP RGBA C-Source image dump (face.c) */
const SDLTest_SurfaceImage_t SDLTest_ImageFace = { const SDLTest_SurfaceImage_t SDLTest_imageFace = {
32, 32, 4, 32, 32, 4,
"\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377" "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
"\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377" "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
@ -218,3 +218,29 @@ const SDLTest_SurfaceImage_t SDLTest_ImageFace = {
"\377\377\0\377\377\377\0", "\377\377\0\377\377\377\0",
}; };
/**
* \brief Returns the Face test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImageFace()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
(void*)SDLTest_imageFace.pixel_data,
SDLTest_imageFace.width,
SDLTest_imageFace.height,
SDLTest_imageFace.bytes_per_pixel * 8,
SDLTest_imageFace.width * SDLTest_imageFace.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
return surface;
}

View file

@ -485,3 +485,28 @@ const SDLTest_SurfaceImage_t SDLTest_imagePrimitives = {
"\310\15I\310\15I\310\15I\310\15I\310\5ii", "\310\15I\310\15I\310\15I\310\15I\310\5ii",
}; };
/**
* \brief Returns the Primitives test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImagePrimitives()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
(void*)SDLTest_imagePrimitives.pixel_data,
SDLTest_imagePrimitives.width,
SDLTest_imagePrimitives.height,
SDLTest_imagePrimitives.bytes_per_pixel * 8,
SDLTest_imagePrimitives.width * SDLTest_imagePrimitives.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
return surface;
}

View file

@ -667,3 +667,28 @@ const SDLTest_SurfaceImage_t SDLTest_imagePrimitivesBlend = {
"\377\377\377\377\377\377\377\377\324X2\377\377\377\333bB\377\377\377", "\377\377\377\377\377\377\377\377\324X2\377\377\377\333bB\377\377\377",
}; };
/**
* \brief Returns the PrimitivesBlend test image as SDL_Surface.
*/
SDL_Surface *SDLTest_ImagePrimitivesBlend()
{
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
(void*)SDLTest_imagePrimitivesBlend.pixel_data,
SDLTest_imagePrimitivesBlend.width,
SDLTest_imagePrimitivesBlend.height,
SDLTest_imagePrimitivesBlend.bytes_per_pixel * 8,
SDLTest_imagePrimitivesBlend.width * SDLTest_imagePrimitivesBlend.bytes_per_pixel,
#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
0xff000000, /* Red bit mask. */
0x00ff0000, /* Green bit mask. */
0x0000ff00, /* Blue bit mask. */
0x000000ff /* Alpha bit mask. */
#else
0x000000ff, /* Red bit mask. */
0x0000ff00, /* Green bit mask. */
0x00ff0000, /* Blue bit mask. */
0xff000000 /* Alpha bit mask. */
#endif
);
return surface;
}

View file

@ -37,6 +37,7 @@ main(int argc, char *argv[])
int testIterations = 1; int testIterations = 1;
Uint64 userExecKey = 0; Uint64 userExecKey = 0;
char *userRunSeed = NULL; char *userRunSeed = NULL;
char *filter = NULL;
int i; int i;
/* Initialize test framework */ /* Initialize test framework */
@ -74,6 +75,12 @@ main(int argc, char *argv[])
consumed = 2; consumed = 2;
} }
} }
else if (SDL_strcasecmp(argv[i], "--filter") == 0) {
if (argv[i + 1]) {
filter = SDL_strdup(argv[i + 1]);
consumed = 2;
}
}
} }
if (consumed < 0) { if (consumed < 0) {
fprintf(stderr, fprintf(stderr,
@ -98,12 +105,15 @@ main(int argc, char *argv[])
} }
/* Call Harness */ /* Call Harness */
result = SDLTest_RunSuites(testSuites, userRunSeed, userExecKey, testIterations); result = SDLTest_RunSuites(testSuites, userRunSeed, userExecKey, filter, testIterations);
/* Clean up */ /* Clean up */
if (userRunSeed != NULL) { if (userRunSeed != NULL) {
SDL_free(userRunSeed); SDL_free(userRunSeed);
} }
if (filter != NULL) {
SDL_free(filter);
}
/* Shutdown everything */ /* Shutdown everything */
quit(result); quit(result);

1025
test/tests/testrender.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -15,7 +15,7 @@ extern SDLTest_TestSuiteReference clipboardTestSuite;
//extern SDLTest_TestSuiteReference keyboardTestSuite; //extern SDLTest_TestSuiteReference keyboardTestSuite;
extern SDLTest_TestSuiteReference platformTestSuite; extern SDLTest_TestSuiteReference platformTestSuite;
extern SDLTest_TestSuiteReference rectTestSuite; extern SDLTest_TestSuiteReference rectTestSuite;
//extern SDLTest_TestSuiteReference renderTestSuite; extern SDLTest_TestSuiteReference renderTestSuite;
extern SDLTest_TestSuiteReference rwopsTestSuite; extern SDLTest_TestSuiteReference rwopsTestSuite;
//extern SDLTest_TestSuiteReference surfaceTestSuite; //extern SDLTest_TestSuiteReference surfaceTestSuite;
//extern SDLTest_TestSuiteReference syswmTestSuite; //extern SDLTest_TestSuiteReference syswmTestSuite;
@ -29,7 +29,7 @@ SDLTest_TestSuiteReference *testSuites[] = {
// &keyboardTestSuite, // &keyboardTestSuite,
&platformTestSuite, &platformTestSuite,
&rectTestSuite, &rectTestSuite,
// &renderTestSuite, &renderTestSuite,
&rwopsTestSuite, &rwopsTestSuite,
// &surfaceTestSuite, // &surfaceTestSuite,
// &syswmTestSuite, // &syswmTestSuite,