blob: 10032af257aebefca0456d93fa7dde88d444e1d0 [file] [log] [blame]
Dimitrie O. Paune39e8a12002-11-11 20:25:54 +00001#!/bin/sh
2#
3# Wrapper script to run tests from inside the Wine tree
4#
5# Usage: runtest [options] input_file
6#
7# Copyright 2002 Alexandre Julliard
8# Copyright 2002 Dimitrie O. Paun
9#
10# This library is free software; you can redistribute it and/or
11# modify it under the terms of the GNU Lesser General Public
12# License as published by the Free Software Foundation; either
13# version 2.1 of the License, or (at your option) any later version.
14#
15# This library is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18# Lesser General Public License for more details.
19#
20# You should have received a copy of the GNU Lesser General Public
21# License along with this library; if not, write to the Free Software
22# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23#
24
25usage()
26{
Francois Gouget28371032002-12-11 00:18:11 +000027 cat >&2 <<EOF
Dimitrie O. Paune39e8a12002-11-11 20:25:54 +000028
29Usage: $0 [options] input_file
30
31Options:
32 -q quiet mode
33 -v verbose mode (can be specified multiple times)
34 -s announce successful tests
35 -p prog name of the program to run for C tests
36 -P name set the current platform name
37 -M names set the module names to be tested
38 -T dir set Wine tree top directory (autodetected if not specified)
39
40EOF
41 exit 1
42}
43
44# Default values
45platform=$WINETEST_PLATFORM
46WINETEST_DEBUG=${WINETEST_DEBUG:-1}
47
48# parse command-line options
49while [ "$#" != 0 ]; do
50 case "$1" in
51 -h)
52 usage
53 ;;
54 -p)
55 shift; program="$1"
56 ;;
57 -q)
58 WINETEST_DEBUG=0
59 ;;
60 -v)
61 WINETEST_DEBUG=`expr $WINETEST_DEBUG + 1`
62 ;;
63 -s)
64 WINETEST_REPORT_SUCCESS=1
65 export WINETEST_REPORT_SUCCESS
66 ;;
67 -P)
68 shift; platform="$1"
69 ;;
70 -M)
71 shift; modules="$1"
72 ;;
73 -T)
74 shift; topobjdir="$1"
Francois Gouget3efdf382002-12-16 22:11:51 +000075 if [ ! -d "$topobjdir" ]; then usage; fi
76 ;;
77 --)
78 break
Dimitrie O. Paune39e8a12002-11-11 20:25:54 +000079 ;;
80 *)
81 infile="$1"
Francois Gouget3efdf382002-12-16 22:11:51 +000082 ;;
Dimitrie O. Paune39e8a12002-11-11 20:25:54 +000083 esac
84 shift
85done
86
87# we must have found an input file
Francois Gouget28371032002-12-11 00:18:11 +000088if [ ! -f "$infile" ]; then usage; fi
Dimitrie O. Paune39e8a12002-11-11 20:25:54 +000089
90# set program to the .c file base name if not specified otherwise
91if [ -z "$program" ]; then
92 program=`basename "$infile" .c`
93fi
94
95# check/detect topobjdir
96if [ -n "$topobjdir" ]; then
Francois Gouget3efdf382002-12-16 22:11:51 +000097 if [ ! -f "$topobjdir/server/wineserver" ]
98 then
Dimitrie O. Paune39e8a12002-11-11 20:25:54 +000099 echo "Wrong -T argument, $topobjdir/server/wineserver does not exist" 2>&1
100 usage
101 fi
102else
103 if [ -f "./server/wineserver" ]; then topobjdir="."
104 elif [ -f "../server/wineserver" ]; then topobjdir=".."
105 elif [ -f "../../server/wineserver" ]; then topobjdir="../.."
106 elif [ -f "../../../server/wineserver" ]; then topobjdir="../../.."
107 fi
108fi
109
110# set environment variables needed for Wine
111
112if [ -n "$modules" ]; then
113 WINEOPTIONS="$WINEOPTIONS --dll $modules=b"
114 export WINEOPTIONS
115fi
116WINETEST_PLATFORM=${platform:-wine}
117export WINETEST_PLATFORM WINETEST_DEBUG
118
119exec "$topobjdir/wine" "$program" "$infile" "$@"