xref: /openbsd-src/gnu/usr.bin/gcc/contrib/test_installed (revision 7e568061828b4c9de34171db633016903197fe19)
1*7e568061Sespie#! /bin/sh
2*7e568061Sespie
3*7e568061Sespie# (C) 1998, 2000, 2002, 2003 Free Software Foundation
4*7e568061Sespie# Originally by Alexandre Oliva <oliva@dcc.unicamp.br>
5*7e568061Sespie
6*7e568061Sespie# This script is Free Software, and it can be copied, distributed and
7*7e568061Sespie# modified as defined in the GNU General Public License.  A copy of
8*7e568061Sespie# its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
9*7e568061Sespie
10*7e568061Sespie# This scripts assumes it lives in the contrib directory of the GCC
11*7e568061Sespie# source tree, so it will find the testsuite tree from its location.
12*7e568061Sespie# If you move it elsewhere, or want to use another testsuite tree, you
13*7e568061Sespie# can override the defaults with --srcdir=/some/dir/GCC or
14*7e568061Sespie# --testsuite=/some/dir/GCC/gcc/testsuite.  If you specify
15*7e568061Sespie# --testsuite, --srcdir will be ignored; otherwise, `/gcc/testsuite'
16*7e568061Sespie# will be appended to the srcdir.
17*7e568061Sespie
18*7e568061Sespie# You may specify where the binaries to be tested should be picked up
19*7e568061Sespie# from.  If you specify --prefix=/some/dir, gcc, g++ and g77 will be
20*7e568061Sespie# looked for at /some/dir/bin.  Each one may be overridden by
21*7e568061Sespie# specifying --with-gcc=/pathname/to/gcc, --with-g++=/pathname/to/g++
22*7e568061Sespie# and --with-g77=/pathname/to/g77.  If you specify --without-gcc,
23*7e568061Sespie# --without-g++ or --without-g77, the test for the specified program
24*7e568061Sespie# will be skipped.  By default, gcc, g++ and g77 will be searched in
25*7e568061Sespie# the PATH.
26*7e568061Sespie
27*7e568061Sespie# An additional argument may specify --tmpdir=/some/dir; by default,
28*7e568061Sespie# temporaries will be stored in the current directory, where the log
29*7e568061Sespie# files will be stored.
30*7e568061Sespie
31*7e568061Sespie# The script will interpret arguments until it finds one it does not
32*7e568061Sespie# understand.  The remaining ones will be passed to `runtest'.  A
33*7e568061Sespie# double-dash can be used to explicitly separate the arguments to
34*7e568061Sespie# `test_installed' from the ones to `runtest'.
35*7e568061Sespie
36*7e568061Sespie# This script should be run in an empty directory; it will refuse to
37*7e568061Sespie# run if it finds a file named site.exp in the current directory.
38*7e568061Sespie
39*7e568061Sespie
40*7e568061Sespieif test -f site.exp; then
41*7e568061Sespie    echo site.exp already exists >&2
42*7e568061Sespie    exit 1
43*7e568061Sespiefi
44*7e568061Sespie
45*7e568061Sespiewhile true; do
46*7e568061Sespie  case "$1" in
47*7e568061Sespie  --with-testsuite=*) testsuite=`echo "$1" | sed 's/[^=]*=//'`; shift;;
48*7e568061Sespie  --srcdir=*) srcdir=`echo "$1" | sed 's/[^=]*=//'`; shift;;
49*7e568061Sespie
50*7e568061Sespie  --prefix=*) prefix=`echo "$1" | sed 's/[^=]*=//'`; shift;;
51*7e568061Sespie  --with-gcc=*) GCC_UNDER_TEST=`echo "$1" | sed 's/[^=]*=//'`; shift;;
52*7e568061Sespie  --with-g++=*) GXX_UNDER_TEST=`echo "$1" | sed 's/[^=]*=//'`; shift;;
53*7e568061Sespie  --with-g77=*) G77_UNDER_TEST=`echo "$1" | sed 's/[^=]*=//'`; shift;;
54*7e568061Sespie  --without-gcc) GCC_UNDER_TEST=no; shift;;
55*7e568061Sespie  --without-g++) GXX_UNDER_TEST=no; shift;;
56*7e568061Sespie  --without-g77) G77_UNDER_TEST=no; shift;;
57*7e568061Sespie  --without-objc) OBJC_UNDER_TEST=no; shift;;
58*7e568061Sespie
59*7e568061Sespie  --tmpdir=*) tmpdir=`echo "$1" | sed 's/[^=]*=//'`; shift;;
60*7e568061Sespie
61*7e568061Sespie  --help) cat <<\EOF
62*7e568061SespieRuns the testsuite for an installed version of gcc/g++/g77/objc
63*7e568061SespieCopyright (C) 1998, 2000, 2002, 2003  Free Software Foundation
64*7e568061Sespieby Alexandre Oliva <oliva@dcc.unicamp.br>
65*7e568061Sespie
66*7e568061SespieSupported arguments:
67*7e568061Sespie
68*7e568061Sespie--help                        prints this page
69*7e568061Sespie
70*7e568061Sespie--with-testsuite=/some/dir/gcc/testsuite   specify the testsuite directory
71*7e568061Sespie--srcdir=/some/dir            same as --with-testsuite=/some/dir/gcc/testsuite
72*7e568061Sespie                              [deduced from shell-script pathname]
73*7e568061Sespie
74*7e568061Sespie--prefix=/some/dir            use gcc, g++ and g77 from /some/dir/bin [PATH]
75*7e568061Sespie--with-gcc=/some/dir/bin/gcc  use specified gcc program [gcc]
76*7e568061Sespie--with-g++=/some/dir/bin/g++  use specified g++ program [g++]
77*7e568061Sespie--with-g77=/some/dir/bin/g77  use specified g77 program [g77]
78*7e568061Sespie--without-gcc                 do not run gcc testsuite
79*7e568061Sespie--without-g++                 do not run g++ testsuite
80*7e568061Sespie--without-g77                 do not run g77 testsuite
81*7e568061Sespie--without-objc                do not run objc testsuite
82*7e568061Sespie
83*7e568061Sespie--tmpdir=/some/dir            create temporaries and leave failed programs
84*7e568061Sespie                              at specified directory [.]
85*7e568061Sespie
86*7e568061Sespie--   end of argument list; following arguments are passed to runtest
87*7e568061SespieEOF
88*7e568061Sespie    exit
89*7e568061Sespie  ;;
90*7e568061Sespie
91*7e568061Sespie  --) shift; break;;
92*7e568061Sespie  *) break;;
93*7e568061Sespie  esac
94*7e568061Sespiedone
95*7e568061Sespie
96*7e568061Sespieif test x"${testsuite+set}" != x"set" && test x"${srcdir+set}" != x"set"; then
97*7e568061Sespie  file=$0
98*7e568061Sespie  while [ -h $file ]; do
99*7e568061Sespie    file=`ls -l $file | sed s/'.* -> '//`
100*7e568061Sespie  done
101*7e568061Sespie  srcdir=`CDPATH=. && cd \`echo "$file" | sed 's,/*[^/]*$,,;s,^$,.,'\`/.. >/dev/null && ${PWDCMD-pwd}`
102*7e568061Sespiefi
103*7e568061Sespie
104*7e568061Sespiecat >site.exp <<EOF
105*7e568061Sespieset rootme "."
106*7e568061Sespieset tmpdir "${tmpdir-`${PWDCMD-pwd}`}"
107*7e568061Sespieset srcdir "${testsuite-${srcdir}/gcc/testsuite}"
108*7e568061Sespieset CFLAGS ""
109*7e568061Sespieset CXXFLAGS ""
110*7e568061Sespieset GCC_UNDER_TEST "${GCC_UNDER_TEST-${prefix}${prefix+/bin/}gcc}"
111*7e568061Sespieset GXX_UNDER_TEST "${GXX_UNDER_TEST-${prefix}${prefix+/bin/}g++}"
112*7e568061Sespieset G77_UNDER_TEST "${G77_UNDER_TEST-${prefix}${prefix+/bin/}g77}"
113*7e568061Sespieset OBJC_UNDER_TEST "${OBJC_UNDER_TEST-${prefix}${prefix+/bin/}gcc}"
114*7e568061SespieEOF
115*7e568061Sespie
116*7e568061Sespietest x"${GCC_UNDER_TEST}" = x"no" || runtest --tool gcc ${1+"$@"}
117*7e568061Sespietest x"${GXX_UNDER_TEST}" = x"no" || runtest --tool g++ ${1+"$@"}
118*7e568061Sespietest x"${G77_UNDER_TEST}" = x"no" || runtest --tool g77 ${1+"$@"}
119*7e568061Sespietest x"${OBJC_UNDER_TEST}" = x"no" || runtest --tool objc ${1+"$@"}
120*7e568061Sespie
121*7e568061Sespieexit 0
122