Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 1 | #!/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 |
Jonathan Ernst | 360a3f9 | 2006-05-18 14:49:52 +0200 | [diff] [blame] | 22 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 23 | # |
| 24 | |
| 25 | usage() |
| 26 | { |
Francois Gouget | 2837103 | 2002-12-11 00:18:11 +0000 | [diff] [blame] | 27 | cat >&2 <<EOF |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 28 | |
Dylan Smith | 443bfc9 | 2008-10-07 12:17:57 -0400 | [diff] [blame] | 29 | Usage: $0 [options] [input_file] |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 30 | |
Jeff Latimer | 6d1b4af | 2006-10-21 19:35:57 +1000 | [diff] [blame] | 31 | input_file: the source code for the test program |
| 32 | |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 33 | Options: |
| 34 | -q quiet mode |
| 35 | -v verbose mode (can be specified multiple times) |
Jörg Höhle | baac2a6 | 2009-10-10 05:54:16 +0200 | [diff] [blame] | 36 | -i interactive mode (runs even more tests) |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 37 | -s announce successful tests |
| 38 | -p prog name of the program to run for C tests |
| 39 | -P name set the current platform name |
| 40 | -M names set the module names to be tested |
| 41 | -T dir set Wine tree top directory (autodetected if not specified) |
| 42 | |
| 43 | EOF |
| 44 | exit 1 |
| 45 | } |
| 46 | |
| 47 | # Default values |
| 48 | platform=$WINETEST_PLATFORM |
| 49 | WINETEST_DEBUG=${WINETEST_DEBUG:-1} |
| 50 | |
| 51 | # parse command-line options |
Dylan Smith | a9b2ee2 | 2008-10-13 19:59:25 -0400 | [diff] [blame] | 52 | while [ "$#" -gt 0 ]; do |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 53 | case "$1" in |
| 54 | -h) |
| 55 | usage |
| 56 | ;; |
| 57 | -p) |
| 58 | shift; program="$1" |
| 59 | ;; |
| 60 | -q) |
| 61 | WINETEST_DEBUG=0 |
| 62 | ;; |
| 63 | -v) |
| 64 | WINETEST_DEBUG=`expr $WINETEST_DEBUG + 1` |
| 65 | ;; |
Jörg Höhle | baac2a6 | 2009-10-10 05:54:16 +0200 | [diff] [blame] | 66 | -i) |
| 67 | WINETEST_INTERACTIVE=1 |
| 68 | export WINETEST_INTERACTIVE |
| 69 | ;; |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 70 | -s) |
| 71 | WINETEST_REPORT_SUCCESS=1 |
| 72 | export WINETEST_REPORT_SUCCESS |
| 73 | ;; |
| 74 | -P) |
| 75 | shift; platform="$1" |
| 76 | ;; |
| 77 | -M) |
| 78 | shift; modules="$1" |
| 79 | ;; |
| 80 | -T) |
| 81 | shift; topobjdir="$1" |
Francois Gouget | 3efdf38 | 2002-12-16 22:11:51 +0000 | [diff] [blame] | 82 | if [ ! -d "$topobjdir" ]; then usage; fi |
| 83 | ;; |
Dylan Smith | a9b2ee2 | 2008-10-13 19:59:25 -0400 | [diff] [blame] | 84 | *) |
Francois Gouget | 3efdf38 | 2002-12-16 22:11:51 +0000 | [diff] [blame] | 85 | break |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 86 | ;; |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 87 | esac |
| 88 | shift |
| 89 | done |
| 90 | |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 91 | if [ -z "$program" ]; then |
Dylan Smith | 634052e | 2008-10-07 12:17:39 -0400 | [diff] [blame] | 92 | # try to autodetect the test program name based on the working directory |
| 93 | working_path=`pwd` |
Alexandre Julliard | 96346ed | 2010-02-15 12:49:08 +0100 | [diff] [blame] | 94 | case $working_path in |
| 95 | */dlls/*/tests) |
| 96 | parent_path=`dirname "$working_path"` |
| 97 | program=`basename "$parent_path"`_test.exe.so |
| 98 | ;; |
| 99 | */dlls/*) |
| 100 | program=tests/`basename "$working_path"`_test.exe.so |
| 101 | ;; |
| 102 | */programs/*/tests) |
| 103 | parent_path=`dirname "$working_path"` |
| 104 | program=`basename "$parent_path"`.exe_test.exe.so |
| 105 | ;; |
| 106 | */programs/*) |
| 107 | program=tests/`basename "$working_path"`.exe_test.exe.so |
| 108 | ;; |
| 109 | esac |
Dylan Smith | 634052e | 2008-10-07 12:17:39 -0400 | [diff] [blame] | 110 | fi |
| 111 | if [ ! -f "$program" ]; then |
| 112 | echo "Can't find the test program, use the -p argument to specify one" 1>&2 |
| 113 | usage |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 114 | fi |
| 115 | |
| 116 | # check/detect topobjdir |
| 117 | if [ -n "$topobjdir" ]; then |
Francois Gouget | 3efdf38 | 2002-12-16 22:11:51 +0000 | [diff] [blame] | 118 | if [ ! -f "$topobjdir/server/wineserver" ] |
| 119 | then |
Dylan Smith | 634052e | 2008-10-07 12:17:39 -0400 | [diff] [blame] | 120 | echo "Wrong -T argument, $topobjdir/server/wineserver does not exist" 1>&2 |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 121 | usage |
| 122 | fi |
| 123 | else |
| 124 | if [ -f "./server/wineserver" ]; then topobjdir="." |
| 125 | elif [ -f "../server/wineserver" ]; then topobjdir=".." |
| 126 | elif [ -f "../../server/wineserver" ]; then topobjdir="../.." |
| 127 | elif [ -f "../../../server/wineserver" ]; then topobjdir="../../.." |
Dylan Smith | 8d88fe6 | 2008-10-07 12:16:36 -0400 | [diff] [blame] | 128 | else |
Dylan Smith | 634052e | 2008-10-07 12:17:39 -0400 | [diff] [blame] | 129 | echo "Can't find the top of the Wine tree (use the -T argument)" 1>&2 |
Dylan Smith | 8d88fe6 | 2008-10-07 12:16:36 -0400 | [diff] [blame] | 130 | usage |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 131 | fi |
| 132 | fi |
| 133 | |
| 134 | # set environment variables needed for Wine |
| 135 | |
Alexandre Julliard | 2052538 | 2003-09-25 20:33:41 +0000 | [diff] [blame] | 136 | if [ -n "$modules" ]; then |
| 137 | WINEDLLOVERRIDES="$WINEDLLOVERRIDES;$modules=b" |
| 138 | export WINEDLLOVERRIDES |
Dimitrie O. Paun | e39e8a1 | 2002-11-11 20:25:54 +0000 | [diff] [blame] | 139 | fi |
| 140 | WINETEST_PLATFORM=${platform:-wine} |
| 141 | export WINETEST_PLATFORM WINETEST_DEBUG |
| 142 | |
Dan Kegel | d18cd89 | 2008-07-18 16:31:43 -0700 | [diff] [blame] | 143 | # WINETEST_WRAPPER is normally empty, but can be set by caller, e.g. |
| 144 | # WINETEST_WRAPPER=time |
| 145 | # would give data about how long each test takes, and |
| 146 | # WINETEST_WRAPPER=valgrind |
| 147 | # would run the tests under valgrind to look for memory errors. |
| 148 | |
Dylan Smith | 443bfc9 | 2008-10-07 12:17:57 -0400 | [diff] [blame] | 149 | exec $WINETEST_WRAPPER "$topobjdir/wine" "$program" "$@" |