Fixed color definition (bg and fg were swapped).
[wine] / programs / winetest / test.pl
1 #
2 # Test script for the winetest program
3 #
4
5 use wine;
6
7 $wine::debug = 0;
8
9 ################################################################
10 # Declarations for functions we use in this script
11
12 wine::declare( "kernel32",
13                SetLastError       => "void",
14                GetLastError       => "int",
15                GlobalAddAtomA     => "word",
16                GlobalGetAtomNameA => "int",
17                GetCurrentThread   => "int",
18                GetExitCodeThread  => "int",
19                GetModuleHandleA   => "int",
20                GetProcAddress     => "int",
21                lstrcatA           => "ptr"
22 );
23
24 ################################################################
25 # Test some simple function calls
26
27 # Test string arguments
28 $atom = GlobalAddAtomA("foo");
29 assert( $atom >= 0xc000 && $atom <= 0xffff );
30 assert( !defined($wine::err) );
31
32 # Test integer and string reference arguments
33 $buffer = "xxxxxx";
34 $ret = GlobalGetAtomNameA( $atom, \$buffer, length(buffer) );
35 assert( !defined($wine::err) );
36 assert( $ret == 3 );
37 assert( lc $buffer eq "foo\000xx" );
38
39 # Test integer reference
40 $code = 0;
41 $ret = GetExitCodeThread( GetCurrentThread(), \$code );
42 assert( !defined($wine::err) );
43 assert( $ret );
44 assert( $code == 0x103 );
45
46 # Test string return value
47 $str = lstrcatA( "foo\0foo", "bar" );
48 assert( !defined($wine::err) );
49 assert( $str eq "foobar" );
50
51 ################################################################
52 # Test last error handling
53
54 SetLastError( 123 );
55 $ret = GetLastError();
56 assert( $ret == 123 );
57
58 ################################################################
59 # Test various error cases
60
61 eval { SetLastError(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7); };
62 assert( $@ =~ /Too many arguments at/ );
63
64 my $funcptr = GetProcAddress( GetModuleHandleA("kernel32"), "SetLastError" );
65 assert( $funcptr );
66 eval { wine::call_wine_API( $funcptr, 10, $wine::debug, 0); };
67 assert( $@ =~ /Bad return type 10 at/ );
68
69 eval { foobar(1,2,3); };
70 assert( $@ =~ /Function 'foobar' not declared at/ );
71
72 print "OK\n";