diff options
| author | Stefan Boberg <[email protected]> | 2025-08-26 13:45:54 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2025-08-26 13:45:54 +0200 |
| commit | f4c029e6accbf8df3496e28ba9e07eed4cbde851 (patch) | |
| tree | ee3329f981e3c0b9609c90cfef4b610ffd2c4223 /src/zenmaster-test | |
| parent | Merge pull request #139 from ue-foundation/de/zen-service-command (diff) | |
| download | zen-f4c029e6accbf8df3496e28ba9e07eed4cbde851.tar.xz zen-f4c029e6accbf8df3496e28ba9e07eed4cbde851.zip | |
zenmaster + zenmaster-test skeletons
Diffstat (limited to 'src/zenmaster-test')
| -rw-r--r-- | src/zenmaster-test/xmake.lua | 17 | ||||
| -rw-r--r-- | src/zenmaster-test/zenmaster-test.cpp | 96 |
2 files changed, 113 insertions, 0 deletions
diff --git a/src/zenmaster-test/xmake.lua b/src/zenmaster-test/xmake.lua new file mode 100644 index 000000000..ace6c4254 --- /dev/null +++ b/src/zenmaster-test/xmake.lua @@ -0,0 +1,17 @@ +-- Copyright Epic Games, Inc. All Rights Reserved. + +target("zenmaster-test") + set_kind("binary") + set_group("tests") + add_headerfiles("**.h") + add_files("*.cpp") + add_files("zenmaster-test.cpp", {unity_ignored = true }) + add_deps("zencore", "zenutil", "zenhttp") + add_deps("zenmaster", {inherit=false}) + add_packages("vcpkg::cpr", "vcpkg::http-parser", "vcpkg::mimalloc") + + if is_plat("macosx") then + add_ldflags("-framework CoreFoundation") + add_ldflags("-framework Security") + add_ldflags("-framework SystemConfiguration") + end diff --git a/src/zenmaster-test/zenmaster-test.cpp b/src/zenmaster-test/zenmaster-test.cpp new file mode 100644 index 000000000..7511d6b4a --- /dev/null +++ b/src/zenmaster-test/zenmaster-test.cpp @@ -0,0 +1,96 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING + +#include <zenbase/refcount.h> +#include <zencore/compactbinary.h> +#include <zencore/compactbinarybuilder.h> +#include <zencore/compactbinarypackage.h> +#include <zencore/compress.h> +#include <zencore/except.h> +#include <zencore/fmtutils.h> +#include <zencore/logging.h> +#include <zencore/memoryview.h> +#include <zencore/scopeguard.h> +#include <zencore/stream.h> +#include <zencore/string.h> +#include <zencore/testutils.h> +#include <zencore/timer.h> +#include <zencore/xxhash.h> +#include <zenutil/logging/testformatter.h> +#include <zenutil/zenserverprocess.h> + +#include <atomic> +#include <filesystem> +#include <map> +#include <random> +#include <span> +#include <thread> +#include <typeindex> +#include <unordered_map> + +#include <zencore/memory/newdelete.h> + +////////////////////////////////////////////////////////////////////////// + +#if ZEN_WITH_TESTS +# define ZEN_TEST_WITH_RUNNER 1 +# include <zencore/testing.h> +#endif + +using namespace std::literals; + +#if !ZEN_WITH_TESTS +int +main() +{ +} +#else +zen::ZenServerEnvironment TestEnv; + +int +main(int argc, char** argv) +{ + using namespace std::literals; + using namespace zen; + +# if ZEN_PLATFORM_LINUX + IgnoreChildSignals(); +# endif + + zen::TraceInit("zenmaster-test"); + zen::logging::InitializeLogging(); + + zen::logging::SetLogLevel(zen::logging::level::Debug); + spdlog::set_formatter(std::make_unique<zen::logging::full_test_formatter>("test", std::chrono::system_clock::now())); + + std::filesystem::path ProgramBaseDir = GetRunningExecutablePath().parent_path(); + std::filesystem::path TestBaseDir = std::filesystem::current_path() / ".test"; + + // This is pretty janky because we're passing most of the options through to the test + // framework, so we can't just use cxxopts (I think). This should ideally be cleaned up + // somehow in the future + + std::string ServerClass; + + for (int i = 1; i < argc; ++i) + { + if (argv[i] == "--http"sv) + { + if ((i + 1) < argc) + { + ServerClass = argv[++i]; + } + } + } + + TestEnv.InitializeForTest(ProgramBaseDir, TestBaseDir, ServerClass); + + ZEN_INFO("Running tests...(base dir: '{}')", TestBaseDir); + + zen::testing::TestRunner Runner; + Runner.ApplyCommandLine(argc, argv); + + return Runner.Run(); +} +#endif |