diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-24 09:54:23 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-24 09:54:44 +0000 |
commit | 836b47cb7e99a977c5a23b059ca1d0b5065d310e (patch) | |
tree | 1604da8f482d02effa033c94a84be42bc0c848c3 /fluent-bit/lib/jemalloc-5.3.0/test/unit/mq.c | |
parent | Releasing debian version 1.44.3-2. (diff) | |
download | netdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.tar.xz netdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.zip |
Merging upstream version 1.46.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'fluent-bit/lib/jemalloc-5.3.0/test/unit/mq.c')
-rw-r--r-- | fluent-bit/lib/jemalloc-5.3.0/test/unit/mq.c | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/fluent-bit/lib/jemalloc-5.3.0/test/unit/mq.c b/fluent-bit/lib/jemalloc-5.3.0/test/unit/mq.c deleted file mode 100644 index f833f77ce..000000000 --- a/fluent-bit/lib/jemalloc-5.3.0/test/unit/mq.c +++ /dev/null @@ -1,89 +0,0 @@ -#include "test/jemalloc_test.h" - -#define NSENDERS 3 -#define NMSGS 100000 - -typedef struct mq_msg_s mq_msg_t; -struct mq_msg_s { - mq_msg(mq_msg_t) link; -}; -mq_gen(static, mq_, mq_t, mq_msg_t, link) - -TEST_BEGIN(test_mq_basic) { - mq_t mq; - mq_msg_t msg; - - expect_false(mq_init(&mq), "Unexpected mq_init() failure"); - expect_u_eq(mq_count(&mq), 0, "mq should be empty"); - expect_ptr_null(mq_tryget(&mq), - "mq_tryget() should fail when the queue is empty"); - - mq_put(&mq, &msg); - expect_u_eq(mq_count(&mq), 1, "mq should contain one message"); - expect_ptr_eq(mq_tryget(&mq), &msg, "mq_tryget() should return msg"); - - mq_put(&mq, &msg); - expect_ptr_eq(mq_get(&mq), &msg, "mq_get() should return msg"); - - mq_fini(&mq); -} -TEST_END - -static void * -thd_receiver_start(void *arg) { - mq_t *mq = (mq_t *)arg; - unsigned i; - - for (i = 0; i < (NSENDERS * NMSGS); i++) { - mq_msg_t *msg = mq_get(mq); - expect_ptr_not_null(msg, "mq_get() should never return NULL"); - dallocx(msg, 0); - } - return NULL; -} - -static void * -thd_sender_start(void *arg) { - mq_t *mq = (mq_t *)arg; - unsigned i; - - for (i = 0; i < NMSGS; i++) { - mq_msg_t *msg; - void *p; - p = mallocx(sizeof(mq_msg_t), 0); - expect_ptr_not_null(p, "Unexpected mallocx() failure"); - msg = (mq_msg_t *)p; - mq_put(mq, msg); - } - return NULL; -} - -TEST_BEGIN(test_mq_threaded) { - mq_t mq; - thd_t receiver; - thd_t senders[NSENDERS]; - unsigned i; - - expect_false(mq_init(&mq), "Unexpected mq_init() failure"); - - thd_create(&receiver, thd_receiver_start, (void *)&mq); - for (i = 0; i < NSENDERS; i++) { - thd_create(&senders[i], thd_sender_start, (void *)&mq); - } - - thd_join(receiver, NULL); - for (i = 0; i < NSENDERS; i++) { - thd_join(senders[i], NULL); - } - - mq_fini(&mq); -} -TEST_END - -int -main(void) { - return test( - test_mq_basic, - test_mq_threaded); -} - |