revive ptrace #5983

only: quality in software begins with proper practices like TDD
This commit is contained in:
Andrey 2024-02-22 15:16:24 -05:00
parent 178e1f39ed
commit a1423085e2
4 changed files with 18 additions and 0 deletions

View File

@ -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;
}

View File

@ -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!

View File

@ -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);
}

View File

@ -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 \