Home | History | Annotate | Download | only in unit
      1 #include "test/jemalloc_test.h"
      2 
      3 TEST_BEGIN(test_pages_huge) {
      4 	size_t alloc_size;
      5 	bool commit;
      6 	void *pages, *hugepage;
      7 
      8 	alloc_size = HUGEPAGE * 2 - PAGE;
      9 	commit = true;
     10 	pages = pages_map(NULL, alloc_size, PAGE, &commit);
     11 	assert_ptr_not_null(pages, "Unexpected pages_map() error");
     12 
     13 	if (init_system_thp_mode == thp_mode_default) {
     14 	    hugepage = (void *)(ALIGNMENT_CEILING((uintptr_t)pages, HUGEPAGE));
     15 	    assert_b_ne(pages_huge(hugepage, HUGEPAGE), have_madvise_huge,
     16 	        "Unexpected pages_huge() result");
     17 	    assert_false(pages_nohuge(hugepage, HUGEPAGE),
     18 	        "Unexpected pages_nohuge() result");
     19 	}
     20 
     21 	pages_unmap(pages, alloc_size);
     22 }
     23 TEST_END
     24 
     25 int
     26 main(void) {
     27 	return test(
     28 	    test_pages_huge);
     29 }
     30