Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfc] Cleanup restore.exp
@ 2004-07-16 19:27 Andrew Cagney
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Cagney @ 2004-07-16 19:27 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 112 bytes --]

Another one, makes the tests unique and uses gdb_test_multiple and 
simplifies some patterns.

comments?
Andrew

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 3913 bytes --]

2004-07-16  Andrew Cagney  <cagney@gnu.org>

	* gdb.base/restore.exp: Update copyright, re-indent.
	(restore_tests): Use gdb_test_multiple.  Add "calleeN calls
	callerN" prefix where needed.  Simplify patterns.

Index: gdb.base/restore.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/restore.exp,v
retrieving revision 1.6
diff -p -u -r1.6 restore.exp
--- gdb.base/restore.exp	22 Jan 2002 01:05:06 -0000	1.6
+++ gdb.base/restore.exp	16 Jul 2004 19:26:00 -0000
@@ -1,4 +1,6 @@
-# Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -14,9 +16,6 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
 
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
-
 # Test GDB's ability to restore saved registers from stack frames
 # when using the `return' command.
 #
@@ -24,7 +23,7 @@
 # fragments borrowed from return.exp.
 
 if $tracelevel then {
-	strace $tracelevel
+    strace $tracelevel
 }
 
 set prms_id 0
@@ -34,13 +33,15 @@ set testfile "restore"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
 }
 
 proc restore_tests { } {
     global gdb_prompt
 
-    if { ! [ runto driver ] } then { return 0 }
+    if { ! [ runto driver ] } {
+	return 0
+    }
 
     set limit 5
 
@@ -48,30 +49,35 @@ proc restore_tests { } {
     #   call each of the callee functions,
     #   force a return from the callee, and
     #   make sure that the local variables still have the right values.
+
     for {set c 1} {$c <= $limit} {incr c} {
 
         # Set a breakpoint at the next caller function.
-        gdb_test "tbreak caller$c" "Breakpoint.*\[0-9\]*\\." "tbreak caller$c"
+        gdb_test "tbreak caller$c" "Breakpoint.*\[0-9\]*\\." \
+	    "tbreak caller$c"
 
 	# Continue to the next caller function.
-	gdb_test "continue" ".*/\\* caller$c \\*/" "run to caller$c"
+	gdb_test "continue" " caller$c .*" "run to caller$c"
 
 	# Do each callee function.
         for {set e 1} {$e <= $limit} {incr e} {
 
             gdb_test "tbreak callee$e" "Breakpoint.*\[0-9\]*\\." \
-                    "tbreak callee$e"
+		"caller$c calls callee$e; tbreak callee"
             
-  	    gdb_test "continue" ".*/\\* callee$e \\*/" "run to callee$e"
-
+  	    gdb_test "continue" " callee$e .*/" \
+		"caller$c calls callee$e; continue to callee"
+	    
             # Do a forced return from the callee.
-	    send_gdb "return 0\n"
-	    gdb_expect {
+	    set test "caller$c calls callee$e; return callee now"
+	    gdb_test_multiple "return 0" "$test" {
 		-re "Make .* return now.*y or n. $" {
 		    send_gdb "y\n"
 		    exp_continue
 		}
-		-re "$gdb_prompt $" { }
+		-re " caller$c .*$gdb_prompt $" {
+		    pass "$test"
+		}
             }
 
             # Check that the values of the local variables are what
@@ -79,7 +85,7 @@ proc restore_tests { } {
             for {set var 1} {$var <= $c} {incr var} {
                 set expected [expr 0x7eeb + $var]
 	        gdb_test "print l$var" " = $expected" \
-                         "caller$c called callee$e; variable l$var restored to $expected"
+		    "caller$c calls callee$e; return restored l$var to $expected"
             }
         }
     }

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [rfc] Cleanup restore.exp
@ 2004-07-16 19:45 Michael Elizabeth Chastain
  2004-07-16 20:53 ` Andrew Cagney
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Elizabeth Chastain @ 2004-07-16 19:45 UTC (permalink / raw)
  To: cagney, gdb-patches

> comments?

Did you test it?

In the copyright years, this file was also edited in 2001 and 2002.

 	# Continue to the next caller function.
-	gdb_test "continue" ".*/\\* caller$c \\*/" "run to caller$c"
+	gdb_test "continue" " caller$c .*" "run to caller$c"
 
This makes the search pattern little bit less specific,
but that's okay.  There are only two " caller$c " in the test
program and it's unlikely we would get a false negative by hitting
the wrong one.

Michael C

2004-07-16  Andrew Cagney  <cagney@gnu.org>

	* gdb.base/restore.exp: Update copyright, re-indent.
	(restore_tests): Use gdb_test_multiple.  Add "calleeN calls
	callerN" prefix where needed.  Simplify patterns.


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [rfc] Cleanup restore.exp
@ 2004-07-16 21:11 Michael Elizabeth Chastain
  2004-07-16 21:33 ` Andrew Cagney
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Elizabeth Chastain @ 2004-07-16 21:11 UTC (permalink / raw)
  To: cagney, mec.gnu; +Cc: gdb-patches

ac> How about I change it to " caller$c prologue .*" with a corresponding 
ac> tweak to restore.c?  That way there's no confusion.

That would be cool, if you want to do that.

But before you touch restore.c, someone has to add a copyright notice to
it.  restore.c was written by Jim Blandy of Cygnus in 1998 so there's no
doubt that FSF owns it.  It was modified in 1998, 1999, 2001, and 2003
(plus it will be modified in 2004 by adding the notice).

For the record, I got this information from ChangeLog, the cvs
repository, and my set of historical gdb releases.

When adding a copyright notice, one has to test the change, because
some *.exp scripts depend on line numbers in their *.c files.
It appears that restore.exp does not have this problem.

It's enough work that I do "add copyright notice" as a separate patch,
especially because I like to separate legally significant changes
from technically significant changes.

Would you like to add a copyright notice to restore.c, or would you like
me to do it?

Michael C


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

end of thread, other threads:[~2004-07-16 22:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-16 19:27 [rfc] Cleanup restore.exp Andrew Cagney
2004-07-16 19:45 Michael Elizabeth Chastain
2004-07-16 20:53 ` Andrew Cagney
2004-07-16 21:11 Michael Elizabeth Chastain
2004-07-16 21:33 ` Andrew Cagney
2004-07-16 22:22   ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox