summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Goldblatt <davidgoldblatt@fb.com>2018-05-11 16:43:43 -0700
committerDavid Goldblatt <davidtgoldblatt@gmail.com>2018-05-18 11:43:03 -0700
commit0379235f47585ac8f583ba85aab9d294abfa44b5 (patch)
tree8d5d41f7fba43d1a0e84bf1b1a67fb38db4e6007 /test
parent59e371f46331a3f4b688d6622a0af7ccc4f96be6 (diff)
Tests: Shouldn't be able to change global slowness.
This can help ensure that we don't leave slowness changes behind in case of resource exhaustion.
Diffstat (limited to 'test')
-rw-r--r--test/src/test.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/src/test.c b/test/src/test.c
index 9c754e33..f97ce4d1 100644
--- a/test/src/test.c
+++ b/test/src/test.c
@@ -110,6 +110,20 @@ p_test_fini(void) {
test_status_string(test_status));
}
+static void
+check_global_slow(test_status_t *status) {
+#ifdef JEMALLOC_UNIT_TEST
+ /*
+ * This check needs to peek into tsd internals, which is why it's only
+ * exposed in unit tests.
+ */
+ if (tsd_global_slow()) {
+ malloc_printf("Testing increased global slow count\n");
+ *status = test_status_fail;
+ }
+#endif
+}
+
static test_status_t
p_test_impl(bool do_malloc_init, bool do_reentrant, test_t *t, va_list ap) {
test_status_t ret;
@@ -136,6 +150,7 @@ p_test_impl(bool do_malloc_init, bool do_reentrant, test_t *t, va_list ap) {
if (test_status > ret) {
ret = test_status;
}
+ check_global_slow(&ret);
/* Reentrant run. */
if (do_reentrant) {
reentrancy = libc_reentrant;
@@ -145,6 +160,7 @@ p_test_impl(bool do_malloc_init, bool do_reentrant, test_t *t, va_list ap) {
if (test_status > ret) {
ret = test_status;
}
+ check_global_slow(&ret);
reentrancy = arena_new_reentrant;
test_hooks_libc_hook = NULL;
@@ -153,6 +169,7 @@ p_test_impl(bool do_malloc_init, bool do_reentrant, test_t *t, va_list ap) {
if (test_status > ret) {
ret = test_status;
}
+ check_global_slow(&ret);
}
}