aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Bachmeyer <jcb@gnu.org>2021-05-05 17:38:20 -0500
committerJacob Bachmeyer <jcb@gnu.org>2021-05-05 17:38:20 -0500
commit4040555d289e26a81c95e54e43264eee671c8450 (patch)
treef9795760ba080961f66e8bd01cead34febffa28a
parent548769541e0e01472265e293dbdeea9c03950df5 (diff)
downloaddejagnu-4040555d289e26a81c95e54e43264eee671c8450.zip
dejagnu-4040555d289e26a81c95e54e43264eee671c8450.tar.gz
dejagnu-4040555d289e26a81c95e54e43264eee671c8450.tar.bz2
Add regression test for PR48155
-rw-r--r--ChangeLog12
-rw-r--r--Makefile.am3
-rwxr-xr-xtestsuite/runtest.main/pr48155-csh.sh8
-rw-r--r--testsuite/runtest.main/pr48155.exp102
4 files changed, 124 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 9dd742b..3ad73d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2021-05-05 Jacob Bachmeyer <jcb@gnu.org>
+
+ PR48155
+
+ * Makefile.am (TESTSUITE_FILES): Update.
+ (CLEANFILES): Add special init file for PR48155 nested tests.
+
+ * testsuite/runtest.main/pr48155.exp: New file.
+ * testsuite/runtest.main/pr48155-csh.sh: New trivial file. This
+ script emulates the behavior of the C shell if an attempt is made
+ to use it to run the config.guess script.
+
2021-05-04 Jacob Bachmeyer <jcb@gnu.org>
PR48155
diff --git a/Makefile.am b/Makefile.am
index 639a23d..01a1ac9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,7 +30,7 @@ EXTRA_DIST = ChangeLog-1992 MAINTAINERS dejagnu runtest \
$(commands_DATA) $(TESTSUITE_FILES) $(TEXINFO_TEX)\
$(CONTRIB)
-CLEANFILES = dbg.log nested-init.exp
+CLEANFILES = dbg.log nested-init.exp pr48155-init.exp
clean-local: clean-local-check
.PHONY: clean-local-check
@@ -208,6 +208,7 @@ TESTSUITE_FILES = \
testsuite/runtest.main/pr42399.exp \
testsuite/runtest.main/nested/testsuite/bug.test/pr42399.awk \
testsuite/runtest.main/nested/testsuite/bug.test/pr42399-sub.exp \
+ testsuite/runtest.main/pr48155.exp \
testsuite/lib/bohman_ssd.exp \
testsuite/lib/launcher.exp \
testsuite/lib/libdejagnu.exp \
diff --git a/testsuite/runtest.main/pr48155-csh.sh b/testsuite/runtest.main/pr48155-csh.sh
new file mode 100755
index 0000000..08bc039
--- /dev/null
+++ b/testsuite/runtest.main/pr48155-csh.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+cat <<EOF 1>&2
+timestamp=2021-01-25: Command not found.
+Illegal variable name.
+EOF
+
+exit 1
diff --git a/testsuite/runtest.main/pr48155.exp b/testsuite/runtest.main/pr48155.exp
new file mode 100644
index 0000000..c477597
--- /dev/null
+++ b/testsuite/runtest.main/pr48155.exp
@@ -0,0 +1,102 @@
+# Copyright (C) 2021 Free Software Foundation, Inc.
+#
+# This file is part of DejaGnu.
+#
+# DejaGnu is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# DejaGnu is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with DejaGnu; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+
+# This file is a regression test for PR48155, where running with the
+# environment variable SHELL set to a C shell could cause an error running
+# config.guess that would not be properly detected.
+
+load_lib util-defs.exp
+
+runtest_setup_nested_testsuite
+
+# We need a modified local init file for this test; the regular
+# nested-init.exp will set host_triplet, which will cause runtest to assume
+# that that is the build_triplet and avoid attempting to run config.guess.
+exec sed -e /_triplet/d < nested-init.exp > pr48155-init.exp
+
+proc test_pr48155_setup {} {
+ upvar 1 envlist envlist
+ upvar 1 save_env save_env
+ upvar 1 unset_env unset_env
+
+ set unset_env [list]
+ foreach {name value} $envlist {
+ if { [info exists ::env($name)] } {
+ set save_env($name) $::env($name)
+ } else {
+ lappend unset_env $name
+ }
+ }
+ foreach name {CONFIG_SHELL SHELL} {
+ if { [info exists ::env($name)] } {
+ set save_env($name) $::env($name)
+ unset ::env($name)
+ }
+ }
+ array set ::env $envlist
+}
+proc test_pr48155_cleanup {} {
+ upvar 1 save_env save_env
+ upvar 1 unset_env unset_env
+
+ foreach name $unset_env { unset ::env($name) }
+ unset -nocomplain ::env(CONFIG_SHELL) ::env(SHELL)
+ array set ::env [array get save_env]
+}
+
+proc test_pr48155_error { name envlist output } {
+ global RUNTEST
+
+ test_pr48155_setup
+
+ if { [util_test $RUNTEST \
+ "--local_init pr48155-init.exp --tool null" \
+ "" \
+ $output] } {
+ fail $name
+ } else {
+ pass $name
+ }
+
+ test_pr48155_cleanup
+}
+
+test_pr48155_error "bogus CONFIG_SHELL as false" \
+ [list CONFIG_SHELL [which false]] \
+ "exited on code 1.*produced bogus build triplet:"
+test_pr48155_error "bogus CONFIG_SHELL as true" \
+ [list CONFIG_SHELL [which true]] \
+ "produced bogus build triplet:"
+test_pr48155_error "bogus CONFIG_SHELL as simulated C shell" \
+ [list CONFIG_SHELL [testsuite file -source -test pr48155-csh.sh]] \
+ "exited on code 1.*produced bogus build triplet:"
+
+# The following tests may change if planned future enhancements to reject
+# unusable values of SHELL are implemented.
+
+test_pr48155_error "bogus SHELL as false" \
+ [list SHELL [which false]] \
+ "exited on code 1.*produced bogus build triplet:"
+test_pr48155_error "bogus SHELL as true" \
+ [list SHELL [which true]] \
+ "produced bogus build triplet:"
+test_pr48155_error "bogus SHELL as simulated C shell" \
+ [list SHELL [testsuite file -source -test pr48155-csh.sh]] \
+ "exited on code 1.*produced bogus build triplet:"
+
+runtest_cleanup_nested_testsuite