mirror of https://github.com/rusefi/rusefi.git
revive ptrace #5983
only: quality in software begins with proper practices like TDD
This commit is contained in:
parent
178e1f39ed
commit
a1423085e2
|
@ -127,6 +127,7 @@ void DisableToothLogger() {
|
|||
setToothLogReady(false);
|
||||
|
||||
// Release the big buffer for another user
|
||||
// C++ magic: here we are calling BigBufferHandle::operator=() with empty instance
|
||||
bufferHandle = {};
|
||||
buffers = nullptr;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,12 @@ static BigBufferUser s_currentUser;
|
|||
// we've only observed issue on F7 in -Os compiler configuration but technically all processors care
|
||||
static uint32_t s_bigBuffer[BIG_BUFFER_SIZE / sizeof(uint32_t)];
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
BigBufferUser &getBigBufferCurrentUser() {
|
||||
return s_currentUser;
|
||||
}
|
||||
#endif // EFI_UNIT_TEST
|
||||
|
||||
static void releaseBuffer(void* bufferPtr, BigBufferUser user) {
|
||||
if (bufferPtr != &s_bigBuffer || user != s_currentUser) {
|
||||
// todo: panic!
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "pch.h"
|
||||
|
||||
BigBufferUser &getBigBufferCurrentUser();
|
||||
|
||||
TEST(BigBuffer, CppMagic) {
|
||||
BigBufferHandle h = getBigBuffer(BigBufferUser::ToothLogger);
|
||||
ASSERT_EQ(getBigBufferCurrentUser(), BigBufferUser::ToothLogger);
|
||||
h = {};
|
||||
ASSERT_EQ(getBigBufferCurrentUser(), BigBufferUser::ToothLogger);
|
||||
}
|
|
@ -58,6 +58,7 @@ TESTS_SRC_CPP = \
|
|||
tests/test_change_engine_type.cpp \
|
||||
tests/util/test_scaled_channel.cpp \
|
||||
tests/util/test_timer.cpp \
|
||||
tests/test_big_buffer.cpp \
|
||||
tests/system/test_periodic_thread_controller.cpp \
|
||||
tests/test_util.cpp \
|
||||
tests/test_start_stop.cpp \
|
||||
|
|
Loading…
Reference in New Issue