binutils-gdb/gdb/testsuite/gdb.testsuite
Tom de Vries 3169d00612 [gdb/testsuite] Make parse_args error out on remaining args
I noticed that introducing a typo here in gdb.mi/mi-breakpoint-changed.exp:
...
     set bp_re [mi_make_breakpoint \
-		   -number $bp_nr \
+		   -nunber $bp_nr \
 		   -type dprintf \
 		   -func marker \
 		   -script [string_to_regexp {["printf \"arg\" \""]}]]
...
didn't make the test fail.

Proc mi_make_breakpoint uses parse_args, but does not check the remaining args
as parse_args suggests:
...
proc parse_args { argset } {
    parse_list 2 args $argset "-" false

    # The remaining args should be checked to see that they match the
    # number of items expected to be passed into the procedure
}
...

We could add the missing check in mi_make_breakpoint, but I think the problem
is likely to occur again because the name parse_args does not suggest that
further action is required.

Fix this instead by:
- copying proc parse_args to new proc parse_some_args,
- adding new proc check_no_args_left, and
- calling check_no_args_left in parse_args.

Also be more strict in a few places where we do lassign for remaining args:
...
    lassign $args a b
...

There may be more arguments left in $args, so check that that's not the case
using check_no_args_left:
...
    set args [lassign $args a b]
    check_no_args_left
...

Fix a few test-cases that trigger on the stricter checking.

Tested on x86_64-linux.

Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>

PR testsuite/32129
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32129
2024-09-23 09:34:48 +02:00
..
board-sanity.exp
capture-command-output.exp
cond-wrap.exp
dump-system-info.exp
foreach_with_prefix.exp
gdb-caching-proc-consistency.exp
gdb-caching-proc.exp
gdb-test.exp
lmap.exp
parse_options_args.exp [gdb/testsuite] Make parse_args error out on remaining args 2024-09-23 09:34:48 +02:00
string_to_regexp.exp
string-cat.exp [gdb/testsuite] Add string cat for tcl version < 8.6.2 2024-06-19 09:56:44 +02:00
with-override.exp