Added regedit unit test, a couple minor changes to regedit.
[wine] / programs / winetest / runtest
1 #!/usr/bin/perl
2 #
3 # Wrapper script to run tests from inside the Wine tree
4 #
5 # Usage: runtest [options] input_file [perl_args...]
6 #
7 # Copyright 2002 Alexandre Julliard
8 #
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
13 #
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 # Lesser General Public License for more details.
18 #
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22 #
23
24 use strict;
25
26 sub usage
27 {
28     print STDERR <<EOF;
29
30 Usage: $0 [options] input_file [perl_args...]
31
32 Options:
33     -q       quiet mode
34     -v       verbose mode (can be specified multiple times)
35     -s       announce successful tests
36     -p prog  name of the program to run for C tests
37     -I dir   prepend dir to Perl include path
38     -P name  set the current platform name
39     -M names set the module names to be tested
40     -T dir   set Wine tree top directory (autodetected if not specified)
41
42 EOF
43     exit 1;
44 }
45
46 # default values
47 my $platform = $ENV{WINETEST_PLATFORM};
48 $ENV{WINETEST_DEBUG} ||= 1;
49
50 my $topobjdir;
51 my $infile;
52 my $program;
53 my @include_dirs;
54 my @modules;
55
56 # parse command-line options
57 while ($#ARGV >= 0)
58 {
59     my $arg = shift @ARGV;
60     if ($arg eq "-h") { usage; }
61     if ($arg eq "-p") { $program = shift @ARGV; next; }
62     if ($arg eq "-q") { $ENV{WINETEST_DEBUG} = 0; next; }
63     if ($arg eq "-v") { $ENV{WINETEST_DEBUG}++; next; }
64     if ($arg eq "-s") { $ENV{WINETEST_REPORT_SUCCESS} = 1; next;}
65     if ($arg eq "-P") { $platform = shift @ARGV; next; }
66     if ($arg eq "-M") { push @modules, split /,/, shift @ARGV; next; }
67     if ($arg eq "-I") { push @include_dirs, shift @ARGV; next; }
68     if ($arg eq "-T")
69     {
70         $topobjdir = shift @ARGV;
71         usage unless (-d $topobjdir);
72         next;
73     }
74     $infile = $arg;
75     last;
76 }
77
78 # we must have found an input file
79 usage unless defined($infile);
80
81 if ($infile =~ /\.c$/ && !defined($program))
82 {
83     # set program to the .c file base name if not specified otherwise
84     ($program = $infile) =~ s/\.c$//;
85 }
86
87 # check/detect topobjdir
88 if (defined($topobjdir))
89 {
90     unless (-f $topobjdir . "/server/wineserver")
91     {
92         printf STDERR "Wrong -T argument, %s/server/wineserver does not exist\n", $topobjdir;
93         usage;
94     }
95 }
96 else  # try to detect it automatically
97 {
98     if (-f "./server/wineserver") { $topobjdir = "."; }
99     elsif (-f "../server/wineserver") { $topobjdir = ".."; }
100     elsif (-f "../../server/wineserver") { $topobjdir = "../.."; }
101     elsif (-f "../../../server/wineserver") { $topobjdir = "../../.."; }
102 }
103
104 # check for include/ dir in script source directory and append it to search path
105 my $basedir = $0;
106 if ($basedir =~ /\//) { $basedir =~ s!/[^/]+$!!; }
107 else { $basedir = "."; }
108 if (-d $basedir . "/include") { push @include_dirs, $basedir . "/include"; }
109
110 $ENV{PERL5LIB} = join( ":", @include_dirs, split( ":", $ENV{PERL5LIB} ) );
111 if (@modules)
112 {
113     if (defined($ENV{WINEOPTIONS})) { $ENV{WINEOPTIONS} .= " "; }
114     $ENV{WINEOPTIONS} .= "--dll " . join(',',@modules) . "=b";
115 }
116
117 # set environment variables needed for Wine
118 if (defined($topobjdir))
119 {
120     chop($topobjdir = `cd $topobjdir && pwd`);
121     $ENV{LD_LIBRARY_PATH} = $topobjdir . ":" . $ENV{LD_LIBRARY_PATH};
122     $ENV{WINEDLLPATH} = $topobjdir . "/dlls:" . $topobjdir . "/programs";
123     $ENV{WINESERVER} = $topobjdir . "/server/wineserver";
124     $ENV{WINELOADER} = $topobjdir . "/wine";
125     $ENV{WINETEST_PLATFORM} = $platform || "wine";
126     $program ||= "winetest.exe";
127     exec $ENV{WINELOADER}, $program, $infile, @ARGV;
128 }
129 else
130 {
131     $ENV{WINETEST_PLATFORM} = $platform || "windows";
132 }
133
134 # and now exec the program
135 $program ||= "winetest.exe";
136 exec $program, $infile, @ARGV;
137 print STDERR "Could not exec $program\n";
138 exit 1;