From: Pedro Alves Date: Sun, 20 Sep 2020 14:58:09 +0000 (+0100) Subject: Robustify gdb.base/testenv.exp:find_env X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dbc49e9ffa4c95413f38e31dae652329fd22dda2;p=binutils-gdb.git Robustify gdb.base/testenv.exp:find_env 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. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 695416cf483..71ec4951f16 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-09-20 Pedro Alves + + * gdb.base/testenv.exp (find_env): Bail out if printing 'envp[$i]' + fails. + 2020-09-19 Andrew Burgess * gdb.fortran/array-slices.exp: Update expected results. 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 "" + } } if {[string match "$varname=*" $var]} {