Avoid lazy-lock in a tcache-dependent test.

This commit is contained in:
Jason Evans 2014-01-21 14:20:29 -08:00
parent 264dfd35d0
commit 7d8fea9871

View File

@ -123,7 +123,8 @@ TEST_BEGIN(test_stats_arenas_summary)
expected, "Unexepected mallctl() result"); expected, "Unexepected mallctl() result");
if (config_stats) { if (config_stats) {
assert_u64_gt(npurge, 0, "At least one purge occurred"); assert_u64_gt(npurge, 0,
"At least one purge should have occurred");
assert_u64_le(nmadvise, purged, assert_u64_le(nmadvise, purged,
"nmadvise should be no greater than purged"); "nmadvise should be no greater than purged");
} }
@ -133,6 +134,22 @@ TEST_BEGIN(test_stats_arenas_summary)
} }
TEST_END TEST_END
void *
thd_start(void *arg)
{
return (NULL);
}
static void
no_lazy_lock(void)
{
thd_t thd;
thd_create(&thd, thd_start, NULL);
thd_join(thd, NULL);
}
TEST_BEGIN(test_stats_arenas_small) TEST_BEGIN(test_stats_arenas_small)
{ {
unsigned arena; unsigned arena;
@ -141,6 +158,8 @@ TEST_BEGIN(test_stats_arenas_small)
uint64_t epoch, nmalloc, ndalloc, nrequests; uint64_t epoch, nmalloc, ndalloc, nrequests;
int expected = config_stats ? 0 : ENOENT; int expected = config_stats ? 0 : ENOENT;
no_lazy_lock(); /* Lazy locking would dodge tcache testing. */
arena = 0; arena = 0;
assert_d_eq(mallctl("thread.arena", NULL, NULL, &arena, sizeof(arena)), assert_d_eq(mallctl("thread.arena", NULL, NULL, &arena, sizeof(arena)),
0, "Unexpected mallctl() failure"); 0, "Unexpected mallctl() failure");
@ -211,13 +230,13 @@ TEST_BEGIN(test_stats_arenas_large)
if (config_stats) { if (config_stats) {
assert_zu_gt(allocated, 0, assert_zu_gt(allocated, 0,
"allocated should be greated than zero"); "allocated should be greater than zero");
assert_zu_gt(nmalloc, 0, assert_zu_gt(nmalloc, 0,
"nmalloc should be no greater than zero"); "nmalloc should be greater than zero");
assert_zu_ge(nmalloc, ndalloc, assert_zu_ge(nmalloc, ndalloc,
"nmalloc should be at least as large as ndalloc"); "nmalloc should be at least as large as ndalloc");
assert_zu_gt(nrequests, 0, assert_zu_gt(nrequests, 0,
"nrequests should be no greater than zero"); "nrequests should be greater than zero");
} }
dallocx(p, 0); dallocx(p, 0);
@ -273,22 +292,23 @@ TEST_BEGIN(test_stats_arenas_bins)
if (config_stats) { if (config_stats) {
assert_zu_gt(allocated, 0, assert_zu_gt(allocated, 0,
"allocated should be greated than zero"); "allocated should be greater than zero");
assert_u64_gt(nmalloc, 0, assert_u64_gt(nmalloc, 0,
"nmalloc should be no greater than zero"); "nmalloc should be greater than zero");
assert_u64_ge(nmalloc, ndalloc, assert_u64_ge(nmalloc, ndalloc,
"nmalloc should be at least as large as ndalloc"); "nmalloc should be at least as large as ndalloc");
assert_u64_gt(nrequests, 0, assert_u64_gt(nrequests, 0,
"nrequests should be no greater than zero"); "nrequests should be greater than zero");
if (config_tcache) { if (config_tcache) {
assert_u64_gt(nfills, 0, assert_u64_gt(nfills, 0,
"At least one fill has occurred"); "At least one fill should have occurred");
assert_u64_gt(nflushes, 0, assert_u64_gt(nflushes, 0,
"At least one flush has occurred"); "At least one flush should have occurred");
} }
assert_u64_gt(nruns, 0, "At least one run has been allocated"); assert_u64_gt(nruns, 0,
"At least one run should have been allocated");
assert_u64_gt(curruns, 0, assert_u64_gt(curruns, 0,
"At least one run is currently allocated"); "At least one run should be currently allocated");
} }
dallocx(p, 0); dallocx(p, 0);
@ -324,13 +344,13 @@ TEST_BEGIN(test_stats_arenas_lruns)
if (config_stats) { if (config_stats) {
assert_u64_gt(nmalloc, 0, assert_u64_gt(nmalloc, 0,
"nmalloc should be no greater than zero"); "nmalloc should be greater than zero");
assert_u64_ge(nmalloc, ndalloc, assert_u64_ge(nmalloc, ndalloc,
"nmalloc should be at least as large as ndalloc"); "nmalloc should be at least as large as ndalloc");
assert_u64_gt(nrequests, 0, assert_u64_gt(nrequests, 0,
"nrequests should be no greater than zero"); "nrequests should be greater than zero");
assert_u64_gt(curruns, 0, assert_u64_gt(curruns, 0,
"At least one run is currently allocated"); "At least one run should be currently allocated");
} }
dallocx(p, 0); dallocx(p, 0);