runtest 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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
  22. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  23. #
  24. usage()
  25. {
  26. cat >&2 <<EOF
  27. Usage: $0 [options] [input_file]
  28. input_file: the source code for the test program
  29. Options:
  30. -q quiet mode
  31. -v verbose mode (can be specified multiple times)
  32. -i interactive mode (runs even more tests)
  33. -s announce successful tests
  34. -p prog name of the program to run for C tests
  35. -P name set the current platform name
  36. -M names set the module names to be tested
  37. -T dir set Wine tree top directory (autodetected if not specified)
  38. EOF
  39. exit 1
  40. }
  41. # Default values
  42. platform=$WINETEST_PLATFORM
  43. WINETEST_DEBUG=${WINETEST_DEBUG:-1}
  44. # parse command-line options
  45. while [ "$#" -gt 0 ]; do
  46. case "$1" in
  47. -h)
  48. usage
  49. ;;
  50. -p)
  51. shift; program="$1"
  52. ;;
  53. -q)
  54. WINETEST_DEBUG=0
  55. ;;
  56. -v)
  57. WINETEST_DEBUG=`expr $WINETEST_DEBUG + 1`
  58. ;;
  59. -i)
  60. WINETEST_INTERACTIVE=1
  61. export WINETEST_INTERACTIVE
  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"
  75. if [ ! -d "$topobjdir" ]; then usage; fi
  76. ;;
  77. *)
  78. break
  79. ;;
  80. esac
  81. shift
  82. done
  83. if [ -z "$program" ]; then
  84. # try to autodetect the test program name based on the working directory
  85. working_path=`pwd`
  86. case $working_path in
  87. */dlls/*/tests)
  88. parent_path=`dirname "$working_path"`
  89. program=`basename "$parent_path"`_test.exe
  90. ;;
  91. */dlls/*)
  92. program=tests/`basename "$working_path"`_test.exe
  93. ;;
  94. */programs/*/tests)
  95. parent_path=`dirname "$working_path"`
  96. program=`basename "$parent_path"`.exe_test.exe
  97. ;;
  98. */programs/*)
  99. program=tests/`basename "$working_path"`.exe_test.exe
  100. ;;
  101. esac
  102. test -f "$program" || program="$program".so
  103. fi
  104. if [ ! -f "$program" ]; then
  105. echo "Can't find the test program, use the -p argument to specify one" 1>&2
  106. usage
  107. fi
  108. # check/detect topobjdir
  109. if [ -n "$topobjdir" ]; then
  110. if [ ! -f "$topobjdir/server/wineserver" ]
  111. then
  112. echo "Wrong -T argument, $topobjdir/server/wineserver does not exist" 1>&2
  113. usage
  114. fi
  115. else
  116. if [ -f "./server/wineserver" ]; then topobjdir="."
  117. elif [ -f "../server/wineserver" ]; then topobjdir=".."
  118. elif [ -f "../../server/wineserver" ]; then topobjdir="../.."
  119. elif [ -f "../../../server/wineserver" ]; then topobjdir="../../.."
  120. else
  121. echo "Can't find the top of the Wine tree (use the -T argument)" 1>&2
  122. usage
  123. fi
  124. fi
  125. # set environment variables needed for Wine
  126. if [ -n "$modules" ]; then
  127. WINEDLLOVERRIDES="$WINEDLLOVERRIDES;$modules=b"
  128. export WINEDLLOVERRIDES
  129. fi
  130. WINETEST_PLATFORM=${platform:-wine}
  131. export WINETEST_PLATFORM WINETEST_DEBUG
  132. # WINETEST_WRAPPER is normally empty, but can be set by caller, e.g.
  133. # WINETEST_WRAPPER=time
  134. # would give data about how long each test takes, and
  135. # WINETEST_WRAPPER=valgrind
  136. # would run the tests under valgrind to look for memory errors.
  137. exec $WINETEST_WRAPPER "$topobjdir/wine" "$program" "$@"