public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/4] gdb/testsuite: gdb.base/args.exp: use save_vars
@ 2021-06-16 19:37 Simon Marchi
  2021-06-16 19:37 ` [PATCH 2/4] gdb/testsuite: gdb.base/args.exp: use $old_gdbflags last two tests Simon Marchi
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Simon Marchi @ 2021-06-16 19:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Use save_vars instead of manually saving/restoring.  This ensures that
if anything throws an error, GDBFLAGS will be correctly restored.

Remove the global GDBFLAGS declaration at the top, it's not necessary.

gdb/testsuite/ChangeLog:

	* gdb.base/args.exp: Use save_vars.

Change-Id: I3a45e4fc1635ec0212de2415040f91eecaf4a057
---
 gdb/testsuite/gdb.base/args.exp | 56 ++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 29 deletions(-)

diff --git a/gdb/testsuite/gdb.base/args.exp b/gdb/testsuite/gdb.base/args.exp
index e848c70a482..bff750dff24 100644
--- a/gdb/testsuite/gdb.base/args.exp
+++ b/gdb/testsuite/gdb.base/args.exp
@@ -15,9 +15,6 @@
 
 # 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
@@ -64,39 +61,40 @@ proc args_test { name arglist } {
 #
 # 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}}
+}
-- 
2.31.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-06-17 13:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16 19:37 [PATCH 1/4] gdb/testsuite: gdb.base/args.exp: use save_vars Simon Marchi
2021-06-16 19:37 ` [PATCH 2/4] gdb/testsuite: gdb.base/args.exp: use $old_gdbflags last two tests Simon Marchi
2021-06-16 19:37 ` [PATCH 3/4] gdb/testsuite: gdb.base/args.exp: remove trailing parenthesis in test names Simon Marchi
2021-06-16 19:37 ` [PATCH 4/4] gdb/testsuite: gdb.base/args.exp: add KFAIL for native-extended-gdbserver Simon Marchi
2021-06-17 10:35   ` Pedro Alves
2021-06-17 13:41     ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).