Command abbreviation in define
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / define.exp
index 59203ec2899eac15c518d648a053c6b996f55983..711ed25e47b9ec797d5c4730aa7b4a46e5090dd7 100644 (file)
@@ -147,6 +147,38 @@ gdb_test_multiple "define ifnospace" "define user command: ifnospace" \
 
 gdb_test "ifnospace" ".*hi there.*" "test ifnospace is parsed correctly"
 
+# Verify that the command parser properly handles command abbreviations.
+with_test_prefix "command abbreviations in define" {
+  set test "define user command: breakmain"
+  gdb_test_multiple "define breakmain" "$test" {
+      -re "Type commands for definition of \"breakmain\".\r\nEnd with a line saying just \"end\".\r\n>$" {
+         pass "$test"
+         set test "send body of breakmain"
+         gdb_test_multiple "break main\ncommand\necho\nend\nend" "$test"  {
+             -re "$gdb_prompt $"\
+                 {pass "$test"}
+         }
+      }
+  }
+
+  gdb_test "breakmain" ".*Breakpoint .*" "run user command"
+
+  # If GDB fails to interpret properly the abbrev "command", the last "end"
+  # will be missing.  Issue it to avoid a desync that would break the other
+  # tests in this file.
+  gdb_test "end" \
+    "This command cannot be used at the top level.*" \
+    "additional end command"
+
+  gdb_test "info break \$bpnum" \
+    [multi_line \
+      "Num     Type\[ \]+Disp Enb Address\[ \]+What.*" \
+      "\[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*" \
+      "\[\t \]+echo.*"] \
+    "info break shows echo command"
+}
+
+
 # Verify that the command parser doesn't require a space after an 'while'
 # command in a user defined function.
 #
This page took 0.046988 seconds and 4 git commands to generate.