Add the profiling settings for tests explicit.

Many profiling related tests make assumptions on the profiling settings,
e.g. opt_prof is off by default, and prof_active is default on when opt_prof is
on.  However the default settings can be changed via --with-malloc-conf at build
time.  Fixing the tests by adding the assumed settings explicitly.
This commit is contained in:
Qi Wang 2021-11-15 15:23:47 -08:00 committed by Qi Wang
parent e491df1d2f
commit bd70d8fc0f
13 changed files with 26 additions and 11 deletions

View File

@ -104,8 +104,8 @@ expect_purging(unsigned arena_ind, bool expect_deferred) {
dallocx(ptr, MALLOCX_TCACHE_NONE); dallocx(ptr, MALLOCX_TCACHE_NONE);
empty_ndirty = get_empty_ndirty(arena_ind); empty_ndirty = get_empty_ndirty(arena_ind);
if (expect_deferred) { if (expect_deferred) {
expect_true(empty_ndirty == 0 || empty_ndirty == 1, expect_true(empty_ndirty == 0 || empty_ndirty == 1 ||
"Unexpected extra dirty page count: %zu", opt_prof, "Unexpected extra dirty page count: %zu",
empty_ndirty); empty_ndirty);
} else { } else {
assert_zu_eq(0, empty_ndirty, assert_zu_eq(0, empty_ndirty,

5
test/unit/inspect.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
if [ "x${enable_prof}" = "x1" ] ; then
export MALLOC_CONF="prof:false"
fi

View File

@ -368,7 +368,10 @@ TEST_BEGIN(test_tcache_none) {
/* Make sure that tcache-based allocation returns p, not q. */ /* Make sure that tcache-based allocation returns p, not q. */
void *p1 = mallocx(42, 0); void *p1 = mallocx(42, 0);
expect_ptr_not_null(p1, "Unexpected mallocx() failure"); expect_ptr_not_null(p1, "Unexpected mallocx() failure");
expect_ptr_eq(p0, p1, "Expected tcache to allocate cached region"); if (!opt_prof) {
expect_ptr_eq(p0, p1,
"Expected tcache to allocate cached region");
}
/* Clean up. */ /* Clean up. */
dallocx(p1, MALLOCX_TCACHE_NONE); dallocx(p1, MALLOCX_TCACHE_NONE);
@ -904,6 +907,7 @@ TEST_BEGIN(test_prof_active) {
* test_mallctl_opt was already enough. * test_mallctl_opt was already enough.
*/ */
test_skip_if(!config_prof); test_skip_if(!config_prof);
test_skip_if(opt_prof);
bool active, old; bool active, old;
size_t len = sizeof(bool); size_t len = sizeof(bool);

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
if [ "x${enable_prof}" = "x1" ] ; then if [ "x${enable_prof}" = "x1" ] ; then
export MALLOC_CONF="prof:true,prof_thread_active_init:false,lg_prof_sample:0" export MALLOC_CONF="prof:true,prof_active:true,prof_thread_active_init:false,lg_prof_sample:0"
fi fi

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
if [ "x${enable_prof}" = "x1" ] ; then if [ "x${enable_prof}" = "x1" ] ; then
export MALLOC_CONF="prof:true,lg_prof_sample:0" export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0"
fi fi

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
if [ "x${enable_prof}" = "x1" ] ; then if [ "x${enable_prof}" = "x1" ] ; then
export MALLOC_CONF="prof:true,lg_prof_sample:0" export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0"
fi fi

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
if [ "x${enable_prof}" = "x1" ] ; then if [ "x${enable_prof}" = "x1" ] ; then
export MALLOC_CONF="prof:true,lg_prof_sample:0,prof_recent_alloc_max:3" export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0,prof_recent_alloc_max:3"
fi fi

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
if [ "x${enable_prof}" = "x1" ] ; then if [ "x${enable_prof}" = "x1" ] ; then
export MALLOC_CONF="prof:true,lg_prof_sample:0,prof_stats:true" export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0,prof_stats:true"
fi fi

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
if [ "x${enable_prof}" = "x1" ] ; then if [ "x${enable_prof}" = "x1" ] ; then
export MALLOC_CONF="prof:true,lg_prof_sample:0,prof_sys_thread_name:true" export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0,prof_sys_thread_name:true"
fi fi

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
if [ "x${enable_prof}" = "x1" ] ; then if [ "x${enable_prof}" = "x1" ] ; then
export MALLOC_CONF="prof:true,lg_prof_sample:0" export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0"
fi fi

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
if [ "x${enable_prof}" = "x1" ] ; then if [ "x${enable_prof}" = "x1" ] ; then
export MALLOC_CONF="prof:true,lg_prof_sample:0" export MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:0"
fi fi

5
test/unit/size_check.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
if [ "x${enable_prof}" = "x1" ] ; then
export MALLOC_CONF="prof:false"
fi

View File

@ -151,6 +151,7 @@ test_tcache_max_impl(void) {
TEST_BEGIN(test_tcache_max) { TEST_BEGIN(test_tcache_max) {
test_skip_if(!config_stats); test_skip_if(!config_stats);
test_skip_if(!opt_tcache); test_skip_if(!opt_tcache);
test_skip_if(opt_prof);
for (alloc_option = alloc_option_start; for (alloc_option = alloc_option_start;
alloc_option < alloc_option_end; alloc_option < alloc_option_end;