Merge branch 'minor'
[automake.git] / t / dejagnu-relative-srcdir.sh
blob2737efcd2b629fb58eddcd262839c8f05e1c917e
1 #! /bin/sh
2 # Copyright (C) 2011-2017 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Check that DejaGnu testsuites have 'srcdir' defined to a relative path
18 # (both as TCL variable and as environment variable).
20 required=runtest
21 . test-init.sh
23 cat >> configure.ac << 'END'
24 AC_OUTPUT
25 END
27 cat > Makefile.am << 'END'
28 AUTOMAKE_OPTIONS = dejagnu
29 DEJATOOL = tcl env
30 EXTRA_DIST = env.test/env.exp tcl.test/tcl.exp lib/tcl.exp
31 END
33 mkdir env.test tcl.test lib
35 # DejaGnu can change $srcdir behind our backs, so we have to
36 # save its original value. Thanks to Ian Lance Taylor for the
37 # suggestion.
38 cat > lib/tcl.exp << 'END'
39 send_user "tcl_lib_srcdir: $srcdir\n"
40 set orig_srcdir $srcdir
41 END
43 cat > env.test/env.exp << 'END'
44 set env_srcdir $env(srcdir)
45 send_user "env_srcdir: $env_srcdir\n"
46 if { [ regexp "^\.(\./\.\.)?$" $env_srcdir ] } {
47 pass "test_env_src"
48 } else {
49 fail "test_env_src"
51 END
53 cat > tcl.test/tcl.exp << 'END'
54 send_user "tcl_srcdir: $srcdir\n"
55 if { [ regexp "^\.(\./\.\.)?$" $srcdir ] } {
56 pass "test_tcl_src"
57 } else {
58 fail "test_tcl_src"
60 send_user "tcl_orig_srcdir: $orig_srcdir\n"
61 if { [ regexp "^\.(\./\.\.)?$" $orig_srcdir ] } {
62 pass "test_tcl_orig_src"
63 } else {
64 fail "test_tcl_orig_src"
66 END
68 $ACLOCAL
69 $AUTOCONF
70 $AUTOMAKE --add-missing
72 ./configure --srcdir=.
74 $MAKE check
76 # Sanity check: all tests have run.
77 test -f env.log
78 test -f env.sum
79 test -f tcl.log
80 test -f tcl.sum
82 $MAKE distcheck