winetest: add support for revision info

Dimitrie O. Paun dpaun at rogers.com
Fri Mar 19 20:31:59 CST 2004


For whatever reason, winetest doesn't run on my box,
but this compiles, and seems OK...

By default, we don't build the revision info into
winetest, because we can't depend on the source
being a CVS tree. Besides, it would slow down the
build process needlessly. This information is
optional, and the processing scripts know now how
to deal with them. To have the revision info into
winetest.exe, you need to issue a
	make revision.info
before building it. This will be done by the nightly
build job (which we'll have hopefully in the near
future).

ChangeLog
    Add revision support to winetest.exe.

Index: programs/winetest/Makefile.in
===================================================================
RCS file: /var/cvs/wine/programs/winetest/Makefile.in,v
retrieving revision 1.22
diff -u -r1.22 Makefile.in
--- programs/winetest/Makefile.in	9 Mar 2004 04:54:07 -0000	1.22
+++ programs/winetest/Makefile.in	19 Mar 2004 18:43:08 -0000
@@ -47,6 +47,9 @@
 winetest.rc: maketest Makefile.in
 	$(SRCDIR)/maketest $(TESTBINS) > $@ || ( $(RM) $@ && exit 1 )
 
+revision.info:
+	(cd $(TOPSRCDIR); for file in dlls/*/tests/*.c; do rev=`cvs stat "$$file" | grep "Working" | awk '{print $$3}'`; echo "$$file:$$rev"; done) > $@ || ( $(RM) $@ && exit 1 )
+
 winetest.res: $(TESTBINS)
 
 clean::
Index: programs/winetest/main.c
===================================================================
RCS file: /var/cvs/wine/programs/winetest/main.c,v
retrieving revision 1.6
diff -u -r1.6 main.c
--- programs/winetest/main.c	19 Mar 2004 01:54:10 -0000	1.6
+++ programs/winetest/main.c	19 Mar 2004 20:06:45 -0000
@@ -49,7 +49,14 @@
     char *exename;
 };
 
+struct rev_info
+{
+    const char* file;
+    const char* rev;
+};
+
 static struct wine_test *wine_tests;
+static struct rev_info *rev_infos;
 
 static const char *wineloader;
 
@@ -115,6 +122,65 @@
                 dir, GetLastError ());
 }
 
+const char* get_test_source_file(const char* test, const char* subtest)
+{
+    static const char* special_dirs[][2] = {
+	{ "gdi32", "gdi"}, { "kernel32", "kernel" },
+	{ "user32", "user" }, { "winspool.drv", "winspool" },
+	{ "ws2_32", "winsock" }, { 0, 0 }
+    };
+    static char buffer[MAX_PATH];
+    int i;
+
+    for (i = 0; special_dirs[i][0]; i++) {
+	if (strcmp(test, special_dirs[i][0]) == 0) {
+	    test = special_dirs[i][1];
+	    break;
+	}
+    }
+
+    snprintf(buffer, sizeof(buffer), "dlls/%s/tests/%s.c", test, subtest);
+    fprintf(stderr, "file=%s\n", buffer);
+    return buffer;
+}
+
+const char* get_file_rev(const char* file)
+{
+    const struct rev_info* rev;
+ 
+    for(rev = rev_infos; rev->file; rev++) {
+	fprintf(stderr, "  ?{%s:%s)\n", rev->file, rev->rev);
+	if (strcmp(rev->file, file) == 0) return rev->rev;
+    }
+
+    return "";
+}
+
+void extract_rev_infos ()
+{
+    char revinfo[256], *p;
+    int size = 0, i = 0, len;
+    HMODULE module = GetModuleHandle (NULL);
+
+    for (i = 0; TRUE; i++) {
+	if (i >= size) {
+	    size += 100;
+	    rev_infos = xrealloc(rev_infos, size);
+	}
+	memset(rev_infos + i, 0, sizeof(rev_infos[i]));
+
+        len = LoadStringA (module, i + 30000, revinfo, sizeof(revinfo));
+        if (len == 0) break; /* end of revision info */
+	if (len >= sizeof(revinfo)) 
+	    report (R_FATAL, "Revision info too long.");
+	if(!(p = strrchr(revinfo, ':')))
+	    report (R_FATAL, "Revision info malformed (i=%d)", i);
+	*p = 0;
+	rev_infos[i].file = strdup(revinfo);
+	rev_infos[i].rev = strdup(p + 1);
+    } while(1);
+}
+
 void* extract_rcdata (int id, DWORD* size)
 {
     HRSRC rsrc;
@@ -236,9 +302,11 @@
 int run_test (struct wine_test* test, const char* subtest)
 {
     int status;
-    const char *argv[] = {"wine", test->exename, subtest, NULL};
+    const char* argv[] = {"wine", test->exename, subtest, NULL};
+    const char* file = get_test_source_file(test->name, subtest);
+    const char* rev = get_file_rev(file);
 
-    xprintf ("%s:%s start\n", test->name, subtest);
+    xprintf ("%s:%s start %s %s\n", test->name, subtest, file, rev);
     if (test->is_elf)
         status = spawnvp (_P_WAIT, wineloader, argv);
     else
@@ -385,6 +453,9 @@
     char *logname = NULL;
     char *tag = NULL, *cp;
     const char *submit = NULL;
+
+    /* initialize the revision information first */
+    extract_rev_infos();
 
     cmdLine = mystrtok (cmdLine);
     while (cmdLine) {
Index: programs/winetest/maketest
===================================================================
RCS file: /var/cvs/wine/programs/winetest/maketest,v
retrieving revision 1.3
diff -u -r1.3 maketest
--- programs/winetest/maketest	19 Feb 2004 04:12:42 -0000	1.3
+++ programs/winetest/maketest	19 Mar 2004 18:49:50 -0000
@@ -15,6 +15,15 @@
     i=`expr $i + 1`
     echo "$i \"$test\""
 done
+
+if [ -f revision.info ]; then
+    i=0
+    for line in `cat revision.info`; do
+        i=`expr $i + 1`
+	echo "$i+30000 \"$line\""
+    done
+fi
+
 echo "}"
 
 i=0


-- 
Dimi.




More information about the wine-patches mailing list