Sebastian Lackner : include: Automatically detect if tests are running under Wine when WINETEST_PLATFORM is not specified.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Apr 6 10:34:18 CDT 2015


Module: wine
Branch: master
Commit: 61b8a189c531ab1712039355267c45fca5b5d032
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=61b8a189c531ab1712039355267c45fca5b5d032

Author: Sebastian Lackner <sebastian at fds-team.de>
Date:   Sun Nov 23 22:50:34 2014 +0100

include: Automatically detect if tests are running under Wine when WINETEST_PLATFORM is not specified.

---

 include/wine/test.h | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/wine/test.h b/include/wine/test.h
index f8b608f..567229a 100644
--- a/include/wine/test.h
+++ b/include/wine/test.h
@@ -618,6 +618,14 @@ static LONG CALLBACK exc_filter( EXCEPTION_POINTERS *ptrs )
     return EXCEPTION_EXECUTE_HANDLER;
 }
 
+/* check if we're running under wine */
+static BOOL running_under_wine(void)
+{
+    HMODULE module = GetModuleHandleA( "ntdll.dll" );
+    if (!module) return FALSE;
+    return (GetProcAddress( module, "wine_server_call" ) != NULL);
+}
+
 #ifdef __GNUC__
 void _fpreset(void) {} /* override the mingw fpu init code */
 #endif
@@ -632,7 +640,11 @@ int main( int argc, char **argv )
     winetest_argc = argc;
     winetest_argv = argv;
 
-    if (GetEnvironmentVariableA( "WINETEST_PLATFORM", p, sizeof(p) )) winetest_platform = strdup(p);
+    if (GetEnvironmentVariableA( "WINETEST_PLATFORM", p, sizeof(p) ))
+        winetest_platform = strdup(p);
+    else if (running_under_wine())
+        winetest_platform = "wine";
+
     if (GetEnvironmentVariableA( "WINETEST_DEBUG", p, sizeof(p) )) winetest_debug = atoi(p);
     if (GetEnvironmentVariableA( "WINETEST_INTERACTIVE", p, sizeof(p) )) winetest_interactive = atoi(p);
     if (GetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", p, sizeof(p) )) report_success = atoi(p);




More information about the wine-cvs mailing list