@@ -329,9 +329,16 @@ TEST_F(MemoryDeathTest, TestReadMemoryRangesReturnsTooMuch) {
329329 dummy_process.read_more_than_requested = true ;
330330 llvm::SmallVector<uint8_t , 0 > buffer (1024 , 0 );
331331 llvm::SmallVector<Range<addr_t , size_t >> ranges = {{0x12345 , 128 }};
332- ASSERT_DEATH (
333- { process_sp->ReadMemoryRanges (ranges, buffer); },
332+
333+ llvm::SmallVector<llvm::MutableArrayRef<uint8_t >> read_results;
334+ ASSERT_DEBUG_DEATH (
335+ { read_results = process_sp->ReadMemoryRanges (ranges, buffer); },
334336 " read more than requested bytes" );
337+ #ifdef NDEBUG
338+ // With asserts off, the read should return empty ranges.
339+ ASSERT_EQ (read_results.size (), 1u );
340+ ASSERT_TRUE (read_results[0 ].empty ());
341+ #endif
335342}
336343
337344TEST_F (MemoryDeathTest, TestReadMemoryRangesWithShortBuffer) {
@@ -346,9 +353,17 @@ TEST_F(MemoryDeathTest, TestReadMemoryRangesWithShortBuffer) {
346353 std::make_shared<DummyReaderProcess>(target_sp, listener_sp);
347354 ASSERT_TRUE (process_sp);
348355
349- llvm::SmallVector<uint8_t , 0 > too_short_buffer (10 , 0 );
350- llvm::SmallVector<Range<addr_t , size_t >> ranges = {{0x12345 , 128 }};
351- ASSERT_DEATH (
352- { process_sp->ReadMemoryRanges (ranges, too_short_buffer); },
356+ llvm::SmallVector<uint8_t , 0 > short_buffer (10 , 0 );
357+ llvm::SmallVector<Range<addr_t , size_t >> ranges = {{0x12345 , 128 },
358+ {0x11 , 128 }};
359+ llvm::SmallVector<llvm::MutableArrayRef<uint8_t >> read_results;
360+ ASSERT_DEBUG_DEATH (
361+ { read_results = process_sp->ReadMemoryRanges (ranges, short_buffer); },
353362 " provided buffer is too short" );
363+ #ifdef NDEBUG
364+ // With asserts off, the read should return empty ranges.
365+ ASSERT_EQ (read_results.size (), ranges.size ());
366+ for (llvm::MutableArrayRef<uint8_t > result : read_results)
367+ ASSERT_TRUE (result.empty ());
368+ #endif
354369}
0 commit comments