diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-01-21 22:52:54 +0100 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-01-21 22:52:54 +0100 |
| commit | dcacc00e3750300617ba6e16eb346713f91a783a (patch) | |
| tree | 38e2d4fb5ed9d119711d4295c6eda4b014af73fd /examples/redis-unstable/deps/jemalloc/test/unit/size_check.c | |
| parent | 58dac10aeb8f5a041c46bddbeaf4c7966a99b998 (diff) | |
| download | crep-dcacc00e3750300617ba6e16eb346713f91a783a.tar.gz | |
Remove testing data
Diffstat (limited to 'examples/redis-unstable/deps/jemalloc/test/unit/size_check.c')
| -rw-r--r-- | examples/redis-unstable/deps/jemalloc/test/unit/size_check.c | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/examples/redis-unstable/deps/jemalloc/test/unit/size_check.c b/examples/redis-unstable/deps/jemalloc/test/unit/size_check.c deleted file mode 100644 index accdc40..0000000 --- a/examples/redis-unstable/deps/jemalloc/test/unit/size_check.c +++ /dev/null | |||
| @@ -1,79 +0,0 @@ | |||
| 1 | #include "test/jemalloc_test.h" | ||
| 2 | |||
| 3 | #include "jemalloc/internal/safety_check.h" | ||
| 4 | |||
| 5 | bool fake_abort_called; | ||
| 6 | void fake_abort(const char *message) { | ||
| 7 | (void)message; | ||
| 8 | fake_abort_called = true; | ||
| 9 | } | ||
| 10 | |||
| 11 | #define SMALL_SIZE1 SC_SMALL_MAXCLASS | ||
| 12 | #define SMALL_SIZE2 (SC_SMALL_MAXCLASS / 2) | ||
| 13 | |||
| 14 | #define LARGE_SIZE1 SC_LARGE_MINCLASS | ||
| 15 | #define LARGE_SIZE2 (LARGE_SIZE1 * 2) | ||
| 16 | |||
| 17 | void * | ||
| 18 | test_invalid_size_pre(size_t sz) { | ||
| 19 | safety_check_set_abort(&fake_abort); | ||
| 20 | |||
| 21 | fake_abort_called = false; | ||
| 22 | void *ptr = malloc(sz); | ||
| 23 | assert_ptr_not_null(ptr, "Unexpected failure"); | ||
| 24 | |||
| 25 | return ptr; | ||
| 26 | } | ||
| 27 | |||
| 28 | void | ||
| 29 | test_invalid_size_post(void) { | ||
| 30 | expect_true(fake_abort_called, "Safety check didn't fire"); | ||
| 31 | safety_check_set_abort(NULL); | ||
| 32 | } | ||
| 33 | |||
| 34 | TEST_BEGIN(test_invalid_size_sdallocx) { | ||
| 35 | test_skip_if(!config_opt_size_checks); | ||
| 36 | |||
| 37 | void *ptr = test_invalid_size_pre(SMALL_SIZE1); | ||
| 38 | sdallocx(ptr, SMALL_SIZE2, 0); | ||
| 39 | test_invalid_size_post(); | ||
| 40 | |||
| 41 | ptr = test_invalid_size_pre(LARGE_SIZE1); | ||
| 42 | sdallocx(ptr, LARGE_SIZE2, 0); | ||
| 43 | test_invalid_size_post(); | ||
| 44 | } | ||
| 45 | TEST_END | ||
| 46 | |||
| 47 | TEST_BEGIN(test_invalid_size_sdallocx_nonzero_flag) { | ||
| 48 | test_skip_if(!config_opt_size_checks); | ||
| 49 | |||
| 50 | void *ptr = test_invalid_size_pre(SMALL_SIZE1); | ||
| 51 | sdallocx(ptr, SMALL_SIZE2, MALLOCX_TCACHE_NONE); | ||
| 52 | test_invalid_size_post(); | ||
| 53 | |||
| 54 | ptr = test_invalid_size_pre(LARGE_SIZE1); | ||
| 55 | sdallocx(ptr, LARGE_SIZE2, MALLOCX_TCACHE_NONE); | ||
| 56 | test_invalid_size_post(); | ||
| 57 | } | ||
| 58 | TEST_END | ||
| 59 | |||
| 60 | TEST_BEGIN(test_invalid_size_sdallocx_noflags) { | ||
| 61 | test_skip_if(!config_opt_size_checks); | ||
| 62 | |||
| 63 | void *ptr = test_invalid_size_pre(SMALL_SIZE1); | ||
| 64 | je_sdallocx_noflags(ptr, SMALL_SIZE2); | ||
| 65 | test_invalid_size_post(); | ||
| 66 | |||
| 67 | ptr = test_invalid_size_pre(LARGE_SIZE1); | ||
| 68 | je_sdallocx_noflags(ptr, LARGE_SIZE2); | ||
| 69 | test_invalid_size_post(); | ||
| 70 | } | ||
| 71 | TEST_END | ||
| 72 | |||
| 73 | int | ||
| 74 | main(void) { | ||
| 75 | return test( | ||
| 76 | test_invalid_size_sdallocx, | ||
| 77 | test_invalid_size_sdallocx_nonzero_flag, | ||
| 78 | test_invalid_size_sdallocx_noflags); | ||
| 79 | } | ||
