[gdb/testsuite] Reduce errors after gdb exit in default_gdb_start
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / interact.exp
index 1f15fd862ed16943f6525b1ad6a373da6a569c9a..c31c2175a2b5f34c618687cde211c861b70a6db7 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011-2020 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -15,7 +15,8 @@
 
 # Create a GDB script that we can source.  The script needs to generate
 # some output, to allow us to verify that it is executed properly.
-set fd [open "zzz-gdbscript" "w"]
+set script [standard_output_file zzz-gdbscript]
+set fd [open $script "w"]
 puts $fd "print 1"
 puts $fd "print 2"
 close $fd
@@ -28,21 +29,36 @@ set script_output "\\$\[0-9\]+ = 1\[\r\n\]+\\$\[0-9\]+ = 2.*"
 gdb_exit
 gdb_start
 
-# Test sourcing of the script with interactive mode `auto'
+# Test sourcing of the script with interactive mode `auto'.
+# Verify that evaluating the script does not cause an unexpected
+# change of the interactive-mode setting.
 gdb_test_no_output "set interactive-mode auto"
-gdb_test "source zzz-gdbscript" "$script_output" \
+gdb_test "source $script" "$script_output" \
          "source script with interactive-mode auto"
 gdb_test "print 3" "= 3" "sanity check with interactive-mode auto"
+gdb_test "show interactive-mode" \
+         "Debugger's interactive mode is auto \\(currently .*\\)\\." \
+         "show interactive-mode (auto)"
 
-# Test sourcing of the script with interactive mode `on'
+# Test sourcing of the script with interactive mode `on'.
+# Verify that evaluating the script does not cause an unexpected
+# change of the interactive-mode setting.
 gdb_test_no_output "set interactive-mode on"
-gdb_test "source zzz-gdbscript" "$script_output" \
+gdb_test "source $script" "$script_output" \
          "source script with interactive-mode on"
 gdb_test "print 4" "= 4" "sanity check with interactive-mode on"
+gdb_test "show interactive-mode" \
+         "Debugger's interactive mode is on\\." \
+         "show interactive-mode (on)"
 
-# Test sourcing of the script with interactive mode `of'
+# Test sourcing of the script with interactive mode `off'.
+# Verify that evaluating the script does not cause an unexpected
+# change of the interactive-mode setting.
 gdb_test_no_output "set interactive-mode off"
-gdb_test "source zzz-gdbscript" "$script_output" \
+gdb_test "source $script" "$script_output" \
          "source script with interactive-mode off"
 gdb_test "print 5" "= 5" "sanity check with interactive-mode off"
+gdb_test "show interactive-mode" \
+         "Debugger's interactive mode is off\\." \
+         "show interactive-mode (off)"
 
This page took 0.027323 seconds and 4 git commands to generate.