diff options
Diffstat (limited to 'examples/redis-unstable/deps/jemalloc/test/integration/cpp')
5 files changed, 0 insertions, 130 deletions
diff --git a/examples/redis-unstable/deps/jemalloc/test/integration/cpp/basic.cpp b/examples/redis-unstable/deps/jemalloc/test/integration/cpp/basic.cpp deleted file mode 100644 index c1cf6cd..0000000 --- a/examples/redis-unstable/deps/jemalloc/test/integration/cpp/basic.cpp +++ /dev/null | |||
| @@ -1,24 +0,0 @@ | |||
| 1 | #include "test/jemalloc_test.h" | ||
| 2 | |||
| 3 | TEST_BEGIN(test_basic) { | ||
| 4 | auto foo = new long(4); | ||
| 5 | expect_ptr_not_null(foo, "Unexpected new[] failure"); | ||
| 6 | delete foo; | ||
| 7 | // Test nullptr handling. | ||
| 8 | foo = nullptr; | ||
| 9 | delete foo; | ||
| 10 | |||
| 11 | auto bar = new long; | ||
| 12 | expect_ptr_not_null(bar, "Unexpected new failure"); | ||
| 13 | delete bar; | ||
| 14 | // Test nullptr handling. | ||
| 15 | bar = nullptr; | ||
| 16 | delete bar; | ||
| 17 | } | ||
| 18 | TEST_END | ||
| 19 | |||
| 20 | int | ||
| 21 | main() { | ||
| 22 | return test( | ||
| 23 | test_basic); | ||
| 24 | } | ||
diff --git a/examples/redis-unstable/deps/jemalloc/test/integration/cpp/infallible_new_false.cpp b/examples/redis-unstable/deps/jemalloc/test/integration/cpp/infallible_new_false.cpp deleted file mode 100644 index 42196d6..0000000 --- a/examples/redis-unstable/deps/jemalloc/test/integration/cpp/infallible_new_false.cpp +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 1 | #include <memory> | ||
| 2 | |||
| 3 | #include "test/jemalloc_test.h" | ||
| 4 | |||
| 5 | TEST_BEGIN(test_failing_alloc) { | ||
| 6 | bool saw_exception = false; | ||
| 7 | try { | ||
| 8 | /* Too big of an allocation to succeed. */ | ||
| 9 | void *volatile ptr = ::operator new((size_t)-1); | ||
| 10 | (void)ptr; | ||
| 11 | } catch (...) { | ||
| 12 | saw_exception = true; | ||
| 13 | } | ||
| 14 | expect_true(saw_exception, "Didn't get a failure"); | ||
| 15 | } | ||
| 16 | TEST_END | ||
| 17 | |||
| 18 | int | ||
| 19 | main(void) { | ||
| 20 | return test( | ||
| 21 | test_failing_alloc); | ||
| 22 | } | ||
| 23 | |||
diff --git a/examples/redis-unstable/deps/jemalloc/test/integration/cpp/infallible_new_false.sh b/examples/redis-unstable/deps/jemalloc/test/integration/cpp/infallible_new_false.sh deleted file mode 100644 index 7d41812..0000000 --- a/examples/redis-unstable/deps/jemalloc/test/integration/cpp/infallible_new_false.sh +++ /dev/null | |||
| @@ -1,8 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | XMALLOC_STR="" | ||
| 4 | if [ "x${enable_xmalloc}" = "x1" ] ; then | ||
| 5 | XMALLOC_STR="xmalloc:false," | ||
| 6 | fi | ||
| 7 | |||
| 8 | export MALLOC_CONF="${XMALLOC_STR}experimental_infallible_new:false" | ||
diff --git a/examples/redis-unstable/deps/jemalloc/test/integration/cpp/infallible_new_true.cpp b/examples/redis-unstable/deps/jemalloc/test/integration/cpp/infallible_new_true.cpp deleted file mode 100644 index d675412..0000000 --- a/examples/redis-unstable/deps/jemalloc/test/integration/cpp/infallible_new_true.cpp +++ /dev/null | |||
| @@ -1,67 +0,0 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | |||
| 3 | #include "test/jemalloc_test.h" | ||
| 4 | |||
| 5 | /* | ||
| 6 | * We can't test C++ in unit tests. In order to intercept abort, use a secret | ||
| 7 | * safety check abort hook in integration tests. | ||
| 8 | */ | ||
| 9 | typedef void (*abort_hook_t)(const char *message); | ||
| 10 | bool fake_abort_called; | ||
| 11 | void fake_abort(const char *message) { | ||
| 12 | if (strcmp(message, "<jemalloc>: Allocation failed and " | ||
| 13 | "opt.experimental_infallible_new is true. Aborting.\n") != 0) { | ||
| 14 | abort(); | ||
| 15 | } | ||
| 16 | fake_abort_called = true; | ||
| 17 | } | ||
| 18 | |||
| 19 | static bool | ||
| 20 | own_operator_new(void) { | ||
| 21 | uint64_t before, after; | ||
| 22 | size_t sz = sizeof(before); | ||
| 23 | |||
| 24 | /* thread.allocated is always available, even w/o config_stats. */ | ||
| 25 | expect_d_eq(mallctl("thread.allocated", (void *)&before, &sz, NULL, 0), | ||
| 26 | 0, "Unexpected mallctl failure reading stats"); | ||
| 27 | void *volatile ptr = ::operator new((size_t)8); | ||
| 28 | expect_ptr_not_null(ptr, "Unexpected allocation failure"); | ||
| 29 | expect_d_eq(mallctl("thread.allocated", (void *)&after, &sz, NULL, 0), | ||
| 30 | 0, "Unexpected mallctl failure reading stats"); | ||
| 31 | |||
| 32 | return (after != before); | ||
| 33 | } | ||
| 34 | |||
| 35 | TEST_BEGIN(test_failing_alloc) { | ||
| 36 | abort_hook_t abort_hook = &fake_abort; | ||
| 37 | expect_d_eq(mallctl("experimental.hooks.safety_check_abort", NULL, NULL, | ||
| 38 | (void *)&abort_hook, sizeof(abort_hook)), 0, | ||
| 39 | "Unexpected mallctl failure setting abort hook"); | ||
| 40 | |||
| 41 | /* | ||
| 42 | * Not owning operator new is only expected to happen on MinGW which | ||
| 43 | * does not support operator new / delete replacement. | ||
| 44 | */ | ||
| 45 | #ifdef _WIN32 | ||
| 46 | test_skip_if(!own_operator_new()); | ||
| 47 | #else | ||
| 48 | expect_true(own_operator_new(), "No operator new overload"); | ||
| 49 | #endif | ||
| 50 | void *volatile ptr = (void *)1; | ||
| 51 | try { | ||
| 52 | /* Too big of an allocation to succeed. */ | ||
| 53 | ptr = ::operator new((size_t)-1); | ||
| 54 | } catch (...) { | ||
| 55 | abort(); | ||
| 56 | } | ||
| 57 | expect_ptr_null(ptr, "Allocation should have failed"); | ||
| 58 | expect_b_eq(fake_abort_called, true, "Abort hook not invoked"); | ||
| 59 | } | ||
| 60 | TEST_END | ||
| 61 | |||
| 62 | int | ||
| 63 | main(void) { | ||
| 64 | return test( | ||
| 65 | test_failing_alloc); | ||
| 66 | } | ||
| 67 | |||
diff --git a/examples/redis-unstable/deps/jemalloc/test/integration/cpp/infallible_new_true.sh b/examples/redis-unstable/deps/jemalloc/test/integration/cpp/infallible_new_true.sh deleted file mode 100644 index 4a0ff54..0000000 --- a/examples/redis-unstable/deps/jemalloc/test/integration/cpp/infallible_new_true.sh +++ /dev/null | |||
| @@ -1,8 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | XMALLOC_STR="" | ||
| 4 | if [ "x${enable_xmalloc}" = "x1" ] ; then | ||
| 5 | XMALLOC_STR="xmalloc:false," | ||
| 6 | fi | ||
| 7 | |||
| 8 | export MALLOC_CONF="${XMALLOC_STR}experimental_infallible_new:true" | ||
