test_event_main.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "unity.h"
  7. #include "unity_test_runner.h"
  8. #include "unity_test_utils_memory.h"
  9. #include "esp_log.h"
  10. #ifdef CONFIG_HEAP_TRACING
  11. #include "memory_checks.h"
  12. #include "esp_heap_trace.h"
  13. #endif
  14. static const char* TAG = "event_test_app";
  15. void setUp(void)
  16. {
  17. // If heap tracing is enabled in kconfig, leak trace the test
  18. #ifdef CONFIG_HEAP_TRACING
  19. setup_heap_record();
  20. heap_trace_start(HEAP_TRACE_LEAKS);
  21. #endif
  22. unity_utils_set_leak_level(0);
  23. unity_utils_record_free_mem();
  24. }
  25. void tearDown(void)
  26. {
  27. #ifdef CONFIG_HEAP_TRACING
  28. heap_trace_stop();
  29. heap_trace_dump();
  30. #endif
  31. unity_utils_evaluate_leaks();
  32. }
  33. void app_main(void)
  34. {
  35. ESP_LOGI(TAG, "Running esp-event test app");
  36. // rand() seems to do a one-time allocation. Call it here so that the memory it allocates
  37. // is not counted as a leak.
  38. unsigned int _rand __attribute__((unused)) = rand();
  39. unity_run_menu();
  40. }