You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rspamd_mem_pool_test.c 972B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "config.h"
  2. #include "mem_pool.h"
  3. #include "tests.h"
  4. #include "unix-std.h"
  5. #include <math.h>
  6. #ifdef HAVE_SYS_WAIT_H
  7. #include <sys/wait.h>
  8. #endif
  9. #define TEST_BUF "test buffer"
  10. #define TEST2_BUF "test buffertest buffer"
  11. void rspamd_mem_pool_test_func(void)
  12. {
  13. rspamd_mempool_t *pool;
  14. rspamd_mempool_stat_t st;
  15. char *tmp, *tmp2, *tmp3;
  16. pool = rspamd_mempool_new(sizeof(TEST_BUF), NULL, 0);
  17. tmp = rspamd_mempool_alloc(pool, sizeof(TEST_BUF));
  18. tmp2 = rspamd_mempool_alloc(pool, sizeof(TEST_BUF) * 2);
  19. tmp3 = rspamd_mempool_alloc_shared(pool, sizeof(TEST_BUF));
  20. snprintf(tmp, sizeof(TEST_BUF), "%s", TEST_BUF);
  21. snprintf(tmp2, sizeof(TEST_BUF) * 2, "%s", TEST2_BUF);
  22. snprintf(tmp3, sizeof(TEST_BUF), "%s", TEST_BUF);
  23. g_assert(strncmp(tmp, TEST_BUF, sizeof(TEST_BUF)) == 0);
  24. g_assert(strncmp(tmp2, TEST2_BUF, sizeof(TEST2_BUF)) == 0);
  25. g_assert(strncmp(tmp3, TEST_BUF, sizeof(TEST_BUF)) == 0);
  26. rspamd_mempool_delete(pool);
  27. rspamd_mempool_stat(&st);
  28. }