1
// Copyright (C) 2008-2011 Colin MacDonald and Christian Stehno
2
// No rights reserved: this software is in the public domain.
4
// This is the entry point for the Irrlicht test suite.
6
// This is an MSVC pragma to link against the Irrlicht library.
7
// Other builds must link against it in the project files.
9
#pragma comment(lib, "Irrlicht.lib")
10
#define _CRT_SECURE_NO_WARNINGS 1
13
#include "testUtils.h"
18
struct STestDefinition
20
//! The test entry point function
21
bool(*testSignature)(void);
23
//! A descriptive name for the test
24
const char * testName;
27
//! This is the main entry point for the Irrlicht test suite.
28
/** \return The number of test that failed, i.e. 0 is success. */
29
int main(int argumentCount, char * arguments[])
33
logTestString("\nUsage: %s [testNumber] [testCount]\n");
40
STestDefinition newTest;\
41
newTest.testSignature = x;\
42
newTest.testName = #x;\
43
tests.push_back(newTest);\
46
// Use an STL vector so that we don't rely on Irrlicht.
47
std::vector<STestDefinition> tests;
49
// Note that to interactively debug a test, you will generally want to move it
50
// (temporarily) to the beginning of the list, since each test runs in its own
53
TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory.
54
// Now the simple tests without device
61
TEST(line2dIntersectWith);
63
TEST(testDimension2d);
70
// TODO: Needs to be fixed first
71
// TEST(testTriangle3d);
72
TEST(vectorPositionDimension2d);
73
// file system checks (with null driver)
77
TEST(serializeAttributes);
81
TEST(collisionResponseAnimator);
82
TEST(enumerateImageManipulators);
83
TEST(removeCustomAnimator);
84
TEST(sceneCollisionManager);
85
TEST(sceneNodeAnimator);
88
// software drivers only
93
TEST(cursorSetVisible);
94
TEST(flyCircleAnimator);
95
TEST(guiDisabledMenu);
96
TEST(makeColorKeyTexture);
100
TEST(testGeometryCreator);
101
TEST(writeImageToFile);
107
TEST(drawRectOutline);
109
TEST(renderTargetTexture);
110
TEST(textureFeatures);
111
TEST(textureRenderStates);
112
TEST(transparentMaterials);
119
TEST(projectionMatrix);
120
// large scenes/long rendering
123
// TEST(stencilShadow);
126
TEST(terrainSceneNode);
129
unsigned int numberOfTests = tests.size();
130
unsigned int testToRun = 0;
131
unsigned int fails = 0;
134
const bool spawn=false;
135
// args: [testNumber] [testCount]
136
if(argumentCount > 1)
138
if (!strcmp(arguments[1],"--list"))
140
for (unsigned int i=0; i<tests.size(); ++i)
142
logTestString("%3d: %s\n", i, tests[i].testName);
148
int tmp = atoi(arguments[1]);
154
if(argumentCount > 2)
156
numberOfTests = testToRun + abs(atoi(arguments[2]));
157
if (numberOfTests>=tests.size())
158
numberOfTests=tests.size();
162
if(testToRun >= numberOfTests)
164
logTestString("\nError: invalid test %d (maximum %d)\n",
165
testToRun, numberOfTests-testToRun);
169
const unsigned int testCount = numberOfTests-testToRun;
170
const bool logFileOpened = openTestLog(firstRun);
171
assert(logFileOpened);
177
for (unsigned int i=testToRun; i<numberOfTests; ++i)
179
logTestString("\nStarting test %d, '%s'\n",
180
i, tests[i].testName);
184
char runNextTest[256];
185
(void)sprintf(runNextTest, "\"%s\" -%d 1", arguments[0], i+1);
186
// Spawn the next test in a new process.
187
if (system(runNextTest))
189
(void)openTestLog(false);
190
logTestString("\n******** Test failure ********\n"\
191
"Test %d '%s' failed\n"\
192
"******** Test failure ********\n",
193
i, tests[i].testName);
197
(void)openTestLog(false);
201
if (!tests[i].testSignature())
203
logTestString("\n******** Test failure ********\n"\
204
"Test %d '%s' failed\n"\
205
"******** Test failure ********\n",
206
i, tests[i].testName);
212
const int passed = testCount - fails;
214
logTestString("\nTests finished. %d test%s of %d passed.\n\n",
215
passed, 1 == passed ? "" : "s", testCount);
217
if(0 == fails && testCount==tests.size())
220
struct tm * timeinfo;
221
(void)time(&rawtime);
222
timeinfo = gmtime(&rawtime);
223
(void)printf("\nTest suite pass at GMT %s\n", asctime(timeinfo));
224
FILE * testsLastPassedAtFile = fopen("tests-last-passed-at.txt", "w");
225
if(testsLastPassedAtFile)
227
(void)fprintf(testsLastPassedAtFile, "Tests finished. %d test%s of %d passed.\n",
228
passed, 1 == passed ? "" : "s", numberOfTests);
230
(void)fprintf(testsLastPassedAtFile, "Compiled as DEBUG\n");
232
(void)fprintf(testsLastPassedAtFile, "Compiled as RELEASE\n");
234
(void)fprintf(testsLastPassedAtFile, "Test suite pass at GMT %s\n", asctime(timeinfo));
235
(void)fclose(testsLastPassedAtFile);
240
(void)system("tests.log");
242
(void)system("$PAGER tests.log");
248
const bool res = tests[testToRun].testSignature();