[*] Update IPC test

This commit is contained in:
Reece Wilson 2022-04-17 14:54:22 +01:00
parent 384b27c48b
commit 5ce2c59161
2 changed files with 40 additions and 13 deletions

@ -1 +1 @@
Subproject commit 7a0d9701b5754c3001c9ece739f804310c410e96
Subproject commit b424a3b434c000b4235706b1165d54966c9d44b8

View File

@ -113,6 +113,8 @@ TEST(IPC, Pipe)
auto pipe = Aurora::IPC::NewPipe();
ASSERT_TRUE(bool(pipe));
ASSERT_FALSE(pipe->AsReadChannelIsOpen()->IsSignaled());
auto handleString = pipe->ExportToString();
ASSERT_TRUE(bool(handleString.size()));
AuLogDbg("Exported pipe handle: {}", handleString);
@ -120,30 +122,55 @@ TEST(IPC, Pipe)
auto pipeImported = Aurora::IPC::ImportPipe(handleString);
ASSERT_TRUE(bool(pipeImported));
static const AuString kHelloWorld = "Hello IPC";
ASSERT_TRUE(pipe->AsReadChannelIsOpen()->IsSignaled());
ASSERT_FALSE(pipe->IsSignaled());
ASSERT_FALSE(pipeImported->IsSignaled());
static const AuString kHelloWorldClient = "Hello Client";
static const AuString kHelloWorldServer = "Hello Server";
//ASSERT_FALSE(pipe->AsReadChannelHasData()->IsSignaled());
ASSERT_FALSE(pipeImported->AsReadChannelHasData()->IsSignaled());
AuUInt bytesWritten;
ASSERT_TRUE(pipe->Write(AuMemoryViewStreamRead(kHelloWorld, bytesWritten), false));
ASSERT_EQ(bytesWritten, kHelloWorld.size());
ASSERT_TRUE(pipe->Write(AuMemoryViewStreamRead(kHelloWorldClient, bytesWritten)));
ASSERT_EQ(bytesWritten, kHelloWorldClient.size());
ASSERT_TRUE(pipe->IsSignaled());
ASSERT_TRUE(pipeImported->IsSignaled());
ASSERT_TRUE(pipeImported->AsReadChannelHasData()->IsSignaled());
ASSERT_FALSE(pipe->AsReadChannelHasData()->IsSignaled());
AuString temp(kHelloWorld.size(), '\00');
AuString temp(kHelloWorldClient.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_EQ(bytesRead, kHelloWorldClient.size());
ASSERT_EQ(temp, kHelloWorldClient);
ASSERT_FALSE(pipe->AsReadChannelHasData()->IsSignaled());
ASSERT_FALSE(pipeImported->AsReadChannelHasData()->IsSignaled());
ASSERT_TRUE(pipeImported->Write(AuMemoryViewStreamRead(kHelloWorldServer, bytesWritten)));
ASSERT_EQ(bytesWritten, kHelloWorldServer.size());
ASSERT_TRUE(pipe->AsReadChannelHasData()->IsSignaled());
ASSERT_FALSE(pipeImported->AsReadChannelHasData()->IsSignaled());
temp.resize(kHelloWorldServer.size());
ASSERT_TRUE(pipe->Read(AuMemoryViewStreamWrite(temp.data(), temp.data() + temp.size(), bytesRead), false));
AuLogDbg("Pipe Message: {}", temp);
ASSERT_EQ(bytesRead, kHelloWorldServer.size());
ASSERT_EQ(temp, kHelloWorldServer);
ASSERT_FALSE(pipeImported->AsReadChannelHasData()->IsSignaled());
ASSERT_FALSE(pipe->AsReadChannelHasData()->IsSignaled());
pipeImported.reset();
ASSERT_FALSE(pipe->AsReadChannelIsOpen()->IsSignaled());
ASSERT_FALSE(pipe->IsSignaled());
ASSERT_FALSE(pipeImported->IsSignaled());
}
void RunTests()