3 # Wrapper script to run tests from inside the Wine tree
5 # Usage: runtest [options] input_file [perl_args...]
14 Usage: $0 [options] input_file [perl_args...]
18 -v verbose mode (can be specified multiple times)
19 -I dir prepend dir to Perl include path
20 -P name set the current platform name
21 -M names set the module names to be tested
22 -T dir set Wine tree top directory (autodetected if not specified)
29 my $platform = $ENV{WINETEST_PLATFORM};
30 $ENV{WINETEST_DEBUG} ||= 1;
37 # parse command-line options
40 my $arg = shift @ARGV;
41 if ($arg eq "-h") { usage; }
42 if ($arg eq "-q") { $ENV{WINETEST_DEBUG} = 0; next; }
43 if ($arg eq "-v") { $ENV{WINETEST_DEBUG}++; next; }
44 if ($arg eq "-P") { $platform = shift @ARGV; next; }
45 if ($arg eq "-M") { push @modules, split /,/, shift @ARGV; next; }
46 if ($arg eq "-I") { push @include_dirs, shift @ARGV; next; }
49 $topobjdir = shift @ARGV;
50 usage unless (-d $topobjdir);
57 # we must have found an input file
58 usage unless defined($infile);
60 # check/detect topobjdir
61 if (defined($topobjdir))
63 unless (-f $topobjdir . "/server/wineserver")
65 printf STDERR "Wrong -T argument, %s/server/wineserver does not exist\n", $topobjdir;
69 else # try to detect it automatically
71 if (-f "./server/wineserver") { $topobjdir = "."; }
72 elsif (-f "../server/wineserver") { $topobjdir = ".."; }
73 elsif (-f "../../server/wineserver") { $topobjdir = "../.."; }
74 elsif (-f "../../../server/wineserver") { $topobjdir = "../../.."; }
77 # set environment variables needed for Wine
78 if (defined($topobjdir))
80 chop($topobjdir = `cd $topobjdir && pwd`);
81 $ENV{LD_LIBRARY_PATH} = $topobjdir . "/dlls:" . $topobjdir . ":" . $ENV{LD_LIBRARY_PATH};
82 $ENV{WINESERVER} ||= $topobjdir . "/server/wineserver";
83 $ENV{WINELOADER} ||= $topobjdir . "/wine";
84 $ENV{WINETEST_PLATFORM} = $platform || "wine";
88 $ENV{WINETEST_PLATFORM} = $platform || "windows";
91 # check for include/ dir in script source directory and append it to search path
93 if ($basedir =~ /\//) { $basedir =~ s!/[^/]+$!!; }
94 else { $basedir = "."; }
95 if (-d $basedir . "/include") { push @include_dirs, $basedir . "/include"; }
97 $ENV{PERL5LIB} = join( ":", @include_dirs, split( ":", $ENV{PERL5LIB} ) );
100 if (defined($ENV{WINEOPTIONS})) { $ENV{WINEOPTIONS} .= " "; }
101 $ENV{WINEOPTIONS} .= "--dll " . join(',',@modules) . "=b";
104 # and now exec winetest
105 if (defined($topobjdir))
107 exec $topobjdir . "/programs/winetest/winetest", $infile, @ARGV;
109 exec "winetest", $infile, @ARGV;
110 print STDERR "Could not exec winetest\n";