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 -p prog name of the program to run for C tests
20 -I dir prepend dir to Perl include path
21 -P name set the current platform name
22 -M names set the module names to be tested
23 -T dir set Wine tree top directory (autodetected if not specified)
30 my $platform = $ENV{WINETEST_PLATFORM};
31 $ENV{WINETEST_DEBUG} ||= 1;
39 # parse command-line options
42 my $arg = shift @ARGV;
43 if ($arg eq "-h") { usage; }
44 if ($arg eq "-p") { $program = shift @ARGV; next; }
45 if ($arg eq "-q") { $ENV{WINETEST_DEBUG} = 0; next; }
46 if ($arg eq "-v") { $ENV{WINETEST_DEBUG}++; next; }
47 if ($arg eq "-P") { $platform = shift @ARGV; next; }
48 if ($arg eq "-M") { push @modules, split /,/, shift @ARGV; next; }
49 if ($arg eq "-I") { push @include_dirs, shift @ARGV; next; }
52 $topobjdir = shift @ARGV;
53 usage unless (-d $topobjdir);
60 # we must have found an input file
61 usage unless defined($infile);
63 if ($infile =~ /\.c$/ && !defined($program))
65 # set program to the .c file base name if not specified otherwise
66 ($program = $infile) =~ s/\.c$//;
69 # check/detect topobjdir
70 if (defined($topobjdir))
72 unless (-f $topobjdir . "/server/wineserver")
74 printf STDERR "Wrong -T argument, %s/server/wineserver does not exist\n", $topobjdir;
78 else # try to detect it automatically
80 if (-f "./server/wineserver") { $topobjdir = "."; }
81 elsif (-f "../server/wineserver") { $topobjdir = ".."; }
82 elsif (-f "../../server/wineserver") { $topobjdir = "../.."; }
83 elsif (-f "../../../server/wineserver") { $topobjdir = "../../.."; }
86 # check for include/ dir in script source directory and append it to search path
88 if ($basedir =~ /\//) { $basedir =~ s!/[^/]+$!!; }
89 else { $basedir = "."; }
90 if (-d $basedir . "/include") { push @include_dirs, $basedir . "/include"; }
92 $ENV{PERL5LIB} = join( ":", @include_dirs, split( ":", $ENV{PERL5LIB} ) );
95 if (defined($ENV{WINEOPTIONS})) { $ENV{WINEOPTIONS} .= " "; }
96 $ENV{WINEOPTIONS} .= "--dll " . join(',',@modules) . "=b";
99 # set environment variables needed for Wine
100 if (defined($topobjdir))
102 chop($topobjdir = `cd $topobjdir && pwd`);
103 $ENV{LD_LIBRARY_PATH} = $topobjdir . "/dlls:" . $topobjdir . ":" . $ENV{LD_LIBRARY_PATH};
104 $ENV{WINESERVER} ||= $topobjdir . "/server/wineserver";
105 $ENV{WINELOADER} ||= $topobjdir . "/wine";
106 $ENV{WINETEST_PLATFORM} = $platform || "wine";
107 $ENV{WINEPRELOAD}=($program || ($topobjdir . "/programs/winetest/winetest")) . ".so";
108 # try to exec the wine loader directly; if it fails continue on to normal exec
109 exec $ENV{WINELOADER}, $infile, @ARGV;
113 $ENV{WINETEST_PLATFORM} = $platform || "windows";
116 # and now exec the program
117 $program ||= "winetest";
118 exec $program, $infile, @ARGV;
119 print STDERR "Could not exec $program\n";