[+] IPC Mutex and Memory test

[*] Update loop
[*] Update submodules
This commit is contained in:
Reece Wilson 2022-04-15 15:47:54 +01:00
parent 9ce2f7e63e
commit 9141a0015c
3 changed files with 60 additions and 2 deletions

@ -1 +1 @@
Subproject commit 44839e6234f6a8eb9c39a09a5ea8cd5ee348ac7f
Subproject commit 9f2ff9de1952c440b62772a51506493dfed927d4

View File

@ -88,6 +88,64 @@ TEST(IPC, Semaphore)
ASSERT_FALSE(semaphore->IsSignaled());
}
TEST(IPC, Memory)
{
auto memory = Aurora::IPC::NewSharedMemory(4096);
ASSERT_TRUE(bool(memory));
auto handleString = memory->ExportToString();
ASSERT_TRUE(bool(handleString.size()));
AuLogDbg("Exported shared view handle: {}", handleString);
auto memoryImported = Aurora::IPC::ImportSharedMemory(handleString);
ASSERT_TRUE(bool(memoryImported));
static const AuString kHelloWorld = "Hello IPC";
AuMemcpy(memory->GetMemory().ptr, kHelloWorld.c_str(), kHelloWorld.size() + 1);
AuLogDbg("Shared Memory String: {}", memoryImported->GetMemory().Begin<char>());
ASSERT_EQ(memoryImported->GetMemory().Begin<char>(), kHelloWorld);
}
TEST(IPC, Pipe)
{
auto pipe = Aurora::IPC::NewPipe();
ASSERT_TRUE(bool(pipe));
auto handleString = pipe->ExportToString();
ASSERT_TRUE(bool(handleString.size()));
AuLogDbg("Exported pipe handle: {}", handleString);
auto pipeImported = Aurora::IPC::ImportPipe(handleString);
ASSERT_TRUE(bool(pipeImported));
static const AuString kHelloWorld = "Hello IPC";
ASSERT_FALSE(pipe->IsSignaled());
ASSERT_FALSE(pipeImported->IsSignaled());
AuUInt bytesWritten;
ASSERT_TRUE(pipe->Write(AuMemoryViewStreamRead(kHelloWorld, bytesWritten), false));
ASSERT_EQ(bytesWritten, kHelloWorld.size());
ASSERT_TRUE(pipe->IsSignaled());
ASSERT_TRUE(pipeImported->IsSignaled());
AuString temp(kHelloWorld.size(), '\00');
AuUInt bytesRead;
ASSERT_TRUE(pipeImported->Read(AuMemoryViewStreamWrite(temp.data(), temp.data() + temp.size(), bytesRead), false));
AuLogDbg("Pipe Message: {}", temp);
ASSERT_EQ(bytesRead, kHelloWorld.size());
ASSERT_EQ(temp, kHelloWorld);
ASSERT_FALSE(pipe->IsSignaled());
ASSERT_FALSE(pipeImported->IsSignaled());
}
void RunTests()
{
Aurora::RuntimeStartInfo info;

View File

@ -34,7 +34,7 @@ TEST(Loop, Semaphore)
});
auto semCCallback = AuMakeShared<Aurora::Loop::ILoopSourceSubscriberExFunctional>([](const AuSPtr<Aurora::Loop::ILoopSource> &source) -> bool
auto semCCallback = AuMakeShared<Aurora::Loop::ILoopSourceSubscriberExFunctional>([](const AuSPtr<Aurora::Loop::ILoopSource> &source, AuUInt8 pos) -> bool
{
AuLogInfo("This should not have been triggered from C");
return false;