# This is a test for the gdb invocation option --args.
-
-global GDBFLAGS
-
# Skip test if target does not support argument passing.
if [target_info exists noargs] {
return
#
# Test that the --args are processed correctly.
#
-set old_gdbflags $GDBFLAGS
-set GDBFLAGS "$old_gdbflags --args $binfile 1 3"
-args_test basic {{1} {3}}
+save_vars { GDBFLAGS } {
+ set old_gdbflags $GDBFLAGS
-#
-# Test that the --args are processed correctly even if one of them is empty.
-# The syntax needed is a little peculiar; DejaGNU treats the arguments as a
-# list and expands them itself, since no shell redirection is involved.
-#
-set GDBFLAGS "$old_gdbflags --args $binfile 1 {} 3"
-args_test "one empty" {{1} {} {3}}
+ set GDBFLAGS "$old_gdbflags --args $binfile 1 3"
+ args_test basic {{1} {3}}
-#
-# try with 2 empty args
-#
-set GDBFLAGS "$old_gdbflags --args $binfile 1 {} {} 3"
-args_test "two empty" {{1} {} {} 3}
+ #
+ # Test that the --args are processed correctly even if one of them is empty.
+ # The syntax needed is a little peculiar; DejaGNU treats the arguments as a
+ # list and expands them itself, since no shell redirection is involved.
+ #
+ set GDBFLAGS "$old_gdbflags --args $binfile 1 {} 3"
+ args_test "one empty" {{1} {} {3}}
-# Try with arguments containing literal single quotes.
+ #
+ # try with 2 empty args
+ #
+ set GDBFLAGS "$old_gdbflags --args $binfile 1 {} {} 3"
+ args_test "two empty" {{1} {} {} 3}
-set GDBFLAGS "$old_gdbflags --args $binfile 1 '' 3"
-args_test "one empty (with single quotes)" {{1} {''} {3}}
+ # Try with arguments containing literal single quotes.
-set GDBFLAGS "$old_gdbflags --args $binfile 1 '' '' 3"
-args_test "two empty (with single quotes)" {{1} {''} {''} {3}}
+ set GDBFLAGS "$old_gdbflags --args $binfile 1 '' 3"
+ args_test "one empty (with single quotes)" {{1} {''} {3}}
-# try with arguments containing literal newlines.
+ set GDBFLAGS "$old_gdbflags --args $binfile 1 '' '' 3"
+ args_test "two empty (with single quotes)" {{1} {''} {''} {3}}
-set GDBFLAGS "-nx --args $binfile 1 {\n} 3"
-args_test "one newline" {{1} {\\n} {3}}
+ # try with arguments containing literal newlines.
-set GDBFLAGS "-nx --args $binfile 1 {\n} {\n} 3"
-args_test "two newlines" {{1} {\\n} {\\n} {3}}
+ set GDBFLAGS "-nx --args $binfile 1 {\n} 3"
+ args_test "one newline" {{1} {\\n} {3}}
-set GDBFLAGS $old_gdbflags
+ set GDBFLAGS "-nx --args $binfile 1 {\n} {\n} 3"
+ args_test "two newlines" {{1} {\\n} {\\n} {3}}
+}