[+] Added early async file io test
This commit is contained in:
parent
74cfa7380c
commit
47162ec671
@ -185,9 +185,58 @@ TEST(FS, Watcher)
|
||||
{
|
||||
AuLogDbg(" {}: {} {}", AuIOFS::EWatchEventToString(update.event), update.file, update.watch.path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST(FS, Async)
|
||||
{
|
||||
auto stream = AuIOFS::OpenAsyncUnique("./AsyncFile", AuIOFS::EFileOpenMode::eReadWrite, true);
|
||||
ASSERT_TRUE(bool(stream));
|
||||
|
||||
AuByteBuffer rngbuffer(32);
|
||||
AuRng::RngFillRange(rngbuffer);
|
||||
|
||||
auto transaction = stream->NewTransaction();
|
||||
ASSERT_TRUE(bool(transaction));
|
||||
|
||||
transaction->SetCallback(AuMakeShared<AuIOFS::IAsyncFinishedSubscriberFunctional>([](AuUInt64 offset, AuUInt32 length)
|
||||
{
|
||||
AuLogDbg("AIO 1 callback: {} {}", offset, length);
|
||||
}));
|
||||
|
||||
AuMemoryViewRead readView(rngbuffer);
|
||||
ASSERT_TRUE(transaction->StartWrite(0, AuUnsafeRaiiToShared(&readView)));
|
||||
|
||||
AuLogDbg("AIO 1: waiting....");
|
||||
ASSERT_TRUE(transaction->Wait(0));
|
||||
AuLogDbg("AIO 1: wait complete....");
|
||||
ASSERT_TRUE(transaction->NewLoopSource()->IsSignaled());
|
||||
ASSERT_TRUE(transaction->Complete());
|
||||
}
|
||||
|
||||
TEST(FS, AsyncAltWait)
|
||||
{
|
||||
auto stream = AuIOFS::OpenAsyncUnique("./AsyncFile", AuIOFS::EFileOpenMode::eReadWrite, true);
|
||||
ASSERT_TRUE(bool(stream));
|
||||
|
||||
AuByteBuffer rngbuffer(32);
|
||||
AuRng::RngFillRange(rngbuffer);
|
||||
|
||||
auto transaction = stream->NewTransaction();
|
||||
ASSERT_TRUE(bool(transaction));
|
||||
|
||||
transaction->SetCallback(AuMakeShared<AuIOFS::IAsyncFinishedSubscriberFunctional>([](AuUInt64 offset, AuUInt32 length)
|
||||
{
|
||||
AuLogDbg("AIO 2 callback: {} {}", offset, length);
|
||||
}));
|
||||
|
||||
AuMemoryViewRead readView(rngbuffer);
|
||||
ASSERT_TRUE(transaction->StartWrite(0, AuUnsafeRaiiToShared(&readView)));
|
||||
|
||||
AuLogDbg("AIO 2: waiting....");
|
||||
ASSERT_TRUE(transaction->NewLoopSource()->WaitOn());
|
||||
AuLogDbg("AIO 2: wait complete....");
|
||||
ASSERT_TRUE(transaction->Complete());
|
||||
}
|
||||
|
||||
static void PrintSystemRoot()
|
||||
{
|
||||
@ -266,14 +315,16 @@ static void PrintSystemRoot()
|
||||
}
|
||||
|
||||
// TODO: sample and test code for:
|
||||
// * async
|
||||
// * file stream objects
|
||||
// * stat
|
||||
// * iterate
|
||||
|
||||
void RunTests()
|
||||
{
|
||||
Aurora::RuntimeStartInfo info;
|
||||
info.console.fio.enableLogging = false;
|
||||
info.fio.defaultBrand = "AuSdkBrand";
|
||||
info.bFIODisableBatching = false;
|
||||
Aurora::RuntimeStart(info);
|
||||
|
||||
PrintSystemRoot();
|
||||
|
Loading…
Reference in New Issue
Block a user