mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-25 22:51:03 +00:00
Support verbose logging during tests
This commit is contained in:
@@ -111,6 +111,7 @@ namespace
|
||||
.registry_directory = options.registry_path,
|
||||
.emulation_root = options.emulation_root,
|
||||
.arguments = parse_arguments(args),
|
||||
.verbose_calls = options.verbose_logging,
|
||||
.silent_until_main = options.concise_logging,
|
||||
};
|
||||
|
||||
@@ -119,7 +120,6 @@ namespace
|
||||
(void)&watch_system_objects;
|
||||
watch_system_objects(win_emu, options.concise_logging);
|
||||
win_emu.buffer_stdout = true;
|
||||
win_emu.verbose_calls = options.verbose_logging;
|
||||
|
||||
const auto& exe = *win_emu.process().executable;
|
||||
|
||||
|
||||
@@ -21,9 +21,15 @@
|
||||
|
||||
namespace test
|
||||
{
|
||||
inline bool enable_verbose_logging()
|
||||
{
|
||||
const auto* env = getenv("EMULATOR_VERBOSE");
|
||||
return env && (env == "1"sv || env == "true"sv);
|
||||
}
|
||||
|
||||
inline std::filesystem::path get_emulator_root()
|
||||
{
|
||||
auto* env = getenv("EMULATOR_ROOT");
|
||||
const auto* env = getenv("EMULATOR_ROOT");
|
||||
if (!env)
|
||||
{
|
||||
throw std::runtime_error("No EMULATOR_ROOT set!");
|
||||
@@ -34,6 +40,14 @@ namespace test
|
||||
|
||||
inline windows_emulator create_sample_emulator(emulator_settings settings, emulator_callbacks callbacks = {})
|
||||
{
|
||||
const auto is_verbose = enable_verbose_logging();
|
||||
|
||||
if (is_verbose)
|
||||
{
|
||||
settings.disable_logging = false;
|
||||
settings.verbose_calls = true;
|
||||
}
|
||||
|
||||
settings.application = "c:/test-sample.exe";
|
||||
settings.emulation_root = get_emulator_root();
|
||||
return windows_emulator{std::move(settings), std::move(callbacks)};
|
||||
|
||||
@@ -838,6 +838,7 @@ windows_emulator::windows_emulator(const emulator_settings& settings, emulator_c
|
||||
this->file_sys().set_working_directory(settings.application.parent());
|
||||
}
|
||||
|
||||
this->verbose_calls = settings.verbose_calls;
|
||||
this->silent_until_main_ = settings.silent_until_main && !settings.disable_logging;
|
||||
this->use_relative_time_ = settings.use_relative_time;
|
||||
this->log.disable_output(settings.disable_logging || this->silent_until_main_);
|
||||
|
||||
@@ -32,6 +32,7 @@ struct emulator_settings
|
||||
std::filesystem::path registry_directory{"./registry"};
|
||||
std::filesystem::path emulation_root{};
|
||||
std::vector<std::u16string> arguments{};
|
||||
bool verbose_calls{false};
|
||||
bool disable_logging{false};
|
||||
bool silent_until_main{false};
|
||||
bool use_relative_time{false};
|
||||
|
||||
Reference in New Issue
Block a user