mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
refactor(ble_log): remove obsolete unit test hooks
This commit is contained in:
@@ -43,9 +43,7 @@ BLE_LOG_STATIC void ble_log_rt_task(void *pvParameters)
|
|||||||
ble_log_prph_trans_t *trans = NULL;
|
ble_log_prph_trans_t *trans = NULL;
|
||||||
uint32_t curr_os_ts = 0;
|
uint32_t curr_os_ts = 0;
|
||||||
uint32_t last_hook_os_ts = 0;
|
uint32_t last_hook_os_ts = 0;
|
||||||
#ifndef UNIT_TEST
|
|
||||||
while (1)
|
while (1)
|
||||||
#endif /* !UNIT_TEST */
|
|
||||||
{
|
{
|
||||||
/* CRITICAL:
|
/* CRITICAL:
|
||||||
* Blocking queue receive is mandatory for light sleep support */
|
* Blocking queue receive is mandatory for light sleep support */
|
||||||
@@ -56,11 +54,7 @@ BLE_LOG_STATIC void ble_log_rt_task(void *pvParameters)
|
|||||||
/* Task hook */
|
/* Task hook */
|
||||||
curr_os_ts = pdTICKS_TO_MS(xTaskGetTickCount());
|
curr_os_ts = pdTICKS_TO_MS(xTaskGetTickCount());
|
||||||
if ((curr_os_ts - last_hook_os_ts) < BLE_LOG_TASK_HOOK_TIMEOUT_MS) {
|
if ((curr_os_ts - last_hook_os_ts) < BLE_LOG_TASK_HOOK_TIMEOUT_MS) {
|
||||||
#ifndef UNIT_TEST
|
|
||||||
continue;
|
continue;
|
||||||
#else /* UNIT_TEST */
|
|
||||||
return;
|
|
||||||
#endif /* !UNIT_TEST */
|
|
||||||
}
|
}
|
||||||
last_hook_os_ts = curr_os_ts;
|
last_hook_os_ts = curr_os_ts;
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,7 @@
|
|||||||
#define BLE_LOG_REF_COUNT_WAIT_TIMEOUT_MS (1000)
|
#define BLE_LOG_REF_COUNT_WAIT_TIMEOUT_MS (1000)
|
||||||
|
|
||||||
/* VARIABLE */
|
/* VARIABLE */
|
||||||
#ifndef UNIT_TEST
|
|
||||||
BLE_LOG_DRAM_ATTR portMUX_TYPE ble_log_spin_lock = portMUX_INITIALIZER_UNLOCKED;
|
BLE_LOG_DRAM_ATTR portMUX_TYPE ble_log_spin_lock = portMUX_INITIALIZER_UNLOCKED;
|
||||||
#endif /* !UNIT_TEST */
|
|
||||||
|
|
||||||
/* INTERNAL INTERFACE */
|
/* INTERNAL INTERFACE */
|
||||||
#include "esp_compiler.h"
|
#include "esp_compiler.h"
|
||||||
|
|||||||
@@ -19,10 +19,8 @@
|
|||||||
#include "esp_bit_defs.h"
|
#include "esp_bit_defs.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
|
|
||||||
#ifndef UNIT_TEST
|
|
||||||
#include "esp_heap_caps.h"
|
#include "esp_heap_caps.h"
|
||||||
#include "esp_rom_serial_output.h"
|
#include "esp_rom_serial_output.h"
|
||||||
#endif /* !UNIT_TEST */
|
|
||||||
|
|
||||||
/* MACRO */
|
/* MACRO */
|
||||||
#define BLE_LOG_ATOMIC_LOAD_ACQUIRE(VAR) __atomic_load_n(&(VAR), __ATOMIC_ACQUIRE)
|
#define BLE_LOG_ATOMIC_LOAD_ACQUIRE(VAR) __atomic_load_n(&(VAR), __ATOMIC_ACQUIRE)
|
||||||
@@ -30,9 +28,6 @@
|
|||||||
#define BLE_LOG_ATOMIC_STORE_RELEASE(VAR, VALUE) __atomic_store_n(&(VAR), (VALUE), __ATOMIC_RELEASE)
|
#define BLE_LOG_ATOMIC_STORE_RELEASE(VAR, VALUE) __atomic_store_n(&(VAR), (VALUE), __ATOMIC_RELEASE)
|
||||||
#define BLE_LOG_ATOMIC_STORE_RELAXED(VAR, VALUE) __atomic_store_n(&(VAR), (VALUE), __ATOMIC_RELAXED)
|
#define BLE_LOG_ATOMIC_STORE_RELAXED(VAR, VALUE) __atomic_store_n(&(VAR), (VALUE), __ATOMIC_RELAXED)
|
||||||
|
|
||||||
/* Unit test */
|
|
||||||
#ifndef UNIT_TEST
|
|
||||||
|
|
||||||
/* Reference counting macros */
|
/* Reference counting macros */
|
||||||
#define BLE_LOG_REF_COUNT_ACQUIRE(VAR) __atomic_fetch_add(VAR, 1, __ATOMIC_ACQUIRE)
|
#define BLE_LOG_REF_COUNT_ACQUIRE(VAR) __atomic_fetch_add(VAR, 1, __ATOMIC_ACQUIRE)
|
||||||
#define BLE_LOG_REF_COUNT_RELEASE(VAR) __atomic_fetch_sub(VAR, 1, __ATOMIC_RELEASE)
|
#define BLE_LOG_REF_COUNT_RELEASE(VAR) __atomic_fetch_sub(VAR, 1, __ATOMIC_RELEASE)
|
||||||
@@ -96,64 +91,6 @@ void ble_log_cas_release(volatile bool *cas_lock)
|
|||||||
__atomic_store_n(cas_lock, false, __ATOMIC_RELEASE);
|
__atomic_store_n(cas_lock, false, __ATOMIC_RELEASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* UNIT_TEST */
|
|
||||||
|
|
||||||
/* Reference counting macros */
|
|
||||||
#define BLE_LOG_REF_COUNT_ACQUIRE(VAR) (*VAR)++
|
|
||||||
#define BLE_LOG_REF_COUNT_RELEASE(VAR) (*VAR)--
|
|
||||||
#define BLE_LOG_ATOMIC_LOAD_SEQ_CST(VAR) BLE_LOG_ATOMIC_LOAD_ACQUIRE(VAR)
|
|
||||||
#define BLE_LOG_ATOMIC_STORE_SEQ_CST(VAR, VALUE) BLE_LOG_ATOMIC_STORE_RELAXED(VAR, VALUE)
|
|
||||||
#define BLE_LOG_REF_COUNT_ACQUIRE_SEQ_CST(VAR) BLE_LOG_REF_COUNT_ACQUIRE(VAR)
|
|
||||||
|
|
||||||
/* Specifier*/
|
|
||||||
#define BLE_LOG_STATIC
|
|
||||||
#define BLE_LOG_INLINE
|
|
||||||
|
|
||||||
/* Section */
|
|
||||||
#define BLE_LOG_DRAM_ATTR
|
|
||||||
#define BLE_LOG_IRAM_ATTR
|
|
||||||
|
|
||||||
/* Memory operation */
|
|
||||||
void *mocked_malloc(size_t size);
|
|
||||||
void mocked_free(void *ptr);
|
|
||||||
void mocked_memcpy(void *dst, const void *src, size_t len);
|
|
||||||
void mocked_memset(void *ptr, int value, size_t len);
|
|
||||||
#define BLE_LOG_MALLOC(size) mocked_malloc(size)
|
|
||||||
#define BLE_LOG_FREE(ptr) mocked_free(ptr)
|
|
||||||
#define BLE_LOG_ALIGNED_MALLOC(size) mocked_malloc(size)
|
|
||||||
#define BLE_LOG_MEMCPY(dst, src, len) mocked_memcpy(dst, src, len)
|
|
||||||
#define BLE_LOG_MEMSET(ptr, value, len) mocked_memset(ptr, value, len)
|
|
||||||
|
|
||||||
/* Critical section wrapper */
|
|
||||||
void mocked_enter_critical(void);
|
|
||||||
void mocked_exit_critical(void);
|
|
||||||
#define BLE_LOG_ENTER_CRITICAL() mocked_enter_critical()
|
|
||||||
#define BLE_LOG_EXIT_CRITICAL() mocked_exit_critical()
|
|
||||||
|
|
||||||
/* FreeRTOS API wrapper */
|
|
||||||
bool mocked_in_isr(void);
|
|
||||||
#define BLE_LOG_IN_ISR() mocked_in_isr()
|
|
||||||
|
|
||||||
/* Spin lock wrapper */
|
|
||||||
void mocked_acquire_spin_lock(void *spin_lock);
|
|
||||||
void mocked_release_spin_lock(void *spin_lock);
|
|
||||||
#define BLE_LOG_ACQUIRE_SPIN_LOCK(spin_lock) mocked_acquire_spin_lock(spin_lock)
|
|
||||||
#define BLE_LOG_RELEASE_SPIN_LOCK(spin_lock) mocked_release_spin_lock(spin_lock)
|
|
||||||
|
|
||||||
/* Printf wrapper */
|
|
||||||
void mocked_printf(const char *fmt, ...);
|
|
||||||
#define BLE_LOG_CONSOLE mocked_printf
|
|
||||||
|
|
||||||
/* Assert wrapper */
|
|
||||||
void mocked_assert(bool expr);
|
|
||||||
#define BLE_LOG_ASSERT(expr) mocked_assert(expr)
|
|
||||||
|
|
||||||
#define BLE_LOG_FEED_WDT()
|
|
||||||
|
|
||||||
bool ble_log_cas_acquire(volatile bool *cas_lock);
|
|
||||||
void ble_log_cas_release(volatile bool *cas_lock);
|
|
||||||
#endif /* UNIT_TEST */
|
|
||||||
|
|
||||||
#define BLE_LOG_VERSION (5)
|
#define BLE_LOG_VERSION (5)
|
||||||
|
|
||||||
/* TYPEDEF */
|
/* TYPEDEF */
|
||||||
|
|||||||
Reference in New Issue
Block a user