winetests: new addition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a rewrite of the stuff Jakob submitted, to
make it fit better in the Wine tree.

It is still not perfect. I'm still not sure how to
support building with PE .exes, but we need to have
this in the tree so others can comment on it, and
submit patches. In particular, I don't want to hold
Feri back from finishing his nice processing script.

I have not added it to the list of programs compiled
by default, as I'm not sure it helps anybody to build
a large program like this. This is obviously trivial
to fix once we are all happy with the result.

ChangeLog
    Dimitrie O. Paun <dpaun@rogers.com>
    Jakob Eriksson <jakob@vmlinux.org>
    New winetests shell for making it easy to run the 
    conformance tests, and submit the results.

Index: configure.ac
===================================================================
RCS file: /var/cvs/wine/configure.ac,v
retrieving revision 1.183
diff -u -r1.183 configure.ac
--- configure.ac	4 Oct 2003 03:48:11 -0000	1.183
+++ configure.ac	7 Oct 2003 18:10:42 -0000
@@ -1577,6 +1577,7 @@
 programs/winemenubuilder/Makefile
 programs/winemine/Makefile
 programs/winepath/Makefile
+programs/winetests/Makefile
 programs/winevdm/Makefile
 programs/winhelp/Makefile
 programs/winver/Makefile
--- /dev/null	2003-01-30 05:24:37.000000000 -0500
+++ programs/winetests/Makefile.in	2003-10-07 15:22:08.000000000 -0400
@@ -0,0 +1,32 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = winetests.exe
+APPMODE   = gui
+IMPORTS   = shell32 user32 gdi32 advapi32 kernel32
+
+C_SRCS = main.c 
+EXTRA_OBJS = winetests.o
+RC_SRCS = winetests.rc
+
+@MAKE_PROG_RULES@
+
+# Special rules
+
+winetests.rc: maketests tests.list
+	$(SRCDIR)/maketests -r > $@
+
+winetests.subtests: maketests tests.list
+	$(SRCDIR)/maketests -s > $@
+
+winetests.tests: maketests tests.list
+	$(SRCDIR)/maketests -t > $@
+
+winetests.c: winetests.tests winetests.subtests
+	(echo "#include \"winetests.h\""; cat winetests.subtests winetests.tests) > $@
+
+### Dependencies:
--- /dev/null	2003-01-30 05:24:37.000000000 -0500
+++ programs/winetests/winetests.h	2003-10-07 14:14:02.000000000 -0400
@@ -0,0 +1,16 @@
+
+#ifndef __WINETESTS_H
+#define __WINETESTS_H
+
+struct wine_test
+{
+    const char *name;
+    int subtest_count;
+    const char **subtests;
+    int is_elf;
+    const char *exename;
+};
+
+extern struct wine_test wine_tests[];
+
+#endif /* __WINETESTS_H */
--- /dev/null	2003-01-30 05:24:37.000000000 -0500
+++ programs/winetests/main.c	2003-10-07 15:24:00.000000000 -0400
@@ -0,0 +1,239 @@
+/*
+ * Wine Conformance Test EXE
+ *
+ * Copyright 2003 Jakob Eriksson   (for Solid Form Sweden AB)
+ * Copyright 2003 Dimitrie O. Paun
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ *
+ * This program is dedicated to Anna Lindh,
+ * Swedish Minister of Foreign Affairs.
+ * Anna was murdered September 11, 2003.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <ctype.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include <wtypes.h>
+#include <shellapi.h>
+#include <shellapi.h>
+
+#include "winetests.h"
+
+#define MARKER "@RESULTS@"
+
+void fatal(const char* msg)
+{
+    MessageBox( NULL, msg, "Error", MB_ICONERROR | MB_OK );
+    exit(1);
+}
+
+char *strmake(const char *fmt, ...)
+{
+    int n;
+    size_t size = 100;
+    char *p;
+    va_list ap;
+
+    if (!(p = malloc (size))) fatal("Out of memory.");
+    
+
+    while (1)
+    {
+        va_start(ap, fmt);
+	n = vsnprintf (p, size, fmt, ap);
+	va_end(ap);
+        if (n > -1 && n < size) return p;
+	size = min( size*2, n+1 );
+	if(!(p = realloc (p, size))) fatal("Out of memory.");
+    }
+}
+
+int print_version(FILE *fout)
+{
+    OSVERSIONINFOEX ver;
+
+    ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); 
+    if (!GetVersionEx ((OSVERSIONINFO *) &ver))
+    {
+	ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 
+	if (!GetVersionEx ((OSVERSIONINFO *) &ver))
+	    return 0;
+    }
+
+    fprintf(fout, "    dwMajorVersion=%ld\n    dwMajorVersion=%ld\n"
+		  "    dwBuildNumber=%ld\n    PlatformId=%ld\n    szCSDVersion=%s\n",
+	          ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber, 
+		  ver.dwPlatformId, ver.szCSDVersion);
+
+    if (ver.dwOSVersionInfoSize < sizeof(OSVERSIONINFOEX)) return 1;
+    
+    fprintf(fout, "    wServicePackMajor=%d\n    wServicePackMinor=%d\n"
+		  "    wSuiteMask=%d\n    wProductType=%d\n    wReserved=%d\n",
+		  ver.wServicePackMajor, ver.wServicePackMinor, ver.wSuiteMask, 
+		  ver.wProductType, ver.wReserved);
+    return 1;
+}
+
+void deletePath( char *path )
+{
+    SHFILEOPSTRUCT fileop;
+
+    path[strlen( path ) + 1] = '\0';
+
+    fileop.hwnd = NULL;
+    fileop.wFunc = FO_DELETE;
+    fileop.pFrom = path;
+    fileop.pTo = NULL;
+    fileop.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI;
+
+    SHFileOperation( &fileop );
+}
+
+int count_tests()
+{
+    struct wine_test* test;
+    int total = 0;
+
+    for (test = wine_tests; test->name; test++)
+	total += test->subtest_count;
+
+    return total;
+}
+
+LPVOID extract_rcdata (const char *name, DWORD* size)
+{
+    HRSRC rsrc;
+    HGLOBAL hdl;
+    
+    if (!(rsrc = FindResource( 0, name, RT_RCDATA ))) return 0;
+    if (!(*size = SizeofResource( 0, rsrc ))) return 0;
+    if (!(hdl = LoadResource( 0, rsrc ))) return 0;
+    return LockResource(hdl);
+}
+
+int extract_test (const char *dir, struct wine_test* test)
+{
+    BYTE* code;
+    DWORD size;
+    FILE* fout;
+
+    if (!(code = extract_rcdata(test->name, &size))) return 0;
+    
+    test->is_elf = (code[1] == 'E' && code[2] == 'L' && code[3] == 'F');
+    test->exename = strmake("%s/%s.exe%s", dir, test->name,
+			    test->is_elf ? ".so" : "");
+
+    if((fout = fopen(test->exename, "wb")))
+    {
+        fwrite(code, size, 1, fout);
+        fclose(fout);
+    }
+    return fout != 0;
+}
+
+int run_test(FILE* logfp, struct wine_test* test, const char* subtest)
+{
+    char line[512], *cmd;
+    FILE *fp;
+
+    fprintf( logfp, "%s:%s start\n", test->name, subtest );
+   
+    cmd = strmake("%s %s %s", test->is_elf ? "wine " : "", test->exename, subtest);
+    if ((fp = popen( cmd, "r" )))
+    {
+	while (fgets( line, sizeof(line), fp ))
+	    fprintf( logfp, "%s", line );
+	fclose( fp );
+    }
+    else fprintf( logfp, "Failed to execute\n");
+
+    fprintf( logfp, "%s:%s done\n", test->name, subtest );
+
+    return fp != 0;
+}
+
+int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow )
+{
+    struct wine_test* test;
+    int nr_of_tests, subtest;
+    char *tempdir, *logfile;
+    char *html, *marker;
+    DWORD htmlSize;
+    FILE *fp;
+
+    SetErrorMode( SEM_FAILCRITICALERRORS );
+
+    if(MessageBox( 0, " This progam will run a series of conformance tests for Windows.\n"
+	    	  " Proceed with tests? ", "Wine Conformance Tester", 
+		  MB_ICONQUESTION | MB_YESNO ) != IDYES) return 0;
+
+    printf( "Setting up environment...\n" );
+    if (!(tempdir = tempnam(0, "wct"))) fatal("Can't create temporary dir.");
+    printf( "    tempdir=%s\n", tempdir );
+    if (mkdir( tempdir, 0777 )) fatal(strmake("Could not create directory: %s", tempdir));
+    if (chdir( tempdir )) fatal(strmake("Could not make %s current directory.", tempdir));
+
+    if (!(logfile = tempnam(0, "res"))) fatal("Can't create result file.");
+    logfile = strmake("%s.html", logfile );
+    printf( "    logfile=%s\n", logfile );
+ 
+    if (!(html = extract_rcdata("results", &htmlSize))) fatal("Can't find HTML.");
+    //html[htmlSize - 1] = 0; /* make sure the HTML is ended properly */
+    if (!(marker = strstr(html, MARKER))) fatal("Invalid HTML."); 
+
+    /* Init log file */
+    if (!(fp = fopen( logfile, "w" ))) fatal("Could not open log file.");
+
+    fwrite( html, marker - html, 1, fp);
+
+    fprintf( fp, "Tests from build %s\n", "FIXME" ); 
+    
+    fprintf( fp, "Operating system version:\n");
+    if (!print_version(fp)) fprintf( fp, "    N/A\n");
+ 
+    fprintf( fp, "Test output:\n" );
+
+    printf( "Extracting tests...\n" );
+    for(test = wine_tests; test->name; test++)
+	if (!extract_test( tempdir, test )) 
+	    fatal(strmake("Failed to extract %s", test->name));
+
+    nr_of_tests = count_tests();
+
+    printf( "Running the %d tests...\n", nr_of_tests );
+    for(test = wine_tests; test->name; test++)
+	for (subtest = 0; subtest < test->subtest_count; subtest++)
+	    run_test( fp, test, test->subtests[subtest] );
+
+    marker += strlen(MARKER);
+    fwrite( marker, htmlSize - (marker - html), 1, fp);
+    fclose( fp );
+
+    printf( "Cleaning up...\n");
+    deletePath( tempdir );
+
+    printf( "Starting web browser...\n");
+    ShellExecute( NULL, "open", logfile, NULL, NULL, SW_SHOWNORMAL );
+
+    printf("Done!\n");
+    return 0;
+}
+
--- /dev/null	2003-01-30 05:24:37.000000000 -0500
+++ programs/winetests/maketests	2003-10-07 14:10:28.000000000 -0400
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+MODE="$1"
+
+BINDIR="../.."
+TEST_EXES="`cat tests.list | sed 's/#.*//'`"
+
+echo "/* Automatically generated -- do not edit! */"
+case $MODE in
+    -r)
+	echo "results RCDATA LOADONCALL DISCARDABLE \"results.html\""
+    ;;
+    -t)
+	echo "#define DECLARE_TEST(test) { #test, sizeof(subtests_for_ ## test)/sizeof(char *), subtests_for_ ## test } "
+	echo "struct wine_test wine_tests[] = {"
+    ;;
+esac
+
+for test in $TEST_EXES; do
+    testname=`basename $test .exe`
+    filename="$BINDIR/$test.so"
+    case $MODE in
+	-r)
+	    strip -s "$filename"
+	    echo "$testname RCDATA LOADONCALL DISCARDABLE \"$filename\""
+	;;
+	-s)
+	    echo "const char* subtests_for_$testname[] = {"
+	    wine "$filename" | sed -n '/^Valid/,$p' | sed '1d;s/    \(.*\)/    "\1",/'
+	    echo "};"
+	;;
+	-t)
+	    echo "    DECLARE_TEST($testname),"
+	;;
+    esac
+done
+
+case $MODE in
+    -t)
+	echo "    { 0 }"
+	echo "};"
+    ;;
+esac
+
--- /dev/null	2003-01-30 05:24:37.000000000 -0500
+++ programs/winetests/results.html	2003-10-06 02:18:20.000000000 -0400
@@ -0,0 +1,23 @@
+<html>
+  <head>
+    <title>Wine Regression testing</title>
+  </head>
+  <body>
+  <h1>Wine Project Test Feedback</h1>
+  Sending this test report to the Wine developers will help them make Wine more
+  Windows conformant. If you want to help, press &quot;Submit Results&quot;.
+  <form method=POST action="mailto:wine-tests@winehq.org"; enctype="text/plain">
+    <input type="submit" value="Submit Results">
+    <p>Enter your name/handle/email here: <br>
+    <input size="100%" type="text" value="" name="Tester">
+    <p>Enter any comment you want to make here: <br>
+    <input size="100%" type="text" value="" name="comment">
+    <p>Data gathered by the test script: <br>
+    <textarea name=logreport id=text wrap=off style=%EDITBOXSTYLE% rows=30 cols=120>
+@RESULTS@
+    </textarea>
+ </form>
+ </body>
+</html>
+
+
--- /dev/null	2003-01-30 05:24:37.000000000 -0500
+++ programs/winetests/tests.list	2003-10-06 13:21:32.000000000 -0400
@@ -0,0 +1,14 @@
+dlls/comctl32/tests/comctl32_test.exe
+dlls/user/tests/user32_test.exe
+dlls/ntdll/tests/ntdll_test.exe
+dlls/rpcrt4/tests/rpcrt4_test.exe
+#dlls/advapi32/tests/advapi32_test.exe
+#dlls/wininet/tests/wininet_test.exe
+#dlls/shlwapi/tests/shlwapi_test.exe
+#dlls/netapi32/tests/netapi32_test.exe
+#dlls/winmm/tests/winmm_test.exe
+#dlls/shell32/tests/shell32_test.exe
+#dlls/oleaut32/tests/oleaut32_test.exe
+#dlls/winsock/tests/ws2_32_test.exe
+#dlls/urlmon/tests/urlmon_test.exe
+#dlls/gdi/tests/gdi32_test.exe

-- 
Dimi.



[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux