aboutsummaryrefslogtreecommitdiff
path: root/zenutil/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-08-06 18:39:13 +0200
committerStefan Boberg <[email protected]>2021-08-06 18:39:13 +0200
commitd1fdbbecaeacf751e66d2e37e191d1eaf44660f9 (patch)
tree58cd901cd0a66219d4c3e3066c6e2f64331e4efd /zenutil/include
parentRepurposing test utility code to enable server control via zen (diff)
downloadzen-d1fdbbecaeacf751e66d2e37e191d1eaf44660f9.tar.xz
zen-d1fdbbecaeacf751e66d2e37e191d1eaf44660f9.zip
Added support for defining test/non-test server environments
Diffstat (limited to 'zenutil/include')
-rw-r--r--zenutil/include/zenserverprocess.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/zenutil/include/zenserverprocess.h b/zenutil/include/zenserverprocess.h
index fbe48abe3..239841a04 100644
--- a/zenutil/include/zenserverprocess.h
+++ b/zenutil/include/zenserverprocess.h
@@ -14,17 +14,20 @@ public:
ZenServerEnvironment();
~ZenServerEnvironment();
- void Initialize(std::filesystem::path ProgramBaseDir, std::filesystem::path TestBaseDir);
+ void Initialize(std::filesystem::path ProgramBaseDir);
+ void InitializeForTest(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; }
+ std::filesystem::path GetTestRootDir(std::string_view Path);
+ inline bool IsInitialized() const { return m_IsInitialized; }
+ inline bool IsTestEnvironment() const { return m_IsTestInstance; }
private:
std::filesystem::path m_ProgramBaseDir;
std::filesystem::path m_TestBaseDir;
- bool m_IsInitialized = false;
+ bool m_IsInitialized = false;
+ bool m_IsTestInstance = false;
};
struct ZenServerInstance
@@ -32,10 +35,11 @@ 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 SignalShutdown() { m_ShutdownEvent.Set(); }
+ void WaitUntilReady();
+ [[nodiscard]] bool WaitUntilReady(int Timeout);
+ void EnableTermination() { m_Terminate = true; }
+ void EnableMesh() { m_MeshEnabled = true; }
void SetTestDir(std::filesystem::path TestDir)
{
@@ -43,10 +47,10 @@ struct ZenServerInstance
m_TestDir = TestDir;
}
- void SpawnServer(int BasePort);
+ void SpawnServer(int BasePort = 0);
private:
- ZenServerEnvironment& m_Env;
+ ZenServerEnvironment& m_Env;
zen::ProcessHandle m_Process;
zen::Event m_ReadyEvent;
zen::Event m_ShutdownEvent;