osrm-backend/test/CMakeLists.txt
Michael Krasnyk 0c6dee4bef Squashed 'third_party/libosmium/' changes from d5ecf4d..c1f34c4
c1f34c4 Release v2.11.0
d3b72e0 Updated change log.
2982b8d Update embedded Protozero to version 1.5.1.
cc1ab2a Add non-const WayNodeList::operator[].
3da372e Add missing example to examples/README.md.
30604ba Add OSMIUM_USE_SLOW_MERCATOR_PROJECTION define.
47a92e0 Clearer CheckOrder handler doc.
f11106d Formatting fixes.
a870737 Use faster implementation of web mercator projection.
041bb42 Test cleanups.
8933bc5 Cleanup *Map::get() functions.
6b989ca Document that (Multipolygon)Collectors only work with unique Ids.
8fb5bd2 Updated included Protozero to version 1.5.0.
76e153d Removed Makefile.
35d7ec9 Update copyright date.
a7f8126 Rename guard define to common scheme.
a923c69 Cleanup I/O tests.
d353993 Add Map::get_noexcept() method for all index maps.
94fa5ac Add const overload for mmap_vector_base::operator[].
3cf9184 Add default constructed "invalid" Coordinates.
358f170 Add Tile constructor from web mercator coordinates.
006aa4c Add index::RelationsMap(Stash|Index) classes.
9cc842e Updated catch to v1.5.9.
bd8c3b6 Use initializer_list trick instead of recursive template.
2c82a6f Merge pull request #183 from daniel-j-h/rvalue-apply
0bf5404 Implements rvalue handler support for apply, resolves #180.
ccaab08 Merge pull request #182 from AMDmi3/freebsd-endianess
bffe626 Handle endianess on FreeBSD properly
7250222 Code formatting and test cleanup.
6652436 Merge pull request #179 from oxidase/add_match_key_std_regex
afadf5b Rename centroid variables and function in example.
8355284 Add envelope() functions to NodeRefList, Way, and Area.
fc83d2e Remove unnecessary include.
9ddd00e Add match_key<std::regex> tag
9c54a53 Update README. Moved some infos to manual.
89a90a6 Update readme and developer docs.
c3446ec Simplify subitem iteration code and made it more flexible.
542b07c Add some static_asserts.
f0fd690 Memory reporting on M68k doesn't work properly.
e8957c6 Compare doubles in test using Approx().
58ae4a6 Add amenity_list example.
53783f8 Fix doxygen config for reproducible builds.
de4e52d Release v2.10.3
0cc42a2 ObjectPointerCollection constructor can't be noexcept.
4472dfb Round out ObjectPointerCollection implementation and test it.
28cb35d Build with XCode 8 and GCC 6 on travis.
03e3e66 Upgrade to new protozero version 1.4.5.
2102c2f Add assertion in queue handling code.

git-subtree-dir: third_party/libosmium
git-subtree-split: c1f34c45507e233a2b9028663906679c610fe179
2017-01-20 14:05:21 +01:00

219 lines
7.3 KiB
CMake

#-----------------------------------------------------------------------------
#
# CMake Config
#
# Libosmium unit tests
#
#-----------------------------------------------------------------------------
message(STATUS "Configuring unit tests")
include(CMakeParseArguments)
include_directories(include)
add_library(testlib STATIC test_main.cpp)
set(ALL_TESTS "")
# Otherwise GCC throws a lot of warnings for REQUIRE(...) from Catch v.1.2.1
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-Wno-parentheses)
endif()
#-----------------------------------------------------------------------------
#
# Define function for adding tests
#
# add_unit_tests(group name [ENABLE_IF bool] [LIBS libs] [LABELS labels])
#
# group - test group (directory)
# name - name of test
# bool - boolean variable telling whether the test should be run (optional)
# libs - lib or libs that should be used when compiling test (optional)
# labels - additional labels this test should get (optional)
#
#-----------------------------------------------------------------------------
function(add_unit_test _tgroup _tname)
set(_testid "${_tgroup}_${_tname}")
set(_tpath "${_tgroup}/${_tname}")
set(ALL_TESTS "${ALL_TESTS};${_tpath}" PARENT_SCOPE)
cmake_parse_arguments(_param "" "ENABLE_IF" "LIBS;LABELS" ${ARGN})
if(Osmium_DEBUG)
message("${_testid} ENABLE_IF=[${_param_ENABLE_IF}] LIBS=[${_param_LIBS}] LABELS=[${_param_LABELS}]")
endif()
if((NOT(DEFINED _param_ENABLE_IF)) OR (_param_ENABLE_IF))
if(Osmium_DEBUG)
message("Adding test: ${_tpath}")
endif()
add_executable(${_testid} t/${_tpath}.cpp)
target_link_libraries(${_testid} testlib)
if(DEFINED _param_LIBS)
if(Osmium_DEBUG)
message(" Adding libs: ${_param_LIBS}")
endif()
target_link_libraries(${_testid} ${_param_LIBS})
endif()
add_test(NAME ${_testid}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${_testid}
)
set(_labels "unit;fast;${_tgroup}")
if(DEFINED _param_LABELS)
if(Osmium_DEBUG)
message(" Adding labels: ${_param_LABELS}")
endif()
set(_labels "${_labels};${_param_LABELS}")
endif()
set_tests_properties(${_testid} PROPERTIES
LABELS "${_labels}"
ENVIRONMENT "OSMIUM_TEST_DATA_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
)
else()
message("Skipped test ${_tpath} because a dependency was not found")
set(OSMIUM_SKIPPED_TESTS
"${OSMIUM_SKIPPED_TESTS} ${_tpath}"
CACHE STRING "Tests that were skipped because of missing dependecies")
endif()
endfunction()
#-----------------------------------------------------------------------------
#
# Prepare some variables so querying it for tests work properly.
#
#-----------------------------------------------------------------------------
if(NOT GEOS_FOUND)
set(GEOS_FOUND FALSE)
endif()
if(NOT PROJ_FOUND)
set(PROJ_FOUND FALSE)
endif()
if(NOT SPARSEHASH_FOUND)
set(SPARSEHASH_FOUND FALSE)
endif()
if(NOT BZIP2_FOUND)
set(BZIP2_FOUND FALSE)
endif()
if(NOT Threads_FOUND)
set(Threads_FOUND FALSE)
endif()
#-----------------------------------------------------------------------------
#
# Add all tests.
#
#-----------------------------------------------------------------------------
add_unit_test(area test_area_id)
add_unit_test(area test_node_ref_segment)
add_unit_test(osm test_area)
add_unit_test(osm test_box)
add_unit_test(osm test_changeset)
add_unit_test(osm test_crc)
add_unit_test(osm test_entity_bits)
add_unit_test(osm test_location)
add_unit_test(osm test_node)
add_unit_test(osm test_node_ref)
add_unit_test(osm test_object_comparisons)
add_unit_test(osm test_relation)
add_unit_test(osm test_timestamp)
add_unit_test(osm test_types_from_string)
add_unit_test(osm test_way)
add_unit_test(memory test_buffer_basics)
add_unit_test(memory test_buffer_node)
add_unit_test(memory test_buffer_purge)
add_unit_test(memory test_type_is_compatible)
add_unit_test(builder test_attr)
add_unit_test(builder test_object_builder)
add_unit_test(geom test_coordinates)
add_unit_test(geom test_crs ENABLE_IF ${PROJ_FOUND} LIBS ${PROJ_LIBRARY})
add_unit_test(geom test_exception)
add_unit_test(geom test_factory_with_projection ENABLE_IF ${PROJ_FOUND} LIBS ${PROJ_LIBRARY})
add_unit_test(geom test_geojson)
add_unit_test(geom test_geos ENABLE_IF ${GEOS_FOUND} LIBS ${GEOS_LIBRARY})
add_unit_test(geom test_mercator)
add_unit_test(geom test_ogr ENABLE_IF ${GDAL_FOUND} LIBS ${GDAL_LIBRARY})
add_unit_test(geom test_ogr_wkb ENABLE_IF ${GDAL_FOUND} LIBS ${GDAL_LIBRARY})
add_unit_test(geom test_projection ENABLE_IF ${PROJ_FOUND} LIBS ${PROJ_LIBRARY})
add_unit_test(geom test_tile)
add_unit_test(geom test_wkb)
add_unit_test(geom test_wkt)
add_unit_test(index test_id_set)
add_unit_test(index test_id_to_location ENABLE_IF ${SPARSEHASH_FOUND})
add_unit_test(index test_file_based_index)
add_unit_test(index test_object_pointer_collection)
add_unit_test(index test_relations_map)
add_unit_test(io test_compression_factory)
add_unit_test(io test_bzip2 ENABLE_IF ${BZIP2_FOUND} LIBS ${BZIP2_LIBRARIES})
add_unit_test(io test_file_formats)
add_unit_test(io test_reader LIBS "${OSMIUM_XML_LIBRARIES};${OSMIUM_PBF_LIBRARIES}")
add_unit_test(io test_reader_with_mock_decompression ENABLE_IF ${Threads_FOUND} LIBS ${OSMIUM_XML_LIBRARIES})
add_unit_test(io test_reader_with_mock_parser ENABLE_IF ${Threads_FOUND} LIBS ${CMAKE_THREAD_LIBS_INIT})
add_unit_test(io test_opl_parser)
add_unit_test(io test_output_utils)
add_unit_test(io test_output_iterator ENABLE_IF ${Threads_FOUND} LIBS ${CMAKE_THREAD_LIBS_INIT})
add_unit_test(io test_string_table)
add_unit_test(io test_writer ENABLE_IF ${Threads_FOUND} LIBS ${OSMIUM_XML_LIBRARIES})
add_unit_test(io test_writer_with_mock_compression ENABLE_IF ${Threads_FOUND} LIBS ${OSMIUM_XML_LIBRARIES})
add_unit_test(io test_writer_with_mock_encoder ENABLE_IF ${Threads_FOUND} LIBS ${OSMIUM_XML_LIBRARIES})
add_unit_test(tags test_filter)
add_unit_test(tags test_operators)
add_unit_test(tags test_tag_list)
add_unit_test(thread test_pool ENABLE_IF ${Threads_FOUND} LIBS ${CMAKE_THREAD_LIBS_INIT})
add_unit_test(util test_cast_with_assert)
add_unit_test(util test_delta)
add_unit_test(util test_double)
add_unit_test(util test_file)
add_unit_test(util test_memory)
add_unit_test(util test_memory_mapping)
add_unit_test(util test_minmax)
add_unit_test(util test_options)
add_unit_test(util test_string)
#-----------------------------------------------------------------------------
#
# Check that all tests available in test/t/*/test_*.cpp are run.
#
#-----------------------------------------------------------------------------
file(GLOB TESTS_IN_DIR RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/t" t/*/test_*.cpp)
foreach(file ${TESTS_IN_DIR})
string(REPLACE ".cpp" "" out1 ${file})
string(REPLACE "//" "/" tname ${out1})
list(FIND ALL_TESTS ${tname} found)
if(${found} EQUAL -1)
message(WARNING "Test '${tname}' not found in cmake config. It will not be run!")
endif()
endforeach()
#-----------------------------------------------------------------------------
message(STATUS "Configuring unit tests - done")
#-----------------------------------------------------------------------------