Skeleton work on Nasal GC test
Incomplete, but the goal is to stess the Nasal GC system by creating and destroying large number of objects continously.
This commit is contained in:
parent
a01f3442c6
commit
ee3958f971
6 changed files with 143 additions and 10 deletions
|
@ -64,7 +64,12 @@ using std::vector;
|
|||
|
||||
void postinitNasalGUI(naRef globals, naContext c);
|
||||
|
||||
static FGNasalSys* nasalSys = 0;
|
||||
static FGNasalSys* nasalSys = nullptr;
|
||||
|
||||
// this is used by the test-suite to simplify
|
||||
// how much Nasal modules we load by default
|
||||
bool global_nasalMinimalInit = false;
|
||||
|
||||
|
||||
// Listener class for loading Nasal modules on demand
|
||||
class FGNasalModuleListener : public SGPropertyChangeListener
|
||||
|
@ -1016,14 +1021,16 @@ void FGNasalSys::init()
|
|||
naSave(_context, _string);
|
||||
initNasalString(_globals, _string, _context);
|
||||
|
||||
initNasalPositioned(_globals, _context);
|
||||
initNasalPositioned_cppbind(_globals, _context);
|
||||
initNasalAircraft(_globals, _context);
|
||||
NasalClipboard::init(this);
|
||||
initNasalCanvas(_globals, _context);
|
||||
initNasalCondition(_globals, _context);
|
||||
initNasalHTTP(_globals, _context);
|
||||
initNasalSGPath(_globals, _context);
|
||||
if (!global_nasalMinimalInit) {
|
||||
initNasalPositioned(_globals, _context);
|
||||
initNasalPositioned_cppbind(_globals, _context);
|
||||
initNasalAircraft(_globals, _context);
|
||||
NasalClipboard::init(this);
|
||||
initNasalCanvas(_globals, _context);
|
||||
initNasalCondition(_globals, _context);
|
||||
initNasalHTTP(_globals, _context);
|
||||
initNasalSGPath(_globals, _context);
|
||||
}
|
||||
|
||||
NasalTimerObj::init("Timer")
|
||||
.method("start", &TimerObj::start)
|
||||
|
@ -1039,6 +1046,13 @@ void FGNasalSys::init()
|
|||
.method("elapsedUSec", &TimeStampObj::elapsedUSec)
|
||||
;
|
||||
|
||||
// everything after here, skip if we're doing minimal init, so
|
||||
// we don'tload FG_DATA/Nasal or add-ons
|
||||
if (global_nasalMinimalInit) {
|
||||
_inited = true;
|
||||
return;
|
||||
}
|
||||
|
||||
flightgear::addons::initAddonClassesForNasal(_globals, _context);
|
||||
|
||||
// Now load the various source files in the Nasal directory
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include <Canvas/canvas_mgr.hxx>
|
||||
#include <Canvas/FGCanvasSystemAdapter.hxx>
|
||||
extern bool global_nasalMinimalInit;
|
||||
|
||||
|
||||
void verifyPixel(osg::Image* img, int x, int y, const uint8_t* pixel)
|
||||
{
|
||||
|
@ -19,6 +21,7 @@ void verifyPixel(osg::Image* img, int x, int y, const uint8_t* pixel)
|
|||
|
||||
void CanvasTests::setUp()
|
||||
{
|
||||
global_nasalMinimalInit = false;
|
||||
FGTestApi::setUp::initTestGlobals("canvas");
|
||||
|
||||
// Canvas needs loadxml command
|
||||
|
|
|
@ -2,11 +2,13 @@ set(TESTSUITE_SOURCES
|
|||
${TESTSUITE_SOURCES}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestSuite.cxx
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/testNasalSys.cxx
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/testGC.cxx
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(TESTSUITE_HEADERS
|
||||
${TESTSUITE_HEADERS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/testNasalSys.hxx
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/testGC.hxx
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
*/
|
||||
|
||||
#include "testNasalSys.hxx"
|
||||
|
||||
#include "testGC.hxx"
|
||||
|
||||
// Set up the unit tests.
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(NasalSysTests, "Unit tests");
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(NasalGCTests, "Unit tests");
|
||||
|
|
69
test_suite/unit_tests/Scripting/testGC.cxx
Normal file
69
test_suite/unit_tests/Scripting/testGC.cxx
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (C) 2020 James Turner
|
||||
*
|
||||
* This file is part of the program FlightGear.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "testGC.hxx"
|
||||
|
||||
#include "test_suite/FGTestApi/testGlobals.hxx"
|
||||
|
||||
#include <Main/globals.hxx>
|
||||
#include <Main/util.hxx>
|
||||
#include <Scripting/NasalSys.hxx>
|
||||
|
||||
#include <Main/FGInterpolator.hxx>
|
||||
|
||||
extern bool global_nasalMinimalInit;
|
||||
|
||||
// Set up function for each test.
|
||||
void NasalGCTests::setUp()
|
||||
{
|
||||
FGTestApi::setUp::initTestGlobals("NasalGC");
|
||||
|
||||
fgInitAllowedPaths();
|
||||
auto nasalNode = globals->get_props()->getNode("nasal", true);
|
||||
|
||||
globals->add_subsystem("prop-interpolator", new FGInterpolator, SGSubsystemMgr::INIT);
|
||||
|
||||
global_nasalMinimalInit = true;
|
||||
globals->add_new_subsystem<FGNasalSys>(SGSubsystemMgr::INIT);
|
||||
}
|
||||
|
||||
|
||||
// Clean up after each test.
|
||||
void NasalGCTests::tearDown()
|
||||
{
|
||||
FGTestApi::tearDown::shutdownTestGlobals();
|
||||
}
|
||||
|
||||
|
||||
// Test test
|
||||
void NasalGCTests::testDummy()
|
||||
{
|
||||
bool ok = FGTestApi::executeNasal(R"(
|
||||
var foo = {
|
||||
"name": "PFD-Test",
|
||||
"size": [512, 512],
|
||||
"view": [768, 1024],
|
||||
"mipmapping": 1
|
||||
};
|
||||
|
||||
globals.foo1 = foo;
|
||||
)");
|
||||
CPPUNIT_ASSERT(ok);
|
||||
}
|
44
test_suite/unit_tests/Scripting/testGC.hxx
Normal file
44
test_suite/unit_tests/Scripting/testGC.hxx
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (C) 2020 James Turner
|
||||
*
|
||||
* This file is part of the program FlightGear.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <cppunit/TestFixture.h>
|
||||
|
||||
|
||||
class NasalGCTests : public CppUnit::TestFixture
|
||||
{
|
||||
// Set up the test suite.
|
||||
CPPUNIT_TEST_SUITE(NasalGCTests);
|
||||
CPPUNIT_TEST(testDummy);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
// Set up function for each test.
|
||||
void setUp();
|
||||
|
||||
// Clean up after each test.
|
||||
void tearDown();
|
||||
|
||||
// The tests.
|
||||
void testDummy();
|
||||
};
|
Loading…
Add table
Reference in a new issue