Skip to content

Commit c120f11

Browse files
committed
Chagne the test case to make sure it triggers the failure case
1 parent 6b1ac05 commit c120f11

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/vm/tests/mock_tests/mock_test_allocate_no_gc.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,30 @@ pub fn allocate_no_gc() {
1313
const MB: usize = 1024 * 1024;
1414
let mut fixture = MutatorFixture::create_with_heapsize(MB);
1515

16-
// Attempt allocation: allocate 1024 bytes. We should fill up the heap by 10 allocations or fewer (some plans reserves more memory, such as semispace and generational GCs)
16+
let mut last_result = crate::util::Address::MAX;
17+
18+
// Attempt allocation: allocate 1024 bytes. We should fill up the heap by 1024 allocations or fewer (some plans reserves more memory, such as semispace and generational GCs)
1719
// Run a few more times to test if we set/unset no_gc_on_fail properly.
18-
for _ in 0..20 {
19-
let addr = memory_manager::alloc_no_gc(
20+
for _ in 0..1100 {
21+
last_result = memory_manager::alloc_no_gc(
2022
&mut fixture.mutator,
2123
1024,
2224
8,
2325
0,
2426
AllocationSemantics::Default,
2527
);
26-
if addr.is_zero() {
28+
if last_result.is_zero() {
2729
read_mockvm(|mock| {
2830
assert!(!mock.block_for_gc.is_called());
2931
});
32+
read_mockvm(|mock| {
33+
assert!(!mock.out_of_memory.is_called());
34+
});
3035
}
3136
}
37+
38+
// The allocation should consume all the heap, and the last result should be zero (failure).
39+
assert!(last_result.is_zero());
3240
},
3341
no_cleanup,
3442
)

0 commit comments

Comments
 (0)