Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions mock/lib-time-mocks.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
#include <rusefi/rusefi_time_math.h>

static int timeNowUs = 0;
static efitick_t timeNowNt = 0;

efitick_t getTimeNowNt() {
return timeNowNt;
}

efitimeus_t getTimeNowUs() {
return timeNowUs;
return NT2US(getTimeNowNt());
}

efitimesec_t getTimeNowS() {
return getTimeNowUs() / 1000 / 1000;
}

efitick_t getTimeNowNt() {
return getTimeNowUs() * US_TO_NT_MULTIPLIER;
void setTimeNowNt(efitick_t nt) {
timeNowNt = nt;
}

void setTimeNowUs(int us) {
timeNowUs = us;
setTimeNowNt(USF2NT((efitick_t)us));
}

void advanceTimeUs(int us) {
timeNowUs += us;
timeNowNt += USF2NT((efitick_t)us);
}
1 change: 1 addition & 0 deletions util/include/rusefi/rusefi_time_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#if EFI_UNIT_TEST
// In unit tests, we can time travel...
void setTimeNowNt(efitick_t nt);
void setTimeNowUs(int us);
void advanceTimeUs(int us);
#endif