onnxruntime
780d7142 - Add error-path tests for InferenceSession Run/Load/Initialize validation (#29555)

Commit
3 days ago
Add error-path tests for InferenceSession Run/Load/Initialize validation (#29555) ### Description Adds error-path unit tests for `InferenceSession` validation / early-return branches, which were under-covered (only failure/`kExpectFailure`-style assertions were a small fraction of the suite). All nine target previously-untested branches and are verified passing against a local Release build. | Test | Branch exercised | Asserted message | |---|---|---| | `RunBeforeInitializeReturnsError` | `Run` when not initialized | `Session not initialized` | | `InitializeBeforeLoadReturnsError` | `Initialize` with no model loaded | `Model was not loaded` | | `RunWithInvalidOutputNameReturnsError` | `ValidateOutputs` unknown output | `Invalid output name` | | `RunWithWrongInputTypeReturnsError` | `CheckTypes` (input) | `Unexpected input data type` | | `RunWithWrongInputRankReturnsError` | `CheckShapes` (input rank) | `Invalid rank for input` | | `RunWithMismatchedFeedCountReturnsError` | feed/name count mismatch | `feed names has ...` | | `RunWithWrongOutputTypeReturnsError` | `CheckTypes` (output) | `Unexpected output data type` | | `LoadMalformedModelFromArrayReturnsError` | malformed model bytes | graceful failure | | `LoadNonexistentModelReturnsError` | missing model file | graceful failure | ### Motivation and Context Error/validation paths in `InferenceSession::Run` / `Initialize` / `Load` were thinly tested relative to the numeric happy-path bulk. These tests lock in the failure contracts (both the non-OK `Status` and the message substring, via `ASSERT_STATUS_NOT_OK_AND_HAS_SUBSTR`) so a regression that changes the behavior or the message surfaces clearly. ### Notes - `"Invalid input name"` is already covered by `TestOptionalInputs`, so it is intentionally not duplicated. - Test-only change (`onnxruntime/test/framework/inference_session_test.cc`); no product/runtime code is touched. --------- Co-authored-by: Gopalakrishnan Nallasamy <gopalakrishnan.nallasamy@microsoft.com>
Parents
Loading