summaryrefslogtreecommitdiffstats
path: root/test/integration/thread_tcache_enabled.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/thread_tcache_enabled.c')
-rw-r--r--test/integration/thread_tcache_enabled.c47
1 files changed, 11 insertions, 36 deletions
diff --git a/test/integration/thread_tcache_enabled.c b/test/integration/thread_tcache_enabled.c
index 2c2825e..0c343a6 100644
--- a/test/integration/thread_tcache_enabled.c
+++ b/test/integration/thread_tcache_enabled.c
@@ -1,30 +1,11 @@
#include "test/jemalloc_test.h"
-static const bool config_tcache =
-#ifdef JEMALLOC_TCACHE
- true
-#else
- false
-#endif
- ;
-
void *
-thd_start(void *arg)
-{
- int err;
- size_t sz;
+thd_start(void *arg) {
bool e0, e1;
-
- sz = sizeof(bool);
- if ((err = mallctl("thread.tcache.enabled", (void *)&e0, &sz, NULL,
- 0))) {
- if (err == ENOENT) {
- assert_false(config_tcache,
- "ENOENT should only be returned if tcache is "
- "disabled");
- }
- goto label_ENOENT;
- }
+ size_t sz = sizeof(bool);
+ assert_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz, NULL,
+ 0), 0, "Unexpected mallctl failure");
if (e0) {
e1 = false;
@@ -78,21 +59,17 @@ thd_start(void *arg)
assert_false(e0, "tcache should be disabled");
free(malloc(1));
- return (NULL);
-label_ENOENT:
+ return NULL;
test_skip("\"thread.tcache.enabled\" mallctl not available");
- return (NULL);
+ return NULL;
}
-TEST_BEGIN(test_main_thread)
-{
-
+TEST_BEGIN(test_main_thread) {
thd_start(NULL);
}
TEST_END
-TEST_BEGIN(test_subthread)
-{
+TEST_BEGIN(test_subthread) {
thd_t thd;
thd_create(&thd, thd_start, NULL);
@@ -101,14 +78,12 @@ TEST_BEGIN(test_subthread)
TEST_END
int
-main(void)
-{
-
+main(void) {
/* Run tests multiple times to check for bad interactions. */
- return (test(
+ return test(
test_main_thread,
test_subthread,
test_main_thread,
test_subthread,
- test_main_thread));
+ test_main_thread);
}