Newer
Older
libkc / modules / test / src / ut.h
Nomura Kei on 29 May 2024 1 KB update
  1. #ifndef UT_H
  2. #define UT_H
  3.  
  4. #include <kc.h>
  5. #include <kc_memory_entry.h>
  6.  
  7. extern void suite_assert(void);
  8. extern void suite_dl(void);
  9. extern void suite_env(void);
  10. extern void suite_list_array(void);
  11. extern void suite_list_linked(void);
  12. extern void suite_lock_guard(void);
  13. extern void suite_map(void);
  14. extern void suite_memory_dump(void);
  15. extern void suite_memory_entry(void);
  16. extern void suite_memory_listener(void);
  17. extern void suite_memory_mark(void);
  18. extern void suite_memory(void);
  19. extern void suite_queue(void);
  20. extern void suite_socket(void);
  21. extern void suite_thread(void);
  22.  
  23. ////////////////////////////////////////////////////////////////////////////////
  24. //
  25. // 以下、メモリ管理操作用
  26. //
  27.  
  28. extern bool (*_UT_KcMemory_can_alloc)(
  29. KcMemoryEntry *entry, size_t alignment, size_t size,
  30. KcMemoryMark mark, const char *file, const char *func, int line);
  31.  
  32. typedef bool (*UT_KcMemory_can_alloc_func)(
  33. KcMemoryEntry *entry, size_t alignment, size_t size,
  34. KcMemoryMark mark, const char *file, const char *func, int line);
  35.  
  36. UT_KcMemory_can_alloc_func _ut_can_alloc_func(int counter);
  37.  
  38. /**
  39. * ut_alloc_control(0)
  40. * {
  41. * // メモリ確保失敗させたい処理
  42. * }
  43. *
  44. * ut_alloc_control(1)
  45. * {
  46. * // 2回目にメモリ確保失敗させたい処理
  47. * }
  48. */
  49. #define ut_alloc_control(counter) \
  50. for (_UT_KcMemory_can_alloc = _ut_can_alloc_func(counter); _UT_KcMemory_can_alloc != NULL; _UT_KcMemory_can_alloc = NULL)
  51.  
  52. #endif // UT_H