diff --git a/.github/workflows/osrm-backend.yml b/.github/workflows/osrm-backend.yml index eb4fc4f3f..c83eb45c1 100644 --- a/.github/workflows/osrm-backend.yml +++ b/.github/workflows/osrm-backend.yml @@ -531,14 +531,7 @@ jobs: # All tests assume to be run from the build directory pushd ${OSRM_BUILD_DIR} - ./unit_tests/library-tests - ./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 + for i in ./unit_tests/*-tests ; do echo Running $i ; $i ; done if [ -z "${ENABLE_SANITIZER}" ] && [ "$TARGET_ARCH" != "i686" ]; then npm run nodejs-tests fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 9677e130e..de89940e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - 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: 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 - Changes from 5.25.0 diff --git a/include/util/geojson_validation.hpp b/include/util/geojson_validation.hpp index 40b986df1..8482395be 100644 --- a/include/util/geojson_validation.hpp +++ b/include/util/geojson_validation.hpp @@ -76,6 +76,14 @@ inline void validateFeature(const rapidjson::Value &feature) const auto coord_array = feature["geometry"].GetObject()["coordinates"].GetArray(); if (coord_array.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 osrm diff --git a/src/util/timezones.cpp b/src/util/timezones.cpp index 30e7b51b4..948f34855 100644 --- a/src/util/timezones.cpp +++ b/src/util/timezones.cpp @@ -110,14 +110,23 @@ void Timezoner::LoadLocalTimesRTree(rapidjson::Document &geojson, std::time_t ut // time zone geojson specific checks const auto &feature = features_array[i].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."); } - 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 const auto &geometry = feature["geometry"].GetObject(); @@ -137,7 +146,7 @@ void Timezoner::LoadLocalTimesRTree(rapidjson::Document &geojson, std::time_t ut local_times.size()); // 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)}); } else diff --git a/unit_tests/library/extract.cpp b/unit_tests/library/extract.cpp index 23f5ea0d9..aa18c7552 100644 --- a/unit_tests/library/extract.cpp +++ b/unit_tests/library/extract.cpp @@ -20,6 +20,8 @@ BOOST_AUTO_TEST_CASE(test_extract_with_valid_config) osrm::ExtractorConfig config; config.input_path = 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(); BOOST_CHECK_NO_THROW(osrm::extract(config)); } diff --git a/unit_tests/updater/timezoner.cpp b/unit_tests/updater/timezoner.cpp index 543c14312..9f4a3744a 100644 --- a/unit_tests/updater/timezoner.cpp +++ b/unit_tests/updater/timezoner.cpp @@ -53,5 +53,19 @@ BOOST_AUTO_TEST_CASE(timezoner_test) "48.88277], [8.57757, 49.07206], [8.28369, " "49.07206], [8.28369, 48.88277]]] }} ]}"; 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() diff --git a/unit_tests/updater/validation.cpp b/unit_tests/updater/validation.cpp index b68c34528..177dc52d5 100644 --- a/unit_tests/updater/validation.cpp +++ b/unit_tests/updater/validation.cpp @@ -65,22 +65,6 @@ BOOST_AUTO_TEST_CASE(timezone_validation_test) doc.Parse(nonobj_props); 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\"," "\"properties\" : { \"TZID\" : \"Europe/Berlin\"}, \"geometries\" : { " "\"type\": \"polygon\", "