Base IACoreV2
Some checks failed
CI / build-linux-and-wasm (x64-linux) (push) Has been cancelled

This commit is contained in:
2026-01-22 05:54:26 +05:30
parent dedf28c6cb
commit 3ad1e3a2fb
57 changed files with 4398 additions and 4639 deletions

View File

@ -23,78 +23,75 @@ IAT_BEGIN_BLOCK(Core, RingBuffer)
// -------------------------------------------------------------------------
// 1. Basic Push Pop
// -------------------------------------------------------------------------
BOOL TestPushPop()
{
// Allocate raw memory for the ring buffer
// ControlBlock (128 bytes) + Data
std::vector<UINT8> memory(sizeof(RingBufferView::ControlBlock) + 1024);
bool TestPushPop() {
// Allocate raw memory for the ring buffer
// ControlBlock (128 bytes) + Data
std::vector<u8> memory(sizeof(RingBufferView::ControlBlock) + 1024);
// Initialize as OWNER (Producer)
RingBufferView producer(std::span<UINT8>(memory), TRUE);
// Initialize as OWNER (Producer)
RingBufferView producer(std::span<u8>(memory), TRUE);
// Initialize as CONSUMER (Pointer to same memory)
RingBufferView consumer(std::span<UINT8>(memory), FALSE);
// Initialize as CONSUMER (Pointer to same memory)
RingBufferView consumer(std::span<u8>(memory), FALSE);
// Data to send
String msg = "Hello RingBuffer";
BOOL pushed = producer.Push(1, {(const UINT8 *) msg.data(), msg.size()});
IAT_CHECK(pushed);
// Data to send
String msg = "Hello RingBuffer";
bool pushed = producer.Push(1, {(const u8 *)msg.data(), msg.size()});
IAT_CHECK(pushed);
// Read back
RingBufferView::PacketHeader header;
UINT8 readBuf[128];
// Read back
RingBufferView::PacketHeader header;
u8 readBuf[128];
INT32 bytesRead = consumer.Pop(header, std::span<UINT8>(readBuf, 128));
i32 bytesRead = consumer.Pop(header, std::span<u8>(readBuf, 128));
IAT_CHECK_EQ(header.ID, (UINT16) 1);
IAT_CHECK_EQ(bytesRead, (INT32) msg.size());
IAT_CHECK_EQ(header.ID, (u16)1);
IAT_CHECK_EQ(bytesRead, (i32)msg.size());
String readMsg((char *) readBuf, bytesRead);
IAT_CHECK_EQ(readMsg, msg);
String readMsg((char *)readBuf, bytesRead);
IAT_CHECK_EQ(readMsg, msg);
return TRUE;
return TRUE;
}
// -------------------------------------------------------------------------
// 2. Wrap Around
// -------------------------------------------------------------------------
BOOL TestWrapAround()
{
// Small buffer to force wrapping quickly
// Capacity will be 100 bytes
std::vector<UINT8> memory(sizeof(RingBufferView::ControlBlock) + 100);
RingBufferView rb(std::span<UINT8>(memory), TRUE);
bool TestWrapAround() {
// Small buffer to force wrapping quickly
// Capacity will be 100 bytes
std::vector<u8> memory(sizeof(RingBufferView::ControlBlock) + 100);
RingBufferView rb(std::span<u8>(memory), TRUE);
// Fill buffer to near end
// Push 80 bytes
std::vector<UINT8> junk(80, 0xFF);
rb.Push(1, junk);
// Fill buffer to near end
// Push 80 bytes
std::vector<u8> junk(80, 0xFF);
rb.Push(1, junk);
// Pop them to advance READ cursor
RingBufferView::PacketHeader header;
UINT8 outBuf[100];
rb.Pop(header, outBuf);
// Pop them to advance READ cursor
RingBufferView::PacketHeader header;
u8 outBuf[100];
rb.Pop(header, outBuf);
// Now READ and WRITE are near index 80.
// Pushing 40 bytes should trigger a wrap-around (split write)
std::vector<UINT8> wrapData(40, 0xAA);
BOOL pushed = rb.Push(2, wrapData);
IAT_CHECK(pushed);
// Now READ and WRITE are near index 80.
// Pushing 40 bytes should trigger a wrap-around (split write)
std::vector<u8> wrapData(40, 0xAA);
bool pushed = rb.Push(2, wrapData);
IAT_CHECK(pushed);
// Pop and verify integrity
INT32 popSize = rb.Pop(header, outBuf);
IAT_CHECK_EQ(popSize, 40);
// Pop and verify integrity
i32 popSize = rb.Pop(header, outBuf);
IAT_CHECK_EQ(popSize, 40);
// Check if data is intact
BOOL match = TRUE;
for (int i = 0; i < 40; i++)
{
if (outBuf[i] != 0xAA)
match = FALSE;
}
IAT_CHECK(match);
// Check if data is intact
bool match = TRUE;
for (int i = 0; i < 40; i++) {
if (outBuf[i] != 0xAA)
match = FALSE;
}
IAT_CHECK(match);
return TRUE;
return TRUE;
}
IAT_BEGIN_TEST_LIST()