Commit c1742366 authored by Alexandre Julliard's avatar Alexandre Julliard

Integrated test script for winetest into the make test

infrastructure. Added a few tests for the new wine.pm functions.
parent 9384184a
Makefile Makefile
Makefile.perl
wine.c wine.c
winetest.spec.c winetest.spec.c
...@@ -12,6 +12,10 @@ C_SRCS = winetest.c ...@@ -12,6 +12,10 @@ C_SRCS = winetest.c
EXTRA_OBJS = wine.o EXTRA_OBJS = wine.o
EXTRASUBDIRS = include tests
PLTESTS = \
tests/wine.pl
@MAKE_PROG_RULES@ @MAKE_PROG_RULES@
......
# ################################################################
# Test script for the winetest program # Tests for wine.pm module functions
# #
use wine; use wine;
$wine::debug = 0;
################################################################ ################################################################
# Declarations for functions we use in this script # Declarations for functions we use in this script
...@@ -26,47 +24,67 @@ wine::declare( "kernel32", ...@@ -26,47 +24,67 @@ wine::declare( "kernel32",
# Test string arguments # Test string arguments
$atom = GlobalAddAtomA("foo"); $atom = GlobalAddAtomA("foo");
assert( $atom >= 0xc000 && $atom <= 0xffff ); ok( $atom >= 0xc000 && $atom <= 0xffff );
assert( !defined($wine::err) ); ok( !defined($wine::err) );
# Test integer and string reference arguments # Test integer and string reference arguments
$buffer = "xxxxxx"; $buffer = "xxxxxx";
$ret = GlobalGetAtomNameA( $atom, \$buffer, length(buffer) ); $ret = GlobalGetAtomNameA( $atom, \$buffer, length(buffer) );
assert( !defined($wine::err) ); ok( !defined($wine::err) );
assert( $ret == 3 ); ok( $ret == 3 );
assert( lc $buffer eq "foo\000xx" ); ok( lc $buffer eq "foo\000xx" );
# Test integer reference # Test integer reference
$code = 0; $code = 0;
$ret = GetExitCodeThread( GetCurrentThread(), \$code ); $ret = GetExitCodeThread( GetCurrentThread(), \$code );
assert( !defined($wine::err) ); ok( !defined($wine::err) );
assert( $ret ); ok( $ret );
assert( $code == 0x103 ); ok( $code == 0x103 );
# Test string return value # Test string return value
$str = lstrcatA( "foo\0foo", "bar" ); $str = lstrcatA( "foo\0foo", "bar" );
assert( !defined($wine::err) ); ok( !defined($wine::err) );
assert( $str eq "foobar" ); ok( $str eq "foobar" );
################################################################ ################################################################
# Test last error handling # Test last error handling
SetLastError( 123 ); SetLastError( 123 );
$ret = GetLastError(); $ret = GetLastError();
assert( $ret == 123 ); ok( $ret == 123 );
################################################################ ################################################################
# Test various error cases # Test various error cases
eval { SetLastError(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7); }; eval { SetLastError(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7); };
assert( $@ =~ /Too many arguments at/ ); ok( $@ =~ /Too many arguments at/ );
my $funcptr = GetProcAddress( GetModuleHandleA("kernel32"), "SetLastError" ); my $funcptr = GetProcAddress( GetModuleHandleA("kernel32"), "SetLastError" );
assert( $funcptr ); ok( $funcptr );
eval { wine::call_wine_API( $funcptr, 10, $wine::debug, 0); }; eval { wine::call_wine_API( $funcptr, 10, $wine::debug-1, 0); };
assert( $@ =~ /Bad return type 10 at/ ); ok( $@ =~ /Bad return type 10 at/ );
eval { foobar(1,2,3); }; eval { foobar(1,2,3); };
assert( $@ =~ /Function 'foobar' not declared at/ ); ok( $@ =~ /Function 'foobar' not declared at/ );
################################################################
# Test assert
assert( 1, "cannot fail" );
eval { assert( 0, "this must fail" ); };
ok( $@ =~ /Assertion failed/ );
ok( $@ =~ /this must fail/ );
################################################################
# Test todo blocks
todo_wine
{
ok( $wine::platform ne "wine", "Must fail only on Wine" );
};
print "OK\n"; todo( $wine::platform,
sub { ok( 0, "Failure must be ignored inside todo" ); } );
todo( $wine::platform . "xxx",
sub { ok( 1, "Success must not cause error inside todo for other platform" ); } );
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