nope, unit tests did not just fix themselves

This commit is contained in:
rusefi 2020-06-17 08:42:37 -04:00
parent 5727723dcc
commit fb5756fe3e
5 changed files with 12 additions and 5 deletions

View File

@ -19,6 +19,7 @@
#include "perf_trace.h"
#if EFI_UNIT_TEST
extern int timeNowUs;
extern bool verboseMode;
#endif /* EFI_UNIT_TEST */
@ -144,7 +145,10 @@ int EventQueue::executeAll(efitime_t now) {
// near future - spin wait for the event to happen and avoid the
// overhead of rescheduling the timer.
while (current->momentX > getTimeNowNt()) ;
// yes, that's a busy wait but that's what we need here
while (current->momentX > getTimeNowNt()) {
UNIT_TEST_BUSY_WAIT_CALLBACK();
}
executionCounter++;

View File

@ -109,6 +109,8 @@ typedef unsigned int time_t;
*/
#define NT2US(nt) ((nt) / US_TO_NT_MULTIPLIER)
#define UNIT_TEST_BUSY_WAIT_CALLBACK() {}
#ifdef __cplusplus
extern "C"
{

View File

@ -56,6 +56,8 @@
extern BaseChannel serialAdapterInstance;
#define UNIT_TEST_BUSY_WAIT_CALLBACK() {}
#ifdef __cplusplus
extern "C"
{

View File

@ -100,3 +100,5 @@ void print(const char *fmt, ...);
#define lockAnyContext() false
#define unlockAnyContext() {}
#define UNIT_TEST_BUSY_WAIT_CALLBACK() { timeNowUs++; }

View File

@ -38,8 +38,7 @@ static void complexCallback(TestPwm *testPwm) {
{ complexCallback, testPwm });
}
static void testSignalExecutor2(void) {
print("*************************************** testSignalExecutor2\r\n");
TEST(misc, testSignalExecutor2) {
EventQueue eq;
TestPwm p1(&eq);
TestPwm p2(&eq);
@ -85,7 +84,6 @@ TEST(misc, testSignalExecutor3) {
eq.insertTask(&s1, 10, { orderCallback, (void*)1 });
eq.insertTask(&s2, 11, { orderCallback, (void*)2 });
eq.insertTask(&s3, 12, { orderCallback, (void*)3 });
eq.executeAll(100);
}
@ -160,5 +158,4 @@ TEST(misc, testSignalExecutor) {
eq.executeAll(11);
ASSERT_EQ(2, callbackCounter);
testSignalExecutor2();
}