1
0
Fork 0

TestSuite: Migration of the old GPS tests to the CppUnit framework.

As this code has significant bit-rot and requires a lot of work to compile and
run again, it is currently deactivated.

The test also writes to the files "/Users/jmt/Desktop/airways.kml" and
"/Users/jmt/Desktop/procedures.kml" and would need to be modified to write to a
temporary directory and the file contents reread and checked by the test.
This commit is contained in:
Edward d'Auvergne 2018-06-14 20:28:22 +02:00
parent fff923d2f4
commit 02c3c6dc97
6 changed files with 106 additions and 23 deletions

View file

@ -65,6 +65,7 @@ include(Dart)
# System test suites.
add_test(AeroMeshSystemTests ${TESTSUITE_OUTPUT_DIR}/run_test_suite --ctest -s AeroMeshTests)
#add_test(GPSSystemTests ${TESTSUITE_OUTPUT_DIR}/run_test_suite --ctest -s GPSTests)
# Unit test suites.
add_test(AddonManagementUnitTests ${TESTSUITE_OUTPUT_DIR}/run_test_suite --ctest -u AddonManagementTests)

View file

@ -1,6 +1,7 @@
# Add each system test category.
foreach( system_test_category
FDM
Instrumentation
)
add_subdirectory(${system_test_category})

View file

@ -0,0 +1,12 @@
set(TESTSUITE_SOURCES
${TESTSUITE_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/TestSuite.cxx
#${CMAKE_CURRENT_SOURCE_DIR}/testgps.cxx
PARENT_SCOPE
)
set(TESTSUITE_HEADERS
${TESTSUITE_HEADERS}
#${CMAKE_CURRENT_SOURCE_DIR}/testgps.hxx
PARENT_SCOPE
)

View file

@ -0,0 +1,24 @@
/*
* Copyright (C) 2018 Edward d'Auvergne
*
* 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 "testgps.hxx"
// Set up the unit tests.
//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(GPSTests, "System tests");

View file

@ -6,7 +6,6 @@
#include <simgear/structure/exception.hxx>
#include <Main/fg_init.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Instrumentation/gps.hxx>
@ -16,6 +15,12 @@
#include <Navaids/waypoint.hxx>
#include <Navaids/procedure.hxx>
#include "test_suite/helpers/globals.hxx"
#include "test_suite/helpers/NavDataCache.hxx"
#include "testgps.hxx"
using std::string;
using namespace flightgear;
@ -77,20 +82,22 @@ void createDummyRoute(FGRouteMgr* rm)
rmInput->setStringValue("OTR");
}
int main(int argc, char* argv[])
void GPSTests::setUp()
{
try{
globals = new FGGlobals;
fgInitFGRoot(argc, argv);
if (!fgInitConfig(argc, argv) ) {
SG_LOG( SG_GENERAL, SG_ALERT, "Config option parsing failed" );
exit(-1);
fgtest::initTestGlobals("GPS");
fgtest::initNavDataCache();
}
fgInitNav();
void GPSTests::tearDown()
{
fgtest::shutdownTestGlobals();
}
void GPSTests::testGPS()
{
fgSetDouble("/environment/magnetic-variation-deg", 0.0);
Airway::load();
@ -101,7 +108,7 @@ try{
SG_LOG(SG_GENERAL, SG_ALERT, "egph: cart location:" << egph->cart());
FGAirport::AirportFilter af;
FGPositioned::List l = FGPositioned::findClosestN(egph->geod(), 20, 2000.0, &af);
FGPositionedList l = FGPositioned::findClosestN(egph->geod(), 20, 2000.0, &af);
for (unsigned int i=0; i<l.size(); ++i) {
SG_LOG(SG_GENERAL, SG_ALERT, "\t" << l[i]->ident() << "/" << l[i]->name());
}
@ -341,14 +348,4 @@ try{
f << "</Document>\n"
"</kml>" << endl;
f.close();
return EXIT_SUCCESS;
} catch (sg_exception& ex) {
SG_LOG(SG_GENERAL, SG_ALERT, "exception:" << ex.getFormattedMessage());
}
return EXIT_FAILURE;
}

View file

@ -0,0 +1,48 @@
/*
* Copyright (C) 2018 Edward d'Auvergne
*
* 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/>.
*/
#ifndef _FG_GPS_SYSTEM_TESTS_HXX
#define _FG_GPS_SYSTEM_TESTS_HXX
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestFixture.h>
// The system tests.
class GPSTests : public CppUnit::TestFixture
{
// Set up the test suite.
CPPUNIT_TEST_SUITE(GPSTests);
CPPUNIT_TEST(testGPS);
CPPUNIT_TEST_SUITE_END();
public:
// Set up function for each test.
void setUp();
// Clean up after each test.
void tearDown();
// The tests.
void testGPS();
};
#endif // _FG_GPS_SYSTEM_TESTS_HXX