Пример #1
0
TEST_END

TEST_BEGIN(test_zero_huge)
{

    test_skip_if(!config_fill);
    test_zero(large_maxclass+1, chunksize*2);
}
Пример #2
0
TEST_END

TEST_BEGIN(test_zero_large)
{

    test_skip_if(!config_fill);
    test_zero(SMALL_MAXCLASS+1, large_maxclass);
}
Пример #3
0
TEST_END

TEST_BEGIN(test_junk_huge)
{

	test_skip_if(!config_fill);
	test_junk(arena_maxclass+1, chunksize*2);
}
Пример #4
0
TEST_END

TEST_BEGIN(test_junk_large)
{

	test_skip_if(!config_fill);
	test_junk(SMALL_MAXCLASS+1, arena_maxclass);
}
Пример #5
0
TEST_END

TEST_BEGIN(test_max_background_threads) {
	test_skip_if(!have_background_thread);

	size_t max_n_thds;
	size_t opt_max_n_thds;
	size_t sz_m = sizeof(max_n_thds);
	assert_d_eq(mallctl("opt.max_background_threads",
	    &opt_max_n_thds, &sz_m, NULL, 0), 0,
	    "Failed to get opt.max_background_threads");
	assert_d_eq(mallctl("max_background_threads", &max_n_thds, &sz_m, NULL,
	    0), 0, "Failed to get max background threads");
	assert_zu_eq(opt_max_n_thds, max_n_thds,
	    "max_background_threads and "
	    "opt.max_background_threads should match");
	assert_d_eq(mallctl("max_background_threads", NULL, NULL, &max_n_thds,
	    sz_m), 0, "Failed to set max background threads");

	unsigned id;
	size_t sz_u = sizeof(unsigned);

	for (unsigned i = 0; i < 10 * ncpus; i++) {
		assert_d_eq(mallctl("arenas.create", &id, &sz_u, NULL, 0), 0,
		    "Failed to create arena");
	}

	bool enable = true;
	size_t sz_b = sizeof(bool);
	assert_d_eq(mallctl("background_thread", NULL, NULL, &enable, sz_b), 0,
	    "Failed to enable background threads");
	assert_zu_eq(n_background_threads, max_n_thds,
	    "Number of background threads should not change.\n");
	size_t new_max_thds = max_n_thds - 1;
	if (new_max_thds > 0) {
		assert_d_eq(mallctl("max_background_threads", NULL, NULL,
		    &new_max_thds, sz_m), 0,
		    "Failed to set max background threads");
		assert_zu_eq(n_background_threads, new_max_thds,
		    "Number of background threads should decrease by 1.\n");
	}
	new_max_thds = 1;
	assert_d_eq(mallctl("max_background_threads", NULL, NULL, &new_max_thds,
	    sz_m), 0, "Failed to set max background threads");
	assert_zu_eq(n_background_threads, new_max_thds,
	    "Number of background threads should be 1.\n");
}
Пример #6
0
TEST_END

TEST_BEGIN(test_tcache_none) {
	test_skip_if(!opt_tcache);

	/* Allocate p and q. */
	void *p0 = mallocx(42, 0);
	assert_ptr_not_null(p0, "Unexpected mallocx() failure");
	void *q = mallocx(42, 0);
	assert_ptr_not_null(q, "Unexpected mallocx() failure");

	/* Deallocate p and q, but bypass the tcache for q. */
	dallocx(p0, 0);
	dallocx(q, MALLOCX_TCACHE_NONE);

	/* Make sure that tcache-based allocation returns p, not q. */
	void *p1 = mallocx(42, 0);
	assert_ptr_not_null(p1, "Unexpected mallocx() failure");
	assert_ptr_eq(p0, p1, "Expected tcache to allocate cached region");

	/* Clean up. */
	dallocx(p1, MALLOCX_TCACHE_NONE);
}
Пример #7
0
TEST_END

TEST_BEGIN(test_junk_large) {
	test_skip_if(!config_fill);
	test_junk(SMALL_MAXCLASS+1, (1U << (LG_LARGE_MINCLASS+1)));
}