Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
0cf75338
Commit
0cf75338
authored
Oct 30, 2002
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved the test routines from wtmain.c into wine/test.h so that they
can be compiled separately with different flags for each dll.
parent
f99c03b9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
285 additions
and
314 deletions
+285
-314
Makefile.in
Makefile.in
+0
-7
Maketest.rules.in
dlls/Maketest.rules.in
+2
-10
test.h
include/wine/test.h
+262
-0
Makefile.in
programs/winetest/Makefile.in
+2
-8
make_ctests
programs/winetest/make_ctests
+19
-4
wtmain.c
programs/winetest/wtmain.c
+0
-285
No files found.
Makefile.in
View file @
0cf75338
...
...
@@ -129,17 +129,10 @@ unicode/__install__: unicode
checklink
::
$(TESTSUBDIRS:%=%/__checklink__)
$(CC)
-o
checklink
$(TOPSRCDIR)
/library/checklink.c
&&
$(RM)
checklink
test_environment
:
dummy
@
cd
programs/winetest
&&
$(MAKE)
test_environment
$(TESTSUBDIRS
:
%=%/__test__): test_environment
check test
::
$(TESTSUBDIRS:%=%/__test__)
crosstest
::
$(TESTSUBDIRS:%=%/__crosstest__)
.PHONY
:
test_environment
# Misc rules
TAGS etags
:
...
...
dlls/Maketest.rules.in
View file @
0cf75338
...
...
@@ -14,18 +14,16 @@ LDDLLFLAGS = @LDDLLFLAGS@
MODULE = $(TESTDLL:%.dll=%)_test.exe
TESTLIST = testlist.c
TESTMAIN = $(TOPOBJDIR)/programs/winetest/wtmain.o
TESTRESULTS = $(CTESTS:.c=.ok)
TESTPROGRAM = $(MODULE)$(DLLEXT)
RUNTESTFLAGS = -q -P wine -M $(TESTDLL) -T $(TOPOBJDIR) -p $(TESTPROGRAM)
C_SRCS = $(CTESTS)
EXTRA_OBJS = $(TEST
MAIN) $(TEST
LIST:.c=.o)
EXTRA_OBJS = $(TESTLIST:.c=.o)
ALL_LIBS = $(LIBWINE) $(EXTRALIBS) $(LIBS)
CROSSTEST = $(TESTDLL:%.dll=%)_crosstest.exe
CROSSTESTMAIN= $(TOPOBJDIR)/programs/winetest/wtmain.cross.o
CROSSOBJS = $(C_SRCS:.c=.cross.o) $(TESTLIST:.c=.cross.o) $(CROSSTESTMAIN)
CROSSOBJS = $(C_SRCS:.c=.cross.o) $(TESTLIST:.c=.cross.o)
@MAKE_RULES@
...
...
@@ -62,9 +60,6 @@ check test:: $(TESTRESULTS) $(SUBDIRS:%=%/__test__)
$(TESTRESULTS): $(MODULE)$(DLLEXT) $(TOPOBJDIR)/dlls/$(TESTDLL)$(DLLEXT)
$(TESTMAIN):
cd $(TOPOBJDIR)/programs/winetest && $(MAKE) wtmain.o
# Rules for cross-compiling tests
crosstest:: @CROSSTEST@
...
...
@@ -72,9 +67,6 @@ crosstest:: @CROSSTEST@
$(CROSSTEST): $(CROSSOBJS) Makefile.in
$(CROSSCC) $(CROSSOBJS) -o $@ $(DELAYIMPORTS:%=-l%) $(IMPORTS:%=-l%) $(LIBS)
$(CROSSTESTMAIN):
cd $(TOPOBJDIR)/programs/winetest && $(MAKE) wtmain.cross.o
# Rules for cleaning
testclean::
...
...
include/wine/test.h
View file @
0cf75338
...
...
@@ -62,4 +62,266 @@ extern void winetest_trace( const char *msg, ... );
winetest_end_todo(platform))
#define todo_wine todo("wine")
/************************************************************************/
/* Below is the implementation of the various functions, to be included
* directly into the generated testlist.c file.
* It is done that way so that the dlls can build the test routines with
* different includes or flags if needed.
*/
#ifdef WINETEST_WANT_MAIN
/* debug level */
int
winetest_debug
=
1
;
/* current platform */
const
char
*
winetest_platform
=
"windows"
;
/* report successful tests (BOOL) */
static
int
report_success
=
0
;
/* passing arguments around */
static
int
winetest_argc
;
static
char
**
winetest_argv
;
static
const
struct
test
*
current_test
;
/* test currently being run */
static
LONG
successes
;
/* number of successful tests */
static
LONG
failures
;
/* number of failures */
static
LONG
todo_successes
;
/* number of successful tests inside todo block */
static
LONG
todo_failures
;
/* number of failures inside todo block */
/* The following data must be kept track of on a per-thread basis */
typedef
struct
{
const
char
*
current_file
;
/* file of current check */
int
current_line
;
/* line of current check */
int
todo_level
;
/* current todo nesting level */
int
todo_do_loop
;
}
tls_data
;
static
DWORD
tls_index
;
static
tls_data
*
get_tls_data
(
void
)
{
tls_data
*
data
;
DWORD
last_error
;
last_error
=
GetLastError
();
data
=
TlsGetValue
(
tls_index
);
if
(
!
data
)
{
data
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
tls_data
));
TlsSetValue
(
tls_index
,
data
);
}
SetLastError
(
last_error
);
return
data
;
}
static
void
exit_process
(
int
code
)
{
fflush
(
stderr
);
ExitProcess
(
code
);
}
/*
* Checks condition.
* Parameters:
* - condition - condition to check;
* - msg test description;
* - file - test application source code file name of the check
* - line - test application source code file line number of the check
* Return:
* 0 if condition does not have the expected value, 1 otherwise
*/
int
winetest_ok
(
int
condition
,
const
char
*
msg
,
...
)
{
va_list
valist
;
tls_data
*
data
=
get_tls_data
();
if
(
data
->
todo_level
)
{
if
(
condition
)
{
fprintf
(
stderr
,
"%s:%d: Test succeeded inside todo block"
,
data
->
current_file
,
data
->
current_line
);
if
(
msg
&&
msg
[
0
])
{
va_start
(
valist
,
msg
);
fprintf
(
stderr
,
": "
);
vfprintf
(
stderr
,
msg
,
valist
);
va_end
(
valist
);
}
fputc
(
'\n'
,
stderr
);
InterlockedIncrement
(
&
todo_failures
);
return
0
;
}
else
InterlockedIncrement
(
&
todo_successes
);
}
else
{
if
(
!
condition
)
{
fprintf
(
stderr
,
"%s:%d: Test failed"
,
data
->
current_file
,
data
->
current_line
);
if
(
msg
&&
msg
[
0
])
{
va_start
(
valist
,
msg
);
fprintf
(
stderr
,
": "
);
vfprintf
(
stderr
,
msg
,
valist
);
va_end
(
valist
);
}
fputc
(
'\n'
,
stderr
);
InterlockedIncrement
(
&
failures
);
return
0
;
}
else
{
if
(
report_success
)
fprintf
(
stderr
,
"%s:%d: Test succeeded
\n
"
,
data
->
current_file
,
data
->
current_line
);
InterlockedIncrement
(
&
successes
);
}
}
return
1
;
}
void
winetest_set_ok_location
(
const
char
*
file
,
int
line
)
{
tls_data
*
data
=
get_tls_data
();
data
->
current_file
=
file
;
data
->
current_line
=
line
;
}
void
winetest_trace
(
const
char
*
msg
,
...
)
{
va_list
valist
;
tls_data
*
data
=
get_tls_data
();
if
(
winetest_debug
>
0
)
{
fprintf
(
stderr
,
"%s:%d:"
,
data
->
current_file
,
data
->
current_line
);
va_start
(
valist
,
msg
);
vfprintf
(
stderr
,
msg
,
valist
);
va_end
(
valist
);
}
}
void
winetest_set_trace_location
(
const
char
*
file
,
int
line
)
{
tls_data
*
data
=
get_tls_data
();
data
->
current_file
=
file
;
data
->
current_line
=
line
;
}
void
winetest_start_todo
(
const
char
*
platform
)
{
tls_data
*
data
=
get_tls_data
();
if
(
strcmp
(
winetest_platform
,
platform
)
==
0
)
data
->
todo_level
++
;
data
->
todo_do_loop
=
1
;
}
int
winetest_loop_todo
(
void
)
{
tls_data
*
data
=
get_tls_data
();
int
do_loop
=
data
->
todo_do_loop
;
data
->
todo_do_loop
=
0
;
return
do_loop
;
}
void
winetest_end_todo
(
const
char
*
platform
)
{
if
(
strcmp
(
winetest_platform
,
platform
)
==
0
)
{
tls_data
*
data
=
get_tls_data
();
data
->
todo_level
--
;
}
}
int
winetest_get_mainargs
(
char
***
pargv
)
{
*
pargv
=
winetest_argv
;
return
winetest_argc
;
}
/* Find a test by name */
static
const
struct
test
*
find_test
(
const
char
*
name
)
{
const
struct
test
*
test
;
const
char
*
p
;
int
len
;
if
((
p
=
strrchr
(
name
,
'/'
)))
name
=
p
+
1
;
if
((
p
=
strrchr
(
name
,
'\\'
)))
name
=
p
+
1
;
len
=
strlen
(
name
);
if
(
len
>
2
&&
!
strcmp
(
name
+
len
-
2
,
".c"
))
len
-=
2
;
for
(
test
=
winetest_testlist
;
test
->
name
;
test
++
)
{
if
(
!
strncmp
(
test
->
name
,
name
,
len
)
&&
!
test
->
name
[
len
])
break
;
}
return
test
->
name
?
test
:
NULL
;
}
/* Run a named test, and return exit status */
static
int
run_test
(
const
char
*
name
)
{
const
struct
test
*
test
;
int
status
;
if
(
!
(
test
=
find_test
(
name
)))
{
fprintf
(
stderr
,
"Fatal: test '%s' does not exist.
\n
"
,
name
);
exit_process
(
1
);
}
successes
=
failures
=
todo_successes
=
todo_failures
=
0
;
tls_index
=
TlsAlloc
();
current_test
=
test
;
test
->
func
();
if
(
winetest_debug
)
{
fprintf
(
stderr
,
"%s: %ld tests executed, %ld marked as todo, %ld %s.
\n
"
,
name
,
successes
+
failures
+
todo_successes
+
todo_failures
,
todo_successes
,
failures
+
todo_failures
,
(
failures
+
todo_failures
!=
1
)
?
"failures"
:
"failure"
);
}
status
=
(
failures
+
todo_failures
<
255
)
?
failures
+
todo_failures
:
255
;
return
status
;
}
/* Display usage and exit */
static
void
usage
(
const
char
*
argv0
)
{
const
struct
test
*
test
;
fprintf
(
stderr
,
"Usage: %s test_name
\n
"
,
argv0
);
fprintf
(
stderr
,
"
\n
Valid test names:
\n
"
);
for
(
test
=
winetest_testlist
;
test
->
name
;
test
++
)
fprintf
(
stderr
,
" %s
\n
"
,
test
->
name
);
exit_process
(
1
);
}
/* main function */
int
main
(
int
argc
,
char
**
argv
)
{
char
*
p
;
winetest_argc
=
argc
;
winetest_argv
=
argv
;
if
((
p
=
getenv
(
"WINETEST_PLATFORM"
)))
winetest_platform
=
p
;
if
((
p
=
getenv
(
"WINETEST_DEBUG"
)))
winetest_debug
=
atoi
(
p
);
if
((
p
=
getenv
(
"WINETEST_REPORT_SUCCESS"
)))
report_success
=
atoi
(
p
);
if
(
!
argv
[
1
])
usage
(
argv
[
0
]
);
return
run_test
(
argv
[
1
]);
}
#endif
/* WINETEST_WANT_MAIN */
#endif
/* __WINE_TEST_H */
programs/winetest/Makefile.in
View file @
0cf75338
...
...
@@ -13,8 +13,6 @@ XSUBPPDIR = `perl -MConfig -e 'print $$Config::Config{privlibexp}'`/ExtUtils
C_SRCS
=
winetest.c
EXTRA_SRCS
=
wtmain.c
EXTRA_OBJS
=
wine.o
EXTRASUBDIRS
=
include tests
...
...
@@ -24,21 +22,17 @@ PLTESTPROGRAM = $(MODULE)$(DLLEXT)
PLTESTS
=
\
tests/wine.pl
CROSSTEST
=
wtmain.cross.o
# override all: target so that we don't build the Perl stuff by default
test_environment
:
wtmain.o @CROSSTEST@
empty-target
:
@MAKE_PROG_RULES@
all
:
test_environment
wine.c
:
wine.xs
perl
$(XSUBPPDIR)
/xsubpp
-typemap
$(XSUBPPDIR)
/typemap
$(SRCDIR)
/wine.xs
>
wine.c
||
$(RM)
wine.c
clean
::
$(RM)
wine.c
.PHONY
:
test_environmen
t
.PHONY
:
empty-targe
t
### Dependencies:
programs/winetest/make_ctests
View file @
0cf75338
...
...
@@ -21,7 +21,14 @@
use
strict
;
print
"/* Automatically generated file; DO NOT EDIT!! */\n\n"
;
print
<<EOF;
/* Automatically generated file; DO NOT EDIT!! */
\#include <stdio.h>
\#include <stdlib.h>
\#include "winbase.h"
EOF
my
@testlist
=
@ARGV
;
foreach
(
@testlist
)
...
...
@@ -32,11 +39,13 @@ foreach (@testlist)
print
<<EOF;
const struc
t
struct tes
t
{
const char *name;
void (*func)(void);
} winetest_testlist[] =
};
static const struct test winetest_testlist[] =
{
EOF
...
...
@@ -44,4 +53,10 @@ foreach (@testlist)
{
printf
" { \"%s\", func_%s },\n"
,
$_
,
$_
;
}
print
" { 0, 0 }\n};\n"
;
print
<<EOF;
{ 0, 0 }
};
\#define WINETEST_WANT_MAIN
\#include "wine/test.h"
EOF
programs/winetest/wtmain.c
deleted
100644 → 0
View file @
f99c03b9
/*
* Main routine for Wine C unit tests.
*
* Copyright 2002 Alexandre Julliard
* Copyright 2002 Andriy Palamarchuk
*
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "wine/test.h"
#include "winbase.h"
/* debug level */
int
winetest_debug
=
1
;
/* current platform */
const
char
*
winetest_platform
=
"windows"
;
/* report successful tests (BOOL) */
int
winetest_report_success
=
0
;
/* passing arguments around */
static
int
winetest_argc
;
static
char
**
winetest_argv
;
struct
test
{
const
char
*
name
;
void
(
*
func
)(
void
);
};
extern
const
struct
test
winetest_testlist
[];
static
const
struct
test
*
current_test
;
/* test currently being run */
static
LONG
successes
;
/* number of successful tests */
static
LONG
failures
;
/* number of failures */
static
LONG
todo_successes
;
/* number of successful tests inside todo block */
static
LONG
todo_failures
;
/* number of failures inside todo block */
/* The following data must be kept track of on a per-thread basis */
typedef
struct
{
const
char
*
current_file
;
/* file of current check */
int
current_line
;
/* line of current check */
int
todo_level
;
/* current todo nesting level */
int
todo_do_loop
;
}
tls_data
;
static
DWORD
tls_index
;
static
tls_data
*
get_tls_data
(
void
)
{
tls_data
*
data
;
DWORD
last_error
;
last_error
=
GetLastError
();
data
=
TlsGetValue
(
tls_index
);
if
(
!
data
)
{
data
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
tls_data
));
TlsSetValue
(
tls_index
,
data
);
}
SetLastError
(
last_error
);
return
data
;
}
static
void
exit_process
(
int
code
)
{
fflush
(
stderr
);
ExitProcess
(
code
);
}
/*
* Checks condition.
* Parameters:
* - condition - condition to check;
* - msg test description;
* - file - test application source code file name of the check
* - line - test application source code file line number of the check
* Return:
* 0 if condition does not have the expected value, 1 otherwise
*/
int
winetest_ok
(
int
condition
,
const
char
*
msg
,
...
)
{
va_list
valist
;
tls_data
*
data
=
get_tls_data
();
if
(
data
->
todo_level
)
{
if
(
condition
)
{
fprintf
(
stderr
,
"%s:%d: Test succeeded inside todo block"
,
data
->
current_file
,
data
->
current_line
);
if
(
msg
&&
msg
[
0
])
{
va_start
(
valist
,
msg
);
fprintf
(
stderr
,
": "
);
vfprintf
(
stderr
,
msg
,
valist
);
va_end
(
valist
);
}
fputc
(
'\n'
,
stderr
);
InterlockedIncrement
(
&
todo_failures
);
return
0
;
}
else
InterlockedIncrement
(
&
todo_successes
);
}
else
{
if
(
!
condition
)
{
fprintf
(
stderr
,
"%s:%d: Test failed"
,
data
->
current_file
,
data
->
current_line
);
if
(
msg
&&
msg
[
0
])
{
va_start
(
valist
,
msg
);
fprintf
(
stderr
,
": "
);
vfprintf
(
stderr
,
msg
,
valist
);
va_end
(
valist
);
}
fputc
(
'\n'
,
stderr
);
InterlockedIncrement
(
&
failures
);
return
0
;
}
else
{
if
(
winetest_report_success
)
fprintf
(
stderr
,
"%s:%d: Test succeeded
\n
"
,
data
->
current_file
,
data
->
current_line
);
InterlockedIncrement
(
&
successes
);
}
}
return
1
;
}
void
winetest_set_ok_location
(
const
char
*
file
,
int
line
)
{
tls_data
*
data
=
get_tls_data
();
data
->
current_file
=
file
;
data
->
current_line
=
line
;
}
void
winetest_trace
(
const
char
*
msg
,
...
)
{
va_list
valist
;
tls_data
*
data
=
get_tls_data
();
if
(
winetest_debug
>
0
)
{
fprintf
(
stderr
,
"%s:%d:"
,
data
->
current_file
,
data
->
current_line
);
va_start
(
valist
,
msg
);
vfprintf
(
stderr
,
msg
,
valist
);
va_end
(
valist
);
}
}
void
winetest_set_trace_location
(
const
char
*
file
,
int
line
)
{
tls_data
*
data
=
get_tls_data
();
data
->
current_file
=
file
;
data
->
current_line
=
line
;
}
void
winetest_start_todo
(
const
char
*
platform
)
{
tls_data
*
data
=
get_tls_data
();
if
(
strcmp
(
winetest_platform
,
platform
)
==
0
)
data
->
todo_level
++
;
data
->
todo_do_loop
=
1
;
}
int
winetest_loop_todo
(
void
)
{
tls_data
*
data
=
get_tls_data
();
int
do_loop
=
data
->
todo_do_loop
;
data
->
todo_do_loop
=
0
;
return
do_loop
;
}
void
winetest_end_todo
(
const
char
*
platform
)
{
if
(
strcmp
(
winetest_platform
,
platform
)
==
0
)
{
tls_data
*
data
=
get_tls_data
();
data
->
todo_level
--
;
}
}
int
winetest_get_mainargs
(
char
***
pargv
)
{
*
pargv
=
winetest_argv
;
return
winetest_argc
;
}
/* Find a test by name */
static
const
struct
test
*
find_test
(
const
char
*
name
)
{
const
struct
test
*
test
;
const
char
*
p
;
int
len
;
if
((
p
=
strrchr
(
name
,
'/'
)))
name
=
p
+
1
;
if
((
p
=
strrchr
(
name
,
'\\'
)))
name
=
p
+
1
;
len
=
strlen
(
name
);
if
(
len
>
2
&&
!
strcmp
(
name
+
len
-
2
,
".c"
))
len
-=
2
;
for
(
test
=
winetest_testlist
;
test
->
name
;
test
++
)
{
if
(
!
strncmp
(
test
->
name
,
name
,
len
)
&&
!
test
->
name
[
len
])
break
;
}
return
test
->
name
?
test
:
NULL
;
}
/* Run a named test, and return exit status */
static
int
run_test
(
const
char
*
name
)
{
const
struct
test
*
test
;
int
status
;
if
(
!
(
test
=
find_test
(
name
)))
{
fprintf
(
stderr
,
"Fatal: test '%s' does not exist.
\n
"
,
name
);
exit_process
(
1
);
}
successes
=
failures
=
todo_successes
=
todo_failures
=
0
;
tls_index
=
TlsAlloc
();
current_test
=
test
;
test
->
func
();
if
(
winetest_debug
)
{
fprintf
(
stderr
,
"%s: %ld tests executed, %ld marked as todo, %ld %s.
\n
"
,
name
,
successes
+
failures
+
todo_successes
+
todo_failures
,
todo_successes
,
failures
+
todo_failures
,
(
failures
+
todo_failures
!=
1
)
?
"failures"
:
"failure"
);
}
status
=
(
failures
+
todo_failures
<
255
)
?
failures
+
todo_failures
:
255
;
return
status
;
}
/* Display usage and exit */
static
void
usage
(
const
char
*
argv0
)
{
const
struct
test
*
test
;
fprintf
(
stderr
,
"Usage: %s test_name
\n
"
,
argv0
);
fprintf
(
stderr
,
"
\n
Valid test names:
\n
"
);
for
(
test
=
winetest_testlist
;
test
->
name
;
test
++
)
fprintf
(
stderr
,
" %s
\n
"
,
test
->
name
);
exit_process
(
1
);
}
/* main function */
int
main
(
int
argc
,
char
**
argv
)
{
char
*
p
;
winetest_argc
=
argc
;
winetest_argv
=
argv
;
if
((
p
=
getenv
(
"WINETEST_PLATFORM"
)))
winetest_platform
=
p
;
if
((
p
=
getenv
(
"WINETEST_DEBUG"
)))
winetest_debug
=
atoi
(
p
);
if
((
p
=
getenv
(
"WINETEST_REPORT_SUCCESS"
)))
winetest_report_success
=
\
atoi
(
p
);
if
(
!
argv
[
1
])
usage
(
argv
[
0
]
);
return
run_test
(
argv
[
1
]);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment