2009-01-05 06:53:30 -08:00
|
|
|
// Copyright (C) 2008-2009 Colin MacDonald and Christian Stehno
|
|
|
|
// No rights reserved: this software is in the public domain.
|
|
|
|
|
2008-12-30 03:13:22 -08:00
|
|
|
// This is the entry point for the Irrlicht test suite.
|
2009-01-05 06:53:30 -08:00
|
|
|
|
2008-12-30 03:13:22 -08:00
|
|
|
// 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")
|
2009-01-16 06:19:38 -08:00
|
|
|
#define _CRT_SECURE_NO_WARNINGS 1
|
2008-12-30 03:13:22 -08:00
|
|
|
#endif // _MSC_VER
|
|
|
|
|
|
|
|
#include "testUtils.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <assert.h>
|
2009-01-05 06:53:30 -08:00
|
|
|
#include <vector>
|
2008-12-30 03:13:22 -08:00
|
|
|
|
2009-01-05 06:53:30 -08:00
|
|
|
// 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")
|
|
|
|
#endif // _MSC_VER
|
|
|
|
|
|
|
|
typedef struct _STestDefinition
|
|
|
|
{
|
|
|
|
bool(*testSignature)(void);
|
|
|
|
const char * testName;
|
|
|
|
} STestDefinition;
|
2008-12-30 03:13:22 -08:00
|
|
|
|
|
|
|
//! 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[])
|
|
|
|
{
|
|
|
|
bool logFileOpened = openTestLog(1 == argumentCount);
|
|
|
|
assert(logFileOpened);
|
|
|
|
|
|
|
|
if(argumentCount > 3)
|
|
|
|
{
|
|
|
|
logTestString("\nUsage: %s [testNumber] [totalFails]\n");
|
|
|
|
closeTestLog();
|
|
|
|
return 9999;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-05 06:53:30 -08:00
|
|
|
#define TEST(x)\
|
|
|
|
{\
|
|
|
|
extern bool x(void);\
|
|
|
|
STestDefinition newTest;\
|
|
|
|
newTest.testSignature = x;\
|
|
|
|
newTest.testName = #x;\
|
|
|
|
tests.push_back(newTest);\
|
|
|
|
}
|
2008-12-30 03:13:22 -08:00
|
|
|
|
2009-01-05 06:53:30 -08:00
|
|
|
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.
|
|
|
|
TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory.
|
|
|
|
TEST(exports);
|
|
|
|
TEST(sceneCollisionManager);
|
|
|
|
TEST(testVector3d);
|
|
|
|
TEST(testVector2d);
|
|
|
|
TEST(planeMatrix);
|
|
|
|
TEST(fast_atof);
|
|
|
|
TEST(line2dIntersectWith);
|
|
|
|
TEST(testDimension2d);
|
|
|
|
TEST(drawPixel);
|
|
|
|
TEST(md2Animation);
|
|
|
|
TEST(guiDisabledMenu);
|
|
|
|
TEST(softwareDevice);
|
|
|
|
TEST(b3dAnimation);
|
|
|
|
TEST(textureRenderStates);
|
|
|
|
TEST(terrainSceneNode);
|
|
|
|
TEST(burningsVideo);
|
2009-01-05 07:34:22 -08:00
|
|
|
TEST(makeColorKeyTexture);
|
2009-01-14 04:37:51 -08:00
|
|
|
TEST(cursorSetVisible);
|
|
|
|
TEST(transparentAlphaChannelRef);
|
|
|
|
TEST(drawRectOutline);
|
2009-01-05 06:53:30 -08:00
|
|
|
|
|
|
|
// Tests available on 1.6+
|
|
|
|
TEST(collisionResponseAnimator);
|
|
|
|
TEST(irrCoreEquals);
|
|
|
|
TEST(makeColorKeyTexture);
|
|
|
|
TEST(matrixOps);
|
|
|
|
TEST(sceneNodeAnimator);
|
|
|
|
TEST(vectorPositionDimension2d);
|
2009-01-16 06:19:38 -08:00
|
|
|
TEST(writeImageToFile);
|
2009-01-05 06:53:30 -08:00
|
|
|
|
|
|
|
const unsigned int numberOfTests = tests.size();
|
2008-12-30 03:13:22 -08:00
|
|
|
|
|
|
|
unsigned int testToRun = 0;
|
|
|
|
unsigned int fails = 0;
|
|
|
|
|
|
|
|
if(argumentCount > 1)
|
|
|
|
{
|
|
|
|
testToRun = (unsigned int)atoi(arguments[1]);
|
|
|
|
if(testToRun >= numberOfTests)
|
|
|
|
{
|
|
|
|
logTestString("\nError: invalid test %d (maximum %d)\n",
|
|
|
|
testToRun, numberOfTests - 1);
|
|
|
|
closeTestLog();
|
|
|
|
return 9999;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(argumentCount > 2)
|
|
|
|
fails = (unsigned int)atoi(arguments[2]);
|
|
|
|
|
|
|
|
logTestString("\nStarting test %d, '%s'\n",
|
2009-01-14 04:37:51 -08:00
|
|
|
testToRun + 1, tests[testToRun].testName);
|
2008-12-30 03:13:22 -08:00
|
|
|
|
|
|
|
bool success = tests[testToRun].testSignature();
|
|
|
|
|
|
|
|
if(!success)
|
|
|
|
{
|
|
|
|
logTestString("\n\n\n******** Test failure ********\nTest %d '%s' failed\n"\
|
|
|
|
"******** Test failure ********\n",
|
2009-01-14 04:37:51 -08:00
|
|
|
testToRun + 1, tests[testToRun].testName);
|
2008-12-30 03:13:22 -08:00
|
|
|
fails++;
|
|
|
|
}
|
|
|
|
|
|
|
|
testToRun++;
|
2009-01-05 06:53:30 -08:00
|
|
|
if(testToRun < numberOfTests)
|
|
|
|
{
|
|
|
|
closeTestLog();
|
|
|
|
char runNextTest[256];
|
|
|
|
(void)sprintf(runNextTest, "\"%s\" %d %d", arguments[0], testToRun, fails);
|
|
|
|
fails = system(runNextTest);
|
|
|
|
}
|
2008-12-30 03:13:22 -08:00
|
|
|
|
2009-01-05 06:53:30 -08:00
|
|
|
if(1 == testToRun)
|
2008-12-30 03:13:22 -08:00
|
|
|
{
|
2009-01-05 06:53:30 -08:00
|
|
|
(void)openTestLog(false);
|
|
|
|
const int passed = numberOfTests - fails;
|
|
|
|
|
|
|
|
logTestString("\nTests finished. %d test%s of %d passed.\n",
|
|
|
|
passed, 1 == passed ? "" : "s", numberOfTests);
|
|
|
|
|
2008-12-30 03:13:22 -08:00
|
|
|
if(0 == fails)
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
return fails;
|
|
|
|
}
|
|
|
|
|