[*] We do some crinkles

This commit is contained in:
Reece Wilson 2022-06-12 21:14:26 +01:00
parent ba4fd61c07
commit 333fe12f9a
7 changed files with 159 additions and 16 deletions

@ -1 +1 @@
Subproject commit 97938fcaeb4f0e1d1f29bff9699c51e7d9091acb Subproject commit 8bd7f698e31fd2c84cedf3512edaa28c9db428de

View File

@ -219,7 +219,7 @@ TEST(IPC, AsyncPipe)
ASSERT_TRUE(transactionB->StartRead(0, AuUnsafeRaiiToShared(&readView))); ASSERT_TRUE(transactionB->StartRead(0, AuUnsafeRaiiToShared(&readView)));
// Create loop to sync against the two outstanding IO requests // Create loop to sync against the two outstanding IO requests
auto loop = Aurora::Loop::NewLoopQueue(); auto loop = AuLoop::NewLoopQueue();
// Add initial loop sources // Add initial loop sources
ASSERT_TRUE(loop->SourceAdd(transactionA->NewLoopSource())); ASSERT_TRUE(loop->SourceAdd(transactionA->NewLoopSource()));

View File

@ -36,7 +36,7 @@ static void ReadStdInNonBlocking()
{ {
AuLogInfo("Awaiting input (10s)"); AuLogInfo("Awaiting input (10s)");
auto loop = Aurora::Loop::NewLoopQueue(); auto loop = AuLoop::NewLoopQueue();
auto source = AuConsole::StdInBufferLoopSource(); auto source = AuConsole::StdInBufferLoopSource();
ASSERT_TRUE(loop->SourceAdd(source)); ASSERT_TRUE(loop->SourceAdd(source));

View File

@ -0,0 +1,140 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Main.cpp
Date: 2022-2-18
Author: Reece
***/
#include <AuroraRuntime.hpp>
#include <Aurora/IO/IOExperimental.hpp>
#include <gtest/gtest.h>
TEST(IO, Proceessor_SoftAbort)
{
static int counter {};
static int counter2 {};
static int counter3 {};
static int counter4 {};
auto ioDrivenQueue = AuIO::NewIOProcessorNoQueue(false);
ASSERT_TRUE(bool(ioDrivenQueue));
auto timer = AuIO::NewWaitableIOTimer();
auto listener = AuMakeShared<AuIO::IIOEventListenerFunctional>();
listener->Tick_SelfIOEventFunctional = [&]()
{
AuLogDbg("SelfIO event fired");
counter++;
};
listener->Tick_AnyFunctional = []()
{
AuLogDbg("* tick event fired");
counter2++;
};
listener->OnNominalCompletionFunctional = [&]()
{
AuLogDbg("* complete");
counter3++;
};
listener->OnFailureCompletionFunctional = [&]()
{
AuLogDbg("* failure");
counter4++;
};
timer->SetConstantTick(AuMSToNS<AuUInt64>(500));
AuLogDbg("Start watch");
auto watch = ioDrivenQueue->StartIOWatch(timer, listener);
for (int i = 0; i < 4; i++)
{
auto pumpedEvents = ioDrivenQueue->RunTick();
AuLogDbg("{} ln: {} io watches ticked", __LINE__, pumpedEvents);
}
AuLogDbg("Aborting / SOFT");
watch->StopWatch();
// Nop
watch->FailWatch();
auto pumpedEvents = ioDrivenQueue->RunTick();
AuLogDbg("{} ln: {} io watches ticked", __LINE__, pumpedEvents);
ASSERT_EQ(counter, 4);
ASSERT_EQ(counter2, 4);
ASSERT_EQ(counter3, 1);
ASSERT_EQ(counter4, 0);
}
TEST(IO, Proceessor_FailAbort)
{
static int counter {};
static int counter2 {};
static int counter3 {};
static int counter4 {};
auto ioDrivenQueue = AuIO::NewIOProcessorNoQueue(false);
ASSERT_TRUE(bool(ioDrivenQueue));
auto timer = AuIO::NewWaitableIOTimer();
auto listener = AuMakeShared<AuIO::IIOEventListenerFunctional>();
listener->Tick_SelfIOEventFunctional = [&]()
{
AuLogDbg("SelfIO event fired");
counter++;
};
listener->Tick_AnyFunctional = []()
{
AuLogDbg("* tick event fired");
counter2++;
};
listener->OnNominalCompletionFunctional = [&]()
{
AuLogDbg("* complete");
counter3++;
};
listener->OnFailureCompletionFunctional = [&]()
{
AuLogDbg("* failure");
counter4++;
};
timer->SetConstantTick(AuMSToNS<AuUInt64>(500));
AuLogDbg("Start watch");
auto watch = ioDrivenQueue->StartIOWatch(timer, listener);
for (int i = 0; i < 4; i++)
{
auto pumpedEvents = ioDrivenQueue->RunTick();
AuLogDbg("{} ln: {} io watches ticked", __LINE__, pumpedEvents);
}
AuLogDbg("Aborting / HARD");
watch->FailWatch();
// Nop
watch->StopWatch();
auto pumpedEvents = ioDrivenQueue->RunTick();
AuLogDbg("{} ln: {} io watches ticked", __LINE__, pumpedEvents);
ASSERT_EQ(counter, 4);
ASSERT_EQ(counter2, 4);
ASSERT_EQ(counter3, 0);
ASSERT_EQ(counter4, 1);
}
void RunTests()
{
Aurora::RuntimeStartInfo info;
info.console.fio.enableLogging = false;
Aurora::RuntimeStart(info);
AuLogDbg("Zero work items ticked means only on final / on error callbacks were dispatched.\nThey are not counted during the IOProcessor tick despite being pumped.\nYou must spin on HasItems over trueness of frame runs/ticks");
}

View File

@ -21,20 +21,20 @@ TEST(Loop, Semaphore)
ASSERT_TRUE(loop->SourceAddWithTimeout(semac, 2000)); ASSERT_TRUE(loop->SourceAddWithTimeout(semac, 2000));
auto semACallback = AuMakeShared<Aurora::Loop::ILoopSourceSubscriberFunctional>([](const AuSPtr<AuLoop::ILoopSource> &source) -> bool auto semACallback = AuMakeShared<AuLoop::ILoopSourceSubscriberFunctional>([](const AuSPtr<AuLoop::ILoopSource> &source) -> bool
{ {
AuLogInfo("Hello from semaphore a's work queue"); AuLogInfo("Hello from semaphore a's work queue");
return false; // dont evict, we'll reuse this *1 (search for me) return false; // dont evict, we'll reuse this *1 (search for me)
}); });
auto semBCallback = AuMakeShared<Aurora::Loop::ILoopSourceSubscriberFunctional>([](const AuSPtr<AuLoop::ILoopSource> &source) -> bool auto semBCallback = AuMakeShared<AuLoop::ILoopSourceSubscriberFunctional>([](const AuSPtr<AuLoop::ILoopSource> &source) -> bool
{ {
AuLogInfo("Hello from semaphore b's work queue"); AuLogInfo("Hello from semaphore b's work queue");
return true; // evict return true; // evict
}); });
auto semCCallback = AuMakeShared<Aurora::Loop::ILoopSourceSubscriberExFunctional>([](const AuSPtr<AuLoop::ILoopSource> &source, AuUInt8 pos) -> bool auto semCCallback = AuMakeShared<AuLoop::ILoopSourceSubscriberExFunctional>([](const AuSPtr<AuLoop::ILoopSource> &source, AuUInt8 pos) -> bool
{ {
AuLogInfo("This should not have been triggered from C"); AuLogInfo("This should not have been triggered from C");
return false; return false;
@ -189,32 +189,32 @@ TEST(Loop, Performance)
{ {
SysBenchmark("Loop Performance A"); SysBenchmark("Loop Performance A");
auto semaA = Aurora::Loop::NewLSSemaphore(1); auto semaA = AuLoop::NewLSSemaphore(1);
auto semaB = Aurora::Loop::NewLSSemaphore(0); auto semaB = AuLoop::NewLSSemaphore(0);
auto semac = Aurora::Loop::NewLSSemaphore(0); auto semac = AuLoop::NewLSSemaphore(0);
auto loop = Aurora::Loop::NewLoopQueue(); auto loop = AuLoop::NewLoopQueue();
auto semACallback = AuMakeShared<Aurora::Loop::ILoopSourceSubscriberFunctional>([](const AuSPtr<Aurora::Loop::ILoopSource> &source) -> bool auto semACallback = AuMakeShared<AuLoop::ILoopSourceSubscriberFunctional>([](const AuSPtr<AuLoop::ILoopSource> &source) -> bool
{ {
//AuLogInfo("Hello from semaphore a's work queue"); //AuLogInfo("Hello from semaphore a's work queue");
return false; // dont evict, we'll reuse this *1 return false; // dont evict, we'll reuse this *1
}); });
auto semBCallback = AuMakeShared<Aurora::Loop::ILoopSourceSubscriberFunctional>([](const AuSPtr<Aurora::Loop::ILoopSource> &source) -> bool auto semBCallback = AuMakeShared<AuLoop::ILoopSourceSubscriberFunctional>([](const AuSPtr<AuLoop::ILoopSource> &source) -> bool
{ {
//AuLogInfo("Hello from semaphore b's work queue"); //AuLogInfo("Hello from semaphore b's work queue");
return true; // evict return true; // evict
}); });
auto semCCallback = AuMakeShared<Aurora::Loop::ILoopSourceSubscriberExFunctional>([](const AuSPtr<Aurora::Loop::ILoopSource> &source) -> bool auto semCCallback = AuMakeShared<AuLoop::ILoopSourceSubscriberExFunctional>([](const AuSPtr<AuLoop::ILoopSource> &source) -> bool
{ {
//AuLogInfo("This should not have been triggered from C"); //AuLogInfo("This should not have been triggered from C");
return false; return false;
}, },
[](const AuSPtr<Aurora::Loop::ILoopSource> &source) -> void [](const AuSPtr<AuLoop::ILoopSource> &source) -> void
{ {
//AuLogInfo("C timedout succesfully!"); //AuLogInfo("C timedout succesfully!");
}); });

View File

@ -107,6 +107,7 @@ static void TestBasicCompression(AuCompression::ECompressionType type)
info.compressionLevel = 4; info.compressionLevel = 4;
ASSERT_TRUE(AuCompression::Compress(pipe, info)); ASSERT_TRUE(AuCompression::Compress(pipe, info));
} }
compressed.GetBuffer()->ResetReadPointer();
// Legacy API // Legacy API
AuIO::Buffered::BlobWriter decompressed; AuIO::Buffered::BlobWriter decompressed;
@ -122,6 +123,8 @@ static void TestBasicCompression(AuCompression::ECompressionType type)
compressed.GetBuffer()->ResetReadPointer(); compressed.GetBuffer()->ResetReadPointer();
decompressed.GetBuffer()->ResetReadPointer();
ASSERT_EQ(compressMeBytes, *decompressed.GetBuffer()); ASSERT_EQ(compressMeBytes, *decompressed.GetBuffer());
// New API // New API

View File

@ -12,7 +12,7 @@ static void PrintLocale()
{ {
auto locale = AuLocale::GetLocale(); auto locale = AuLocale::GetLocale();
AuLogInfo("Localization information..."); AuLogInfo("Localization information...");
AuLogInfo("language: {}, country: {}, codeset: {})", locale.language, locale.country, locale.codeset); AuLogInfo("language: {}, country: {}, codeset: {})", *locale.language, *locale.country, *locale.codeset);
} }
TEST(TranslateEncoding, utf16to8) TEST(TranslateEncoding, utf16to8)