From 2637035e5e4ba36022caffd4c3acdd889ed02285 Mon Sep 17 00:00:00 2001 From: J Reece Wilson Date: Mon, 11 Apr 2022 20:14:39 +0100 Subject: [PATCH] [+] Add extended file watcher tests (with whole directory test) [+] Updated AuLoop IsSignaled API // Temp disabling benchmark [+] Added some linux benchmark figures [*] Update submodules [+] Linux NoToolKit script --- Aurora/ROXTL | 2 +- Aurora/Runtime | 2 +- Build_Scripts | 2 +- Include | 2 +- Linux_x64_NoToolkit | 5 ++ Tests/Public/4. Hello FS/Main.cpp | 88 ++++++++++++++++++++++++--- Tests/Public/5. Hello Loop/Main.cpp | 6 +- Tests/Public/8. Hello Locale/Main.cpp | 2 +- Vendor/nlohmannjson | 2 +- 9 files changed, 93 insertions(+), 18 deletions(-) create mode 100755 Linux_x64_NoToolkit diff --git a/Aurora/ROXTL b/Aurora/ROXTL index 4fa7f61..32fa7e6 160000 --- a/Aurora/ROXTL +++ b/Aurora/ROXTL @@ -1 +1 @@ -Subproject commit 4fa7f61b8f57e1c55b69661f75356beeb289f63c +Subproject commit 32fa7e6e2ce9d755dfe8aec7b41671f4a5153434 diff --git a/Aurora/Runtime b/Aurora/Runtime index 603c68f..2de033a 160000 --- a/Aurora/Runtime +++ b/Aurora/Runtime @@ -1 +1 @@ -Subproject commit 603c68f3cac297fa2a32c2209f4f327e7fa3de94 +Subproject commit 2de033a575a3f151fbab7a776f6339d7b15272b6 diff --git a/Build_Scripts b/Build_Scripts index e3dd284..a4e296c 160000 --- a/Build_Scripts +++ b/Build_Scripts @@ -1 +1 @@ -Subproject commit e3dd28450807c05c7e5c2a878d8506c839b4857e +Subproject commit a4e296c86744973cf5212e094d8e7d8b88195f00 diff --git a/Include b/Include index 07b229a..f30d2db 160000 --- a/Include +++ b/Include @@ -1 +1 @@ -Subproject commit 07b229a4bbe3d92b0ca6697732eca10b46c2b1e0 +Subproject commit f30d2db9a2185043ec847b1e566c00dc44c1a24c diff --git a/Linux_x64_NoToolkit b/Linux_x64_NoToolkit new file mode 100755 index 0000000..4a87490 --- /dev/null +++ b/Linux_x64_NoToolkit @@ -0,0 +1,5 @@ +#!/bin/bash + +cd Build_Scripts +./linux_x64 "$@" +cd .. \ No newline at end of file diff --git a/Tests/Public/4. Hello FS/Main.cpp b/Tests/Public/4. Hello FS/Main.cpp index b26d187..57a6dd1 100644 --- a/Tests/Public/4. Hello FS/Main.cpp +++ b/Tests/Public/4. Hello FS/Main.cpp @@ -12,12 +12,12 @@ Blocking read/write test Test 1) - Input parameters: 1k cycles, 32B RNG + Input parameters: 1k cycles, 32B RNG With 4k ops and 1600ms average ~= 0.4ms per blocking read/write Test 2) - Input parameters: 1k cycles, 64KiB RNG + Input parameters: 1k cycles, 64KiB RNG Result: FS.WriteRead (9248 ms) > 9248 / 4 (ops) @@ -29,10 +29,17 @@ Test 2) > 27 * 1000 (kB / s) 27000 > 27000 / 1024 (mB / s) - 26.3671875 + 26.3671875 26 MB/s or 208Mb/s 29/03/2022 (under vm vdisk and with nt caching) + +Test 3) + Input parameters: 1k cycles, 32B RNG + With 4k ops and 64ms average + ~= 0.016ms per blocking read/write + +10/04/2022 (linux) */ TEST(FS, WriteRead) { @@ -65,7 +72,7 @@ TEST(FS, WriteCopyRead) AuIOFS::Remove("./test_rng_blob_2"); ASSERT_TRUE(AuIOFS::Copy("./test_rng_blob_1", "./test_rng_blob_2")); - + ASSERT_TRUE(AuIOFS::ReadFile("./test_rng_blob_2", inputblob)); ASSERT_EQ(inputblob, rngbuffer); } @@ -103,24 +110,85 @@ TEST(FS, Watcher) auto watcher = AuIOFS::NewWatcherUnique(); ASSERT_TRUE(watcher); - AuIOFS::WatchedFile file; - file.path = "~/Watcher.txt"; - ASSERT_TRUE(watcher->AddWatch(file)); + AuIOFS::WatchRequest request; + request.watch.path = "~/Watcher.txt"; + ASSERT_TRUE(AuListFromArgs(request.events, + AuIOFS::EWatchEvent::eSelfModify, + AuIOFS::EWatchEvent::eSelfDelete, + + AuIOFS::EWatchEvent::eFileDelete, + AuIOFS::EWatchEvent::eFileModify, + AuIOFS::EWatchEvent::eFileCreate)); + ASSERT_TRUE(watcher->AddWatch(request)); ASSERT_FALSE(watcher->AsLoopSource()->IsSignaled()); ASSERT_TRUE(AuIOFS::WriteString("~/Watcher.txt", "testing2")); ASSERT_TRUE(watcher->AsLoopSource()->IsSignaled()); ASSERT_TRUE(watcher->AsLoopSource()->IsSignaled()); - ASSERT_TRUE(watcher->QueryUpdates().size()); + + auto updates = watcher->QueryUpdates(); ASSERT_FALSE(watcher->AsLoopSource()->IsSignaled()); + + ASSERT_TRUE(updates.size()); + AuLogDbg("First pass updates: {}", updates.size()); + for (const auto &update : updates) + { + AuLogDbg(" {}: {}", AuIOFS::EWatchEventToString(update.event), update.file); + } + ASSERT_TRUE(AuIOFS::WriteString("~/Watcher.txt", "testing2")); - ASSERT_TRUE(watcher->AsLoopSource()->IsSignaled()); - ASSERT_TRUE(watcher->QueryUpdates().size()); + + updates = watcher->QueryUpdates(); + ASSERT_TRUE(updates.size()); + AuLogDbg("Second pass updates: {}", updates.size()); + for (const auto &update : updates) + { + AuLogDbg(" {}: {}", AuIOFS::EWatchEventToString(update.event), update.file); + } + ASSERT_TRUE(AuIOFS::WriteString("~/Watcher2.txt", "testing2")); ASSERT_FALSE(watcher->AsLoopSource()->IsSignaled()); + + + // Test for basic file mk and rm + AuIOFS::DirMk("~/WatcherDir"); + request.watch.path = "~/WatcherDir"; + ASSERT_TRUE(watcher->AddWatch(request)); + + // I don't know? + updates = watcher->QueryUpdates(); + AuLogDbg("Hello World?: {}", updates.size()); + for (const auto &update : updates) + { + AuLogDbg(" {}: {} {}", AuIOFS::EWatchEventToString(update.event), update.file, update.watch.path); + } + + // .. + ASSERT_TRUE(AuIOFS::WriteString("~/WatcherDir/Poke.TXT", "...?")); + + updates = watcher->QueryUpdates(); + ASSERT_TRUE(updates.size()); + AuLogDbg("Created a file called 'Poke.TXT': {}", updates.size()); + for (const auto &update : updates) + { + AuLogDbg(" {}: {} {}", AuIOFS::EWatchEventToString(update.event), update.file, update.watch.path); + } + + + AuIOFS::Remove("~/WatcherDir/Poke.TXT"); + + updates = watcher->QueryUpdates(); + ASSERT_TRUE(updates.size()); + AuLogDbg("Removed a file called 'Poke.TXT': {}", updates.size()); + for (const auto &update : updates) + { + AuLogDbg(" {}: {} {}", AuIOFS::EWatchEventToString(update.event), update.file, update.watch.path); + } + } + static void PrintSystemRoot() { AuString path; diff --git a/Tests/Public/5. Hello Loop/Main.cpp b/Tests/Public/5. Hello Loop/Main.cpp index de0172a..3d72f53 100644 --- a/Tests/Public/5. Hello Loop/Main.cpp +++ b/Tests/Public/5. Hello Loop/Main.cpp @@ -55,7 +55,8 @@ TEST(Loop, Semaphore) ASSERT_TRUE(loop->Commit()); // Dispatch any (IE: semaphore A) non-blocking - ASSERT_TRUE(loop->IsSignaled()); + ASSERT_TRUE(loop->IsSignaledPeek()); + ASSERT_TRUE(loop->WaitAny(0)); // Reuse semaphore A semaA->AddOne(); // *1 @@ -84,7 +85,7 @@ TEST(Loop, Semaphore) ASSERT_TRUE(loop->WaitAll(100)); } - +#if 0 TEST(Loop, Performance) { SysBenchmark("Loop Performance A"); @@ -218,6 +219,7 @@ TEST(Loop, Performance) semaA->AddOne(); // account for initial starting count of 1 } } +#endif void RunTests() { diff --git a/Tests/Public/8. Hello Locale/Main.cpp b/Tests/Public/8. Hello Locale/Main.cpp index a32627c..ba25c3b 100644 --- a/Tests/Public/8. Hello Locale/Main.cpp +++ b/Tests/Public/8. Hello Locale/Main.cpp @@ -12,7 +12,7 @@ static void PrintLocale() { auto locale = AuLocale::GetLocale(); 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) diff --git a/Vendor/nlohmannjson b/Vendor/nlohmannjson index 66f6b4b..3b16057 160000 --- a/Vendor/nlohmannjson +++ b/Vendor/nlohmannjson @@ -1 +1 @@ -Subproject commit 66f6b4b6a0b897e91f7fdd5f6058a8c62137895f +Subproject commit 3b16057ffaaed250cf207233f9238392ea0245ee