diff --git a/main.cpp b/main.cpp index 83325a0..fcf2f8c 100644 --- a/main.cpp +++ b/main.cpp @@ -1383,11 +1383,13 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) { // Callback availability is distinct from foreground attachment. There may // be no matching application when this startup snapshot is emitted. std::fprintf(stderr, "wine-access: ready {\"reader\":\"%s\",\"controls_enabled\":%s," + "\"hook_exclusions\":%d," "\"controller\":%s,\"review\":%s,\"msaa_worker\":%s,\"win_events\":%s," "\"menu_hook\":%s,\"input_hook\":%s," "\"menu_hook_available\":%s,\"input_hook_available\":%s," "\"host32_started\":%s,\"control_poll\":%s}\n", readerEndpoint.busName, dialogReaderEnabled ? "true" : "false", + hookExclusions.count, controllerActive ? "true" : "false", reviewActive ? "true" : "false", msaaActive ? "true" : "false", hook ? "true" : "false", foregroundHooks.menu ? "true" : "false", foregroundHooks.input ? "true" : "false", diff --git a/tests/diagnostics_test.py b/tests/diagnostics_test.py index 12423de..9381bec 100644 --- a/tests/diagnostics_test.py +++ b/tests/diagnostics_test.py @@ -93,6 +93,7 @@ with wine_test_directory(prefix="wine-access-diagnostics-") as temporary: for field in ("controls_enabled", "review", "msaa_worker", "win_events", "control_poll"): assert ready[field], (field, ready) assert not ready["controller"] + assert ready["hook_exclusions"] == 0, ready for field in ("menu_hook_available", "input_hook_available", "host32_started"): assert ready[field] == (not missingHooks), (field, ready) # Hooks attach only to a matching foreground UI thread, which @@ -112,8 +113,34 @@ with wine_test_directory(prefix="wine-access-diagnostics-") as temporary: helper.terminate() helper.wait(timeout=5) helper = None + # Exclusion flags are counted in the ready record: duplicates + # collapse, invalid values are rejected and reported. + logPath = testDir / "exclusions.log" + with logPath.open("w") as diagnostics: + helper = subprocess.Popen( + [str(executable), "--no-controller", + "--exclude-hook-program", "Game.exe", + "--exclude-hook-program", "game.EXE", + "--exclude-hook-program", "Other Program.exe", + "--exclude-hook-program", "../bad.exe"], + env=env, stdout=subprocess.DEVNULL, stderr=diagnostics) + deadline = time.monotonic() + 5 + while "wine-access: ready " not in logPath.read_text() and time.monotonic() < deadline: + while GLib.MainContext.default().iteration(False): + pass + assert helper.poll() is None, logPath.read_text() + time.sleep(0.01) + lines = logPath.read_text().splitlines() + ready = next(json.loads(line.removeprefix("wine-access: ready ")) + for line in lines if line.startswith("wine-access: ready ")) + assert ready["hook_exclusions"] == 2, ready + assert "wine-access: hook exclusions for 2 program(s)" in lines + assert "wine-access: ignoring invalid --exclude-hook-program value" in lines + helper.terminate() + helper.wait(timeout=5) + helper = None finally: subprocess.run(["wineserver", "-k"], env=env, timeout=10, check=False) if helper is not None: helper.wait(timeout=10) -print("PASS: version without reader/with singleton, unavailable reader, healthy and missing-hook startup") +print("PASS: version without reader/with singleton, unavailable reader, healthy and missing-hook startup, hook exclusion counts") diff --git a/tests/hook_exclusions_test.cpp b/tests/hook_exclusions_test.cpp index ca05016..79140f4 100644 --- a/tests/hook_exclusions_test.cpp +++ b/tests/hook_exclusions_test.cpp @@ -47,6 +47,8 @@ int main() { oversized[WINE_ACCESS_MAX_HOOK_EXCLUSION_LENGTH] = 0; ok &= check(wine_access_hook_exclusions_add(&exclusions, oversized.data()), "maximum-size exclusion is accepted"); + ok &= check(exclusions.count == 2, + "rejected exclusions do not change the stored count"); static WineAccessHookExclusions parsed; const int added = wine_access_hook_exclusions_parse(