Francois Gouget : testbot/TestLauncher: Import some sanity checks from WineTest.

Alexandre Julliard julliard at winehq.org
Mon Mar 29 15:47:42 CDT 2021


Module: tools
Branch: master
Commit: ce576c3c9760be0e3329da9b6e08851bec13403d
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=ce576c3c9760be0e3329da9b6e08851bec13403d

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Mon Mar 29 16:01:52 2021 +0200

testbot/TestLauncher: Import some sanity checks from WineTest.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/src/TestLauncher/TestLauncher.c | 106 ++++++++++++++++++++++++++++++++
 1 file changed, 106 insertions(+)

diff --git a/testbot/src/TestLauncher/TestLauncher.c b/testbot/src/TestLauncher/TestLauncher.c
index 2a423d2..b024714 100644
--- a/testbot/src/TestLauncher/TestLauncher.c
+++ b/testbot/src/TestLauncher/TestLauncher.c
@@ -21,6 +21,7 @@
  */
 
 #include <stdio.h>
+#include <assert.h>
 #include <errno.h>
 #include <windows.h>
 
@@ -49,6 +50,90 @@ void Error(const char* Format, ...)
 }
 
 
+/*
+ * Configuration / wineprefix sanity checks (from winetest.exe)
+ */
+
+static BOOL is_wow64(void)
+{
+   BOOL is_wow64;
+   BOOL (WINAPI *pIsWow64Process)(HANDLE hProcess, PBOOL Wow64Process);
+   HANDLE hkernel32 = GetModuleHandleA("kernel32.dll");
+   pIsWow64Process = (void *)GetProcAddress(hkernel32, "IsWow64Process");
+   if (!pIsWow64Process || !pIsWow64Process(GetCurrentProcess(), &is_wow64))
+      return FALSE;
+   return is_wow64;
+}
+
+static BOOL running_under_wine (void)
+{
+   HMODULE module = GetModuleHandleA("ntdll.dll");
+
+   if (!module) return FALSE;
+   return (GetProcAddress(module, "wine_server_call") != NULL);
+}
+
+static BOOL check_mount_mgr(void)
+{
+   HANDLE handle = CreateFileA( "\\\\.\\MountPointManager", GENERIC_READ,
+                                FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
+   if (handle == INVALID_HANDLE_VALUE) return FALSE;
+   CloseHandle( handle );
+   return TRUE;
+}
+
+static BOOL check_wow64_registry(void)
+{
+   char buffer[MAX_PATH];
+   DWORD type, size = MAX_PATH;
+   HKEY hkey;
+   BOOL ret;
+
+   if (!is_wow64()) return TRUE;
+   if (RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion", &hkey ))
+      return FALSE;
+   ret = !RegQueryValueExA( hkey, "ProgramFilesDir (x86)", NULL, &type, (BYTE *)buffer, &size );
+   RegCloseKey( hkey );
+   return ret;
+}
+
+static BOOL check_display_driver(void)
+{
+   HWND hwnd = CreateWindowA( "STATIC", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
+                              0, 0, GetModuleHandleA(0), 0 );
+   if (!hwnd) return FALSE;
+   DestroyWindow( hwnd );
+   return TRUE;
+}
+
+static BOOL running_on_visible_desktop (void)
+{
+    HWND desktop;
+    HMODULE huser32 = GetModuleHandleA("user32.dll");
+    HWINSTA (WINAPI *pGetProcessWindowStation)(void);
+    BOOL (WINAPI *pGetUserObjectInformationA)(HANDLE,INT,LPVOID,DWORD,LPDWORD);
+
+    pGetProcessWindowStation = (void *)GetProcAddress(huser32, "GetProcessWindowStation");
+    pGetUserObjectInformationA = (void *)GetProcAddress(huser32, "GetUserObjectInformationA");
+
+    desktop = GetDesktopWindow();
+    if (!GetWindowLongPtrW(desktop, GWLP_WNDPROC)) /* Win9x */
+        return IsWindowVisible(desktop);
+
+    if (pGetProcessWindowStation && pGetUserObjectInformationA)
+    {
+        DWORD len;
+        HWINSTA wstation;
+        USEROBJECTFLAGS uoflags;
+
+        wstation = pGetProcessWindowStation();
+        assert(pGetUserObjectInformationA(wstation, UOI_FLAGS, &uoflags, sizeof(uoflags), &len));
+        return (uoflags.dwFlags & WSF_VISIBLE) != 0;
+    }
+    return IsWindowVisible(desktop);
+}
+
+
 /*
  * Missing dll and entry point detection.
  */
@@ -152,6 +237,8 @@ int main(int argc, char *argv[])
       p++;
    }
 
+   /* Command line parsing and validation */
+
    TimeOut = INFINITE;
    CommandLine = NULL;
    Arg = 1;
@@ -230,6 +317,25 @@ int main(int argc, char *argv[])
       return 1;
    }
 
+   /* Configuration / wineprefix sanity checks (from winetest.exe) */
+
+   if (!running_on_visible_desktop())
+      Error("Tests must be run on a visible desktop\n");
+
+   if (running_under_wine())
+   {
+      if (!check_mount_mgr())
+         Error("Mount manager not running, most likely your WINEPREFIX wasn't created correctly\n");
+
+      if (!check_wow64_registry())
+         Error("WoW64 keys missing, most likely your WINEPREFIX wasn't created correctly\n");
+
+      if (!check_display_driver())
+         Error("Unable to create a window, the display driver is not working\n");
+   }
+
+   /* Run the test */
+
    Start = GetTickCount();
    printf("%s:%s start -\n", TestName, Subtest);
    fflush(stdout);




More information about the wine-cvs mailing list