diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df554e8f..16c6d6bc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,15 @@ on: - "**" types: [opened, synchronize, reopened] workflow_dispatch: + inputs: + verbose: + description: "Enable verbose logging during tests" + type: choice + required: false + default: "false" + options: + - "true" + - "false" #concurrency: # group: ${{ github.ref }} @@ -246,6 +255,7 @@ jobs: run: cd build/${{matrix.preset}} && ctest --verbose env: EMULATOR_ROOT: ${{github.workspace}}/build/${{matrix.preset}}/artifacts/root + EMULATOR_VERBOSE: ${{ github.event.inputs.verbose }} smoke-test-android: name: Smoke Test Android diff --git a/src/analyzer/main.cpp b/src/analyzer/main.cpp index 19d366a2..3b855fc4 100644 --- a/src/analyzer/main.cpp +++ b/src/analyzer/main.cpp @@ -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; diff --git a/src/windows-emulator-test/emulation_test_utils.hpp b/src/windows-emulator-test/emulation_test_utils.hpp index f36ce716..fc483139 100644 --- a/src/windows-emulator-test/emulation_test_utils.hpp +++ b/src/windows-emulator-test/emulation_test_utils.hpp @@ -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)}; diff --git a/src/windows-emulator/windows_emulator.cpp b/src/windows-emulator/windows_emulator.cpp index 479b40a4..e72a1795 100644 --- a/src/windows-emulator/windows_emulator.cpp +++ b/src/windows-emulator/windows_emulator.cpp @@ -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_); diff --git a/src/windows-emulator/windows_emulator.hpp b/src/windows-emulator/windows_emulator.hpp index e88a522f..332f6f4c 100644 --- a/src/windows-emulator/windows_emulator.hpp +++ b/src/windows-emulator/windows_emulator.hpp @@ -32,6 +32,7 @@ struct emulator_settings std::filesystem::path registry_directory{"./registry"}; std::filesystem::path emulation_root{}; std::vector arguments{}; + bool verbose_calls{false}; bool disable_logging{false}; bool silent_until_main{false}; bool use_relative_time{false};