Merge branch 'next' of ssh://git.code.sf.net/p/flightgear/flightgear into next
This commit is contained in:
commit
f3893c54bd
16 changed files with 265 additions and 91 deletions
2
3rdparty/sqlite3/CMakeLists.txt
vendored
2
3rdparty/sqlite3/CMakeLists.txt
vendored
|
@ -2,4 +2,4 @@
|
|||
add_definitions(-DSQLITE_OMIT_LOAD_EXTENSION)
|
||||
add_definitions(-DNDEBUG)
|
||||
add_library(fgsqlite3 sqlite3.c)
|
||||
set_target_properties(fgsqlite3 PROPERTIES COMPILE_FLAGS "-fno-fast-math")
|
||||
set_target_properties(fgsqlite3 PROPERTIES COMPILE_FLAGS "-fpic -fno-fast-math")
|
||||
|
|
|
@ -509,8 +509,6 @@ configure_file (
|
|||
|
||||
add_subdirectory(3rdparty)
|
||||
add_subdirectory(utils)
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(man)
|
||||
|
||||
if(ENABLE_TESTS)
|
||||
# enable CTest / make test target
|
||||
|
@ -528,6 +526,9 @@ else()
|
|||
message(STATUS "Tests: DISABLED")
|
||||
endif(ENABLE_TESTS)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(man)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
### uninstall target
|
||||
#-----------------------------------------------------------------------------
|
||||
|
|
|
@ -832,7 +832,12 @@ Wing* FGFDM::parseWing(XMLAttributes* a, const char* type, Version * version)
|
|||
w->setSweep(attrf(a, "sweep", 0) * DEG2RAD);
|
||||
w->setTaper(attrf(a, "taper", 1));
|
||||
w->setDihedral(attrf(a, "dihedral", defDihed) * DEG2RAD);
|
||||
w->setCamber(attrf(a, "camber", 0));
|
||||
|
||||
float camber = attrf(a, "camber", 0);
|
||||
if (!version->isVersionOrNewer(Version::YASIM_VERSION_2017_2) && (camber == 0)) {
|
||||
SG_LOG(SG_FLIGHT, SG_DEV_WARN, "YASIM warning: versions before 2017.2 are buggy for wings with camber=0");
|
||||
}
|
||||
w->setCamber(camber);
|
||||
|
||||
// These come in with positive indicating positive AoA, but the
|
||||
// internals expect a rotation about the left-pointing Y axis, so
|
||||
|
|
|
@ -55,13 +55,12 @@ void RigidBody::setMass(int handle, float mass)
|
|||
|
||||
void RigidBody::setMass(int handle, float mass, const float* pos, bool isStatic)
|
||||
{
|
||||
_masses[handle].m = mass;
|
||||
_masses[handle].isStatic = isStatic;
|
||||
Math::set3(pos, _masses[handle].p);
|
||||
setMass(handle, mass);
|
||||
if (_bodyN != 0) {
|
||||
SGPropertyNode_ptr n = _bodyN->getChild("mass", handle, true);
|
||||
n->getNode("isStatic", true)->setValue(isStatic);
|
||||
n->getNode("mass", true)->setFloatValue(mass);
|
||||
n->getNode("pos-x", true)->setFloatValue(pos[0]);
|
||||
n->getNode("pos-y", true)->setFloatValue(pos[1]);
|
||||
n->getNode("pos-z", true)->setFloatValue(pos[2]);
|
||||
|
|
|
@ -82,7 +82,7 @@ public:
|
|||
void setBodySpin(const float* rotation) { Math::set3(rotation, _spin); }
|
||||
|
||||
// Returns the center of gravity of the masses, in the body
|
||||
// coordinate system.
|
||||
// coordinate system. valid only after recalc()
|
||||
void getCG(float* cgOut) { Math::set3(_cg, cgOut); }
|
||||
|
||||
// Returns the acceleration of the body's c.g. relative to the
|
||||
|
|
|
@ -174,12 +174,15 @@ void yasim_drag(Airplane* a, const float aoa, const float alt, int cfg = CONFIG_
|
|||
|
||||
int usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: yasim <ac.xml> [-g [-a alt] [-s kts] [-approach | -cruise] ]\n");
|
||||
fprintf(stderr, " yasim <ac.xml> [-d [-a alt] [-approach | -cruise] ]\n");
|
||||
fprintf(stderr, " yasim <ac.xml> [-m]\n");
|
||||
fprintf(stderr, " -g print lift/drag table: aoa, lift, drag, lift/drag \n");
|
||||
fprintf(stderr, " -d print drag over TAS: kts, drag\n");
|
||||
fprintf(stderr, " -m print mass distribution table: id, x, y, z, mass \n");
|
||||
fprintf(stderr, "Usage: \n");
|
||||
fprintf(stderr, " yasim <aircraft.xml> [-g [-a meters] [-s kts] [-approach | -cruise] ]\n");
|
||||
fprintf(stderr, " yasim <aircraft.xml> [-d [-a meters] [-approach | -cruise] ]\n");
|
||||
fprintf(stderr, " yasim <aircraft.xml> [-m]\n");
|
||||
fprintf(stderr, " -g print lift/drag table: aoa, lift, drag, lift/drag \n");
|
||||
fprintf(stderr, " -d print drag over TAS: kts, drag\n");
|
||||
fprintf(stderr, " -a set altitude in meters!\n");
|
||||
fprintf(stderr, " -s set speed in knots\n");
|
||||
fprintf(stderr, " -m print mass distribution table: id, x, y, z, mass \n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#define PKGLIBDIR "@FG_DATA_DIR@"
|
||||
#define FGSRCDIR "@PROJECT_SOURCE_DIR@"
|
||||
#define FGBUILDDIR "@PROJECT_BINARY_DIR@"
|
||||
#define WEB_BROWSER "@WEB_BROWSER@"
|
||||
|
||||
// Ensure FG_HAVE_xxx always have a value
|
||||
|
|
|
@ -184,3 +184,7 @@ if(ENABLE_METAR)
|
|||
|
||||
install(TARGETS metar RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
||||
if (ENABLE_TESTS)
|
||||
flightgear_test(posinit test_posinit.cxx)
|
||||
endif()
|
||||
|
|
|
@ -231,7 +231,7 @@ do_tile_cache_reload (const SGPropertyNode * arg)
|
|||
master_freeze->setBoolValue(true);
|
||||
}
|
||||
|
||||
globals->get_subsystem("tile-manager")->reinit();
|
||||
globals->get_subsystem("scenery")->reinit();
|
||||
|
||||
if ( !freeze ) {
|
||||
master_freeze->setBoolValue(false);
|
||||
|
|
|
@ -95,7 +95,7 @@ using namespace flightgear;
|
|||
|
||||
#define NEW_DEFAULT_MODEL_HZ 120
|
||||
|
||||
static flightgear::Options* shared_instance = NULL;
|
||||
static flightgear::Options* shared_instance = nullptr;
|
||||
|
||||
static double
|
||||
atof( const string& str )
|
||||
|
@ -1979,6 +1979,14 @@ Options* Options::sharedInstance()
|
|||
return shared_instance;
|
||||
}
|
||||
|
||||
void Options::reset()
|
||||
{
|
||||
if (shared_instance != nullptr) {
|
||||
delete shared_instance;
|
||||
shared_instance = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Options::Options() :
|
||||
p(new OptionsPrivate())
|
||||
{
|
||||
|
@ -2034,7 +2042,9 @@ void Options::init(int argc, char **argv, const SGPath& appDataPath)
|
|||
}
|
||||
|
||||
if (!p->shouldLoadDefaultConfig) {
|
||||
#if !defined(FG_TESTLIB)
|
||||
setupRoot(argc, argv);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,13 @@ private:
|
|||
public:
|
||||
static Options* sharedInstance();
|
||||
|
||||
/**
|
||||
* Delete the entire options object. Use with a degree of care, no code
|
||||
* should ever be caching the Options pointer but this has not actually been
|
||||
* checked across the whole code :)
|
||||
*/
|
||||
static void reset();
|
||||
|
||||
~Options();
|
||||
|
||||
/**
|
||||
|
|
|
@ -453,6 +453,8 @@ static bool fgSetPosFromCarrier( const string& carrier, const string& posid ) {
|
|||
SGGeod geodPos;
|
||||
double heading;
|
||||
SGVec3d uvw;
|
||||
|
||||
#ifndef FG_TESTLIB
|
||||
if (FGAIManager::getStartPosition(carrier, posid, geodPos, heading, uvw)) {
|
||||
double lon = geodPos.getLongitudeDeg();
|
||||
double lat = geodPos.getLatitudeDeg();
|
||||
|
@ -482,7 +484,9 @@ static bool fgSetPosFromCarrier( const string& carrier, const string& posid ) {
|
|||
fgSetBool("/sim/presets/onground", true);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Failed to locate aircraft carrier = "
|
||||
<< carrier );
|
||||
return false;
|
||||
|
|
119
src/Main/test_posinit.cxx
Normal file
119
src/Main/test_posinit.cxx
Normal file
|
@ -0,0 +1,119 @@
|
|||
#include "config.h"
|
||||
|
||||
#include "unitTestHelpers.hxx"
|
||||
|
||||
#include <simgear/misc/test_macros.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
|
||||
#include "Main/positioninit.hxx"
|
||||
#include "Main/options.hxx"
|
||||
#include "Main/globals.hxx"
|
||||
#include "Main/fg_props.hxx"
|
||||
|
||||
#include "Airports/airport.hxx"
|
||||
|
||||
using namespace flightgear;
|
||||
|
||||
void testDefaultStartup()
|
||||
{
|
||||
fgtest::initTestGlobals("posinit");
|
||||
Options::reset();
|
||||
|
||||
fgLoadProps("defaults.xml", globals->get_props());
|
||||
|
||||
{
|
||||
Options* opts = Options::sharedInstance();
|
||||
opts->setShouldLoadDefaultConfig(false);
|
||||
|
||||
const char* args[] = {"dummypath"};
|
||||
opts->init(1, (char**) args, SGPath());
|
||||
opts->processOptions();
|
||||
}
|
||||
|
||||
initPosition();
|
||||
|
||||
// verify we got the location specified in location-preset.xml
|
||||
// this unfortunately means manually parsing that file, oh well
|
||||
|
||||
{
|
||||
SGPath presets = fgtest::fgdataPath() / "location-presets.xml";
|
||||
SG_VERIFY(presets.exists());
|
||||
SGPropertyNode_ptr props(new SGPropertyNode);
|
||||
readProperties(presets, props);
|
||||
|
||||
std::string icao = props->getStringValue("/sim/presets/airport-id");
|
||||
SG_CHECK_EQUAL(globals->get_props()->getStringValue("/sim/airport/closest-airport-id"), icao);
|
||||
|
||||
SGGeod pos = globals->get_aircraft_position();
|
||||
|
||||
FGAirportRef defaultAirport = FGAirport::getByIdent(icao);
|
||||
|
||||
double dist = SGGeodesy::distanceM(pos, defaultAirport->geod());
|
||||
SG_CHECK_LT(dist, 10000);
|
||||
}
|
||||
fgtest::shutdownTestGlobals();
|
||||
|
||||
}
|
||||
|
||||
void testAirportOnlyStartup()
|
||||
{
|
||||
fgtest::initTestGlobals("posinit");
|
||||
Options::reset();
|
||||
fgLoadProps("defaults.xml", globals->get_props());
|
||||
|
||||
{
|
||||
Options* opts = Options::sharedInstance();
|
||||
opts->setShouldLoadDefaultConfig(false);
|
||||
|
||||
const char* args[] = {"dummypath", "--airport=EDDF"};
|
||||
opts->init(2, (char**) args, SGPath());
|
||||
opts->processOptions();
|
||||
}
|
||||
|
||||
SG_VERIFY(fgGetBool("/sim/presets/airport-requested"));
|
||||
initPosition();
|
||||
|
||||
SG_CHECK_EQUAL(globals->get_props()->getStringValue("/sim/airport/closest-airport-id"), std::string("EDDF"));
|
||||
double dist = SGGeodesy::distanceM(globals->get_aircraft_position(),
|
||||
FGAirport::getByIdent("EDDF")->geod());
|
||||
SG_CHECK_LT(dist, 10000);
|
||||
fgtest::shutdownTestGlobals();
|
||||
|
||||
}
|
||||
|
||||
void testAirportAndMetarStartup()
|
||||
{
|
||||
fgtest::initTestGlobals("posinit");
|
||||
|
||||
Options::reset();
|
||||
fgLoadProps("defaults.xml", globals->get_props());
|
||||
|
||||
{
|
||||
Options* opts = Options::sharedInstance();
|
||||
opts->setShouldLoadDefaultConfig(false);
|
||||
const char* args[] = {"dummypath", "--airport=LOWI", "--metar=XXXX 271320Z 08007KT 030V130 CAVOK 17/02 Q1020 NOSIG"};
|
||||
opts->init(3, (char**) args, SGPath());
|
||||
opts->processOptions();
|
||||
}
|
||||
|
||||
initPosition();
|
||||
|
||||
SG_CHECK_EQUAL(globals->get_props()->getStringValue("/sim/airport/closest-airport-id"), std::string("LOWI"));
|
||||
double dist = SGGeodesy::distanceM(globals->get_aircraft_position(),
|
||||
FGAirport::getByIdent("LOWI")->geod());
|
||||
SG_CHECK_LT(dist, 10000);
|
||||
///sim/atc/runway
|
||||
SG_CHECK_EQUAL(globals->get_props()->getStringValue("sim/atc/runway"), std::string("26"));
|
||||
|
||||
fgtest::shutdownTestGlobals();
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
testDefaultStartup();
|
||||
testAirportOnlyStartup();
|
||||
testAirportAndMetarStartup();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
|
@ -6,6 +6,7 @@ set(sources
|
|||
Main/globals.cxx
|
||||
Main/locale.cxx
|
||||
Main/util.cxx
|
||||
Main/positioninit.cxx
|
||||
Aircraft/controls.cxx
|
||||
Aircraft/FlightHistory.cxx
|
||||
Aircraft/flightrecorder.cxx
|
||||
|
@ -90,16 +91,21 @@ set_target_properties (fgtestlib
|
|||
COMPILE_DEFINITIONS "FG_TESTLIB"
|
||||
)
|
||||
|
||||
target_link_libraries(fgtestlib SimGearCore ${PLATFORM_LIBS})
|
||||
if(FG_HAVE_GPERFTOOLS)
|
||||
target_include_directories(fgtestlib PRIVATE ${GooglePerfTools_INCLUDE_DIR})
|
||||
target_link_libraries(fgtestlib ${GooglePerfTools_LIBRARIES})
|
||||
endif()
|
||||
target_link_libraries(fgtestlib SimGearCore ${PLATFORM_LIBS} ${SQLITE3_LIBRARY})
|
||||
|
||||
add_executable(fgtest fgTestDriver.cxx)
|
||||
target_link_libraries(fgtest fgtestlib)
|
||||
|
||||
# repeat this section for each unit-test executable
|
||||
add_executable(testnavs test_navaids2.cxx)
|
||||
target_link_libraries(testnavs fgtestlib fgsqlite3)
|
||||
add_test(testnavs ${EXECUTABLE_OUTPUT_PATH}/testnavs)
|
||||
macro(flightgear_test name sources)
|
||||
add_executable(${name} ${sources})
|
||||
target_include_directories(${name} PRIVATE ${CMAKE_SOURCE_DIR}/tests)
|
||||
target_link_libraries(${name} fgtestlib)
|
||||
add_test(${name} ${EXECUTABLE_OUTPUT_PATH}/${name})
|
||||
endmacro()
|
||||
|
||||
add_executable(testflightplan test_flightplan.cxx)
|
||||
target_link_libraries(testflightplan fgtestlib fgsqlite3)
|
||||
add_test(testflightplan ${EXECUTABLE_OUTPUT_PATH}/testflightplan)
|
||||
flightgear_test(test_navs test_navaids2.cxx)
|
||||
flightgear_test(test_flightplan test_flightplan.cxx)
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "unitTestHelpers.hxx"
|
||||
|
||||
#include <Main/globals.hxx>
|
||||
#include <Main/options.hxx>
|
||||
|
||||
#include <Navaids/NavDataCache.hxx>
|
||||
#include <Time/TimeManager.hxx>
|
||||
|
||||
|
@ -13,6 +15,8 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
static SGPath tests_fgdata;
|
||||
|
||||
namespace fgtest
|
||||
{
|
||||
|
||||
|
@ -21,6 +25,12 @@ namespace fgtest
|
|||
return (path / "defaults.xml").exists();
|
||||
}
|
||||
|
||||
|
||||
SGPath fgdataPath()
|
||||
{
|
||||
return tests_fgdata;
|
||||
}
|
||||
|
||||
void initTestGlobals(const std::string& testName)
|
||||
{
|
||||
sglog().setLogLevels( SG_ALL, SG_WARN );
|
||||
|
@ -58,15 +68,18 @@ namespace fgtest
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
tests_fgdata = globals->get_fg_root();
|
||||
|
||||
// current dir
|
||||
SGPath homePath = simgear::Dir::current().path() / "test_home";
|
||||
SGPath homePath = SGPath::fromUtf8(FGBUILDDIR) / "test_home";
|
||||
if (!homePath.exists()) {
|
||||
(homePath / "dummyFile").create_dir(0755);
|
||||
}
|
||||
|
||||
globals->set_fg_home(homePath);
|
||||
|
||||
fgSetDefaults();
|
||||
|
||||
flightgear::NavDataCache* cache = flightgear::NavDataCache::createInstance();
|
||||
if (cache->isRebuildRequired()) {
|
||||
std::cerr << "Navcache rebuild for testing" << std::flush;
|
||||
|
|
|
@ -10,6 +10,8 @@ namespace fgtest
|
|||
void initTestGlobals(const std::string& testName);
|
||||
|
||||
void shutdownTestGlobals();
|
||||
|
||||
SGPath fgdataPath();
|
||||
}
|
||||
|
||||
#endif // of FG_TEST_HELPERS_HXX
|
||||
|
|
Loading…
Reference in a new issue