GCC Code Coverage Report


Directory: ./
File: test/unit-tests/stubs/freertos/timers.h
Date: 2025-12-16 19:41:02
Exec Total Coverage
Lines: 12 18 66.7%
Functions: 4 7 57.1%
Branches: 2 6 33.3%

Line Branch Exec Source
1 #pragma once
2
3 #include "freertos/FreeRTOS.h"
4 #include <cstddef>
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 typedef struct TimerStub {
11 void* id;
12 TickType_t period_ticks;
13 BaseType_t auto_reload;
14 }* TimerHandle_t;
15
16 typedef void (*TimerCallbackFunction_t)(TimerHandle_t xTimer);
17
18 18 static inline TimerHandle_t xTimerCreate(const char* /*pcTimerName*/, TickType_t xTimerPeriodInTicks,
19 BaseType_t uxAutoReload, void* pvTimerID,
20 TimerCallbackFunction_t /*pxCallbackFunction*/) {
21 18 TimerHandle_t h = new TimerStub{pvTimerID, xTimerPeriodInTicks, uxAutoReload};
22 18 return h;
23 }
24
25 static inline void vTimerSetTimerID(TimerHandle_t xTimer, void* id) {
26 if (xTimer)
27 xTimer->id = id;
28 }
29
30 ✗ static inline void* pvTimerGetTimerID(TimerHandle_t xTimer) {
31 ✗ return xTimer ? xTimer->id : nullptr;
32 }
33
34 18 static inline BaseType_t xTimerDelete(TimerHandle_t xTimer, TickType_t /*xTicksToWait*/) {
35
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 delete xTimer;
36 18 return pdPASS;
37 }
38
39 10 static inline BaseType_t xTimerReset(TimerHandle_t /*xTimer*/, TickType_t /*xTicksToWait*/) {
40 10 return pdPASS;
41 }
42
43 ✗ static inline BaseType_t xTimerStop(TimerHandle_t /*xTimer*/, TickType_t /*xTicksToWait*/) {
44 ✗ return pdPASS;
45 }
46
47 ✗ static inline BaseType_t xTimerIsTimerActive(TimerHandle_t xTimer) {
48 // In host stubs, we just return false (timer not active)
49 ✗ return xTimer ? pdFALSE : pdFALSE;
50 }
51
52 4 static inline BaseType_t xTimerChangePeriod(TimerHandle_t xTimer, TickType_t xNewPeriod, TickType_t /*xTicksToWait*/) {
53
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (xTimer) {
54 4 xTimer->period_ticks = xNewPeriod;
55 }
56 4 return pdPASS;
57 }
58
59 #ifdef __cplusplus
60 }
61 #endif
62