Hardcode path to test data dir for library-tests

This was needed because we now need multiple datasets for testing.
CMake will automatically prepare these over the makefile in test/data.
This commit is contained in:
Patrick Niklaus
2017-03-05 22:53:41 +00:00
committed by Patrick Niklaus
parent 8ad9a0aa9a
commit fc9b5938e6
12 changed files with 77 additions and 158 deletions
-32
View File
@@ -1,32 +0,0 @@
#ifndef OSRM_UNIT_TEST_ARGS
#define OSRM_UNIT_TEST_ARGS
#include "util/log.hpp"
#include <boost/filesystem.hpp>
#include <iostream>
#include <iostream>
#include <string>
#include <vector>
inline std::vector<std::string> get_args()
{
osrm::util::LogPolicy::GetInstance().Unmute();
if ((boost::unit_test::framework::master_test_suite().argc != 2) ||
(!boost::filesystem::is_regular_file(
boost::unit_test::framework::master_test_suite().argv[1])))
{
osrm::util::Log(logERROR) << "Please provide valid input osrm file";
osrm::util::Log(logERROR) << "Usage: "
<< boost::unit_test::framework::master_test_suite().argv[0]
<< " /path/to/input_osrm_file" << std::endl;
std::exit(EXIT_FAILURE);
}
// Split off argv[0], store actual positional arguments in args
const auto argc = boost::unit_test::framework::master_test_suite().argc - 1;
const auto argv = boost::unit_test::framework::master_test_suite().argv + 1;
return {argv, argv + argc};
}
#endif
+5 -22
View File
@@ -1,8 +1,6 @@
#include <boost/test/test_case_template.hpp>
#include <boost/test/unit_test.hpp>
#include "args.hpp"
#include "osrm/match_parameters.hpp"
#include "osrm/nearest_parameters.hpp"
#include "osrm/route_parameters.hpp"
@@ -27,13 +25,10 @@ BOOST_AUTO_TEST_SUITE(limits)
BOOST_AUTO_TEST_CASE(test_trip_limits)
{
const auto args = get_args();
BOOST_REQUIRE_EQUAL(args.size(), 1);
using namespace osrm;
EngineConfig config;
config.storage_config = {args[0]};
config.storage_config = {OSRM_TEST_DATA_DIR "/monaco_CH.osrm"};
config.use_shared_memory = false;
config.max_locations_trip = 2;
@@ -57,13 +52,10 @@ BOOST_AUTO_TEST_CASE(test_trip_limits)
BOOST_AUTO_TEST_CASE(test_route_limits)
{
const auto args = get_args();
BOOST_REQUIRE_EQUAL(args.size(), 1);
using namespace osrm;
EngineConfig config;
config.storage_config = {args[0]};
config.storage_config = {OSRM_TEST_DATA_DIR "/monaco_CH.osrm"};
config.use_shared_memory = false;
config.max_locations_viaroute = 2;
@@ -87,13 +79,10 @@ BOOST_AUTO_TEST_CASE(test_route_limits)
BOOST_AUTO_TEST_CASE(test_table_limits)
{
const auto args = get_args();
BOOST_REQUIRE_EQUAL(args.size(), 1);
using namespace osrm;
EngineConfig config;
config.storage_config = {args[0]};
config.storage_config = {OSRM_TEST_DATA_DIR "/monaco_CH.osrm"};
config.use_shared_memory = false;
config.max_locations_distance_table = 2;
@@ -117,13 +106,10 @@ BOOST_AUTO_TEST_CASE(test_table_limits)
BOOST_AUTO_TEST_CASE(test_match_limits)
{
const auto args = get_args();
BOOST_REQUIRE_EQUAL(args.size(), 1);
using namespace osrm;
EngineConfig config;
config.storage_config = {args[0]};
config.storage_config = {OSRM_TEST_DATA_DIR "/monaco_CH.osrm"};
config.use_shared_memory = false;
config.max_locations_map_matching = 2;
@@ -147,13 +133,10 @@ BOOST_AUTO_TEST_CASE(test_match_limits)
BOOST_AUTO_TEST_CASE(test_nearest_limits)
{
const auto args = get_args();
BOOST_REQUIRE_EQUAL(args.size(), 1);
using namespace osrm;
EngineConfig config;
config.storage_config = {args[0]};
config.storage_config = {OSRM_TEST_DATA_DIR "/monaco_CH.osrm"};
config.use_shared_memory = false;
config.max_results_nearest = 2;
+1 -5
View File
@@ -1,7 +1,6 @@
#include <boost/test/test_case_template.hpp>
#include <boost/test/unit_test.hpp>
#include "args.hpp"
#include "coordinates.hpp"
#include "fixture.hpp"
#include "waypoint_check.hpp"
@@ -18,12 +17,9 @@ BOOST_AUTO_TEST_SUITE(match)
BOOST_AUTO_TEST_CASE(test_match)
{
const auto args = get_args();
BOOST_REQUIRE_EQUAL(args.size(), 1);
using namespace osrm;
auto osrm = getOSRM(args[0]);
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
MatchParameters params;
params.coordinates.push_back(get_dummy_location());
+4 -9
View File
@@ -1,7 +1,6 @@
#include <boost/test/test_case_template.hpp>
#include <boost/test/unit_test.hpp>
#include "args.hpp"
#include "coordinates.hpp"
#include "fixture.hpp"
@@ -17,8 +16,7 @@ BOOST_AUTO_TEST_SUITE(nearest)
BOOST_AUTO_TEST_CASE(test_nearest_response)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
using namespace osrm;
@@ -45,8 +43,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_response)
BOOST_AUTO_TEST_CASE(test_nearest_response_no_coordinates)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
using namespace osrm;
@@ -62,8 +59,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_response_no_coordinates)
BOOST_AUTO_TEST_CASE(test_nearest_response_multiple_coordinates)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
using namespace osrm;
@@ -81,8 +77,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_response_multiple_coordinates)
BOOST_AUTO_TEST_CASE(test_nearest_response_for_location_in_small_component)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
using namespace osrm;
+6 -10
View File
@@ -1,7 +1,6 @@
#include <boost/test/test_case_template.hpp>
#include <boost/test/unit_test.hpp>
#include "args.hpp"
#include "coordinates.hpp"
#include "equal_json.hpp"
#include "fixture.hpp"
@@ -12,33 +11,30 @@ BOOST_AUTO_TEST_SUITE(options)
BOOST_AUTO_TEST_CASE(test_ch)
{
const auto args = get_args();
using namespace osrm;
EngineConfig config;
config.storage_config = storage::StorageConfig(args.at(0));
config.use_shared_memory = false;
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
config.algorithm = EngineConfig::Algorithm::CH;
OSRM osrm{config};
}
BOOST_AUTO_TEST_CASE(test_corech)
{
const auto args = get_args();
using namespace osrm;
EngineConfig config;
config.storage_config = storage::StorageConfig(args.at(0));
config.use_shared_memory = false;
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/monaco_CoreCH.osrm");
config.algorithm = EngineConfig::Algorithm::CoreCH;
OSRM osrm{config};
}
BOOST_AUTO_TEST_CASE(test_mld)
{
const auto args = get_args();
using namespace osrm;
EngineConfig config;
config.storage_config = storage::StorageConfig(args.at(0));
config.use_shared_memory = false;
config.storage_config = storage::StorageConfig(OSRM_TEST_DATA_DIR "/monaco_CoreCH.osrm");
config.algorithm = EngineConfig::Algorithm::MLD;
OSRM osrm{config};
}
+8 -17
View File
@@ -1,7 +1,6 @@
#include <boost/test/test_case_template.hpp>
#include <boost/test/unit_test.hpp>
#include "args.hpp"
#include "coordinates.hpp"
#include "equal_json.hpp"
#include "fixture.hpp"
@@ -18,8 +17,7 @@ BOOST_AUTO_TEST_SUITE(route)
BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
using namespace osrm;
@@ -105,8 +103,7 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates_fixture)
BOOST_AUTO_TEST_CASE(test_route_same_coordinates)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
using namespace osrm;
@@ -258,8 +255,7 @@ BOOST_AUTO_TEST_CASE(test_route_same_coordinates)
BOOST_AUTO_TEST_CASE(test_route_response_for_locations_in_small_component)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
using namespace osrm;
@@ -294,8 +290,7 @@ BOOST_AUTO_TEST_CASE(test_route_response_for_locations_in_small_component)
BOOST_AUTO_TEST_CASE(test_route_response_for_locations_in_big_component)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
using namespace osrm;
@@ -330,8 +325,7 @@ BOOST_AUTO_TEST_CASE(test_route_response_for_locations_in_big_component)
BOOST_AUTO_TEST_CASE(test_route_response_for_locations_across_components)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
using namespace osrm;
@@ -368,8 +362,7 @@ BOOST_AUTO_TEST_CASE(test_route_response_for_locations_across_components)
BOOST_AUTO_TEST_CASE(test_route_user_disables_generating_hints)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
using namespace osrm;
@@ -389,8 +382,7 @@ BOOST_AUTO_TEST_CASE(test_route_user_disables_generating_hints)
BOOST_AUTO_TEST_CASE(speed_annotation_matches_duration_and_distance)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
using namespace osrm;
@@ -424,8 +416,7 @@ BOOST_AUTO_TEST_CASE(speed_annotation_matches_duration_and_distance)
BOOST_AUTO_TEST_CASE(test_manual_setting_of_annotations_property)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
using namespace osrm;
+3 -13
View File
@@ -1,7 +1,6 @@
#include <boost/test/test_case_template.hpp>
#include <boost/test/unit_test.hpp>
#include "args.hpp"
#include "coordinates.hpp"
#include "fixture.hpp"
#include "waypoint_check.hpp"
@@ -18,12 +17,9 @@ BOOST_AUTO_TEST_SUITE(table)
BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_one_dest_matrix)
{
const auto args = get_args();
BOOST_REQUIRE_EQUAL(args.size(), 1);
using namespace osrm;
auto osrm = getOSRM(args[0]);
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
TableParameters params;
params.coordinates.push_back(get_dummy_location());
@@ -68,12 +64,9 @@ BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_one_dest_matrix)
BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_matrix)
{
const auto args = get_args();
BOOST_REQUIRE_EQUAL(args.size(), 1);
using namespace osrm;
auto osrm = getOSRM(args[0]);
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
TableParameters params;
params.coordinates.push_back(get_dummy_location());
@@ -118,12 +111,9 @@ BOOST_AUTO_TEST_CASE(test_table_three_coords_one_source_matrix)
BOOST_AUTO_TEST_CASE(test_table_three_coordinates_matrix)
{
const auto args = get_args();
BOOST_REQUIRE_EQUAL(args.size(), 1);
using namespace osrm;
auto osrm = getOSRM(args[0]);
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
TableParameters params;
params.coordinates.push_back(get_dummy_location());
+5 -10
View File
@@ -1,7 +1,6 @@
#include <boost/test/test_case_template.hpp>
#include <boost/test/unit_test.hpp>
#include "args.hpp"
#include "fixture.hpp"
#include "osrm/tile_parameters.hpp"
@@ -23,11 +22,10 @@ BOOST_AUTO_TEST_SUITE(tile)
BOOST_AUTO_TEST_CASE(test_tile)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
// This tile should contain most of monaco
TileParameters params{17059, 11948, 15};
@@ -213,11 +211,9 @@ BOOST_AUTO_TEST_CASE(test_tile)
BOOST_AUTO_TEST_CASE(test_tile_turns)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
// Small tile where we can test all the values
TileParameters params{272953, 191177, 19};
@@ -363,11 +359,10 @@ BOOST_AUTO_TEST_CASE(test_tile_turns)
BOOST_AUTO_TEST_CASE(test_tile_speeds)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
// Small tile so we can test all the values
// TileParameters params{272953, 191177, 19};
TileParameters params{136477, 95580, 18};
+7 -20
View File
@@ -1,7 +1,6 @@
#include <boost/test/test_case_template.hpp>
#include <boost/test/unit_test.hpp>
#include "args.hpp"
#include "coordinates.hpp"
#include "fixture.hpp"
@@ -17,11 +16,9 @@ BOOST_AUTO_TEST_SUITE(trip)
BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_small_component)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
const auto locations = get_locations_in_small_component();
TripParameters params;
@@ -61,11 +58,9 @@ BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_small_component)
BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_big_component)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
const auto locations = get_locations_in_big_component();
TripParameters params;
@@ -105,11 +100,9 @@ BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_big_component)
BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_across_components)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
const auto small = get_locations_in_small_component();
const auto big = get_locations_in_big_component();
@@ -153,11 +146,9 @@ BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_across_components)
BOOST_AUTO_TEST_CASE(test_tfse_1)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
const auto locations = get_locations_in_small_component();
TripParameters params;
@@ -201,11 +192,9 @@ BOOST_AUTO_TEST_CASE(test_tfse_1)
BOOST_AUTO_TEST_CASE(test_tfse_2)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
const auto locations = get_locations_in_big_component();
TripParameters params;
@@ -274,10 +263,9 @@ void CheckOk(const osrm::OSRM &osrm, osrm::TripParameters &params)
BOOST_AUTO_TEST_CASE(test_tfse_illegal_parameters)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
const auto locations = get_locations_in_big_component();
auto params = osrm::TripParameters();
@@ -326,9 +314,8 @@ BOOST_AUTO_TEST_CASE(test_tfse_illegal_parameters)
BOOST_AUTO_TEST_CASE(test_tfse_legal_parameters)
{
const auto args = get_args();
auto osrm = getOSRM(args.at(0));
using namespace osrm;
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/monaco_CH.osrm");
const auto locations = get_locations_in_big_component();
json::Object result;
TripParameters params;