diff options
author | sfan5 <sfan5@live.de> | 2022-03-09 22:43:35 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-03-09 22:52:11 +0100 |
commit | 8b1d0db8e28a0d45b98319d93a0c87bf33d2757a (patch) | |
tree | 6aa433edd8212eca96d797eab0f94dbe3a1c12fa /examples/AutomatedTest/main.cpp | |
parent | e469c54f76f6d24f92389b4e8a27b9cce7152888 (diff) | |
download | irrlicht-8b1d0db8e28a0d45b98319d93a0c87bf33d2757a.tar.xz |
AutomatedTest: improve and run under macOS CI too
Diffstat (limited to 'examples/AutomatedTest/main.cpp')
-rw-r--r-- | examples/AutomatedTest/main.cpp | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/examples/AutomatedTest/main.cpp b/examples/AutomatedTest/main.cpp index 386e14c..0966892 100644 --- a/examples/AutomatedTest/main.cpp +++ b/examples/AutomatedTest/main.cpp @@ -3,6 +3,9 @@ using namespace irr;
+static IrrlichtDevice *device = nullptr;
+static int test_fail = 0;
+
static video::E_DRIVER_TYPE chooseDriver(const char *arg_)
{
if (core::stringc(arg_) == "null")
@@ -15,6 +18,15 @@ static video::E_DRIVER_TYPE chooseDriver(const char *arg_) return video::EDT_OPENGL;
}
+static inline void check(bool ok, const char *msg)
+{
+ if (!ok)
+ {
+ test_fail++;
+ device->getLogger()->log((core::stringc("FAILED TEST: ") + msg).c_str(), ELL_ERROR);
+ }
+}
+
int main(int argc, char *argv[])
{
SIrrlichtCreationParameters p;
@@ -23,10 +35,18 @@ int main(int argc, char *argv[]) p.Vsync = true;
p.LoggingLevel = ELL_DEBUG;
- IrrlichtDevice *device = createDeviceEx(p);
+ device = createDeviceEx(p);
if (!device)
return 1;
+ {
+ u32 total = 0;
+ device->getOSOperator()->getSystemMemory(&total, nullptr);
+ core::stringc message = core::stringc("Total RAM in MiB: ") + core::stringc(total >> 10);
+ device->getLogger()->log(message.c_str(), ELL_INFORMATION);
+ check(total > 130 * 1024, "RAM amount");
+ }
+
device->setWindowCaption(L"Hello World!");
device->setResizable(true);
@@ -46,15 +66,19 @@ int main(int argc, char *argv[]) const io::path mediaPath = getExampleMediaPath();
scene::IAnimatedMesh* mesh = smgr->getMesh(mediaPath + "coolguy_opt.x");
- if (!mesh)
- return 1;
- scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
- if (node)
+ check(mesh, "mesh loading");
+ if (mesh)
{
- node->setMaterialFlag(video::EMF_LIGHTING, false);
- node->setFrameLoop(0, 29);
- node->setAnimationSpeed(30);
- node->setMaterialTexture(0, driver->getTexture(mediaPath + "cooltexture.png"));
+ video::ITexture* tex = driver->getTexture(mediaPath + "cooltexture.png");
+ check(tex, "texture loading");
+ scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
+ if (node)
+ {
+ node->setMaterialFlag(video::EMF_LIGHTING, false);
+ node->setFrameLoop(0, 29);
+ node->setAnimationSpeed(30);
+ node->setMaterialTexture(0, tex);
+ }
}
smgr->addCameraSceneNode(0, core::vector3df(0,4,5), core::vector3df(0,2,0));
@@ -102,12 +126,9 @@ int main(int argc, char *argv[]) driver->endScene();
}
- if (core::stringw(L"a") != editbox->getText()) {
- device->getLogger()->log("EditBox text mismatch", ELL_INFORMATION);
- return 1;
- }
+ check(core::stringw(L"a") == editbox->getText(), "EditBox text");
device->getLogger()->log("Done.", ELL_INFORMATION);
device->drop();
- return 0;
+ return test_fail > 0 ? 1 : 0;
}
|