Skip to content

Commit 50fe8e0

Browse files
committed
Add automated test for the firmware subsystem
1 parent 112dc2d commit 50fe8e0

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/**
2+
* @file FirmwareRunTest.cpp
3+
*
4+
* @author Ángel Fernández Pineda. Madrid. Spain.
5+
* @date 2025-09-26
6+
* @brief Unit test
7+
*
8+
* @copyright Licensed under the EUPL
9+
*
10+
*/
11+
12+
#include "SimWheel.hpp"
13+
#include "SimWheelInternals.hpp"
14+
#include "InternalServices.hpp"
15+
#include <cassert>
16+
#include <iostream>
17+
18+
//------------------------------------------------------------------
19+
// Globals
20+
//------------------------------------------------------------------
21+
22+
bool customFirmwareReady = false;
23+
bool batteryMonitorReady = false;
24+
bool batteryCalibrationReady = false;
25+
bool pixelsReady = false;
26+
bool uiReady = false;
27+
bool inputsReady = false;
28+
bool inputHubReady = false;
29+
bool storageReady = false;
30+
bool inputMapReady = false;
31+
bool powerReady = false;
32+
bool hidCommonReady = false;
33+
bool started = false;
34+
35+
//------------------------------------------------------------------
36+
// Mocks
37+
//------------------------------------------------------------------
38+
39+
void customFirmware() { customFirmwareReady = true; }
40+
41+
void onStart() { started = true; }
42+
43+
void internals::batteryMonitor::getReady() { batteryMonitorReady = true; }
44+
45+
void internals::batteryCalibration::getReady() { batteryCalibrationReady = true; }
46+
47+
void internals::pixels::getReady() { pixelsReady = true; }
48+
49+
void internals::ui::getReady() { uiReady = true; }
50+
51+
void internals::inputs::getReady() { inputsReady = true; }
52+
53+
void internals::inputHub::getReady() { inputHubReady = true; }
54+
55+
void internals::storage::getReady() { storageReady = true; }
56+
57+
void internals::inputMap::getReady() { inputMapReady = true; }
58+
59+
void internals::power::getReady() { powerReady = true; }
60+
61+
void internals::hid::common::getReady() { hidCommonReady = true; }
62+
63+
//------------------------------------------------------------------
64+
//------------------------------------------------------------------
65+
// Entry point
66+
//------------------------------------------------------------------
67+
//------------------------------------------------------------------
68+
69+
int main()
70+
{
71+
// Check that this test initialization is good
72+
assert(!customFirmwareReady);
73+
assert(!batteryMonitorReady);
74+
assert(!batteryCalibrationReady);
75+
assert(!pixelsReady);
76+
assert(!uiReady);
77+
assert(!inputsReady);
78+
assert(!inputHubReady);
79+
assert(!storageReady);
80+
assert(!inputMapReady);
81+
assert(!powerReady);
82+
assert(!hidCommonReady);
83+
assert(!started);
84+
85+
// Check that the firmware is not running
86+
assert(!FirmwareService::call::isRunning());
87+
88+
// Start subsystems
89+
OnStart::subscribe(onStart);
90+
firmware::run(customFirmware);
91+
92+
// Check that all subsystems where initialized and started
93+
assert(customFirmwareReady);
94+
assert(batteryMonitorReady);
95+
assert(batteryCalibrationReady);
96+
assert(pixelsReady);
97+
assert(uiReady);
98+
assert(inputsReady);
99+
assert(inputHubReady);
100+
assert(storageReady);
101+
assert(inputMapReady);
102+
assert(powerReady);
103+
assert(hidCommonReady);
104+
assert(started);
105+
106+
// Check that the firmware is running
107+
assert(FirmwareService::call::isRunning());
108+
109+
return 0;
110+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FirmwareRunTest.cpp
2+
firmware.cpp

0 commit comments

Comments
 (0)