summaryrefslogtreecommitdiff
path: root/examples/redis-unstable/deps/jemalloc/test/unit/prof_tctx.c
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-01-21 22:40:55 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-01-21 22:40:55 +0100
commit5d8dfe892a2ea89f706ee140c3bdcfd89fe03fda (patch)
tree1acdfa5220cd13b7be43a2a01368e80d306473ca /examples/redis-unstable/deps/jemalloc/test/unit/prof_tctx.c
parentc7ab12bba64d9c20ccd79b132dac475f7bc3923e (diff)
downloadcrep-5d8dfe892a2ea89f706ee140c3bdcfd89fe03fda.tar.gz
Add Redis source code for testing
Diffstat (limited to 'examples/redis-unstable/deps/jemalloc/test/unit/prof_tctx.c')
-rw-r--r--examples/redis-unstable/deps/jemalloc/test/unit/prof_tctx.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/examples/redis-unstable/deps/jemalloc/test/unit/prof_tctx.c b/examples/redis-unstable/deps/jemalloc/test/unit/prof_tctx.c
new file mode 100644
index 0000000..e0efdc3
--- /dev/null
+++ b/examples/redis-unstable/deps/jemalloc/test/unit/prof_tctx.c
@@ -0,0 +1,48 @@
1#include "test/jemalloc_test.h"
2
3#include "jemalloc/internal/prof_data.h"
4
5TEST_BEGIN(test_prof_realloc) {
6 tsd_t *tsd;
7 int flags;
8 void *p, *q;
9 prof_info_t prof_info_p, prof_info_q;
10 prof_cnt_t cnt_0, cnt_1, cnt_2, cnt_3;
11
12 test_skip_if(!config_prof);
13
14 tsd = tsd_fetch();
15 flags = MALLOCX_TCACHE_NONE;
16
17 prof_cnt_all(&cnt_0);
18 p = mallocx(1024, flags);
19 expect_ptr_not_null(p, "Unexpected mallocx() failure");
20 prof_info_get(tsd, p, NULL, &prof_info_p);
21 expect_ptr_ne(prof_info_p.alloc_tctx, (prof_tctx_t *)(uintptr_t)1U,
22 "Expected valid tctx");
23 prof_cnt_all(&cnt_1);
24 expect_u64_eq(cnt_0.curobjs + 1, cnt_1.curobjs,
25 "Allocation should have increased sample size");
26
27 q = rallocx(p, 2048, flags);
28 expect_ptr_ne(p, q, "Expected move");
29 expect_ptr_not_null(p, "Unexpected rmallocx() failure");
30 prof_info_get(tsd, q, NULL, &prof_info_q);
31 expect_ptr_ne(prof_info_q.alloc_tctx, (prof_tctx_t *)(uintptr_t)1U,
32 "Expected valid tctx");
33 prof_cnt_all(&cnt_2);
34 expect_u64_eq(cnt_1.curobjs, cnt_2.curobjs,
35 "Reallocation should not have changed sample size");
36
37 dallocx(q, flags);
38 prof_cnt_all(&cnt_3);
39 expect_u64_eq(cnt_0.curobjs, cnt_3.curobjs,
40 "Sample size should have returned to base level");
41}
42TEST_END
43
44int
45main(void) {
46 return test_no_reentrancy(
47 test_prof_realloc);
48}