winetest: move to resources (take n+1)
Ferenc Wagner
wferi at afavant.elte.hu
Tue Jun 15 10:57:58 CDT 2004
Alexandre Julliard <julliard at winehq.org> writes:
> the build info text formatting should be done in the code,
> not in the makefile.
OK, I've always suspected I couldn't avoid that loop. Done.
Hope I got it right... :) C is not the best tool for this job.
> Also I think it would be cleaner to use a different rc
> file for the dist case instead of using #ifdefs.
I agree. The problem is the single-rc-file limitation,
which would require some code duplication. That's why I
went for the #ifdefs. Please come back at me if you still
have strong feelings about this.
Feri.
New files: programs/winetest/README
programs/winetest/resource.h
programs/winetest/winetest.rc
ChangeLog:
- Resource script restructuring.
- Build info et al. is given by files instead of env. vars.
- Store that information in resources.
- Make the main windows not resizeable.
- Insist on creating a fresh log file.
Index: programs/winetest/Makefile.in
===================================================================
RCS file: /home/wine/wine/programs/winetest/Makefile.in,v
retrieving revision 1.26
diff -u -r1.26 Makefile.in
--- programs/winetest/Makefile.in 5 May 2004 01:01:31 -0000 1.26
+++ programs/winetest/Makefile.in 15 Jun 2004 15:41:08 -0000
@@ -13,7 +13,7 @@
util.c
RC_SRCS = \
- gui.rc
+ winetest.rc
RC_BINSRC = gui.rc
RC_BINARIES = wine.ico
@@ -44,15 +44,15 @@
TESTBINS = $(TESTS:%=%_test.exe$(DLLEXT))
-winetest.rc: maketest Makefile.in
+tests.rc: maketest Makefile.in
$(SRCDIR)/maketest $(TOPSRCDIR) $(TESTBINS) > $@ || ( $(RM) $@ && exit 1 )
-gui.res: winetest.rc $(TESTBINS)
+winetest.res: $(TESTBINS)
clean::
- $(RM) winetest.rc $(TESTBINS)
+ $(RM) tests.rc $(TESTBINS)
-depend: winetest.rc
+depend: tests.rc
# rules for stripping the test executables
@@ -92,5 +92,31 @@
cp $(DLLDIR)/winspool/tests/winspool.drv_test.exe$(DLLEXT) $@ && $(STRIP) $@
ws2_32_test.exe$(DLLEXT): $(DLLDIR)/winsock/tests/ws2_32_test.exe$(DLLEXT)
cp $(DLLDIR)/winsock/tests/ws2_32_test.exe$(DLLEXT) $@ && $(STRIP) $@
+
+# Rules for building distributable executable
+
+DIST_MODULE = winetest-dist.exe
+
+dist.res: winetest.rc build.id build.nfo tests.url $(TESTBINS) $(RC_BINARIES)
+ $(LDPATH) $(RC) -DWINETEST_DIST $(RCFLAGS) -fo$@ $<
+
+clean::
+ rm -f dist.res winetest-dist winetest-dist.exe
+
+# The following lines are adapted from programs/Makeprog.rules.in
+
+DIST_BASEMODULE = $(DIST_MODULE:.exe=)
+
+.PHONY: dist
+dist: $(DIST_MODULE)$(DLLEXT) $(DIST_BASEMODULE)$(EXEEXT)
+
+$(DIST_MODULE).so: $(ALL_OBJS) dist.res Makefile.in
+ $(WINEGCC) -B$(TOOLSDIR)/tools/winebuild $(APPMODE) $(ALL_OBJS) dist.res -o $@ -L$(DLLDIR) $(DELAYIMPORTS:%=-Wb,-d%) $(ALL_LIBS)
+
+$(DIST_BASEMODULE): $(WINEWRAPPER)
+ $(RM) $@ && $(LN_S) $(WINEWRAPPER) $@
+
+$(DIST_MODULE): $(ALL_OBJS) dist.res.o Makefile.in
+ $(CC) $(APPMODE) $(ALL_OBJS) dist.res.o -o $@ $(DELAYIMPORTS:%=-l%) $(ALL_LIBS)
### Dependencies:
Index: programs/winetest/README
===================================================================
RCS file: programs/winetest/README
diff -N programs/winetest/README
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ programs/winetest/README 15 Jun 2004 15:41:08 -0000
@@ -0,0 +1,22 @@
+ Wine Test Shell
+ ~~~~~~~~~~~~~~~
+
+Winetest is a single-executable version of all the DLL conformance
+test programs suitable for unattended testing and report submission.
+People assigned to build winetest must take care of the following
+files, which are only used by 'make dist':
+
+* build.id
+
+Contains a single (either CR or CR-LF) terminated line providing the
+build identification. The accepted characters are [-.0-9a-zA-Z].
+
+* archive.url
+
+Also contains a single terminated line providing the archive URL of
+the testing suite being built.
+
+* build.nfo
+
+Contains a block of terminated lines providing miscellaneous
+information about the build, like eg. the tools being used.
Index: programs/winetest/gui.rc
===================================================================
RCS file: /home/wine/wine/programs/winetest/gui.rc,v
retrieving revision 1.3
diff -u -r1.3 gui.rc
--- programs/winetest/gui.rc 24 Mar 2004 23:40:06 -0000 1.3
+++ programs/winetest/gui.rc 15 Jun 2004 15:41:08 -0000
@@ -21,10 +21,9 @@
#include <windows.h>
#include <winres.h>
#include "guires.h"
-#include "winetest.rc" /* for the MinGW cross-compiler */
IDD_STATUS DIALOG 0, 0, 160, 140
-STYLE WS_OVERLAPPEDWINDOW
+STYLE WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
CAPTION "Wine Test Shell"
BEGIN
LTEXT "Extracting:", IDC_ST0, 10, 5, 140, 10
Index: programs/winetest/main.c
===================================================================
RCS file: /home/wine/wine/programs/winetest/main.c,v
retrieving revision 1.18
diff -u -r1.18 main.c
--- programs/winetest/main.c 5 May 2004 19:00:34 -0000 1.18
+++ programs/winetest/main.c 15 Jun 2004 15:41:08 -0000
@@ -36,8 +36,7 @@
#include <windows.h>
#include "winetest.h"
-
-#define TESTRESOURCE "USERDATA"
+#include "resource.h"
struct wine_test
{
@@ -174,7 +173,7 @@
}
memset(rev_infos + i, 0, sizeof(rev_infos[i]));
- len = LoadStringA (module, i + 30000, revinfo, sizeof(revinfo));
+ len = LoadStringA (module, REV_INFO+i, revinfo, sizeof(revinfo));
if (len == 0) break; /* end of revision info */
if (len >= sizeof(revinfo) - 1)
report (R_FATAL, "Revision info too long.");
@@ -186,18 +185,18 @@
}
}
-void* extract_rcdata (int id, DWORD* size)
+void* extract_rcdata (int id, int type, DWORD* size)
{
HRSRC rsrc;
HGLOBAL hdl;
LPVOID addr = NULL;
- if (!(rsrc = FindResource (0, (LPTSTR)id, TESTRESOURCE)) ||
+ if (!(rsrc = FindResource (NULL, (LPTSTR)id, MAKEINTRESOURCE(type))) ||
!(*size = SizeofResource (0, rsrc)) ||
!(hdl = LoadResource (0, rsrc)) ||
!(addr = LockResource (hdl)))
- report (R_FATAL, "Can't extract test file of id %d: %d",
- id, GetLastError ());
+ report (R_FATAL, "Can't find resource of type %x, id %d: %d",
+ type, id, GetLastError ());
return addr;
}
@@ -211,7 +210,7 @@
int strlen, bufflen = 128;
char *exepos;
- code = extract_rcdata (id, &size);
+ code = extract_rcdata (id, TESTRES, &size);
test->name = xmalloc (bufflen);
while ((strlen = LoadStringA (NULL, id, test->name, bufflen))
== bufflen - 1) {
@@ -406,47 +405,63 @@
{
int nr_of_files = 0, nr_of_tests = 0, i;
char *tempdir;
- FILE *logfile;
- char build_tag[128];
+ int logfile;
+ char *strres, *eol, *nextline = NULL;
+ DWORD strsize;
SetErrorMode (SEM_NOGPFAULTERRORBOX);
- tempdir = tempnam (0, "wct");
- if (!tempdir)
- report (R_FATAL, "Can't name temporary dir (check %%TEMP%%).");
- report (R_DIR, tempdir);
- if (!CreateDirectory (tempdir, NULL))
- report (R_FATAL, "Could not create directory: %s", tempdir);
-
if (!logname) {
logname = tempnam (0, "res");
if (!logname) report (R_FATAL, "Can't name logfile.");
}
report (R_OUT, logname);
- logfile = fopen (logname, "a");
- if (!logfile) report (R_FATAL, "Could not open logfile.");
- if (-1 == dup2 (fileno (logfile), 1))
- report (R_FATAL, "Can't redirect stdout.");
- fclose (logfile);
+ logfile = open (logname, O_WRONLY | O_CREAT | O_EXCL | O_APPEND,
+ 0666);
+ if (-1 == logfile) {
+ if (EEXIST == errno)
+ report (R_FATAL, "File %s already exists.");
+ else report (R_FATAL, "Could not open logfile: %d", errno);
+ }
+ if (-1 == dup2 (logfile, 1))
+ report (R_FATAL, "Can't redirect stdout: %d", errno);
+ close (logfile);
+
+ tempdir = tempnam (0, "wct");
+ if (!tempdir)
+ report (R_FATAL, "Can't name temporary dir (check %%TEMP%%).");
+ report (R_DIR, tempdir);
+ if (!CreateDirectory (tempdir, NULL))
+ report (R_FATAL, "Could not create directory: %s", tempdir);
xprintf ("Version 3\n");
- i = LoadStringA (GetModuleHandle (NULL), 0,
- build_tag, sizeof build_tag);
- if (i == 0) report (R_FATAL, "Build descriptor not found: %d",
- GetLastError ());
- if (i >= sizeof build_tag)
- report (R_FATAL, "Build descriptor too long.");
- xprintf ("Tests from build %s\n", build_tag);
- xprintf ("Archive: %s\n", url?url:"");
+ strres = extract_rcdata (WINE_BUILD, STRINGRES, &strsize);
+ xprintf ("Tests from build %.*s", strsize, strres);
+ strres = extract_rcdata (TESTS_URL, STRINGRES, &strsize);
+ xprintf ("Archive: %.*s", strsize, strres);
xprintf ("Tag: %s\n", tag?tag:"");
xprintf ("Build info:\n");
+ strres = extract_rcdata (BUILD_INFO, STRINGRES, &strsize);
+ while (strsize > 0) {
+ eol = memchr (strres, '\n', strsize);
+ if (!eol) {
+ strsize = 0;
+ eol = strres + strsize;
+ } else {
+ strsize -= eol - strres + 1;
+ nextline = eol + 1;
+ if (eol > strres && *(eol-1) == '\r') eol--;
+ }
+ xprintf (" %.*s\n", eol-strres, strres);
+ strres = nextline;
+ }
xprintf ("Operating system version:\n");
print_version ();
xprintf ("Test output:\n" );
report (R_STATUS, "Counting tests");
- if (!EnumResourceNames (NULL, TESTRESOURCE,
+ if (!EnumResourceNames (NULL, MAKEINTRESOURCE(TESTRES),
EnumTestFileProc, (LPARAM)&nr_of_files))
report (R_FATAL, "Can't enumerate test files: %d",
GetLastError ());
@@ -455,7 +470,7 @@
report (R_STATUS, "Extracting tests");
report (R_PROGRESS, 0, nr_of_files);
for (i = 0; i < nr_of_files; i++) {
- get_subtests (tempdir, wine_tests+i, i+1);
+ get_subtests (tempdir, wine_tests+i, i);
nr_of_tests += wine_tests[i].subtest_count;
}
report (R_DELTA, 0, "Extracting: Done");
Index: programs/winetest/maketest
===================================================================
RCS file: /home/wine/wine/programs/winetest/maketest,v
retrieving revision 1.5
diff -u -r1.5 maketest
--- programs/winetest/maketest 24 Mar 2004 23:40:06 -0000 1.5
+++ programs/winetest/maketest 15 Jun 2004 15:41:08 -0000
@@ -1,31 +1,26 @@
#!/bin/sh
-if [ -z "$WINE_BUILD" ]; then
- WINE_BUILD="`date +%Y%m%d.%H%M-auto`"
- echo "warning: using automatically generated BUILD tag: $WINE_BUILD" 1>&2
-fi
-
TOPSRCDIR="$1"
shift
echo "/* Automatically generated -- do not edit! */"
+echo "#include \"resource.h\""
echo "STRINGTABLE {"
-echo "0 \"$WINE_BUILD\""
i=0
for test
do
- i=`expr $i + 1`
echo "$i \"$test\""
+ i=`expr $i + 1`
done
-i=30000
+i=0
cd $TOPSRCDIR
for dir in dlls/*/tests; do
sed -ne "s|^/\([^.]*.c\)/\([^/]*\).*|$dir/\1:\2|p" $dir/CVS/Entries 2>/dev/null
done |\
while read; do
- echo "$i \"$REPLY\""
+ echo "REV_INFO+$i \"$REPLY\""
i=`expr $i + 1`
done
@@ -34,6 +29,6 @@
i=0
for test
do
+ echo "$i TESTRES \"$test\""
i=`expr $i + 1`
- echo "$i USERDATA \"$test\""
done
Index: programs/winetest/resource.h
===================================================================
RCS file: programs/winetest/resource.h
diff -N programs/winetest/resource.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ programs/winetest/resource.h 15 Jun 2004 15:41:08 -0000
@@ -0,0 +1,13 @@
+/* Resource types */
+
+#define TESTRES 1000
+#define STRINGRES 1001
+
+/* String resources */
+
+#define WINE_BUILD 10000
+#define BUILD_INFO 10001
+#define TESTS_URL 10002
+
+/* Revision info strings start from this index: */
+#define REV_INFO 30000
Index: programs/winetest/winetest.rc
===================================================================
RCS file: programs/winetest/winetest.rc
diff -N programs/winetest/winetest.rc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ programs/winetest/winetest.rc 15 Jun 2004 15:41:08 -0000
@@ -0,0 +1,29 @@
+#include "resource.h"
+
+#include "tests.rc" /* The MinGW tools can't handle */
+#include "gui.rc" /* more than one resource script */
+
+#ifdef WINETEST_DIST
+
+WINE_BUILD STRINGRES "build.id"
+BUILD_INFO STRINGRES "build.nfo"
+TESTS_URL STRINGRES "tests.url"
+
+#else /* WINETEST_DIST */
+
+WINE_BUILD STRINGRES
+BEGIN
+ "-\r\n"
+END
+
+BUILD_INFO STRINGRES
+BEGIN
+ "-\r\n"
+END
+
+TESTS_URL STRINGRES
+BEGIN
+ "-\r\n"
+END
+
+#endif /* WINETEST_DIST */
More information about the wine-patches
mailing list