GCC Code Coverage Report


Directory: ./
File: test/unit-tests/stubs/freertos/task.h
Date: 2025-12-16 19:41:02
Exec Total Coverage
Lines: 0 9 0.0%
Functions: 0 3 0.0%
Branches: 0 4 0.0%

Line Branch Exec Source
1 #pragma once
2
3 #include "freertos/FreeRTOS.h"
4
5 #include <stdint.h>
6
7 // C++ headers must be outside extern "C" block
8 #ifdef __cplusplus
9 #include <chrono>
10 #include <thread>
11 #endif
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 typedef void (*TaskFunction_t)(void*);
18
19 ✗ static inline BaseType_t xTaskCreate(TaskFunction_t pxTaskCode,
20 const char* /*pcName*/,
21 const uint32_t /*usStackDepth*/,
22 void* pvParameters,
23 UBaseType_t /*uxPriority*/,
24 TaskHandle_t* pxCreatedTask) {
25 // For host stubs, we do not create a real thread.
26 // Simulate successful creation and optionally run the function synchronously in tests that depend on it.
27 ✗ if (pxCreatedTask) {
28 ✗ *pxCreatedTask = (TaskHandle_t) 0x1; // non-null handle
29 }
30 // Do NOT run pxTaskCode here to avoid unexpected blocking in tests.
31 ✗ return pdPASS;
32 }
33
34 ✗ static inline void vTaskDelete(TaskHandle_t /*xTaskToDelete*/) {
35 // No-op in host stub
36 ✗ }
37
38 #ifdef __cplusplus
39 }
40 // vTaskDelay implementation needs C++ headers, so define outside extern "C"
41 ✗ static inline void vTaskDelay(const TickType_t xTicksToDelay) {
42 // Approximate: ticks map to milliseconds via pdMS_TO_TICKS in stubs
43 ✗ std::this_thread::sleep_for(std::chrono::milliseconds(xTicksToDelay));
44 ✗ }
45 extern "C" {
46 #endif
47
48 #ifdef __cplusplus
49 }
50 #endif
51