Add basic facades for Extractor and Contractor run methods.
Based on idea suggested in comments to #3776, simplifies use of extractor and contractor as libraries.
This commit is contained in:
committed by
Patrick Niklaus
parent
5aba239fc1
commit
e13ba8ba11
@@ -13,6 +13,15 @@ file(GLOB PartitionTestsSources
|
||||
file(GLOB LibraryTestsSources
|
||||
library_tests.cpp
|
||||
library/*.cpp)
|
||||
list(REMOVE_ITEM LibraryTestsSources ${CMAKE_CURRENT_SOURCE_DIR}/library/extract.cpp ${CMAKE_CURRENT_SOURCE_DIR}/library/contract.cpp)
|
||||
|
||||
file(GLOB LibraryExtractTestsSources
|
||||
library_tests.cpp
|
||||
library/extract.cpp)
|
||||
|
||||
file(GLOB LibraryContractTestsSources
|
||||
library_tests.cpp
|
||||
library/contract.cpp)
|
||||
|
||||
file(GLOB ServerTestsSources
|
||||
server_tests.cpp
|
||||
@@ -41,6 +50,14 @@ add_executable(library-tests
|
||||
EXCLUDE_FROM_ALL
|
||||
${LibraryTestsSources})
|
||||
|
||||
add_executable(library-extract-tests
|
||||
EXCLUDE_FROM_ALL
|
||||
${LibraryExtractTestsSources})
|
||||
|
||||
add_executable(library-contract-tests
|
||||
EXCLUDE_FROM_ALL
|
||||
${LibraryContractTestsSources})
|
||||
|
||||
add_executable(server-tests
|
||||
EXCLUDE_FROM_ALL
|
||||
${ServerTestsSources}
|
||||
@@ -65,9 +82,13 @@ endif()
|
||||
|
||||
target_compile_definitions(extractor-tests PRIVATE COMPILE_DEFINITIONS OSRM_FIXTURES_DIR="${CMAKE_SOURCE_DIR}/unit_tests/fixtures")
|
||||
target_compile_definitions(library-tests PRIVATE COMPILE_DEFINITIONS OSRM_TEST_DATA_DIR="${TEST_DATA_DIR}")
|
||||
target_compile_definitions(library-extract-tests PRIVATE COMPILE_DEFINITIONS OSRM_TEST_DATA_DIR="${TEST_DATA_DIR}")
|
||||
target_compile_definitions(library-contract-tests PRIVATE COMPILE_DEFINITIONS OSRM_TEST_DATA_DIR="${TEST_DATA_DIR}")
|
||||
|
||||
target_include_directories(engine-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(library-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(library-extract-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(library-contract-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(util-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(partition-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
@@ -75,8 +96,10 @@ target_link_libraries(engine-tests ${ENGINE_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWO
|
||||
target_link_libraries(extractor-tests ${EXTRACTOR_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
||||
target_link_libraries(partition-tests ${PARTITIONER_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
||||
target_link_libraries(library-tests osrm ${ENGINE_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
||||
target_link_libraries(library-extract-tests osrm_extract ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
||||
target_link_libraries(library-contract-tests osrm_contract ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
||||
target_link_libraries(server-tests osrm ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
||||
target_link_libraries(util-tests ${UTIL_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
||||
|
||||
add_custom_target(tests
|
||||
DEPENDS engine-tests extractor-tests partition-tests library-tests server-tests util-tests)
|
||||
DEPENDS engine-tests extractor-tests partition-tests library-tests library-extract-tests server-tests util-tests)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "osrm/contractor.hpp"
|
||||
#include "osrm/contractor_config.hpp"
|
||||
|
||||
#include <tbb/task_scheduler_init.h> // default_num_threads
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(library_contract)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_contract_with_invalid_config)
|
||||
{
|
||||
using namespace osrm;
|
||||
|
||||
osrm::ContractorConfig config;
|
||||
config.requested_num_threads = tbb::task_scheduler_init::default_num_threads();
|
||||
BOOST_CHECK_THROW(osrm::contract(config),
|
||||
std::exception); // including osrm::util::exception, etc.
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <boost/test/test_case_template.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "osrm/extractor.hpp"
|
||||
#include "osrm/extractor_config.hpp"
|
||||
|
||||
#include <tbb/task_scheduler_init.h> // default_num_threads
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(library_extract)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_extract_with_invalid_config)
|
||||
{
|
||||
osrm::ExtractorConfig config;
|
||||
config.requested_num_threads = tbb::task_scheduler_init::default_num_threads();
|
||||
BOOST_CHECK_THROW(osrm::extract(config),
|
||||
std::exception); // including osrm::util::exception, osmium::io_error, etc.
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_extract_with_valid_config)
|
||||
{
|
||||
osrm::ExtractorConfig config;
|
||||
config.input_path = {OSRM_TEST_DATA_DIR "/monaco.osm.pbf"};
|
||||
config.requested_num_threads = tbb::task_scheduler_init::default_num_threads();
|
||||
BOOST_CHECK_NO_THROW(osrm::extract(config));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
Reference in New Issue
Block a user