From ba2af1dc3a027cad6ed0f1222d5ee95c6961bdb6 Mon Sep 17 00:00:00 2001 From: snkmcb Date: Sat, 5 Sep 2026 19:31:26 +0900 Subject: [PATCH 1/3] test: cover mid-read cancellation --- docs/roadmap/implementation-status.md | 13 ++++++----- libs/usd-geotiff/tests/test_geotiff_pixel.cpp | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/docs/roadmap/implementation-status.md b/docs/roadmap/implementation-status.md index b41d519..c8cb8d7 100644 --- a/docs/roadmap/implementation-status.md +++ b/docs/roadmap/implementation-status.md @@ -10,10 +10,11 @@ lane, the core libraries, the initial GeoTIFF window reader, the metadata authoring library, and the first format-specific plugin are built and tested. The optional libtiff backend now decodes Deflate, LZW, and PackBits windows through the RandomAccessSource client-I/O boundary. Uncompressed floating-point -predictor windows are decoded in the reader, while broad read planning and converter -sources are not implemented yet. The initial GeoTIFF-to-regular-grid mesh slice is now -connected and tested, including its interactive vertex ceiling, and no release -has been tagged. +predictor windows are decoded in the reader, and read planning, memory budgets, +and tile-boundary cancellation are covered by tests. Converter sources are not +implemented yet. The initial GeoTIFF-to-regular-grid mesh slice is now connected +and tested, including its interactive vertex ceiling, and no release has been +tagged. Status words, from [MODULE_README_CONTRACT.md](../contributing/MODULE_README_CONTRACT.md): @@ -128,8 +129,8 @@ Detail in [phase-1-raster-core.md](phase-1-raster-core.md). | `ReadScanlines` | implemented | | Read planning and range coalescing | implemented | | I/O counters and amplification reporting | implemented | -| Memory budget enforcement | planned | -| Cancellation at tile boundaries | planned | +| Memory budget enforcement | implemented | +| Cancellation at tile boundaries | implemented | ## Milestone 4 — mesh authoring (in progress, `v0.3.0`) diff --git a/libs/usd-geotiff/tests/test_geotiff_pixel.cpp b/libs/usd-geotiff/tests/test_geotiff_pixel.cpp index 4d27063..4b93891 100644 --- a/libs/usd-geotiff/tests/test_geotiff_pixel.cpp +++ b/libs/usd-geotiff/tests/test_geotiff_pixel.cpp @@ -399,6 +399,28 @@ int main() { usdgeo::DiagnosticCode::Cancelled, diagnostics); options.isCancelled = {}; + diagnostics.Clear(); + auto midReadBytes = ReadFile(std::string(FIXTURE_DIR) + + "/geotiff-8x8-uint16-striped.tif"); + usdraster::MemorySource midReadSource(midReadBytes.data(), + midReadBytes.size(), "mid-read"); + usdraster::RecordingSource midReadRecording(midReadSource); + usdgeotiff::GeoTiffReader midReadReader(midReadRecording); + std::size_t cancellationChecks = 0; + options.isCancelled = [&cancellationChecks] { + return ++cancellationChecks >= 2; + }; + grid = usdraster::RasterGrid{}; + Check(!midReadReader.ReadWindow({0, 0, 8, 8}, options, &grid, + &diagnostics), + "mid-read cancellation fails the window"); + Check(HasCode(diagnostics, usdgeo::DiagnosticCode::Cancelled), + "mid-read cancellation has typed diagnostic"); + Check(grid.IsEmpty(), "mid-read cancellation releases the partial grid"); + Check(midReadRecording.GetRanges().size() == 1, + "mid-read cancellation stops at a segment boundary"); + options.isCancelled = {}; + diagnostics.Clear(); CheckIntegerFixture("geotiff-2x2-uint8-striped.tif", usdraster::RasterDataType::UInt8, 4, From 2fa8af302de741efb9b3a0732e90af366911e1b0 Mon Sep 17 00:00:00 2001 From: snkmcb Date: Sat, 5 Sep 2026 19:33:35 +0900 Subject: [PATCH 2/3] test: count only pixel reads on cancellation --- libs/usd-geotiff/tests/test_geotiff_pixel.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/usd-geotiff/tests/test_geotiff_pixel.cpp b/libs/usd-geotiff/tests/test_geotiff_pixel.cpp index 4b93891..c3afc48 100644 --- a/libs/usd-geotiff/tests/test_geotiff_pixel.cpp +++ b/libs/usd-geotiff/tests/test_geotiff_pixel.cpp @@ -417,7 +417,12 @@ int main() { Check(HasCode(diagnostics, usdgeo::DiagnosticCode::Cancelled), "mid-read cancellation has typed diagnostic"); Check(grid.IsEmpty(), "mid-read cancellation releases the partial grid"); - Check(midReadRecording.GetRanges().size() == 1, + const std::uint64_t midReadPixelOffset = midReadBytes.size() - 128; + std::size_t midReadPixelRanges = 0; + for (const auto& range : midReadRecording.GetRanges()) { + if (range.offset >= midReadPixelOffset) ++midReadPixelRanges; + } + Check(midReadPixelRanges == 1, "mid-read cancellation stops at a segment boundary"); options.isCancelled = {}; From 12f7767a158e6ef91324ece304a2300bcde03c90 Mon Sep 17 00:00:00 2001 From: snkmcb Date: Sat, 5 Sep 2026 19:36:10 +0900 Subject: [PATCH 3/3] test: cancel after the first pixel segment --- libs/usd-geotiff/tests/test_geotiff_pixel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/usd-geotiff/tests/test_geotiff_pixel.cpp b/libs/usd-geotiff/tests/test_geotiff_pixel.cpp index c3afc48..d99fb75 100644 --- a/libs/usd-geotiff/tests/test_geotiff_pixel.cpp +++ b/libs/usd-geotiff/tests/test_geotiff_pixel.cpp @@ -408,7 +408,7 @@ int main() { usdgeotiff::GeoTiffReader midReadReader(midReadRecording); std::size_t cancellationChecks = 0; options.isCancelled = [&cancellationChecks] { - return ++cancellationChecks >= 2; + return ++cancellationChecks >= 3; }; grid = usdraster::RasterGrid{}; Check(!midReadReader.ReadWindow({0, 0, 8, 8}, options, &grid,