From 99a50508a71f0966fea5b0e34d9ad25a97084717 Mon Sep 17 00:00:00 2001 From: Edward d'Auvergne Date: Sun, 10 Jun 2018 15:43:20 +0200 Subject: [PATCH] TestSuite: Spun out the NavDataCache initialisation code. Not all tests will require the NavDataCache, so it is no longer set up with the dummy globals data structure. --- test_suite/FGTestApi/CMakeLists.txt | 2 + test_suite/FGTestApi/NavDataCache.cxx | 25 +++++++++ test_suite/FGTestApi/NavDataCache.hxx | 15 +++++ test_suite/FGTestApi/globals.cxx | 55 ++++++------------- test_suite/FGTestApi/globals.hxx | 9 +-- test_suite/unit_tests/Main/test_posinit.cxx | 32 +++++------ test_suite/unit_tests/Main/test_posinit.hxx | 4 +- .../unit_tests/Navaids/test_flightplan.cxx | 2 + .../unit_tests/Navaids/test_navaids2.cxx | 2 + 9 files changed, 81 insertions(+), 65 deletions(-) create mode 100644 test_suite/FGTestApi/NavDataCache.cxx create mode 100644 test_suite/FGTestApi/NavDataCache.hxx diff --git a/test_suite/FGTestApi/CMakeLists.txt b/test_suite/FGTestApi/CMakeLists.txt index a68aeb00c..045ba7dde 100644 --- a/test_suite/FGTestApi/CMakeLists.txt +++ b/test_suite/FGTestApi/CMakeLists.txt @@ -1,6 +1,7 @@ set(TESTSUITE_SOURCES ${TESTSUITE_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/globals.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/NavDataCache.cxx ${CMAKE_CURRENT_SOURCE_DIR}/PrivateAccessorFDM.cxx ${CMAKE_CURRENT_SOURCE_DIR}/scene_graph.cxx PARENT_SCOPE @@ -10,6 +11,7 @@ set(TESTSUITE_SOURCES set(TESTSUITE_HEADERS ${TESTSUITE_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/globals.hxx + ${CMAKE_CURRENT_SOURCE_DIR}/NavDataCache.hxx ${CMAKE_CURRENT_SOURCE_DIR}/PrivateAccessorFDM.hxx ${CMAKE_CURRENT_SOURCE_DIR}/scene_graph.hxx PARENT_SCOPE diff --git a/test_suite/FGTestApi/NavDataCache.cxx b/test_suite/FGTestApi/NavDataCache.cxx new file mode 100644 index 000000000..d29161c64 --- /dev/null +++ b/test_suite/FGTestApi/NavDataCache.cxx @@ -0,0 +1,25 @@ +#include "NavDataCache.hxx" + +#include + + +namespace FGTestApi { + +namespace setUp { + +void initNavDataCache() +{ + flightgear::NavDataCache* cache = flightgear::NavDataCache::createInstance(); + if (cache->isRebuildRequired()) { + std::cerr << "Navcache rebuild for testing" << std::flush; + + while (cache->rebuild() != flightgear::NavDataCache::REBUILD_DONE) { + SGTimeStamp::sleepForMSec(1000); + std::cerr << "." << std::flush; + } + } +} + +} // End of namespace setUp. + +} // End of namespace FGTestApi. diff --git a/test_suite/FGTestApi/NavDataCache.hxx b/test_suite/FGTestApi/NavDataCache.hxx new file mode 100644 index 000000000..c7a819281 --- /dev/null +++ b/test_suite/FGTestApi/NavDataCache.hxx @@ -0,0 +1,15 @@ +#ifndef FG_NAV_DATA_CACHE_TEST_HELPERS_HXX +#define FG_NAV_DATA_CACHE_TEST_HELPERS_HXX + +namespace FGTestApi { + +namespace setUp { + + +void initNavDataCache(); + +} // End of namespace setUp. + +} // End of namespace FGTestApi. + +#endif // of FG_NAV_DATA_CACHE_TEST_HELPERS_HXX diff --git a/test_suite/FGTestApi/globals.cxx b/test_suite/FGTestApi/globals.cxx index d857ed706..42771a793 100644 --- a/test_suite/FGTestApi/globals.cxx +++ b/test_suite/FGTestApi/globals.cxx @@ -1,4 +1,3 @@ - #include "config.h" #include "test_suite/dataStore.hxx" @@ -12,28 +11,17 @@ #include
#include
-#include #include