From 16665672a45c4f85cb2e1a47873825f2b48fcf1a Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 30 Oct 2019 12:24:07 +0700 Subject: [PATCH] initally adding test_usbd.c --- src/device/dcd.h | 2 +- test/project.yml | 5 ++- test/test/support/tusb_config.h | 11 +++--- test/test/test_usbd.c | 68 +++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 test/test/test_usbd.c diff --git a/src/device/dcd.h b/src/device/dcd.h index 444b4a6f..9fa98c66 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -124,7 +124,7 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr); //--------------------------------------------------------------------+ // Called by DCD to notify device stack -void dcd_event_handler(dcd_event_t const * event, bool in_isr); +extern void dcd_event_handler(dcd_event_t const * event, bool in_isr); // helper to send bus signal event static inline void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr); diff --git a/test/project.yml b/test/project.yml index 403aa011..cf29c3b0 100644 --- a/test/project.yml +++ b/test/project.yml @@ -9,6 +9,7 @@ :use_exceptions: TRUE :use_test_preprocessor: TRUE :use_auxiliary_dependencies: TRUE + :use_deep_dependencies: TRUE :build_root: _build # :release_build: TRUE :test_file_prefix: test_ @@ -41,10 +42,10 @@ :commmon: &common_defines [] :test: - *common_defines - - TEST + - _TEST_ :test_preprocess: - *common_defines - - TEST + - _TEST_ :cmock: :mock_prefix: mock_ diff --git a/test/test/support/tusb_config.h b/test/test/support/tusb_config.h index b82a09a2..bfe5bf9e 100644 --- a/test/test/support/tusb_config.h +++ b/test/test/support/tusb_config.h @@ -73,12 +73,11 @@ #define CFG_TUD_ENDOINT0_SIZE 64 //------------- CLASS -------------// -#define CFG_TUD_CDC 1 -#define CFG_TUD_MSC 1 -#define CFG_TUD_HID 1 - -#define CFG_TUD_MIDI 1 -#define CFG_TUD_VENDOR 1 +#define CFG_TUD_CDC 0 +#define CFG_TUD_MSC 0 +#define CFG_TUD_HID 0 +#define CFG_TUD_MIDI 0 +#define CFG_TUD_VENDOR 0 //------------- CDC -------------// diff --git a/test/test/test_usbd.c b/test/test/test_usbd.c new file mode 100644 index 00000000..8c29ee85 --- /dev/null +++ b/test/test/test_usbd.c @@ -0,0 +1,68 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2019 hathach for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "unity.h" + +// Files to test +#include "tusb_fifo.h" +#include "tusb.h" +#include "usbd.h" +TEST_FILE("usbd_control.c") + +// Mock File +#include "mock_dcd.h" + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM DECLARATION +//--------------------------------------------------------------------+ + +uint8_t const * tud_descriptor_device_cb(void) +{ + return NULL; +} + +uint8_t const * tud_descriptor_configuration_cb(uint8_t index) +{ + return NULL; +} + +uint16_t const* tud_descriptor_string_cb(uint8_t index) +{ + return NULL; +} + +//------------- IMPLEMENTATION -------------// +void setUp(void) +{ + +} + +void tearDown(void) +{ +} + +void test_ok(void) +{ + +}