adding TEST_FAIL() for TU_ASSERT()

This commit is contained in:
hathach 2019-11-01 17:50:40 +07:00
parent ab84731f2a
commit 5b68cc91ad
No known key found for this signature in database
GPG Key ID: 2FA891220FBFD581
2 changed files with 15 additions and 4 deletions

View File

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

View File

@ -26,6 +26,9 @@
#ifndef _TUSB_CONFIG_H_
#define _TUSB_CONFIG_H_
// testing framework
#include "unity.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -49,7 +52,7 @@
#define CFG_TUSB_OS OPT_OS_NONE
// 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.
* Tinyusb use follows macros to declare transferring memory so that they can be put