irrlicht/tests/main.cpp

223 lines
5.6 KiB
C++
Raw Normal View History

// Copyright (C) 2008-2009 Colin MacDonald and Christian Stehno
// No rights reserved: this software is in the public domain.
// This is the entry point for the Irrlicht test suite.
// This is an MSVC pragma to link against the Irrlicht library.
// Other builds must link against it in the project files.
#if defined(_MSC_VER)
#pragma comment(lib, "Irrlicht.lib")
#define _CRT_SECURE_NO_WARNINGS 1
#endif // _MSC_VER
#include "testUtils.h"
#include <stdio.h>
#include <time.h>
#include <vector>
struct STestDefinition
{
//! The test entry point function
bool(*testSignature)(void);
//! A descriptive name for the test
const char * testName;
};
//! This is the main entry point for the Irrlicht test suite.
/** \return The number of test that failed, i.e. 0 is success. */
int main(int argumentCount, char * arguments[])
{
if(argumentCount > 3)
{
logTestString("\nUsage: %s [testNumber] [testCount]\n");
return 9999;
}
#define TEST(x)\
{\
extern bool x(void);\
STestDefinition newTest;\
newTest.testSignature = x;\
newTest.testName = #x;\
tests.push_back(newTest);\
}
// Use an STL vector so that we don't rely on Irrlicht.
std::vector<STestDefinition> tests;
// Note that to interactively debug a test, you will generally want to move it
// (temporarily) to the beginning of the list, since each test runs in its own
// process.
Changes in 1.6 TA - PixelBlend16 and PixelBlend16_simd are working for the new rules. - bugfix. CLightSceneNode didn't correctly update it's attributes Lighting Linear Attenuation. = 1.f / radius The Example loadirr files set the lightscene radius to 1000.f but stays on the previous default attentuation with the older radius 100 -> 1.f / 100 so the examples looks golden-brown. Now the radius is correctly!! set to the attenuation of 1.f/1000.f because the file doesn't have special attenuation. and now it looks more yellow. can anybody show me a correct screenshot for this file;-)? Niko? Or is this behavior the default lighting?. then it would be a fixed constant linear attenuation of 0.01f;-). Please clearify For now i didn't fixed it I encountered this behavior because i ( burning video ) used the original radius for calculations and so i've found that radius != 1.f / linearAttenuation but in the LightSceneNode this formula was used.. confused;-) - vector template and equals tests as working with the test suits i cleaned the template behavior (mixed types are used in the templates) and added all missing special math function with their coressponding type I also set the equal test for s32 to behave like the f32 routine. The function equals always implements a weak test. that means a tolerance MUST always be used if you use the equal function. default is 1. you can set it to zero a==b-> equals ( a, b, 0 ) but do it explicit like you have to for floating compare. This is important when irrlicht is going to use special hardware math acceleration on a per function base, like sse2, or the other way round fixpoint. - VideoDriver drawPixel The HW renderes are using the alpha components for blending. The Software Renderes and image loaders are using CImage::setPixel copy. so setPixel is engaged to either blends or copy the pixel default: false - Burningvideo added RenderMaterial EMT_SPHERE_MAP pushed burningsvideo to 0.43 added RenderMaterial EMT_REFLECTION_2_LAYER pushed burningsvideo to 0.44 set EMT_TRANSPARENT_ALPHA_CHANNEL_REF to use AlphaRef 0.5 like Direct3D One Note: in OpenGL there is know difference between sphere_map and reflection layer both using GL_TEXTURE_GEN_MODE GL_SPHERE_MAP, whereas in d3d one time using camera_normal on sphere and reflection on refletcion_layer. The visual difference is that on sphere map the "image is not moving" when you rotate the viewer. For Buring i took the opengl visual. always moving - rename quake3 SEntity to IEntity to be confom with IShader even IShader and IEntity are none pure virtual interfaces like most irrlicht objects git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2207 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-02-10 07:08:23 -08:00
TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory.
// Now the simple tests without device
TEST(testArray);
TEST(exports);
TEST(irrCoreEquals);
TEST(testIrrString);
TEST(line2dIntersectWith);
TEST(matrixOps);
TEST(testDimension2d);
TEST(testVector2d);
TEST(testVector3d);
// TODO: Needs to be fixed first
// TEST(testTriangle3d);
TEST(vectorPositionDimension2d);
// file system checks (with null driver)
TEST(filesystem);
TEST(archiveReader);
TEST(testXML);
TEST(serializeAttributes);
// null driver
TEST(fast_atof);
TEST(collisionResponseAnimator);
TEST(enumerateImageManipulators);
TEST(removeCustomAnimator);
TEST(sceneCollisionManager);
TEST(sceneNodeAnimator);
TEST(meshLoaders);
// software drivers only
TEST(softwareDevice);
TEST(b3dAnimation);
TEST(burningsVideo);
TEST(cursorSetVisible);
TEST(drawRectOutline);
TEST(flyCircleAnimator);
TEST(md2Animation);
TEST(testGeometryCreator);
TEST(writeImageToFile);
// all driver checks
TEST(drawPixel);
TEST(guiDisabledMenu);
Changes in 1.6 TA - PixelBlend16 and PixelBlend16_simd are working for the new rules. - bugfix. CLightSceneNode didn't correctly update it's attributes Lighting Linear Attenuation. = 1.f / radius The Example loadirr files set the lightscene radius to 1000.f but stays on the previous default attentuation with the older radius 100 -> 1.f / 100 so the examples looks golden-brown. Now the radius is correctly!! set to the attenuation of 1.f/1000.f because the file doesn't have special attenuation. and now it looks more yellow. can anybody show me a correct screenshot for this file;-)? Niko? Or is this behavior the default lighting?. then it would be a fixed constant linear attenuation of 0.01f;-). Please clearify For now i didn't fixed it I encountered this behavior because i ( burning video ) used the original radius for calculations and so i've found that radius != 1.f / linearAttenuation but in the LightSceneNode this formula was used.. confused;-) - vector template and equals tests as working with the test suits i cleaned the template behavior (mixed types are used in the templates) and added all missing special math function with their coressponding type I also set the equal test for s32 to behave like the f32 routine. The function equals always implements a weak test. that means a tolerance MUST always be used if you use the equal function. default is 1. you can set it to zero a==b-> equals ( a, b, 0 ) but do it explicit like you have to for floating compare. This is important when irrlicht is going to use special hardware math acceleration on a per function base, like sse2, or the other way round fixpoint. - VideoDriver drawPixel The HW renderes are using the alpha components for blending. The Software Renderes and image loaders are using CImage::setPixel copy. so setPixel is engaged to either blends or copy the pixel default: false - Burningvideo added RenderMaterial EMT_SPHERE_MAP pushed burningsvideo to 0.43 added RenderMaterial EMT_REFLECTION_2_LAYER pushed burningsvideo to 0.44 set EMT_TRANSPARENT_ALPHA_CHANNEL_REF to use AlphaRef 0.5 like Direct3D One Note: in OpenGL there is know difference between sphere_map and reflection layer both using GL_TEXTURE_GEN_MODE GL_SPHERE_MAP, whereas in d3d one time using camera_normal on sphere and reflection on refletcion_layer. The visual difference is that on sphere map the "image is not moving" when you rotate the viewer. For Buring i took the opengl visual. always moving - rename quake3 SEntity to IEntity to be confom with IShader even IShader and IEntity are none pure virtual interfaces like most irrlicht objects git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2207 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-02-10 07:08:23 -08:00
TEST(makeColorKeyTexture);
TEST(renderTargetTexture);
TEST(textureFeatures);
TEST(textureRenderStates);
TEST(transparentAlphaChannelRef);
// TODO: Needs to be fixed first.
// TEST(projectionMatrix);
// large scenes
TEST(planeMatrix);
TEST(terrainSceneNode);
TEST(lightMaps);
unsigned int numberOfTests = tests.size();
unsigned int testToRun = 0;
unsigned int fails = 0;
bool firstRun=true;
const bool spawn=false;
// args: [testNumber] [testCount]
if(argumentCount > 1)
{
if (!strcmp(arguments[1],"--list"))
{
for (unsigned int i=0; i<tests.size(); ++i)
{
printf("%3d: %s\n", i, tests[i].testName);
}
printf("\n");
return 0;
}
int tmp = atoi(arguments[1]);
firstRun = (tmp>=0);
testToRun=abs(tmp);
if (!firstRun)
testToRun -= 1;
if(argumentCount > 2)
{
numberOfTests = testToRun + abs(atoi(arguments[2]));
if (numberOfTests>=tests.size())
numberOfTests=tests.size();
}
}
if(testToRun >= numberOfTests)
{
logTestString("\nError: invalid test %d (maximum %d)\n",
testToRun, numberOfTests-testToRun);
return 9999;
}
const unsigned int testCount = numberOfTests-testToRun;
const bool logFileOpened = openTestLog(firstRun);
assert(logFileOpened);
if (firstRun)
{
if (numberOfTests)
{
for (unsigned int i=testToRun; i<numberOfTests; ++i)
{
logTestString("\nStarting test %d, '%s'\n",
i, tests[i].testName);
if (spawn)
{
closeTestLog();
char runNextTest[256];
(void)sprintf(runNextTest, "\"%s\" -%d 1", arguments[0], i+1);
// Spawn the next test in a new process.
if (system(runNextTest))
{
(void)openTestLog(false);
logTestString("\n******** Test failure ********\n"\
"Test %d '%s' failed\n"\
"******** Test failure ********\n",
i, tests[i].testName);
++fails;
}
else
(void)openTestLog(false);
}
else
{
if (!tests[i].testSignature())
{
logTestString("\n******** Test failure ********\n"\
"Test %d '%s' failed\n"\
"******** Test failure ********\n",
i, tests[i].testName);
++fails;
}
}
}
}
const int passed = testCount - fails;
logTestString("\nTests finished. %d test%s of %d passed.\n\n",
passed, 1 == passed ? "" : "s", testCount);
if(0 == fails && testCount==tests.size())
{
time_t rawtime;
struct tm * timeinfo;
(void)time(&rawtime);
timeinfo = gmtime(&rawtime);
(void)printf("\nTest suite pass at GMT %s\n", asctime(timeinfo));
FILE * testsLastPassedAtFile = fopen("tests-last-passed-at.txt", "w");
if(testsLastPassedAtFile)
{
(void)fprintf(testsLastPassedAtFile, "Test suite pass at GMT %s\n", asctime(timeinfo));
(void)fclose(testsLastPassedAtFile);
}
}
closeTestLog();
#ifdef _IRR_WINDOWS_
(void)system("tests.log");
#else
(void)system("$PAGER tests.log");
#endif
return fails;
}
else
{
const bool res = tests[testToRun].testSignature();
closeTestLog();
return res?0:1;
}
}