-# 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
# 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
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)"