Commit 5e0a8157 authored by Alexandre Julliard's avatar Alexandre Julliard

winetest: Store the test name as the resource name instead of in a separate string table.

parent aa336618
...@@ -57,6 +57,7 @@ struct rev_info ...@@ -57,6 +57,7 @@ struct rev_info
char *tag = NULL; char *tag = NULL;
static struct wine_test *wine_tests; static struct wine_test *wine_tests;
static int nr_of_files, nr_of_tests;
static struct rev_info *rev_infos = NULL; static struct rev_info *rev_infos = NULL;
static const char whitespace[] = " \t\r\n"; static const char whitespace[] = " \t\r\n";
...@@ -220,13 +221,13 @@ static void extract_rev_infos (void) ...@@ -220,13 +221,13 @@ static void extract_rev_infos (void)
} }
} }
static void* extract_rcdata (int id, int type, DWORD* size) static void* extract_rcdata (LPTSTR name, int type, DWORD* size)
{ {
HRSRC rsrc; HRSRC rsrc;
HGLOBAL hdl; HGLOBAL hdl;
LPVOID addr; LPVOID addr;
if (!(rsrc = FindResource (NULL, (LPTSTR)id, MAKEINTRESOURCE(type))) || if (!(rsrc = FindResource (NULL, name, MAKEINTRESOURCE(type))) ||
!(*size = SizeofResource (0, rsrc)) || !(*size = SizeofResource (0, rsrc)) ||
!(hdl = LoadResource (0, rsrc)) || !(hdl = LoadResource (0, rsrc)) ||
!(addr = LockResource (hdl))) !(addr = LockResource (hdl)))
...@@ -236,24 +237,18 @@ static void* extract_rcdata (int id, int type, DWORD* size) ...@@ -236,24 +237,18 @@ static void* extract_rcdata (int id, int type, DWORD* size)
/* Fills in the name and exename fields */ /* Fills in the name and exename fields */
static void static void
extract_test (struct wine_test *test, const char *dir, int id) extract_test (struct wine_test *test, const char *dir, LPTSTR res_name)
{ {
BYTE* code; BYTE* code;
DWORD size; DWORD size;
FILE* fout; FILE* fout;
int strlen, bufflen = 128;
char *exepos; char *exepos;
code = extract_rcdata (id, TESTRES, &size); code = extract_rcdata (res_name, TESTRES, &size);
if (!code) report (R_FATAL, "Can't find test resource %d: %d", if (!code) report (R_FATAL, "Can't find test resource %s: %d",
id, GetLastError ()); res_name, GetLastError ());
test->name = xmalloc (bufflen); test->name = xstrdup( res_name );
while ((strlen = LoadStringA (NULL, id, test->name, bufflen)) CharLowerA( test->name );
== bufflen - 1) {
bufflen *= 2;
test->name = xrealloc (test->name, bufflen);
}
if (!strlen) report (R_FATAL, "Can't read name of test %d.", id);
test->exename = strmake (NULL, "%s/%s", dir, test->name); test->exename = strmake (NULL, "%s/%s", dir, test->name);
exepos = strstr (test->name, "_test.exe"); exepos = strstr (test->name, "_test.exe");
if (!exepos) report (R_FATAL, "Not an .exe file: %s", test->name); if (!exepos) report (R_FATAL, "Not an .exe file: %s", test->name);
...@@ -351,7 +346,7 @@ run_ex (char *cmd, const char *out, DWORD ms) ...@@ -351,7 +346,7 @@ run_ex (char *cmd, const char *out, DWORD ms)
} }
static void static void
get_subtests (const char *tempdir, struct wine_test *test, int id) get_subtests (const char *tempdir, struct wine_test *test, LPTSTR res_name)
{ {
char *subname, *cmd; char *subname, *cmd;
FILE *subfile; FILE *subfile;
...@@ -365,7 +360,7 @@ get_subtests (const char *tempdir, struct wine_test *test, int id) ...@@ -365,7 +360,7 @@ get_subtests (const char *tempdir, struct wine_test *test, int id)
subname = tempnam (0, "sub"); subname = tempnam (0, "sub");
if (!subname) report (R_FATAL, "Can't name subtests file."); if (!subname) report (R_FATAL, "Can't name subtests file.");
extract_test (test, tempdir, id); extract_test (test, tempdir, res_name);
cmd = strmake (NULL, "%s --list", test->exename); cmd = strmake (NULL, "%s --list", test->exename);
run_ex (cmd, subname, 5000); run_ex (cmd, subname, 5000);
free (cmd); free (cmd);
...@@ -437,10 +432,21 @@ EnumTestFileProc (HMODULE hModule, LPCTSTR lpszType, ...@@ -437,10 +432,21 @@ EnumTestFileProc (HMODULE hModule, LPCTSTR lpszType,
return TRUE; return TRUE;
} }
static BOOL CALLBACK
extract_test_proc (HMODULE hModule, LPCTSTR lpszType,
LPTSTR lpszName, LONG_PTR lParam)
{
const char *tempdir = (const char *)lParam;
get_subtests( tempdir, &wine_tests[nr_of_files], lpszName );
nr_of_tests += wine_tests[nr_of_files].subtest_count;
nr_of_files++;
return TRUE;
}
static char * static char *
run_tests (char *logname) run_tests (char *logname)
{ {
int nr_of_files = 0, nr_of_tests = 0, i; int i;
char *tempdir, *shorttempdir; char *tempdir, *shorttempdir;
int logfile; int logfile;
char *strres, *eol, *nextline; char *strres, *eol, *nextline;
...@@ -481,17 +487,17 @@ run_tests (char *logname) ...@@ -481,17 +487,17 @@ run_tests (char *logname)
report (R_DIR, tempdir); report (R_DIR, tempdir);
xprintf ("Version 3\n"); xprintf ("Version 3\n");
strres = extract_rcdata (WINE_BUILD, STRINGRES, &strsize); strres = extract_rcdata (MAKEINTRESOURCE(WINE_BUILD), STRINGRES, &strsize);
xprintf ("Tests from build "); xprintf ("Tests from build ");
if (strres) xprintf ("%.*s", strsize, strres); if (strres) xprintf ("%.*s", strsize, strres);
else xprintf ("-\n"); else xprintf ("-\n");
strres = extract_rcdata (TESTS_URL, STRINGRES, &strsize); strres = extract_rcdata (MAKEINTRESOURCE(TESTS_URL), STRINGRES, &strsize);
xprintf ("Archive: "); xprintf ("Archive: ");
if (strres) xprintf ("%.*s", strsize, strres); if (strres) xprintf ("%.*s", strsize, strres);
else xprintf ("-\n"); else xprintf ("-\n");
xprintf ("Tag: %s\n", tag); xprintf ("Tag: %s\n", tag);
xprintf ("Build info:\n"); xprintf ("Build info:\n");
strres = extract_rcdata (BUILD_INFO, STRINGRES, &strsize); strres = extract_rcdata (MAKEINTRESOURCE(BUILD_INFO), STRINGRES, &strsize);
while (strres) { while (strres) {
eol = memchr (strres, '\n', strsize); eol = memchr (strres, '\n', strsize);
if (!eol) { if (!eol) {
...@@ -518,10 +524,13 @@ run_tests (char *logname) ...@@ -518,10 +524,13 @@ run_tests (char *logname)
report (R_STATUS, "Extracting tests"); report (R_STATUS, "Extracting tests");
report (R_PROGRESS, 0, nr_of_files); report (R_PROGRESS, 0, nr_of_files);
for (i = 0; i < nr_of_files; i++) { nr_of_files = 0;
get_subtests (tempdir, wine_tests+i, i); nr_of_tests = 0;
nr_of_tests += wine_tests[i].subtest_count; if (!EnumResourceNames (NULL, MAKEINTRESOURCE(TESTRES),
} extract_test_proc, (LPARAM)tempdir))
report (R_FATAL, "Can't enumerate test files: %d",
GetLastError ());
report (R_DELTA, 0, "Extracting: Done"); report (R_DELTA, 0, "Extracting: Done");
report (R_STATUS, "Running tests"); report (R_STATUS, "Running tests");
......
...@@ -8,13 +8,6 @@ echo "#include \"resource.h\"" ...@@ -8,13 +8,6 @@ echo "#include \"resource.h\""
echo "STRINGTABLE {" echo "STRINGTABLE {"
i=0 i=0
for test
do
echo "$i \"$test\""
i=`expr $i + 1`
done
i=0
cd $TOPSRCDIR cd $TOPSRCDIR
if [ -d .git ] if [ -d .git ]
then then
...@@ -32,9 +25,7 @@ done ...@@ -32,9 +25,7 @@ done
echo "}" echo "}"
i=0
for test for test
do do
echo "$i TESTRES \"$test\"" echo "$test TESTRES \"$test\""
i=`expr $i + 1`
done done
...@@ -40,6 +40,13 @@ void *xrealloc (void *op, size_t len) ...@@ -40,6 +40,13 @@ void *xrealloc (void *op, size_t len)
return p; return p;
} }
char *xstrdup( const char *str )
{
char *res = strdup( str );
if (!res) report (R_FATAL, "Out of memory.");
return res;
}
static char *vstrfmtmake (size_t *lenp, const char *fmt, va_list ap) static char *vstrfmtmake (size_t *lenp, const char *fmt, va_list ap)
{ {
size_t size = 1000; size_t size = 1000;
......
...@@ -30,6 +30,7 @@ void fatal (const char* msg); ...@@ -30,6 +30,7 @@ void fatal (const char* msg);
void warning (const char* msg); void warning (const char* msg);
void *xmalloc (size_t len); void *xmalloc (size_t len);
void *xrealloc (void *op, size_t len); void *xrealloc (void *op, size_t len);
char *xstrdup( const char *str );
void xprintf (const char *fmt, ...); void xprintf (const char *fmt, ...);
char *vstrmake (size_t *lenp, va_list ap); char *vstrmake (size_t *lenp, va_list ap);
char *strmake (size_t *lenp, ...); char *strmake (size_t *lenp, ...);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment