Skip to content

Commit

Permalink
ci(usb_host): Run class driver test apps on esp32p4
Browse files Browse the repository at this point in the history
    - Enabled drivers CDC-ACM, HID, MSC, UVC
    - Added new usb_host esp32p4 CI runner
  • Loading branch information
peter-marcisovsky authored and tore-espressif committed Dec 2, 2024
1 parent 5459ee9 commit c7e81e2
Show file tree
Hide file tree
Showing 20 changed files with 392 additions and 550 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/build_and_run_test_app_usb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ jobs:
fail-fast: false
matrix:
idf_ver: ["release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3", "release-v5.4", "latest"]
idf_target: ["esp32s2"]
idf_target: ["esp32s2", "esp32p4"]
runner_tag: ["usb_host", "usb_device"]
exclude:
- idf_ver: "release-v5.0" # esp32p4 was added in IDF 5.3
idf_target: "esp32p4"
- idf_ver: "release-v5.1" # esp32p4 was added in IDF 5.3
idf_target: "esp32p4"
- idf_ver: "release-v5.2" # esp32p4 was added in IDF 5.3
idf_target: "esp32p4"
runs-on: [self-hosted, linux, docker, "${{ matrix.idf_target }}", "${{ matrix.runner_tag }}"]
container:
image: python:3.11-bookworm
Expand Down
3 changes: 3 additions & 0 deletions host/class/cdc/usb_host_cdc_acm/test_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ It tests basic functionality of the driver like open/close/read/write operations

### Hardware Required

This test requires two ESP32 development board with USB-OTG support. The development boards shall have interconnected USB peripherals,
one acting as host running CDC-ACM host driver and another CDC-ACM device driver (tinyusb).

This test expects that TinyUSB dual CDC device with VID = 0x303A and PID = 0x4002 is connected to the USB host.
40 changes: 13 additions & 27 deletions host/class/cdc/usb_host_cdc_acm/test_app/main/test_app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
#include <stdio.h>
#include <string.h>
#include "unity.h"
#include "esp_heap_caps.h"
#include "unity_test_runner.h"
#include "unity_test_utils_memory.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "usb/cdc_acm_host.h"

static size_t before_free_8bit;
static size_t before_free_32bit;

#define TEST_MEMORY_LEAK_THRESHOLD (-530)
static void check_leak(size_t before_free, size_t after_free, const char *type)
void tearDown(void)
{
ssize_t delta = after_free - before_free;
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta);
TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak");
// Clean-up
ESP_ERROR_CHECK(cdc_acm_host_uninstall());
vTaskDelay(20); // Short delay to allow task to be cleaned up

unity_utils_evaluate_leaks();
}

void app_main(void)
Expand All @@ -35,23 +37,7 @@ void app_main(void)
printf("|______/ /_______ / |______ / |__| \\___ >____ > |__| \r\n");
printf(" \\/ \\/ \\/ \\/ \r\n");

UNITY_BEGIN();
unity_utils_setup_heap_record(80);
unity_utils_set_leak_level(530);
unity_run_menu();
UNITY_END();
}

/* setUp runs before every test */
void setUp(void)
{
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
}

/* tearDown runs after every test */
void tearDown(void)
{
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
check_leak(before_free_8bit, after_free_8bit, "8BIT");
check_leak(before_free_32bit, after_free_32bit, "32BIT");
}
Loading

0 comments on commit c7e81e2

Please sign in to comment.