2
0

prof_idump.c 969 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "test/jemalloc_test.h"
  2. #ifdef JEMALLOC_PROF
  3. const char *malloc_conf =
  4. "prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0,"
  5. "lg_prof_interval:0";
  6. #endif
  7. static bool did_prof_dump_open;
  8. static int
  9. prof_dump_open_intercept(bool propagate_err, const char *filename)
  10. {
  11. int fd;
  12. did_prof_dump_open = true;
  13. fd = open("/dev/null", O_WRONLY);
  14. assert_d_ne(fd, -1, "Unexpected open() failure");
  15. return (fd);
  16. }
  17. TEST_BEGIN(test_idump)
  18. {
  19. bool active;
  20. void *p;
  21. test_skip_if(!config_prof);
  22. active = true;
  23. assert_d_eq(mallctl("prof.active", NULL, NULL, &active, sizeof(active)),
  24. 0, "Unexpected mallctl failure while activating profiling");
  25. prof_dump_open = prof_dump_open_intercept;
  26. did_prof_dump_open = false;
  27. p = mallocx(1, 0);
  28. assert_ptr_not_null(p, "Unexpected mallocx() failure");
  29. dallocx(p, 0);
  30. assert_true(did_prof_dump_open, "Expected a profile dump");
  31. }
  32. TEST_END
  33. int
  34. main(void)
  35. {
  36. return (test(
  37. test_idump));
  38. }