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_random.h" />
<ClInclude Include="..\..\include\SDL_test_images.h" />
<ClInclude Include="..\..\include\SDL_test_compare.h" />
</ItemGroup>
<ItemGroup>
<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_imagePrimitives.c" />
<ClCompile Include="..\..\src\test\SDL_test_imagePrimitivesBlend.c" />
<ClCompile Include="..\..\src\test\SDL_test_compare.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View file

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

View file

@ -41,6 +41,7 @@
#include "SDL_test_assert.h"
#include "SDL_test_harness.h"
#include "SDL_test_images.h"
#include "SDL_test_compare.h"
#include "begin_code.h"
/* 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 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 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 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++ */

View file

@ -36,6 +36,8 @@
#ifndef _SDL_test_images_h
#define _SDL_test_images_h
#include "SDL.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
@ -44,7 +46,6 @@ extern "C" {
/* *INDENT-ON* */
#endif
/**
*Type for test images.
*/
@ -56,17 +57,17 @@ typedef struct SDLTest_SurfaceImage_s {
} SDLTest_SurfaceImage_t;
/* Test images */
const SDLTest_SurfaceImage_t SDLTest_imageBlit;
const SDLTest_SurfaceImage_t SDLTest_imageBlitColor;
const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha;
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd;
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend;
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod;
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone;
const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll;
const SDLTest_SurfaceImage_t SDLTest_ImageFace;
const SDLTest_SurfaceImage_t SDLTest_imagePrimitives;
const SDLTest_SurfaceImage_t SDLTest_imagePrimitivesBlend;
SDL_Surface *SDLTest_ImageBlit();
SDL_Surface *SDLTest_ImageBlitColor();
SDL_Surface *SDLTest_ImageBlitAlpha();
SDL_Surface *SDLTest_ImageBlitBlendAdd();
SDL_Surface *SDLTest_ImageBlitBlend();
SDL_Surface *SDLTest_ImageBlitBlendMod();
SDL_Surface *SDLTest_ImageBlitBlendNone();
SDL_Surface *SDLTest_ImageBlitBlendAll();
SDL_Surface *SDLTest_ImageFace();
SDL_Surface *SDLTest_ImagePrimitives();
SDL_Surface *SDLTest_ImagePrimitivesBlend();
/* Ends C function definitions when using C++ */
#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,7 +116,7 @@ SDLTest_RandomUint32()
Uint64
SDLTest_RandomUint64()
{
Uint64 value;
Uint64 value = 0;
Uint32 *vp = (void *)&value;
fuzzerInvocationCounter++;
@ -130,7 +130,7 @@ SDLTest_RandomUint64()
Sint64
SDLTest_RandomSint64()
{
Uint64 value;
Uint64 value = 0;
Uint32 *vp = (void *)&value;
fuzzerInvocationCounter++;

View file

@ -201,6 +201,9 @@ SDLTest_SetTestTimeout(int timeout, void (*callback)())
return timerID;
}
/**
* \brief Timeout handler. Aborts test run and exits harness process.
*/
void
SDLTest_BailOut()
{
@ -232,10 +235,11 @@ SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, SDLTest_TestCaseReference
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;
}
// Initialize fuzzer
SDLTest_FuzzerInit(execKey);
@ -317,15 +321,19 @@ float GetClock()
/**
* \brief Execute a test suite using the given run seend and execution key.
*
* The filter string is matched to the suite name (full comparison) to select a single suite,
* or if no suite matches, it is matched to the test names (full comparison) to select a single test.
*
* \param testSuites Suites containing the test case.
* \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 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
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 testCounter;
@ -343,6 +351,10 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
float suiteEndSeconds;
float testEndSeconds;
float runtime;
int suiteFilter = 0;
char *suiteFilterName = NULL;
int testFilter = 0;
char *testFilterName = NULL;
int testResult = 0;
int runResult = 0;
Uint32 totalTestFailedCount = 0;
@ -370,6 +382,7 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
runSeed = userRunSeed;
}
// Reset per-run counters
totalTestFailedCount = 0;
totalTestPassedCount = 0;
@ -381,12 +394,62 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
// Log run with fuzzer parameters
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
suiteCounter = 0;
while(testSuites[suiteCounter]) {
testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter];
currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat);
suiteCounter++;
// Filter suite if flag set and we have a name
if (suiteFilter == 1 && suiteFilterName != NULL && testSuite->name != NULL &&
SDL_strcmp(suiteFilterName, testSuite->name) != 0) {
// Skip suite
SDLTest_Log("===== Test Suite %i: '%s' skipped\n",
suiteCounter,
currentSuiteName);
} else {
// Reset per-suite counters
testFailedCount = 0;
testPassedCount = 0;
@ -396,7 +459,6 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
suiteStartSeconds = GetClock();
// Log suite started
currentSuiteName = (char *)((testSuite->name) ? testSuite->name : SDLTest_InvalidNameFormat);
SDLTest_Log("===== Test Suite %i: '%s' started\n",
suiteCounter,
currentSuiteName);
@ -406,13 +468,23 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
while(testSuite->testCases[testCounter])
{
testCase=(SDLTest_TestCaseReference *)testSuite->testCases[testCounter];
currentTestName = (char *)((testCase->name) ? testCase->name : SDLTest_InvalidNameFormat);
testCounter++;
// Filter tests if flag set and we have a name
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 {
// Take time - test start
testStartSeconds = GetClock();
// Log test started
currentTestName = (char *)((testCase->name) ? testCase->name : SDLTest_InvalidNameFormat);
SDLTest_Log("----- Test Case %i.%i: '%s' started",
suiteCounter,
testCounter,
@ -457,10 +529,10 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
if (testIterations > 1) {
// Log test runtime
SDLTest_Log("Runtime of %i iterations: %.1f sec", testIterations, runtime);
SDLTest_Log("Test runtime: %.5f sec", runtime / (float)testIterations);
SDLTest_Log("Average Test runtime: %.5f sec", runtime / (float)testIterations);
} else {
// Log test runtime
SDLTest_Log("Test runtime: %.1f sec", runtime);
SDLTest_Log("Total Test runtime: %.1f sec", runtime);
}
// Log final test result
@ -475,6 +547,8 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
SDLTest_LogError((char *)SDLTest_FinalResultFormat,"Test", currentTestName, "No Asserts");
break;
}
}
}
// Take time - suite end
@ -483,7 +557,7 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
if (runtime < 0.0f) runtime = 0.0f;
// Log suite runtime
SDLTest_Log("Suite runtime: %.1f sec", runtime);
SDLTest_Log("Total Suite runtime: %.1f sec", runtime);
// Log summary and final Suite result
countSum = testPassedCount + testFailedCount + testSkippedCount;
@ -497,6 +571,8 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
SDLTest_LogError(logFormat, "Suite", countSum, testPassedCount, testFailedCount, testSkippedCount);
SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Suite", currentSuiteName, "Failed");
}
}
}
// Take time - run end
@ -505,11 +581,11 @@ SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], char *userRunSeed, U
if (runtime < 0.0f) runtime = 0.0f;
// Log total runtime
SDLTest_Log("Total runtime: %.1f sec", runtime);
SDLTest_Log("Total Run runtime: %.1f sec", runtime);
// Log summary and final run result
countSum = totalTestPassedCount + totalTestFailedCount + totalTestSkippedCount;
if (testFailedCount == 0)
if (totalTestFailedCount == 0)
{
runResult = 0;
SDLTest_Log(logFormat, "Run", countSum, totalTestPassedCount, totalTestFailedCount, totalTestSkippedCount);

View file

@ -535,6 +535,32 @@ const SDLTest_SurfaceImage_t SDLTest_imageBlit = {
"\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 = {
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"
@ -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",
};
/**
* \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 = {
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"
@ -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",
};
/**
* \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",
};
/**
* \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 = {
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"
@ -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",
};
/**
* \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 = {
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"
@ -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",
};
/**
* \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 = {
80, 60, 3,
"\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",
};
/**
* \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 = {
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"
@ -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",
};
/**
* \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) */
const SDLTest_SurfaceImage_t SDLTest_ImageFace = {
const SDLTest_SurfaceImage_t SDLTest_imageFace = {
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\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",
};
/**
* \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",
};
/**
* \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",
};
/**
* \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;
Uint64 userExecKey = 0;
char *userRunSeed = NULL;
char *filter = NULL;
int i;
/* Initialize test framework */
@ -74,6 +75,12 @@ main(int argc, char *argv[])
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) {
fprintf(stderr,
@ -98,12 +105,15 @@ main(int argc, char *argv[])
}
/* Call Harness */
result = SDLTest_RunSuites(testSuites, userRunSeed, userExecKey, testIterations);
result = SDLTest_RunSuites(testSuites, userRunSeed, userExecKey, filter, testIterations);
/* Clean up */
if (userRunSeed != NULL) {
SDL_free(userRunSeed);
}
if (filter != NULL) {
SDL_free(filter);
}
/* Shutdown everything */
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 platformTestSuite;
extern SDLTest_TestSuiteReference rectTestSuite;
//extern SDLTest_TestSuiteReference renderTestSuite;
extern SDLTest_TestSuiteReference renderTestSuite;
extern SDLTest_TestSuiteReference rwopsTestSuite;
//extern SDLTest_TestSuiteReference surfaceTestSuite;
//extern SDLTest_TestSuiteReference syswmTestSuite;
@ -29,7 +29,7 @@ SDLTest_TestSuiteReference *testSuites[] = {
// &keyboardTestSuite,
&platformTestSuite,
&rectTestSuite,
// &renderTestSuite,
&renderTestSuite,
&rwopsTestSuite,
// &surfaceTestSuite,
// &syswmTestSuite,