1 # Copyright (C) 2021 Free Software Foundation, Inc.
3 # This file is part of DejaGnu.
5 # DejaGnu is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # DejaGnu is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with DejaGnu; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
19 # This file is a regression test for PR48155, where running with the
20 # environment variable SHELL set to a C shell could cause an error running
21 # config.guess that would not be properly detected.
23 load_lib util-defs.exp
25 runtest_setup_nested_testsuite
27 # We need a modified local init file for this test; the regular
28 # nested-init.exp will set host_triplet, which will cause runtest to assume
29 # that that is the build_triplet and avoid attempting to run config.guess.
30 exec sed -e /_triplet/d < nested-init.exp > pr48155-init.exp
32 proc test_pr48155_setup {} {
33 upvar 1 envlist envlist
34 upvar 1 save_env save_env
35 upvar 1 unset_env unset_env
38 foreach {name value} $envlist {
39 if { [info exists ::env($name)] } {
40 set save_env($name) $::env($name)
42 lappend unset_env $name
45 foreach name {CONFIG_SHELL SHELL} {
46 if { [info exists ::env($name)] } {
47 set save_env($name) $::env($name)
51 array set ::env $envlist
53 proc test_pr48155_cleanup {} {
54 upvar 1 save_env save_env
55 upvar 1 unset_env unset_env
57 foreach name $unset_env { unset ::env($name) }
58 unset -nocomplain ::env(CONFIG_SHELL) ::env(SHELL)
59 array set ::env [array get save_env]
62 proc test_pr48155_error { name envlist output } {
67 if { [util_test $RUNTEST \
68 "--local_init pr48155-init.exp --tool null" \
79 test_pr48155_error "bogus CONFIG_SHELL as false" \
80 [list CONFIG_SHELL [which false]] \
81 "exited on code .*produced bogus build triplet:"
82 test_pr48155_error "bogus CONFIG_SHELL as true" \
83 [list CONFIG_SHELL [which true]] \
84 "produced bogus build triplet:"
85 test_pr48155_error "bogus CONFIG_SHELL as simulated C shell" \
86 [list CONFIG_SHELL [testsuite file -source -test pr48155-csh.sh]] \
87 "exited on code 1.*produced bogus build triplet:"
89 # The following tests may change if planned future enhancements to reject
90 # unusable values of SHELL are implemented.
92 test_pr48155_error "bogus SHELL as false" \
93 [list SHELL [which false]] \
94 "exited on code .*produced bogus build triplet:"
95 test_pr48155_error "bogus SHELL as true" \
96 [list SHELL [which true]] \
97 "produced bogus build triplet:"
98 test_pr48155_error "bogus SHELL as simulated C shell" \
99 [list SHELL [testsuite file -source -test pr48155-csh.sh]] \
100 "exited on code 1.*produced bogus build triplet:"
102 runtest_cleanup_nested_testsuite