static void overcommit_memory_test(void) { /* start to test overcommit_memory=2 */ set_sys_tune("overcommit_memory", 2, 1); update_mem(); alloc_and_check(commit_left * 2, EXPECT_FAIL); alloc_and_check(commit_limit, EXPECT_FAIL); update_mem(); alloc_and_check(commit_left / 2, EXPECT_PASS); /* start to test overcommit_memory=0 */ set_sys_tune("overcommit_memory", 0, 1); update_mem(); alloc_and_check(free_total / 2, EXPECT_PASS); update_mem(); alloc_and_check(free_total * 2, EXPECT_FAIL); alloc_and_check(sum_total, EXPECT_FAIL); /* start to test overcommit_memory=1 */ set_sys_tune("overcommit_memory", 1, 1); alloc_and_check(sum_total / 2, EXPECT_PASS); alloc_and_check(sum_total, EXPECT_PASS); alloc_and_check(sum_total * 2, EXPECT_PASS); }
static void overcommit_memory_test(void) { #if __WORDSIZE == 32 tst_brk(TCONF, "test is not designed for 32-bit system."); #endif /* start to test overcommit_memory=2 */ set_sys_tune("overcommit_memory", 2, 1); update_mem_commit(); alloc_and_check(commit_left * 2, EXPECT_FAIL); alloc_and_check(commit_limit, EXPECT_FAIL); update_mem_commit(); alloc_and_check(commit_left / 2, EXPECT_PASS); /* start to test overcommit_memory=0 */ set_sys_tune("overcommit_memory", 0, 1); update_mem(); alloc_and_check(free_total / 2, EXPECT_PASS); update_mem(); alloc_and_check(free_total * 2, EXPECT_FAIL); alloc_and_check(sum_total, EXPECT_FAIL); /* start to test overcommit_memory=1 */ set_sys_tune("overcommit_memory", 1, 1); alloc_and_check(sum_total / 2, EXPECT_PASS); alloc_and_check(sum_total, EXPECT_PASS); alloc_and_check(sum_total * 2, EXPECT_PASS); }