TestSuite: Initial support for a FlightGear test suite based on CppUnit.
This includes the basic CMake infrastructure for building and executing the test suite. Four test categories have been added - unit, system/functional, GUI, and simgear unit tests. The test suite is run by typing 'make test_suite'. All of the fgfs sources are included in the new run_test_suite executable, excluding the bootstrap routine and its main() function. The test suite currently consists of a single dummy unit test for the NasalSys subsystem, and a single demonstration simgear/props unit test.
This commit is contained in:
parent
01f840487d
commit
8b438cb97e
19 changed files with 771 additions and 0 deletions
|
@ -594,3 +594,13 @@ CONFIGURE_FILE(
|
||||||
IMMEDIATE @ONLY)
|
IMMEDIATE @ONLY)
|
||||||
ADD_CUSTOM_TARGET(uninstall
|
ADD_CUSTOM_TARGET(uninstall
|
||||||
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||||
|
|
||||||
|
|
||||||
|
# The test suite.
|
||||||
|
find_package(CppUnit)
|
||||||
|
if (CPPUNIT_FOUND)
|
||||||
|
message(STATUS "CppUnit found.")
|
||||||
|
add_subdirectory(test_suite EXCLUDE_FROM_ALL)
|
||||||
|
else()
|
||||||
|
message(STATUS "CppUnit not found.")
|
||||||
|
endif()
|
||||||
|
|
42
CMakeModules/FindCppUnit.cmake
Normal file
42
CMakeModules/FindCppUnit.cmake
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
# Locate CppUnit.
|
||||||
|
#
|
||||||
|
# This module defines
|
||||||
|
# CPPUNIT_FOUND
|
||||||
|
# CPPUNIT_LIBRARIES
|
||||||
|
# CPPUNIT_INCLUDE_DIR
|
||||||
|
|
||||||
|
# Find CppUnit.
|
||||||
|
if (NOT CPPUNIT_LIBRARIES AND NOT CPPUNIT_INCLUDE_DIR)
|
||||||
|
# Find the headers.
|
||||||
|
find_path(CPPUNIT_INCLUDE_DIR
|
||||||
|
NAMES
|
||||||
|
cppunit/Test.h
|
||||||
|
PATHS
|
||||||
|
/usr/include
|
||||||
|
/usr/local/include
|
||||||
|
/opt/include
|
||||||
|
/opt/local/include
|
||||||
|
/sw/include
|
||||||
|
)
|
||||||
|
|
||||||
|
# Find the library.
|
||||||
|
find_library(CPPUNIT_LIBRARIES
|
||||||
|
NAMES
|
||||||
|
cppunit
|
||||||
|
PATHS
|
||||||
|
/usr/lib
|
||||||
|
/usr/local/lib
|
||||||
|
/opt/lib
|
||||||
|
/opt/local/lib
|
||||||
|
/sw/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
# Pre-set or found.
|
||||||
|
if (CPPUNIT_LIBRARIES AND CPPUNIT_INCLUDE_DIR)
|
||||||
|
set(CPPUNIT_FOUND TRUE)
|
||||||
|
message(STATUS "CppUnit library found: ${CPPUNIT_LIBRARIES}")
|
||||||
|
message(STATUS "CppUnit include directory found: ${CPPUNIT_INCLUDE_DIR}")
|
||||||
|
endif ()
|
223
test_suite/CMakeLists.txt
Normal file
223
test_suite/CMakeLists.txt
Normal file
|
@ -0,0 +1,223 @@
|
||||||
|
# Add each test suite category.
|
||||||
|
foreach(test_category
|
||||||
|
gui_tests
|
||||||
|
simgear_tests
|
||||||
|
system_tests
|
||||||
|
unit_tests
|
||||||
|
)
|
||||||
|
add_subdirectory(${test_category})
|
||||||
|
endforeach(test_category)
|
||||||
|
|
||||||
|
# Add all test suite sources and headers.
|
||||||
|
set(TESTSUITE_SOURCES
|
||||||
|
${TESTSUITE_SOURCES}
|
||||||
|
bootstrap.cxx
|
||||||
|
fgTestRunner.cxx
|
||||||
|
testSuite.cxx
|
||||||
|
)
|
||||||
|
set(TESTSUITE_HEADERS
|
||||||
|
${TESTSUITE_HEADERS}
|
||||||
|
fgTestRunner.hxx
|
||||||
|
)
|
||||||
|
|
||||||
|
# The test suite output directory.
|
||||||
|
set(TESTSUITE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# From here on, this is a modified copy of src/Main/CMakeLists.txt. This is
|
||||||
|
# designed to have a minimal diff so that this can be updated together with the
|
||||||
|
# main CMakeLists.txt file.
|
||||||
|
|
||||||
|
# Set up the Main FG file sources and headers (excluding bootstrap.cxx and its main() function).
|
||||||
|
if(MSVC)
|
||||||
|
set(RESOURCE_FILE ${PROJECT_SOURCE_DIR}/src/Main/flightgear.rc)
|
||||||
|
endif(MSVC)
|
||||||
|
|
||||||
|
set(MAIN_SOURCES
|
||||||
|
#${PROJECT_SOURCE_DIR}/src/Main/bootstrap.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/fg_commands.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/fg_init.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/fg_io.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/fg_os_common.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/fg_scene_commands.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/fg_props.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/FGInterpolator.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/globals.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/locale.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/logger.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/main.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/options.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/positioninit.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/screensaver_control.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/subsystemFactory.cxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/util.cxx
|
||||||
|
${RESOURCE_FILE}
|
||||||
|
${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.cxx
|
||||||
|
)
|
||||||
|
|
||||||
|
set(MAIN_HEADERS
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/AircraftDirVisitorBase.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/fg_commands.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/fg_init.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/fg_io.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/fg_props.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/FGInterpolator.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/globals.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/locale.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/logger.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/main.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/options.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/positioninit.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/screensaver_control.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/subsystemFactory.hxx
|
||||||
|
${PROJECT_SOURCE_DIR}/src/Main/util.hxx
|
||||||
|
${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.hxx
|
||||||
|
)
|
||||||
|
|
||||||
|
# On Windows, make sure fgrcc can be run (it needs third-party libraries)
|
||||||
|
if(MSVC)
|
||||||
|
if(MSVC_3RDPARTY_ROOT AND MSVC_3RDPARTY_DIR)
|
||||||
|
set(CMAKE_MSVCIDE_RUN_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/bin)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Either MSVC_3RDPARTY_ROOT or MSVC_3RDPARTY_DIR is empty or unset")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.cxx
|
||||||
|
${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.hxx
|
||||||
|
COMMAND fgrcc --root=${CMAKE_SOURCE_DIR} --output-cpp-file=${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.cxx --init-func-name=initFlightGearEmbeddedResources --output-header-file=${CMAKE_BINARY_DIR}/src/EmbeddedResources/FlightGear-resources.hxx --output-header-identifier=_FG_FLIGHTGEAR_EMBEDDED_RESOURCES ${CMAKE_SOURCE_DIR}/src/EmbeddedResources/FlightGear-resources.xml
|
||||||
|
DEPENDS
|
||||||
|
fgrcc ${CMAKE_SOURCE_DIR}/src/EmbeddedResources/FlightGear-resources.xml
|
||||||
|
)
|
||||||
|
|
||||||
|
# Get the FG sources and headers to be built into the test suite.
|
||||||
|
get_property(FG_SOURCES GLOBAL PROPERTY FG_SOURCES)
|
||||||
|
get_property(FG_HEADERS GLOBAL PROPERTY FG_HEADERS)
|
||||||
|
|
||||||
|
link_directories ( ${Boost_LIBRARY_DIRS} )
|
||||||
|
|
||||||
|
# Set up the source groups.
|
||||||
|
get_property(FG_GROUPS_C GLOBAL PROPERTY FG_GROUPS_C)
|
||||||
|
string(REPLACE "@" ";" groups ${FG_GROUPS_C} )
|
||||||
|
foreach(g ${groups})
|
||||||
|
string(REPLACE "#" ";" g2 ${g})
|
||||||
|
list(GET g2 0 name)
|
||||||
|
list(REMOVE_AT g2 0)
|
||||||
|
source_group("${name}\\Sources" FILES ${g2})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Set up the header groups.
|
||||||
|
get_property(FG_GROUPS_H GLOBAL PROPERTY FG_GROUPS_H)
|
||||||
|
string(REPLACE "@" ";" groups ${FG_GROUPS_H} )
|
||||||
|
foreach(g ${groups})
|
||||||
|
string(REPLACE "#" ";" g2 ${g})
|
||||||
|
list(GET g2 0 name)
|
||||||
|
list(REMOVE_AT g2 0)
|
||||||
|
source_group("${name}\\Headers" FILES ${g2})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
source_group("Main\\Headers" FILES ${HEADERS})
|
||||||
|
source_group("Main\\Sources" FILES ${SOURCES})
|
||||||
|
|
||||||
|
# Set up the separate executable for running the test suite.
|
||||||
|
add_executable(run_test_suite
|
||||||
|
${FG_SOURCES}
|
||||||
|
${FG_HEADERS}
|
||||||
|
${MAIN_SOURCES}
|
||||||
|
${MAIN_HEADERS}
|
||||||
|
${TESTSUITE_SOURCES}
|
||||||
|
${TESTSUITE_HEADERS}
|
||||||
|
)
|
||||||
|
set_target_properties(run_test_suite
|
||||||
|
PROPERTIES
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY "${TESTSUITE_OUTPUT_DIR}"
|
||||||
|
)
|
||||||
|
add_custom_target(test_suite "${TESTSUITE_OUTPUT_DIR}/run_test_suite"
|
||||||
|
DEPENDS run_test_suite
|
||||||
|
COMMENT "Running the full FlightGear test-suite.")
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_property(FG_LIBS GLOBAL PROPERTY FG_LIBS)
|
||||||
|
#message(STATUS "fg libs ${FG_LIBS}")
|
||||||
|
#message(STATUS "OSG libs ${OPENSCENEGRAPH_LIBRARIES}")
|
||||||
|
#message(STATUS "SG libs ${SIMGEAR_LIBRARIES}")
|
||||||
|
|
||||||
|
if(RTI_FOUND)
|
||||||
|
set(HLA_LIBRARIES ${RTI_LIBRARIES})
|
||||||
|
else()
|
||||||
|
set(HLA_LIBRARIES "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(GDAL_FOUND)
|
||||||
|
set(GDAL_LIBRARIES ${GDAL_LIBRARY})
|
||||||
|
else()
|
||||||
|
set(GDAL_LIBRARIES "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_JSBSIM)
|
||||||
|
# FIXME - remove once JSBSim doesn't expose private headers
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/src/FDM/JSBSim)
|
||||||
|
|
||||||
|
target_link_libraries(run_test_suite JSBSim)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_IAX)
|
||||||
|
target_link_libraries(run_test_suite iaxclient_lib ${OPENAL_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_DBUS)
|
||||||
|
target_link_libraries(run_test_suite ${DBUS_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FG_HAVE_GPERFTOOLS)
|
||||||
|
include_directories(${GooglePerfTools_INCLUDE_DIR})
|
||||||
|
target_link_libraries(run_test_suite ${GooglePerfTools_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CRASHRPT_FOUND)
|
||||||
|
target_link_libraries(run_test_suite ${CRASHRPT_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(X11_FOUND)
|
||||||
|
target_link_libraries(run_test_suite ${X11_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(run_test_suite
|
||||||
|
SimGearCore
|
||||||
|
SimGearScene
|
||||||
|
${CPPUNIT_LIBRARIES}
|
||||||
|
${EVENT_INPUT_LIBRARIES}
|
||||||
|
${GDAL_LIBRARIES}
|
||||||
|
${HLA_LIBRARIES}
|
||||||
|
${OPENGL_LIBRARIES}
|
||||||
|
${OPENSCENEGRAPH_LIBRARIES}
|
||||||
|
${PLATFORM_LIBS}
|
||||||
|
${PLIB_LIBRARIES}
|
||||||
|
${SQLITE3_LIBRARY}
|
||||||
|
${SIMGEAR_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if(ENABLE_FLITE)
|
||||||
|
if(SYSTEM_HTS_ENGINE)
|
||||||
|
target_link_libraries(run_test_suite flite_hts ${HTS_ENGINE_LIBRARIES})
|
||||||
|
else()
|
||||||
|
target_link_libraries(run_test_suite flite_hts hts_engine)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(Qt5Core_FOUND)
|
||||||
|
target_link_libraries(run_test_suite Qt5::Core Qt5::Widgets fglauncher fgqmlui)
|
||||||
|
set_property(TARGET run_test_suite PROPERTY AUTOMOC ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_AEONWAVE)
|
||||||
|
target_link_libraries(run_test_suite ${AAX_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||||
|
target_link_libraries(run_test_suite execinfo)
|
||||||
|
endif()
|
29
test_suite/bootstrap.cxx
Normal file
29
test_suite/bootstrap.cxx
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// bootstrap.cxx -- replacement bootstrap routines for the test suite.
|
||||||
|
//
|
||||||
|
// Written by Edward d'Auvergne, started May 2017.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 Edward d'Auvergne
|
||||||
|
//
|
||||||
|
// 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, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
bool global_crashRptEnabled = false;
|
||||||
|
|
||||||
|
int _bootstrap_OSInit;
|
||||||
|
std::string hostname;
|
46
test_suite/fgTestRunner.cxx
Normal file
46
test_suite/fgTestRunner.cxx
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016-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 <cppunit/CompilerOutputter.h>
|
||||||
|
#include <cppunit/TestResult.h>
|
||||||
|
#include <cppunit/TestResultCollector.h>
|
||||||
|
#include <cppunit/TextTestRunner.h>
|
||||||
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||||
|
|
||||||
|
|
||||||
|
// Execute all test suites for the given test category.
|
||||||
|
int testRunner(const std::string& title)
|
||||||
|
{
|
||||||
|
// Declarations.
|
||||||
|
CppUnit::TextTestRunner runner;
|
||||||
|
|
||||||
|
// Get all tests.
|
||||||
|
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(title).makeTest());
|
||||||
|
|
||||||
|
// Set the test suite output IO stream.
|
||||||
|
runner.setOutputter(CppUnit::CompilerOutputter::defaultOutputter(&runner.result(), std::cerr));
|
||||||
|
|
||||||
|
// Execute the tests.
|
||||||
|
runner.run("", false, true, false);
|
||||||
|
|
||||||
|
// Return the status of the tests.
|
||||||
|
CppUnit::TestResultCollector &status = runner.result();
|
||||||
|
return status.testFailures();
|
||||||
|
}
|
29
test_suite/fgTestRunner.hxx
Normal file
29
test_suite/fgTestRunner.hxx
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016-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_TEST_RUNNER_HXX
|
||||||
|
#define _FG_TEST_RUNNER_HXX
|
||||||
|
|
||||||
|
|
||||||
|
// Execute all test suites for the given test category.
|
||||||
|
int testRunner(const std::string&);
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _FG_TEST_RUNNER_HXX
|
19
test_suite/gui_tests/CMakeLists.txt
Normal file
19
test_suite/gui_tests/CMakeLists.txt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Add each GUI test category.
|
||||||
|
foreach( gui_test_category
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory(${gui_test_category})
|
||||||
|
|
||||||
|
endforeach( gui_test_category )
|
||||||
|
|
||||||
|
|
||||||
|
set(TESTSUITE_SOURCES
|
||||||
|
${TESTSUITE_SOURCES}
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
set(TESTSUITE_HEADERS
|
||||||
|
${TESTSUITE_HEADERS}
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
20
test_suite/simgear_tests/CMakeLists.txt
Normal file
20
test_suite/simgear_tests/CMakeLists.txt
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Add each simgear test category.
|
||||||
|
foreach( simgear_test_category
|
||||||
|
props
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory(${simgear_test_category})
|
||||||
|
|
||||||
|
endforeach( simgear_test_category )
|
||||||
|
|
||||||
|
|
||||||
|
set(TESTSUITE_SOURCES
|
||||||
|
${TESTSUITE_SOURCES}
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
set(TESTSUITE_HEADERS
|
||||||
|
${TESTSUITE_HEADERS}
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
12
test_suite/simgear_tests/props/CMakeLists.txt
Normal file
12
test_suite/simgear_tests/props/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
set(TESTSUITE_SOURCES
|
||||||
|
${TESTSUITE_SOURCES}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/TestSuite.cxx
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/test_props.cxx
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
|
|
||||||
|
set(TESTSUITE_HEADERS
|
||||||
|
${TESTSUITE_HEADERS}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/test_props.hxx
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
24
test_suite/simgear_tests/props/TestSuite.cxx
Normal file
24
test_suite/simgear_tests/props/TestSuite.cxx
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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 "test_props.hxx"
|
||||||
|
|
||||||
|
|
||||||
|
// Set up the tests.
|
||||||
|
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(SimgearPropsTests, "Simgear unit tests");
|
52
test_suite/simgear_tests/props/test_props.cxx
Normal file
52
test_suite/simgear_tests/props/test_props.cxx
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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 "test_props.hxx"
|
||||||
|
|
||||||
|
|
||||||
|
// Set up function for each test.
|
||||||
|
void SimgearPropsTests::setUp()
|
||||||
|
{
|
||||||
|
// Create a property tree.
|
||||||
|
tree = new SGPropertyNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Clean up after each test.
|
||||||
|
void SimgearPropsTests::tearDown()
|
||||||
|
{
|
||||||
|
// Delete the tree (avoiding the memory leak).
|
||||||
|
delete tree;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Test property aliasing, to catch possible memory leaks.
|
||||||
|
void SimgearPropsTests::testAliasLeak()
|
||||||
|
{
|
||||||
|
// Declarations.
|
||||||
|
SGPropertyNode *alias;
|
||||||
|
|
||||||
|
// Create a new node.
|
||||||
|
tree->getNode("test-node", true);
|
||||||
|
|
||||||
|
// Aliased node.
|
||||||
|
alias = tree->getNode("test-alias", true);
|
||||||
|
alias->alias("test-node");
|
||||||
|
}
|
54
test_suite/simgear_tests/props/test_props.hxx
Normal file
54
test_suite/simgear_tests/props/test_props.hxx
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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_SIMGEAR_PROPS_SIMGEAR_UNIT_TESTS_HXX
|
||||||
|
#define _FG_SIMGEAR_PROPS_SIMGEAR_UNIT_TESTS_HXX
|
||||||
|
|
||||||
|
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
#include <cppunit/TestFixture.h>
|
||||||
|
|
||||||
|
#include <simgear/props/props.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
// The unit tests of the simgear property tree.
|
||||||
|
class SimgearPropsTests : public CppUnit::TestFixture
|
||||||
|
{
|
||||||
|
// Set up the test suite.
|
||||||
|
CPPUNIT_TEST_SUITE(SimgearPropsTests);
|
||||||
|
CPPUNIT_TEST(testAliasLeak);
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Set up function for each test.
|
||||||
|
void setUp();
|
||||||
|
|
||||||
|
// Clean up after each test.
|
||||||
|
void tearDown();
|
||||||
|
|
||||||
|
// The tests.
|
||||||
|
void testAliasLeak();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// A property tree.
|
||||||
|
SGPropertyNode *tree;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _FG_SIMGEAR_PROPS_SIMGEAR_UNIT_TESTS_HXX
|
19
test_suite/system_tests/CMakeLists.txt
Normal file
19
test_suite/system_tests/CMakeLists.txt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Add each system test category.
|
||||||
|
foreach( system_test_category
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory(${system_test_category})
|
||||||
|
|
||||||
|
endforeach( system_test_category )
|
||||||
|
|
||||||
|
|
||||||
|
set(TESTSUITE_SOURCES
|
||||||
|
${TESTSUITE_SOURCES}
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
set(TESTSUITE_HEADERS
|
||||||
|
${TESTSUITE_HEADERS}
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
48
test_suite/testSuite.cxx
Normal file
48
test_suite/testSuite.cxx
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016-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 <iostream>
|
||||||
|
|
||||||
|
#include "fgTestRunner.hxx"
|
||||||
|
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Declarations.
|
||||||
|
int status_gui, status_simgear, status_system, status_unit;
|
||||||
|
|
||||||
|
// Execute each of the test suite categories.
|
||||||
|
status_system = testRunner("System tests");
|
||||||
|
status_unit = testRunner("Unit tests");
|
||||||
|
status_gui = testRunner("GUI tests");
|
||||||
|
status_simgear = testRunner("Simgear unit tests");
|
||||||
|
|
||||||
|
// Failure.
|
||||||
|
if (status_system > 0)
|
||||||
|
return 1;
|
||||||
|
if (status_unit > 0)
|
||||||
|
return 1;
|
||||||
|
if (status_gui > 0)
|
||||||
|
return 1;
|
||||||
|
if (status_simgear > 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
// Success.
|
||||||
|
return 0;
|
||||||
|
}
|
20
test_suite/unit_tests/CMakeLists.txt
Normal file
20
test_suite/unit_tests/CMakeLists.txt
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Add each unit test category.
|
||||||
|
foreach( unit_test_category
|
||||||
|
Scripting
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory(${unit_test_category})
|
||||||
|
|
||||||
|
endforeach( unit_test_category )
|
||||||
|
|
||||||
|
|
||||||
|
set(TESTSUITE_SOURCES
|
||||||
|
${TESTSUITE_SOURCES}
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
set(TESTSUITE_HEADERS
|
||||||
|
${TESTSUITE_HEADERS}
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
12
test_suite/unit_tests/Scripting/CMakeLists.txt
Normal file
12
test_suite/unit_tests/Scripting/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
set(TESTSUITE_SOURCES
|
||||||
|
${TESTSUITE_SOURCES}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/TestSuite.cxx
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/testNasalSys.cxx
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
|
|
||||||
|
set(TESTSUITE_HEADERS
|
||||||
|
${TESTSUITE_HEADERS}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/testNasalSys.hxx
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
24
test_suite/unit_tests/Scripting/TestSuite.cxx
Normal file
24
test_suite/unit_tests/Scripting/TestSuite.cxx
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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 "testNasalSys.hxx"
|
||||||
|
|
||||||
|
|
||||||
|
// Set up the unit tests.
|
||||||
|
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(NasalSysTests, "Unit tests");
|
40
test_suite/unit_tests/Scripting/testNasalSys.cxx
Normal file
40
test_suite/unit_tests/Scripting/testNasalSys.cxx
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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 "testNasalSys.hxx"
|
||||||
|
|
||||||
|
|
||||||
|
// Set up function for each test.
|
||||||
|
void NasalSysTests::setUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Clean up after each test.
|
||||||
|
void NasalSysTests::tearDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Test test
|
||||||
|
void NasalSysTests::testDummy()
|
||||||
|
{
|
||||||
|
CPPUNIT_ASSERT(1 != 2);
|
||||||
|
}
|
48
test_suite/unit_tests/Scripting/testNasalSys.hxx
Normal file
48
test_suite/unit_tests/Scripting/testNasalSys.hxx
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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_NASALSYS_UNIT_TESTS_HXX
|
||||||
|
#define _FG_NASALSYS_UNIT_TESTS_HXX
|
||||||
|
|
||||||
|
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
#include <cppunit/TestFixture.h>
|
||||||
|
|
||||||
|
|
||||||
|
// The unit tests of the FGNasalSys subsystem.
|
||||||
|
class NasalSysTests : public CppUnit::TestFixture
|
||||||
|
{
|
||||||
|
// Set up the test suite.
|
||||||
|
CPPUNIT_TEST_SUITE(NasalSysTests);
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _FG_NASALSYS_UNIT_TESTS_HXX
|
Loading…
Reference in a new issue