public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed] Robustify gdb.base/testenv.exp:find_env
@ 2020-09-20 15:03 Pedro Alves
  0 siblings, 0 replies; only message in thread
From: Pedro Alves @ 2020-09-20 15:03 UTC (permalink / raw)
  To: gdb-patches

If printing 'envp[$i]' in find_env fails, the testcase goes into an
infinite loop:

 Running /home/pedro/rocm/gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/testenv.exp ...
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[0] ? envp[0] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[1] ? envp[1] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[2] ? envp[2] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[3] ? envp[3] : ""
 ...
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[2519] ? envp[2519] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[2520] ? envp[2520] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[2521] ? envp[2521] : ""
 ..
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[5128] ? envp[5128] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[5129] ? envp[5129] : ""
 FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[5130] ? envp[5130] : ""
 ...

Fix that by bailing out of the loop on failure.

gdb/testsuite/ChangeLog:

	* gdb.base/testenv.exp (find_env): Bail out if printing 'envp[$i]'
	fails.
---
 gdb/testsuite/gdb.base/testenv.exp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gdb/testsuite/gdb.base/testenv.exp b/gdb/testsuite/gdb.base/testenv.exp
index 1599b72c27b..4dea043472c 100644
--- a/gdb/testsuite/gdb.base/testenv.exp
+++ b/gdb/testsuite/gdb.base/testenv.exp
@@ -68,6 +68,12 @@ proc find_env {varname} {
 	    -re "var: \(\[^\r\n\]*\)\r\n$gdb_prompt $" {
 		set var $expect_out(1,string)
 	    }
+	    -re "$gdb_prompt $" {
+		# If this fails, bail out, otherwise we get stuck in
+		# an infinite loop.  The caller will end up emiting a
+		# FAIL.
+		return "<fail>"
+	    }
 	}
 
 	if {[string match "$varname=*" $var]} {

base-commit: 851257b5fc3a21659cfb2504c03001535756cf4a
-- 
2.14.5


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-20 15:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-20 15:03 [pushed] Robustify gdb.base/testenv.exp:find_env Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).