1
0
Fork 0

TestSuite: FGData existence and version validation check prior to running tests.

This mimics the validation normally performed by Options::setupRoot().
This commit is contained in:
Edward d'Auvergne 2019-11-08 10:16:33 +01:00
parent 4105b70f74
commit 85c889f13d
3 changed files with 36 additions and 0 deletions

View file

@ -20,6 +20,11 @@
#include <iostream>
#include <simgear/misc/strutils.hxx>
#include <Main/fg_init.hxx>
#include <Include/version.h>
#include "config.h"
#include "dataStore.hxx"
@ -101,3 +106,30 @@ SGPath DataStore::getFGRoot()
{
return _fgRootPath;
}
// Perform a version validation of FGData, returning zero if ok.
int DataStore::validateFGRoot()
{
// The FGData version.
SGPath root = getFGRoot();
std::string base_version = fgBasePackageVersion(root);
if (base_version.empty()) {
std::cout << "Base package not found." << std::endl;
std::cout << "Required FGData files not found, please check your configuration." << std::endl;
std::cout << "Looking for FGData files in '" << root.str() << "'." << std::endl;
std::cout.flush();
return 1;
}
// Comparison of only the major and minor version numbers.
const int versionComp = simgear::strutils::compare_versions(FLIGHTGEAR_VERSION, base_version, 2);
if (versionComp != 0) {
std::cout << "Base package version mismatch." << std::endl;
std::cout << "Version check failed, please check your configuration." << std::endl;
std::cout << "The FGData version '" << base_version << "' in '" << root.str();
std::cout << "does not match the FlightGear version '" << std::string(FLIGHTGEAR_VERSION);
std::cout << "'." << std::endl;
std::cout.flush();
}
return versionComp;
}

View file

@ -41,6 +41,7 @@ public:
// FGData path functions.
int findFGRoot(const std::string& fgRootCmdLineOpt, bool debug = false);
SGPath getFGRoot();
int validateFGRoot();
private:
DataStore() = default;

View file

@ -403,6 +403,9 @@ int main(int argc, char **argv)
if (data.findFGRoot(fgRoot, debug) != 0) {
return 1;
}
if (data.validateFGRoot() != 0) {
return 1;
}
// Set up logging.
sglog().setDeveloperMode(true);