aboutsummaryrefslogtreecommitdiff
path: root/zenutil/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-08-06 17:02:17 +0200
committerStefan Boberg <[email protected]>2021-08-06 17:03:47 +0200
commit4d70af00d66cbfbd9f52afdfce7bcb4ec1881121 (patch)
tree95108f43f576adceb6cd394238ae6caca74a711d /zenutil/include
parentzen::Process -> zen::ProcessHandle (diff)
downloadzen-4d70af00d66cbfbd9f52afdfce7bcb4ec1881121.tar.xz
zen-4d70af00d66cbfbd9f52afdfce7bcb4ec1881121.zip
Repurposing test utility code to enable server control via zen
Diffstat (limited to 'zenutil/include')
-rw-r--r--zenutil/include/zenserverprocess.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/zenutil/include/zenserverprocess.h b/zenutil/include/zenserverprocess.h
new file mode 100644
index 000000000..fbe48abe3
--- /dev/null
+++ b/zenutil/include/zenserverprocess.h
@@ -0,0 +1,56 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#pragma once
+
+#include <zencore/thread.h>
+
+#include <spdlog/spdlog.h>
+
+#include <filesystem>
+
+class ZenServerEnvironment
+{
+public:
+ ZenServerEnvironment();
+ ~ZenServerEnvironment();
+
+ void Initialize(std::filesystem::path ProgramBaseDir, std::filesystem::path TestBaseDir);
+
+ std::filesystem::path CreateNewTestDir();
+ std::filesystem::path ProgramBaseDir() const { return m_ProgramBaseDir; }
+ std::filesystem::path RootDir(std::string_view Path);
+ bool IsInitialized() const { return m_IsInitialized; }
+
+private:
+ std::filesystem::path m_ProgramBaseDir;
+ std::filesystem::path m_TestBaseDir;
+ bool m_IsInitialized = false;
+};
+
+struct ZenServerInstance
+{
+ ZenServerInstance(ZenServerEnvironment& TestEnvironment);
+ ~ZenServerInstance();
+
+ void SignalShutdown() { m_ShutdownEvent.Set(); }
+ void WaitUntilReady() { m_ReadyEvent.Wait(); }
+ void EnableTermination() { m_Terminate = true; }
+ void EnableMesh() { m_MeshEnabled = true; }
+
+ void SetTestDir(std::filesystem::path TestDir)
+ {
+ ZEN_ASSERT(!m_Process.IsValid());
+ m_TestDir = TestDir;
+ }
+
+ void SpawnServer(int BasePort);
+
+private:
+ ZenServerEnvironment& m_Env;
+ zen::ProcessHandle m_Process;
+ zen::Event m_ReadyEvent;
+ zen::Event m_ShutdownEvent;
+ bool m_Terminate = false;
+ std::filesystem::path m_TestDir;
+ bool m_MeshEnabled = false;
+};