Add the prof_sys_thread_name feature in the prof_recent unit test.
This tests the combination of the prof_recent and thread_name features. Verified that it catches the issue being fixed in this PR. Also explicitly set thread name in test/unit/prof_recent. This fixes the name testing when no default thread name is set (e.g. FreeBSD).
This commit is contained in:
parent
94ace05832
commit
d4a2b8bab1
@ -7,3 +7,5 @@ typedef pthread_t thd_t;
|
||||
|
||||
void thd_create(thd_t *thd, void *(*proc)(void *), void *arg);
|
||||
void thd_join(thd_t thd, void **ret);
|
||||
bool thd_has_setname(void);
|
||||
void thd_setname(const char *name);
|
||||
|
@ -32,3 +32,21 @@ thd_join(thd_t thd, void **ret) {
|
||||
pthread_join(thd, ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
thd_setname(const char *name) {
|
||||
#ifdef JEMALLOC_HAVE_PTHREAD_SETNAME_NP
|
||||
pthread_setname_np(pthread_self(), name);
|
||||
#elif defined(JEMALLOC_HAVE_PTHREAD_SET_NAME_NP)
|
||||
pthread_set_name_np(pthread_self(), name);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
thd_has_setname(void) {
|
||||
#if defined(JEMALLOC_HAVE_PTHREAD_SETNAME_NP) || defined(JEMALLOC_HAVE_PTHREAD_SET_NAME_NP)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
/* As specified in the shell script */
|
||||
#define OPT_ALLOC_MAX 3
|
||||
|
||||
const char *test_thread_name = "test_thread";
|
||||
|
||||
/* Invariant before and after every test (when config_prof is on) */
|
||||
static void
|
||||
confirm_prof_setup() {
|
||||
@ -439,16 +441,11 @@ confirm_record(const char *template, const confirm_record_t *records,
|
||||
}
|
||||
ASSERT_CHAR(',');
|
||||
|
||||
if (opt_prof_sys_thread_name) {
|
||||
if (thd_has_setname() && opt_prof_sys_thread_name) {
|
||||
ASSERT_FORMATTED_STR("\"%s_thread_name\"",
|
||||
*type);
|
||||
ASSERT_CHAR(':');
|
||||
ASSERT_CHAR('"');
|
||||
while (*start != '"') {
|
||||
++start;
|
||||
}
|
||||
ASSERT_CHAR('"');
|
||||
ASSERT_CHAR(',');
|
||||
ASSERT_FORMATTED_STR(":\"%s\",",
|
||||
test_thread_name);
|
||||
}
|
||||
|
||||
ASSERT_FORMATTED_STR("\"%s_time\"", *type);
|
||||
@ -495,6 +492,7 @@ confirm_record(const char *template, const confirm_record_t *records,
|
||||
TEST_BEGIN(test_prof_recent_alloc_dump) {
|
||||
test_skip_if(!config_prof);
|
||||
|
||||
thd_setname(test_thread_name);
|
||||
confirm_prof_setup();
|
||||
|
||||
ssize_t future;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "x${enable_prof}" = "x1" ] ; then
|
||||
export MALLOC_CONF="prof:true,prof_active: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,prof_sys_thread_name:true"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user