test_app_main.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: CC0-1.0
  5. */
  6. #include "unity.h"
  7. #include "unity_test_runner.h"
  8. #include "unity_test_utils_memory.h"
  9. #include "freertos/FreeRTOS.h"
  10. #include "freertos/task.h"
  11. #include "test_usb_common.h"
  12. #include "test_usb_mock_msc.h"
  13. #include "usb/usb_host.h"
  14. void setUp(void)
  15. {
  16. mock_msc_scsi_init_reference_descriptors();
  17. unity_utils_record_free_mem();
  18. test_usb_init_phy(); //Initialize the internal USB PHY and USB Controller for testing
  19. //Install USB Host
  20. usb_host_config_t host_config = {
  21. .skip_phy_setup = true, //test_usb_init_phy() will already have setup the internal USB PHY for us
  22. .intr_flags = ESP_INTR_FLAG_LEVEL1,
  23. };
  24. ESP_ERROR_CHECK(usb_host_install(&host_config));
  25. printf("USB Host installed\n");
  26. }
  27. void tearDown(void)
  28. {
  29. //Short delay to allow task to be cleaned up
  30. vTaskDelay(10);
  31. //Clean up USB Host
  32. ESP_ERROR_CHECK(usb_host_uninstall());
  33. test_usb_deinit_phy(); //Deinitialize the internal USB PHY after testing
  34. unity_utils_evaluate_leaks();
  35. }
  36. void app_main(void)
  37. {
  38. // ____ ___ ___________________ __ __
  39. // | | \/ _____/\______ \ _/ |_ ____ _______/ |_
  40. // | | /\_____ \ | | _/ \ __\/ __ \ / ___/\ __\.
  41. // | | / / \ | | \ | | \ ___/ \___ \ | |
  42. // |______/ /_______ / |______ / |__| \___ >____ > |__|
  43. // \/ \/ \/ \/
  44. printf(" ____ ___ ___________________ __ __ \r\n");
  45. printf("| | \\/ _____/\\______ \\ _/ |_ ____ _______/ |_ \r\n");
  46. printf("| | /\\_____ \\ | | _/ \\ __\\/ __ \\ / ___/\\ __\\\r\n");
  47. printf("| | / / \\ | | \\ | | \\ ___/ \\___ \\ | | \r\n");
  48. printf("|______/ /_______ / |______ / |__| \\___ >____ > |__| \r\n");
  49. printf(" \\/ \\/ \\/ \\/ \r\n");
  50. unity_utils_setup_heap_record(80);
  51. unity_utils_set_leak_level(128);
  52. unity_run_menu();
  53. }