summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-11-01 17:50:40 +0700
committerhathach <[email protected]>2019-11-01 17:50:40 +0700
commit5b68cc91ad5059c595536016c19a914af6928296 (patch)
tree916f581360403c826927af1394abd9fa923c4634
parentab84731f2afeea4b9e56020a7657697cceac9bbf (diff)
adding TEST_FAIL() for TU_ASSERT()
-rw-r--r--src/common/tusb_verify.h14
-rw-r--r--test/test/support/tusb_config.h5
2 files changed, 15 insertions, 4 deletions
diff --git a/src/common/tusb_verify.h b/src/common/tusb_verify.h
index e59481352..5ae3afc95 100644
--- a/src/common/tusb_verify.h
+++ b/src/common/tusb_verify.h
@@ -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
diff --git a/test/test/support/tusb_config.h b/test/test/support/tusb_config.h
index b75b76678..c745320da 100644
--- a/test/test/support/tusb_config.h
+++ b/test/test/support/tusb_config.h
@@ -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