From 24624f6b5db2416c6ff95612150e2fbff682a7ef Mon Sep 17 00:00:00 2001 From: Ferenc Wagner Date: Tue, 15 Jun 2004 22:45:15 +0000 Subject: [PATCH] - 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. - Introduce the make dist target. --- programs/winetest/.cvsignore | 4 +- programs/winetest/Makefile.in | 31 ++++++-- programs/winetest/README | 22 ++++++ programs/winetest/dist.rc | 25 +++++++ programs/winetest/gui.c | 4 +- programs/winetest/main.c | 87 ++++++++++++++-------- programs/winetest/maketest | 15 ++-- programs/winetest/{guires.h => resource.h} | 18 ++++- programs/winetest/send.c | 3 +- programs/winetest/util.c | 3 +- programs/winetest/winetest.h | 2 +- programs/winetest/{gui.rc => winetest.rc} | 10 +-- 12 files changed, 160 insertions(+), 64 deletions(-) create mode 100644 programs/winetest/README create mode 100644 programs/winetest/dist.rc rename programs/winetest/{guires.h => resource.h} (74%) rename programs/winetest/{gui.rc => winetest.rc} (96%) diff --git a/programs/winetest/.cvsignore b/programs/winetest/.cvsignore index 4ba4aa35ddd..52487faf600 100644 --- a/programs/winetest/.cvsignore +++ b/programs/winetest/.cvsignore @@ -1,6 +1,6 @@ Makefile -gui.res +dist.res +tests.rc wine.ico winetest.exe.dbg.c -winetest.rc winetest.res diff --git a/programs/winetest/Makefile.in b/programs/winetest/Makefile.in index 9939097bbfa..1da9b588cc6 100644 --- a/programs/winetest/Makefile.in +++ b/programs/winetest/Makefile.in @@ -13,9 +13,9 @@ C_SRCS = \ util.c RC_SRCS = \ - gui.rc + winetest.rc -RC_BINSRC = gui.rc +RC_BINSRC = winetest.rc RC_BINARIES = wine.ico TESTS = \ @@ -44,17 +44,34 @@ TESTS = \ 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 dist.res winetest-dist winetest-dist.exe $(TESTBINS) -depend: winetest.rc +depend: tests.rc -# rules for stripping the test executables +# Rules for building distributable executable + +.PHONY: dist + +dist: winetest-dist.exe$(DLLEXT) winetest-dist$(EXEEXT) + +winetest-dist.exe.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) + +winetest-dist: $(WINEWRAPPER) + $(RM) $@ && $(LN_S) $(WINEWRAPPER) $@ + +winetest-dist.exe: $(ALL_OBJS) dist.res.o Makefile.in + $(CC) $(APPMODE) $(ALL_OBJS) dist.res.o -o $@ $(DELAYIMPORTS:%=-l%) $(ALL_LIBS) + +dist.res: winetest.rc tests.rc build.id build.nfo tests.url $(TESTBINS) $(RC_BINARIES) + +# Rules for stripping the test executables advapi32_test.exe$(DLLEXT): $(DLLDIR)/advapi32/tests/advapi32_test.exe$(DLLEXT) cp $(DLLDIR)/advapi32/tests/advapi32_test.exe$(DLLEXT) $@ && $(STRIP) $@ diff --git a/programs/winetest/README b/programs/winetest/README new file mode 100644 index 00000000000..90e8accd8a9 --- /dev/null +++ b/programs/winetest/README @@ -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]. + +* tests.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. diff --git a/programs/winetest/dist.rc b/programs/winetest/dist.rc new file mode 100644 index 00000000000..50a22886126 --- /dev/null +++ b/programs/winetest/dist.rc @@ -0,0 +1,25 @@ +/* + * Resources for the binary we distribute to testers + * + * Copyright 2004 Ferenc Wagner + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "winetest.rc" + +WINE_BUILD STRINGRES "build.id" +BUILD_INFO STRINGRES "build.nfo" +TESTS_URL STRINGRES "tests.url" diff --git a/programs/winetest/gui.c b/programs/winetest/gui.c index 0704deac349..89a310825a3 100644 --- a/programs/winetest/gui.c +++ b/programs/winetest/gui.c @@ -15,13 +15,13 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include -#include "guires.h" +#include "resource.h" #include "winetest.h" /* Event object to signal successful window creation to main thread. diff --git a/programs/winetest/main.c b/programs/winetest/main.c index 8b9db14d57e..d749f002705 100644 --- a/programs/winetest/main.c +++ b/programs/winetest/main.c @@ -17,6 +17,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * This program is dedicated to Anna Lindh, * Swedish Minister of Foreign Affairs. @@ -36,8 +37,7 @@ #include #include "winetest.h" - -#define TESTRESOURCE "USERDATA" +#include "resource.h" struct wine_test { @@ -174,7 +174,7 @@ void extract_rev_infos () } 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 +186,17 @@ void extract_rev_infos () } } -void* extract_rcdata (int id, DWORD* size) +void* extract_rcdata (int id, int type, DWORD* size) { HRSRC rsrc; HGLOBAL hdl; - LPVOID addr = NULL; + LPVOID addr; - 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 ()); + return NULL; return addr; } @@ -211,7 +210,9 @@ extract_test (struct wine_test *test, const char *dir, int id) int strlen, bufflen = 128; char *exepos; - code = extract_rcdata (id, &size); + code = extract_rcdata (id, TESTRES, &size); + if (!code) report (R_FATAL, "Can't find test resource %d: %d", + id, GetLastError ()); test->name = xmalloc (bufflen); while ((strlen = LoadStringA (NULL, id, test->name, bufflen)) == bufflen - 1) { @@ -406,11 +407,29 @@ run_tests (char *logname, const char *tag, const char *url) { int nr_of_files = 0, nr_of_tests = 0, i; char *tempdir; - FILE *logfile; - char build_tag[128]; + int logfile; + char *strres, *eol, *nextline; + DWORD strsize; SetErrorMode (SEM_NOGPFAULTERRORBOX); + if (!logname) { + logname = tempnam (0, "res"); + if (!logname) report (R_FATAL, "Can't name logfile."); + } + report (R_OUT, logname); + + 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%%)."); @@ -418,35 +437,37 @@ run_tests (char *logname, const char *tag, const char *url) 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); - 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 "); + if (strres) xprintf ("%.*s", strsize, strres); + else xprintf ("-\n"); + strres = extract_rcdata (TESTS_URL, STRINGRES, &strsize); + xprintf ("Archive: "); + if (strres) xprintf ("%.*s", strsize, strres); + else xprintf ("-\n"); xprintf ("Tag: %s\n", tag?tag:""); xprintf ("Build info:\n"); + strres = extract_rcdata (BUILD_INFO, STRINGRES, &strsize); + while (strres) { + eol = memchr (strres, '\n', strsize); + if (!eol) { + nextline = NULL; + eol = strres + strsize; + } else { + strsize -= eol - strres + 1; + nextline = strsize?eol+1:NULL; + 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 +476,7 @@ run_tests (char *logname, const char *tag, const char *url) 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"); diff --git a/programs/winetest/maketest b/programs/winetest/maketest index b2bc9ff7f6b..4d18b39e1d3 100755 --- a/programs/winetest/maketest +++ b/programs/winetest/maketest @@ -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 @@ echo "}" i=0 for test do + echo "$i TESTRES \"$test\"" i=`expr $i + 1` - echo "$i USERDATA \"$test\"" done diff --git a/programs/winetest/guires.h b/programs/winetest/resource.h similarity index 74% rename from programs/winetest/guires.h rename to programs/winetest/resource.h index 24f0379e895..1c81e6bbc86 100644 --- a/programs/winetest/guires.h +++ b/programs/winetest/resource.h @@ -1,5 +1,5 @@ /* - * GUI resource definitions + * Resource definitions * * Copyright 2004 Ferenc Wagner * @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define IDI_WINE 1 @@ -37,3 +37,17 @@ #define IDC_EDIT 4000 #define IDC_ABOUT 4001 + +/* 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 diff --git a/programs/winetest/send.c b/programs/winetest/send.c index 4385b92231e..e95fc244aab 100644 --- a/programs/winetest/send.c +++ b/programs/winetest/send.c @@ -15,8 +15,9 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include #include #include diff --git a/programs/winetest/util.c b/programs/winetest/util.c index 94da1e8406c..d09b90bcc51 100644 --- a/programs/winetest/util.c +++ b/programs/winetest/util.c @@ -16,8 +16,9 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include #include diff --git a/programs/winetest/winetest.h b/programs/winetest/winetest.h index 22dbad07a7b..97ea097df21 100644 --- a/programs/winetest/winetest.h +++ b/programs/winetest/winetest.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __WINETESTS_H diff --git a/programs/winetest/gui.rc b/programs/winetest/winetest.rc similarity index 96% rename from programs/winetest/gui.rc rename to programs/winetest/winetest.rc index 5422a8737b6..c9b7b0cad00 100644 --- a/programs/winetest/gui.rc +++ b/programs/winetest/winetest.rc @@ -1,5 +1,5 @@ /* - * GUI resources + * Winetest resources * * Copyright 2004 Ferenc Wagner * @@ -15,16 +15,16 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include -#include "guires.h" -#include "winetest.rc" /* for the MinGW cross-compiler */ +#include "resource.h" +#include "tests.rc" 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