From a41173a1aed8a04ec128544e2a04bf24095beea9 Mon Sep 17 00:00:00 2001 From: Sc4ros <353102343+Sc4ros@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:15:41 +0100 Subject: Tests: gameinput_host fails instead of skipping when GameInput.dll is present (review) - gameinput_host_test decides the skip before mapping: LoadLibraryExW of GameInput.dll from System32. Only "not found" skips (77); an import that then binds to nothing is a failure. Breaking host ordinal binding in Loader::resolve now fails the test (4 failures) instead of skipping. - The gameinput_host fixture links in Debug: /RTC1 with /NODEFAULTLIB left _RTC_InitBase, _RTC_Shutdown and _RTC_CheckStackVars unresolved, so the fixture defines them as no-ops when runtime checks are on. - The fixture reports E_FAIL, not S_OK, when GameInputCreate fails, and the test counts a gamepad as attached only when the library was created. Co-Authored-By: Claude Sonnet 5.5 --- runtime/test/gameinput_host_test.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'runtime/test/gameinput_host_test.cpp') diff --git a/runtime/test/gameinput_host_test.cpp b/runtime/test/gameinput_host_test.cpp index 5673965a9..cdd071055 100644 --- a/runtime/test/gameinput_host_test.cpp +++ b/runtime/test/gameinput_host_test.cpp @@ -6,7 +6,8 @@ // - GameInputCreate succeeds from mapped code, and the library answers GetCurrentTimestamp; // - GetCurrentReading says either "reading" or "no reading found": no crash, no other error. With a gamepad attached // GetGamepadState must succeed on the reading; the test passes with or without one. -// Skips (exit 77) where there is no GameInput.dll (the import is then unimplemented). No game files. +// Skips (exit 77) only where Windows itself cannot load GameInput.dll (asked before mapping, with LoadLibraryExW). +// When the DLL is there, an import that binds to nothing is a failure, not a skip. No game files. #include #include @@ -37,6 +38,19 @@ int main(int argc, char** argv) { return 2; } const std::filesystem::path fixture = argv[1]; + + // Decide the skip from the machine, not from the loader's answer: a broken host binding must fail the test. + HMODULE const host_gameinput = LoadLibraryExW(L"GameInput.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); + if (!host_gameinput) { + const DWORD error = GetLastError(); + if (error == ERROR_MOD_NOT_FOUND || error == ERROR_FILE_NOT_FOUND || error == ERROR_PATH_NOT_FOUND) { + std::printf("SKIP: no GameInput.dll on this machine\n"); + return 77; + } + std::printf("FAIL GameInput.dll is present but does not load (error %lu)\n", static_cast(error)); + return 1; + } + try { rt::Loader loader(fixture.parent_path()); rt::Module& m = loader.load(fixture); @@ -49,10 +63,6 @@ int main(int argc, char** argv) { binding = r.binding; ++seen; } - if (seen == 1 && binding == rt::Binding::Unimplemented) { - std::printf("SKIP: no GameInput.dll on this machine\n"); - return 77; - } check(seen == 1 && binding == rt::Binding::Host, "the GameInput.dll import binds to the host's copy"); loader.initialise(); @@ -65,7 +75,7 @@ int main(int argc, char** argv) { timestamp, static_cast(reading_hr)); check(created == 1 && create_hr == 0, "GameInputCreate succeeds from mapped code"); check(timestamp != 0, "GetCurrentTimestamp returns a time"); - const bool pad = reading_hr == 0; + const bool pad = created == 1 && reading_hr == 0; check(pad || static_cast(reading_hr) == kReadingNotFound, "GetCurrentReading says either 'reading' or 'no reading found'"); std::printf(" gamepad reading: %s\n", pad ? "yes (a gamepad is attached)" : "none (no gamepad attached)"); @@ -74,6 +84,7 @@ int main(int argc, char** argv) { std::printf("FAIL unexpected exception: %s\n", e.what()); ++g_failures; } + FreeLibrary(host_gameinput); std::printf("gameinput_host_test: %s (%d failures)\n", g_failures ? "FAILED" : "OK", g_failures); return g_failures ? 1 : 0; } -- cgit v1.2.3