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" #include "perf_trace.h"
#if EFI_UNIT_TEST #if EFI_UNIT_TEST
extern int timeNowUs;
extern bool verboseMode; extern bool verboseMode;
#endif /* EFI_UNIT_TEST */ #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 // near future - spin wait for the event to happen and avoid the
// overhead of rescheduling the timer. // 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++; executionCounter++;

View File

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

View File

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

View File

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

View File

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