Skip to content

Commit 1d89835

Browse files
benvanikclaude
andauthored
[NFC] Make status test macros take ownership of iree_status_t. (#23276)
Adds `ConsumeForTest` overloads that wrap raw `iree_status_t` in `iree::Status` RAII wrappers, ensuring automatic cleanup on test failure. The macros `IREE_EXPECT_OK`, `IREE_ASSERT_OK`, `IREE_EXPECT_STATUS_IS`, and `IREE_ASSERT_STATUS_IS` now consume the status they test. For lvalue status variables, the source is cleared to a code-only value so any existing `iree_status_ignore`/`iree_status_free` calls become harmless no-ops. This allows incremental migration without breaking existing tests. Most tests (outside of tokenizer) have been updated. tokenizer is being reworked and the next feature branch merge will adopt this behavior. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1a912be commit 1d89835

12 files changed

Lines changed: 260 additions & 289 deletions

File tree

runtime/src/iree/base/allocator_test.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -417,18 +417,18 @@ TEST(StructLayout, ZeroCountField) {
417417

418418
TEST(StructLayout, OverflowOnMultiply) {
419419
iree_host_size_t total = 0;
420-
iree_status_t status = IREE_STRUCT_LAYOUT(
421-
0, &total, IREE_STRUCT_FIELD(SIZE_MAX, TestElement, NULL));
422-
EXPECT_TRUE(iree_status_is_out_of_range(status));
423-
iree_status_free(status);
420+
IREE_EXPECT_STATUS_IS(
421+
IREE_STATUS_OUT_OF_RANGE,
422+
IREE_STRUCT_LAYOUT(0, &total,
423+
IREE_STRUCT_FIELD(SIZE_MAX, TestElement, NULL)));
424424
}
425425

426426
TEST(StructLayout, OverflowOnAdd) {
427427
iree_host_size_t total = 0;
428-
iree_status_t status = IREE_STRUCT_LAYOUT(
429-
SIZE_MAX - 10, &total, IREE_STRUCT_FIELD(100, uint8_t, NULL));
430-
EXPECT_TRUE(iree_status_is_out_of_range(status));
431-
iree_status_free(status);
428+
IREE_EXPECT_STATUS_IS(
429+
IREE_STATUS_OUT_OF_RANGE,
430+
IREE_STRUCT_LAYOUT(SIZE_MAX - 10, &total,
431+
IREE_STRUCT_FIELD(100, uint8_t, NULL)));
432432
}
433433

434434
TEST(StructLayout, SingleField) {

0 commit comments

Comments
 (0)