parent
286fa10b15
commit
a42077bef8
|
@ -149,13 +149,15 @@ bool stopTsPort(ts_channel_s *tsChannel) {
|
|||
}
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size) {
|
||||
int sr5TestWriteDataIndex = 0;
|
||||
uint8_t st5TestBuffer[16000];
|
||||
|
||||
void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size) {
|
||||
memcpy(&st5TestBuffer[sr5TestWriteDataIndex], buffer, size);
|
||||
sr5TestWriteDataIndex += size;
|
||||
}
|
||||
#endif // EFI_UNIT_TEST
|
||||
|
||||
|
||||
|
||||
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||
void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size) {
|
||||
efiAssertVoid(CUSTOM_ERR_6570, getCurrentRemainingStack() > 64, "tunerStudioWriteData");
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#include "engine_test_helper.h"
|
||||
#include "tunerstudio_io.h"
|
||||
|
||||
extern int sr5TestWriteDataIndex;
|
||||
extern uint8_t st5TestBuffer[16000];
|
||||
|
||||
TEST(binary, testWriteCrc) {
|
||||
sr5TestWriteDataIndex = 0;
|
||||
|
||||
#define CODE 2
|
||||
#define PAYLOAD "123"
|
||||
#define SIZE strlen(PAYLOAD)
|
||||
|
||||
sr5WriteCrcPacket(nullptr, CODE, (const uint8_t * )PAYLOAD, SIZE);
|
||||
ASSERT_EQ(sr5TestWriteDataIndex, SIZE + 7);
|
||||
|
||||
// todo: proper uint16 comparison
|
||||
ASSERT_EQ(st5TestBuffer[0], 0);
|
||||
ASSERT_EQ(st5TestBuffer[1], SIZE + 1);
|
||||
|
||||
ASSERT_EQ(st5TestBuffer[2], CODE);
|
||||
|
||||
ASSERT_EQ(memcmp(&st5TestBuffer[3], PAYLOAD, SIZE), 0);
|
||||
|
||||
|
||||
// todo: proper uint32 comparison
|
||||
ASSERT_EQ(st5TestBuffer[6], 252);
|
||||
ASSERT_EQ(st5TestBuffer[7], 68);
|
||||
ASSERT_EQ(st5TestBuffer[8], 173);
|
||||
ASSERT_EQ(st5TestBuffer[9], 87);
|
||||
|
||||
|
||||
}
|
|
@ -31,6 +31,7 @@ TESTS_SRC_CPP = \
|
|||
tests/test_fuel_map.cpp \
|
||||
tests/test_fuel_wall_wetting.cpp \
|
||||
tests/test_one_cylinder_logic.cpp \
|
||||
tests/test_tunerstudio.cpp \
|
||||
tests/test_pwm_generator.cpp \
|
||||
tests/test_logic_expression.cpp \
|
||||
tests/test_signal_executor.cpp \
|
||||
|
|
Loading…
Reference in New Issue