Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable all unit tests #5248

Merged
merged 5 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/osrm-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions include/util/geojson_validation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 14 additions & 5 deletions src/util/timezones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,22 @@ 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"))
{
throw osrm::util::exception("Feature is missing 'tzid' member in properties.");
if (!properties["tzid"].IsString())
throw osrm::util::exception("Feature has non-string 'tzid' value.");
tzid_key = "tzid";
}
else if (!properties["tzid"].IsString())
else if (properties.HasMember("TZID"))
{
throw osrm::util::exception("Feature has non-string 'tzid' value.");
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.");
}

// Case-sensitive check of type https://tools.ietf.org/html/rfc7946#section-1.4
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions unit_tests/library/extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
14 changes: 14 additions & 0 deletions unit_tests/updater/timezoner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
16 changes: 0 additions & 16 deletions unit_tests/updater/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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\", "
Expand Down