Enable all unit tests (#5248)
* Add missing profile name to library extract test. * Support both tzid and TZID properties on timezone geometry. Improve validation of timezone polygons. * Missing tzid property wasn't a geojson validation issue, shouldn't have been tested there. * Use filesystem glob to loop over all test executables so we don't miss any in the future. Co-authored-by: Michael Bell <michael@mjjbell.com>
This commit is contained in:
parent
b120c971a0
commit
d5cd702242
9
.github/workflows/osrm-backend.yml
vendored
9
.github/workflows/osrm-backend.yml
vendored
@ -531,14 +531,7 @@ jobs:
|
|||||||
|
|
||||||
# All tests assume to be run from the build directory
|
# All tests assume to be run from the build directory
|
||||||
pushd ${OSRM_BUILD_DIR}
|
pushd ${OSRM_BUILD_DIR}
|
||||||
./unit_tests/library-tests
|
for i in ./unit_tests/*-tests ; do echo Running $i ; $i ; done
|
||||||
./unit_tests/extractor-tests
|
|
||||||
./unit_tests/contractor-tests
|
|
||||||
./unit_tests/engine-tests
|
|
||||||
./unit_tests/util-tests
|
|
||||||
./unit_tests/server-tests
|
|
||||||
./unit_tests/partitioner-tests
|
|
||||||
./unit_tests/customizer-tests
|
|
||||||
if [ -z "${ENABLE_SANITIZER}" ] && [ "$TARGET_ARCH" != "i686" ]; then
|
if [ -z "${ENABLE_SANITIZER}" ] && [ "$TARGET_ARCH" != "i686" ]; then
|
||||||
npm run nodejs-tests
|
npm run nodejs-tests
|
||||||
fi
|
fi
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
- CHANGED: Upgrade Boost dependency to 1.70 [#6113](https://github.com/Project-OSRM/osrm-backend/pull/6113)
|
- CHANGED: Upgrade Boost dependency to 1.70 [#6113](https://github.com/Project-OSRM/osrm-backend/pull/6113)
|
||||||
- CHANGED: Upgrade Ubuntu CI builds to 20.04 [#6119](https://github.com/Project-OSRM/osrm-backend/pull/6119)
|
- CHANGED: Upgrade Ubuntu CI builds to 20.04 [#6119](https://github.com/Project-OSRM/osrm-backend/pull/6119)
|
||||||
- CHANGED: Make building osrm-routed optional [#6144](https://github.com/Project-OSRM/osrm-backend/pull/6144)
|
- CHANGED: Make building osrm-routed optional [#6144](https://github.com/Project-OSRM/osrm-backend/pull/6144)
|
||||||
|
- FIXED: Run all unit tests in CI [#5248](https://github.com/Project-OSRM/osrm-backend/pull/5248)
|
||||||
|
|
||||||
# 5.26.0
|
# 5.26.0
|
||||||
- Changes from 5.25.0
|
- Changes from 5.25.0
|
||||||
|
@ -76,6 +76,14 @@ inline void validateFeature(const rapidjson::Value &feature)
|
|||||||
const auto coord_array = feature["geometry"].GetObject()["coordinates"].GetArray();
|
const auto coord_array = feature["geometry"].GetObject()["coordinates"].GetArray();
|
||||||
if (coord_array.Empty())
|
if (coord_array.Empty())
|
||||||
throw osrm::util::exception("Feature geometry coordinates member is empty.");
|
throw osrm::util::exception("Feature geometry coordinates member is empty.");
|
||||||
|
|
||||||
|
if (feature["geometry"]["type"] == "polygon" || feature["geometry"]["type"] == "Polygon")
|
||||||
|
{
|
||||||
|
if (!coord_array[0].IsArray() || !coord_array[0][0].IsArray())
|
||||||
|
{
|
||||||
|
throw osrm::util::exception("Polygon geometry missing outer ring");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // namespace util
|
} // namespace util
|
||||||
} // namespace osrm
|
} // namespace osrm
|
||||||
|
@ -110,14 +110,23 @@ void Timezoner::LoadLocalTimesRTree(rapidjson::Document &geojson, std::time_t ut
|
|||||||
// time zone geojson specific checks
|
// time zone geojson specific checks
|
||||||
const auto &feature = features_array[i].GetObject();
|
const auto &feature = features_array[i].GetObject();
|
||||||
const auto &properties = feature["properties"].GetObject();
|
const auto &properties = feature["properties"].GetObject();
|
||||||
if (!properties.HasMember("tzid"))
|
std::string tzid_key = "tzid";
|
||||||
|
if (properties.HasMember("tzid"))
|
||||||
|
{
|
||||||
|
if (!properties["tzid"].IsString())
|
||||||
|
throw osrm::util::exception("Feature has non-string 'tzid' value.");
|
||||||
|
tzid_key = "tzid";
|
||||||
|
}
|
||||||
|
else if (properties.HasMember("TZID"))
|
||||||
|
{
|
||||||
|
if (!properties["TZID"].IsString())
|
||||||
|
throw osrm::util::exception("Feature has non-string 'TZID' value.");
|
||||||
|
tzid_key = "TZID";
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
throw osrm::util::exception("Feature is missing 'tzid' member in properties.");
|
throw osrm::util::exception("Feature is missing 'tzid' member in properties.");
|
||||||
}
|
}
|
||||||
else if (!properties["tzid"].IsString())
|
|
||||||
{
|
|
||||||
throw osrm::util::exception("Feature has non-string 'tzid' value.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Case-sensitive check of type https://tools.ietf.org/html/rfc7946#section-1.4
|
// Case-sensitive check of type https://tools.ietf.org/html/rfc7946#section-1.4
|
||||||
const auto &geometry = feature["geometry"].GetObject();
|
const auto &geometry = feature["geometry"].GetObject();
|
||||||
@ -137,7 +146,7 @@ void Timezoner::LoadLocalTimesRTree(rapidjson::Document &geojson, std::time_t ut
|
|||||||
local_times.size());
|
local_times.size());
|
||||||
|
|
||||||
// Get time zone name and emplace polygon and local time for the UTC input
|
// Get time zone name and emplace polygon and local time for the UTC input
|
||||||
const auto &tzname = properties["tzid"].GetString();
|
const auto &tzname = properties[tzid_key.c_str()].GetString();
|
||||||
local_times.push_back(local_time_t{polygon, get_local_time_in_tz(tzname)});
|
local_times.push_back(local_time_t{polygon, get_local_time_in_tz(tzname)});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -20,6 +20,8 @@ BOOST_AUTO_TEST_CASE(test_extract_with_valid_config)
|
|||||||
osrm::ExtractorConfig config;
|
osrm::ExtractorConfig config;
|
||||||
config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
config.input_path = OSRM_TEST_DATA_DIR "/monaco.osm.pbf";
|
||||||
config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
config.UseDefaultOutputNames(OSRM_TEST_DATA_DIR "/monaco.osm.pbf");
|
||||||
|
config.profile_path = OSRM_TEST_DATA_DIR "/../../profiles/car.lua";
|
||||||
|
config.small_component_size = 1000;
|
||||||
config.requested_num_threads = std::thread::hardware_concurrency();
|
config.requested_num_threads = std::thread::hardware_concurrency();
|
||||||
BOOST_CHECK_NO_THROW(osrm::extract(config));
|
BOOST_CHECK_NO_THROW(osrm::extract(config));
|
||||||
}
|
}
|
||||||
|
@ -53,5 +53,19 @@ BOOST_AUTO_TEST_CASE(timezoner_test)
|
|||||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||||
"49.07206], [8.28369, 48.88277]]] }} ]}";
|
"49.07206], [8.28369, 48.88277]]] }} ]}";
|
||||||
BOOST_CHECK_THROW(Timezoner tz(missing_featc, now), util::exception);
|
BOOST_CHECK_THROW(Timezoner tz(missing_featc, now), util::exception);
|
||||||
|
|
||||||
|
char missing_tzid[] = "{ \"type\" : \"Feature\","
|
||||||
|
"\"properties\" : { }, \"geometry\" : { \"type\": \"polygon\", "
|
||||||
|
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||||
|
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||||
|
"49.07206], [8.28369, 48.88277]]] }}";
|
||||||
|
BOOST_CHECK_THROW(Timezoner tz(missing_tzid, now), util::exception);
|
||||||
|
|
||||||
|
char tzid_err[] = "{ \"type\" : \"Feature\","
|
||||||
|
"\"properties\" : { \"TZID\" : []}, \"geometry\" : { \"type\": \"polygon\", "
|
||||||
|
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
||||||
|
"48.88277], [8.57757, 49.07206], [8.28369, "
|
||||||
|
"49.07206], [8.28369, 48.88277]]] }}";
|
||||||
|
BOOST_CHECK_THROW(Timezoner tz(tzid_err, now), util::exception);
|
||||||
}
|
}
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
@ -65,22 +65,6 @@ BOOST_AUTO_TEST_CASE(timezone_validation_test)
|
|||||||
doc.Parse(nonobj_props);
|
doc.Parse(nonobj_props);
|
||||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
||||||
|
|
||||||
char missing_tzid[] = "{ \"type\" : \"Feature\","
|
|
||||||
"\"properties\" : { }, \"geometry\" : { \"type\": \"polygon\", "
|
|
||||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
|
||||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
|
||||||
"49.07206], [8.28369, 48.88277]]] }}";
|
|
||||||
doc.Parse(missing_tzid);
|
|
||||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
|
||||||
|
|
||||||
char tzid_err[] = "{ \"type\" : \"Feature\","
|
|
||||||
"\"properties\" : { \"TZID\" : []}, \"geometry\" : { \"type\": \"polygon\", "
|
|
||||||
"\"coordinates\": [[[8.28369,48.88277], [8.57757, "
|
|
||||||
"48.88277], [8.57757, 49.07206], [8.28369, "
|
|
||||||
"49.07206], [8.28369, 48.88277]]] }}";
|
|
||||||
doc.Parse(tzid_err);
|
|
||||||
BOOST_CHECK_THROW(util::validateFeature(doc), util::exception);
|
|
||||||
|
|
||||||
char missing_geom[] = "{ \"type\" : \"Feature\","
|
char missing_geom[] = "{ \"type\" : \"Feature\","
|
||||||
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometries\" : { "
|
"\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometries\" : { "
|
||||||
"\"type\": \"polygon\", "
|
"\"type\": \"polygon\", "
|
||||||
|
Loading…
Reference in New Issue
Block a user