3 # Wrapper script to run tests from inside the Wine tree
5 # Usage: runtest [options] input_file [perl_args...]
7 # Copyright 2002 Alexandre Julliard
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.
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.
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
30 Usage: $0 [options] input_file [perl_args...]
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)
47 my $platform = $ENV{WINETEST_PLATFORM
};
48 $ENV{WINETEST_DEBUG
} ||= 1;
56 # parse command-line options
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; }
70 $topobjdir = shift @ARGV;
71 usage
unless (-d
$topobjdir);
78 # we must have found an input file
79 usage
unless defined($infile);
81 if ($infile =~ /\.c$/ && !defined($program))
83 # set program to the .c file base name if not specified otherwise
84 ($program = $infile) =~ s/\.c$//;
87 # check/detect topobjdir
88 if (defined($topobjdir))
90 unless (-f
$topobjdir . "/server/wineserver")
92 printf STDERR
"Wrong -T argument, %s/server/wineserver does not exist\n", $topobjdir;
96 else # try to detect it automatically
98 if (-f
"./server/wineserver") { $topobjdir = "."; }
99 elsif (-f
"../server/wineserver") { $topobjdir = ".."; }
100 elsif (-f
"../../server/wineserver") { $topobjdir = "../.."; }
101 elsif (-f
"../../../server/wineserver") { $topobjdir = "../../.."; }
104 # check for include/ dir in script source directory and append it to search path
106 if ($basedir =~ /\//) { $basedir =~ s!/[^/]+$!!; }
107 else { $basedir = "."; }
108 if (-d
$basedir . "/include") { push @include_dirs, $basedir . "/include"; }
110 $ENV{PERL5LIB
} = join( ":", @include_dirs, split( ":", $ENV{PERL5LIB
} ) );
113 if (defined($ENV{WINEOPTIONS
})) { $ENV{WINEOPTIONS
} .= " "; }
114 $ENV{WINEOPTIONS
} .= "--dll " . join(',',@modules) . "=b";
117 # set environment variables needed for Wine
118 if (defined($topobjdir))
120 chop($topobjdir = `cd $topobjdir && pwd`);
121 $ENV{LD_LIBRARY_PATH
} = $topobjdir . ":" . $ENV{LD_LIBRARY_PATH
};
122 $ENV{WINEDLLPATH
} = $topobjdir . "/dlls";
123 $ENV{WINESERVER
} = $topobjdir . "/server/wineserver";
124 $ENV{WINELOADER
} = $topobjdir . "/wine";
125 $ENV{WINETEST_PLATFORM
} = $platform || "wine";
126 $ENV{WINEPRELOAD
}=($program || ($topobjdir . "/programs/winetest/winetest")) . ".so";
127 # try to exec the wine loader directly; if it fails continue on to normal exec
128 exec $ENV{WINELOADER
}, $infile, @ARGV;
132 $ENV{WINETEST_PLATFORM
} = $platform || "windows";
135 # and now exec the program
136 $program ||= "winetest";
137 exec $program, $infile, @ARGV;
138 print STDERR
"Could not exec $program\n";