Wed Jan 11 00:14:40 1995 Jeff Law (law@snake.cs.utah.edu)
+ * gdb.base/commands.exp: Test a simple user defined command with
+ arguments and if/while statements; verify the full user command is
+ printed by "show user".
+
* gdb.base/commands.exp: Test if/while commands as part of a
breakpoint command list; verify they appear in breakpoint
information.
send "commands\n"
expect {
-re "End with" { }
- default "{ fail (timeout or eof) commands" }
+ default { fail "(timeout or eof) commands" }
}
# This test should alternate between 0xdeadbeef and 0xfeedface two times.
gdb_test "while value > 0\\nset value -= 1\\nif \(value % 2\) == 1\\np/x 0xdeadbeef\\nelse\\np/x 0xfeedface\\nend\\nend\\nend\\n" ".*$prompt.*" "commands"
gdb_test "info break" "while.*set.*if.*p/x.*else.*p/x.*end.*" "info break"
}
+# Test a simple user defined command (with arguments)
+proc user_defined_command_test {} {
+ global prompt
+
+ gdb_test "set \\\$foo = 4"
+ # For some stupid reason doing this with a gdb_test timed out. Weird.
+ send "define mycommand\n"
+ expect {
+ -re "End with" { }
+ default { fail "(timeout or eof) enter user defined command" }
+ }
+ # This test should alternate between 0xdeadbeef and 0xfeedface two times.
+ gdb_test "while \\\$arg0 > 0\\nset \\\$arg0 -= 1\\nif \(\\\$arg0 % 2\) == 1\\np/x 0xdeadbeef\\nelse\\np/x 0xfeedface\\nend\\nend\\nend\\n" ".*$prompt.*" "enter user defined command"
+
+ gdb_test "mycommand \\\$foo" "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" "execute user defined command"
+ gdb_test "show user mycommand" "while.*set.*if.*p/x.*else.*p/x.*end.*" "display user command"
+}
+
gdbvar_simple_if_test
gdbvar_simple_while_test
gdbvar_complex_if_while_test
progvar_simple_while_test
progvar_complex_if_while_test
if_while_breakpoint_command_test
+user_defined_command_test