adding TEST_FAIL() for TU_ASSERT()

This commit is contained in:
hathach
2019-11-01 17:50:40 +07:00
parent ab84731f2a
commit 5b68cc91ad
2 changed files with 15 additions and 4 deletions

View File

@@ -73,13 +73,21 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// TU_VERIFY Helper // TU_VERIFY Helper
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Running unit tests
#ifdef _UNITY_TEST_
#define _TEST_FAILED() TEST_FAIL();
#else
#define _TEST_FAILED()
#endif
#if CFG_TUSB_DEBUG #if CFG_TUSB_DEBUG
#include <stdio.h> #include <stdio.h>
#define _MESS_ERR(_err) printf("%s: %d: failed, error = %s\n", __func__, __LINE__, tusb_strerr[_err]) #define _MESS_ERR(_err) printf("%s %d: failed, error = %s\n", __func__, __LINE__, tusb_strerr[_err])
#define _MESS_FAILED() printf("%s: %d: failed\n", __func__, __LINE__) #define _MESS_FAILED() do { printf("%s %d: assert failed\n", __func__, __LINE__); _TEST_FAILED() } while(0)
#else #else
#define _MESS_ERR(_err) #define _MESS_ERR(_err)
#define _MESS_FAILED() #define _MESS_FAILED() _TEST_FAILED()
#endif #endif
// Halt CPU (breakpoint) when hitting error, only apply for Cortex M3, M4, M7 // Halt CPU (breakpoint) when hitting error, only apply for Cortex M3, M4, M7

View File

@@ -26,6 +26,9 @@
#ifndef _TUSB_CONFIG_H_ #ifndef _TUSB_CONFIG_H_
#define _TUSB_CONFIG_H_ #define _TUSB_CONFIG_H_
// testing framework
#include "unity.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@@ -49,7 +52,7 @@
#define CFG_TUSB_OS OPT_OS_NONE #define CFG_TUSB_OS OPT_OS_NONE
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build // CFG_TUSB_DEBUG is defined by compiler in DEBUG build
// #define CFG_TUSB_DEBUG 0 #define CFG_TUSB_DEBUG 0
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment. /* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
* Tinyusb use follows macros to declare transferring memory so that they can be put * Tinyusb use follows macros to declare transferring memory so that they can be put