Make "frame apply" support -OPT options
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / options.exp
index 3b4e7ee189f4c0e5e2535aadefa22d3140d6967e..195bbb168ae5fd25b707f6d4e5f93eac04a0dc16 100644 (file)
 # The test uses the "maintenance test-options" subcommands to exercise
 # TAB-completion and option processing.
 #
-# It also tests option integration in various commands, including
-# "print" and "compile print".
+# It also tests option integration in various commands, including:
+#
+#  - print
+#  - compile print
+#  - backtrace
+#  - frame apply
+#  - faas
+#  - tfaas
 
 load_lib completion-support.exp
 
@@ -231,6 +237,140 @@ proc_with_prefix test-print {{prefix ""}} {
        "Left operand of assignment is not an lvalue\\."
 }
 
+# Basic option-machinery + "backtrace" command integration tests.
+proc_with_prefix test-backtrace {} {
+    clean_restart
+
+    test_gdb_complete_unique "backtrace" "backtrace"
+    test_gdb_complete_none "backtrace "
+
+    gdb_test "backtrace -" "Ambiguous option at: -"
+    gdb_test "backtrace --" "No stack\\."
+    gdb_test "backtrace -- -" "No stack\\."
+
+    test_gdb_complete_multiple "backtrace " "-" "" {
+       "-entry-values"
+       "-frame-arguments"
+       "-full"
+       "-hide"
+       "-no-filters"
+       "-past-entry"
+       "-past-main"
+       "-raw-frame-arguments"
+    }
+
+    # Test that we complete the qualifiers, if there's any.
+    test_gdb_complete_unique \
+       "backtrace ful" \
+       "backtrace full"
+    test_gdb_complete_unique \
+       "backtrace hid" \
+       "backtrace hide"
+    test_gdb_complete_unique \
+       "backtrace no-fil" \
+       "backtrace no-filters"
+
+    global binfile
+    clean_restart $binfile
+
+    if ![runto_main] {
+       fail "cannot run to main"
+       return
+    }
+
+    # COUNT in "backtrace COUNT" is parsed as an expression.  Check
+    # that we complete expressions.
+
+    test_gdb_complete_unique \
+       "backtrace xxx" \
+       "backtrace xxx1"
+
+    test_gdb_complete_unique \
+       "backtrace -xxx" \
+       "backtrace -xxx1"
+
+    test_gdb_complete_unique \
+       "backtrace 1 + xxx" \
+       "backtrace 1 + xxx1"
+
+    test_gdb_complete_unique \
+       "backtrace (1 + xxx" \
+       "backtrace (1 + xxx1"
+}
+
+# Basic option-machinery + "frame apply" command integration tests.
+proc_with_prefix test-frame-apply {} {
+    test_gdb_complete_unique "frame apply all" "frame apply all"
+
+    gdb_test "frame apply level 0-" \
+       "Please specify a command to apply on the selected frames"
+    test_gdb_complete_none "frame apply level 0-"
+
+    foreach cmd {
+       "frame apply all"
+       "frame apply 1"
+       "frame apply level 0"
+       "faas"
+       "tfaas"
+    } {
+       test_gdb_completion_offers_commands "$cmd "
+
+       # tfaas is silent on command error by design.  This procedure
+       # hides that aspect.  EXPECTED_RE is only considered when not
+       # testing with "faas"/"tfaas".
+       proc test_error_cmd {cmd arg expected_re} {
+           if {$cmd == "tfaas"} {
+               gdb_test_no_output "$cmd$arg"
+           } else {
+               gdb_test "$cmd$arg" $expected_re
+           }
+       }
+       # Same, but for tests where both "faas" and "tfaas" are
+       # expected to be silent.
+       proc test_error_cmd2 {cmd arg expected_re} {
+           if {$cmd == "tfaas" || $cmd == "faas"} {
+               gdb_test_no_output "$cmd$arg"
+           } else {
+               gdb_test "$cmd$arg" $expected_re
+           }
+       }
+
+       test_error_cmd $cmd " -" "Ambiguous option at: -"
+       test_gdb_complete_multiple "$cmd " "-" "" {
+           "-c"
+           "-past-entry"
+           "-past-main"
+           "-q"
+           "-s"
+       }
+
+       with_test_prefix "no-trailing-space" {
+           test_error_cmd $cmd " --" \
+               "Please specify a command to apply on the selected frames"
+           test_gdb_complete_unique "$cmd --" "$cmd --"
+       }
+
+       with_test_prefix "trailing-space" {
+           test_error_cmd $cmd " -- " \
+               "Please specify a command to apply on the selected frames"
+           test_gdb_completion_offers_commands "$cmd -- "
+       }
+
+       # '-' is a valid TUI command.
+       test_error_cmd2 $cmd " -- -" \
+           "Cannot enable the TUI when output is not a terminal"
+       test_gdb_complete_unique \
+           "$cmd -- -" \
+           "$cmd -- -"
+
+       test_error_cmd2 $cmd " -foo" \
+           "Undefined command: \"-foo\".  Try \"help\"\\."
+       test_gdb_complete_none "$cmd -foo"
+
+       test_gdb_completion_offers_commands "$cmd -s "
+    }
+}
+
 # Miscellaneous tests.
 proc_with_prefix test-misc {variant} {
     global all_options
@@ -667,10 +807,28 @@ foreach_with_prefix cmd {
     test-enum $cmd
 }
 
-# Run the print integration tests.
-test-print ""
+# Run the print integration tests, both as "standalone", and under
+# "frame apply".  The latter checks that the "frame apply ... COMMAND"
+# commands recurse the completion machinery for COMMAND completion
+# correctly.
+foreach prefix {
+    ""
+    "frame apply all "
+    "frame apply 1 "
+    "frame apply level 0 "
+} {
+    test-print $prefix
+}
 
-# Same for "compile print".
+# Same for "compile print".  Not really a wrapper prefix command like
+# "frame apply", but similar enough that we test pretty much the same
+# things.
 if ![skip_compile_feature_tests] {
     test-print "compile "
 }
+
+# Basic "backtrace" integration tests.
+test-backtrace
+
+# Basic "frame apply" integration tests.
+test-frame-apply
This page took 0.02746 seconds and 4 git commands to generate.