This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] gdb.base/list.exp: fix unmatching pass/fail


This patch fixes PR gdb/37:

  http://sources.redhat.com/cgi-bin/gnatsweb.pl?database=gdb&cmd=view&pr=37
  testsuite/gdb.base/list.exp has unmatching PASS/FAIL

gdb.base/list.exp has a lot of code like this:

    set testcnt 0

    send_gdb "list list0.c:1\n"
    gdb_expect {
	-re "1\[ \t\]+#include \"list0.h\".*10\[ \t]+x = 0;\r\n$gdb_prompt $" {
	    incr testcnt 
	}
	-re ".*$gdb_prompt $" { fail "list list0.c:1" ; gdb_suppress_tests }
	timeout { fail "list list0.c:1 (timeout)" ; gdb_suppress_tests }
    }

At the end of the test procedure, there is a single line:

    pass "list filename:number ($testcnt tests)"

I think this is more correct and more simple:

    gdb_test "list list0.c:1"  \
      "1\[ \t\]+#include \"list0.h\".*10\[ \t]+x = 0;" \
      "list filename:number list0.c:1"

Testing: I tested this on native i686-pc-linux-gnulibc2.2 with
five versions of gcc and both -gdwarf-2 and -gstabs+.

Okay to apply?

Michael C

===

2002-02-19  Michael Chastain  <mec@shout.net>

	* gdb.base/list.exp (test_list_filename_and_number): Kill testcnt.
	Simply report PASS for each test that passes.
	(test_list_forward): Likewise.
	(test_repeat_list_command): Likewise.
	(test_list_backwards): Likewise.
	(test_list_filename_and_function) Likewise.

Index: gdb/testsuite/gdb.base/list.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/list.exp,v
retrieving revision 1.4
diff -c -3 -p -r1.4 list.exp
*** list.exp	2002/02/14 06:25:18	1.4
--- list.exp	2002/02/19 00:24:54
***************
*** 1,4 ****
! # Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999
  # Free Software Foundation, Inc.
  
  # This program is free software; you can redistribute it and/or modify
--- 1,4 ----
! # Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2002
  # Free Software Foundation, Inc.
  
  # This program is free software; you can redistribute it and/or modify
*************** proc test_list_include_file {} {
*** 178,221 ****
  #
  
  proc test_list_filename_and_number {} {
!     global gdb_prompt
! 
!     set testcnt 0
! 
!     send_gdb "list list0.c:1\n"
!     gdb_expect {
! 	-re "1\[ \t\]+#include \"list0.h\".*10\[ \t]+x = 0;\r\n$gdb_prompt $" {
! 	    incr testcnt 
! 	}
! 	-re ".*$gdb_prompt $" { fail "list list0.c:1" ; gdb_suppress_tests }
! 	timeout { fail "list list0.c:1 (timeout)" ; gdb_suppress_tests }
!     }
!     send_gdb "list list0.c:10\n"
!     gdb_expect {
! 	-re "5\[ \t\]+int x;.*14\[ \t\]+foo .x\[+)\]+;\r\n$gdb_prompt $" {
! 	    incr testcnt 
! 	}
! 	-re ".*$gdb_prompt $" { fail "list list.c:10" ; gdb_suppress_tests }
! 	timeout { fail "list list.c:10 (timeout)" ; gdb_suppress_tests }
!     }
!     send_gdb "list list1.c:1\n"
!     gdb_expect {
! 	-re "1\[ \t\]+\#include.*4\[ \t\]+.*int oof\[ \t\]*\(.*\);\r\n.*$gdb_prompt $" {
! 	    incr testcnt 
! 	}
! 	-re ".*$gdb_prompt $" { fail "list list1.c:1" ; gdb_suppress_tests }
! 	timeout { fail "list list1.c:1 (timeout)" ; gdb_suppress_tests }
!     }
!     send_gdb "list list1.c:12\n"
!     gdb_expect {
! 	-re "12\[ \t\]+long_line \[(\]+.*\[)\]+;.*13\[ \t\]+\}\r\n.*$gdb_prompt $" {
! 	    incr testcnt 
! 	}
! 	-re ".*$gdb_prompt $" { fail "list list1.c:12" ; gdb_suppress_tests }
! 	timeout { fail "list list1.c:12 (timeout)" ; gdb_suppress_tests }
!     }
!     pass "list filename:number ($testcnt tests)"
!     gdb_stop_suppressing_tests;
  }
  
  #
--- 178,195 ----
  #
  
  proc test_list_filename_and_number {} {
!     gdb_test "list list0.c:1"  \
!       "1\[ \t\]+#include \"list0.h\".*10\[ \t]+x = 0;" \
!       "list filename:number list0.c:1"
!     gdb_test "list list0.c:10" \
!       "5\[ \t\]+int x;.*14\[ \t\]+foo .x\[+)\]+;" \
!       "list filename:number list0.c:10"
!     gdb_test "list list1.c:1"  \
!       "1\[ \t\]+\#include.*4\[ \t\]+.*int oof\[ \t\]*\(.*\);" \
!       "list filename:number list1.c:1"
!     gdb_test "list list1.c:12" \
!       "7\[ \t\]+void bar.*16\[ \t\]+unused \[(\]\[)\]" \
!       "list filename:number list1.c:12"
  }
  
  #
*************** proc test_list_function {} {
*** 245,284 ****
  }
  
  proc test_list_forward {} {
!     global gdb_prompt
! 
!     set testcnt 0
! 
!     send_gdb "list list0.c:10\n"
!     gdb_expect {
! 	-re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
! 	-re ".*$gdb_prompt $" { fail "list list0.c:10" ; gdb_suppress_tests }
! 	timeout { fail "list list0.c:10 (timeout)" ; gdb_suppress_tests }
!     }
! 
!     send_gdb "list\n"
!     gdb_expect {
! 	-re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
! 	-re ".*$gdb_prompt $" { fail "list 15-24" ; gdb_suppress_tests }
! 	timeout { fail "list 15-24 (timeout)" ; gdb_suppress_tests }
!     }
! 
!     send_gdb "list\n"
!     gdb_expect {
! 	-re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
! 	-re ".*$gdb_prompt $" { fail "list 25-34" ; gdb_suppress_tests }
! 	timeout { fail "list 25-34 (timeout)" ; gdb_suppress_tests }
!     }
! 
!     send_gdb "list\n"
!     gdb_expect {
! 	-re "35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}\r\n$gdb_prompt $" { incr testcnt }
! 	-re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests }
! 	timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests }
!     }
! 
!     pass "successive list commands to page forward ($testcnt tests)"
!     gdb_stop_suppressing_tests;
  }
  
  # Test that repeating the list linenum command doesn't print the same
--- 219,236 ----
  }
  
  proc test_list_forward {} {
!     gdb_test "list list0.c:10" \
!       "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;" \
!       "list forward list0.c:10"
!     gdb_test "list" \
!       "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;" \
!       "list forward 15-24"
!     gdb_test "list" \
!       "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;" \
!       "list forward 25-34"
!     gdb_test "list" \
!       "35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}" \
!       "list forward 35-42"
  }
  
  # Test that repeating the list linenum command doesn't print the same
*************** proc test_list_forward {} {
*** 288,363 ****
  
  proc test_repeat_list_command {} {
      global gdb_prompt
- 
-     set testcnt 0
  
!     send_gdb "list list0.c:10\n"
!     gdb_expect {
! 	-re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
! 	-re ".*$gdb_prompt $" { fail "list list0.c:10" ; gdb_suppress_tests }
! 	timeout { fail "list list0.c:10 (timeout)" ; gdb_suppress_tests }
!     }
  
      send_gdb "\n"
!     gdb_expect {
! 	-re "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
! 	-re ".*$gdb_prompt $" { fail "list 15-24" ; gdb_suppress_tests }
! 	timeout { fail "list 15-24 (timeout)" ; gdb_suppress_tests }
!     }
  
      send_gdb "\n"
!     gdb_expect {
! 	-re "25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
! 	-re ".*$gdb_prompt $" { fail "list 25-34" ; gdb_suppress_tests }
! 	timeout { fail "list 25-34 (timeout)" ; gdb_suppress_tests }
!     }
  
      send_gdb "\n"
!     gdb_expect {
! 	-re "35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}\r\n$gdb_prompt $" { incr testcnt }
! 	-re ".*$gdb_prompt $" { fail "list 35-42" ; gdb_suppress_tests }
! 	timeout { fail "list 35-42 (timeout)" ; gdb_suppress_tests }
!     }
! 
!     pass "repeat list commands to page forward using 'return' ($testcnt tests)"
!     gdb_stop_suppressing_tests;
  }
  
  proc test_list_backwards {} {
!     global gdb_prompt
! 
!     set testcnt 0
! 
!     send_gdb "list list0.c:33\n"
!     gdb_expect {
! 	-re "28\[ \t\]+foo \\(.*\\);.*37\[ \t\]+\}\r\n$gdb_prompt $" { incr testcnt }
! 	-re ".*$gdb_prompt $" { fail "list list0.c:33" ; gdb_suppress_tests }
! 	timeout { fail "list list0.c:33 (timeout)" ; gdb_suppress_tests }
!     }
! 
!     send_gdb "list -\n"
!     gdb_expect {
! 	-re "18\[ \t\]+foo \[(\]+.*\[)\]+;.*27\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
! 	-re ".*$gdb_prompt $" { fail "list 18-27" ; gdb_suppress_tests }
! 	timeout { fail "list 18-27 (timeout)" ; gdb_suppress_tests }
!     }
! 
!     send_gdb "list -\n"
!     gdb_expect {
! 	-re "8\[ \t\]+breakpoint\[(\]\[)\];.*17\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
! 	-re ".*$gdb_prompt $" { fail "list 8-17" ; gdb_suppress_tests }
! 	timeout { fail "list 8-17 (timeout)" ; gdb_suppress_tests }
!     }
! 
!     send_gdb "list -\n"
!     gdb_expect {
! 	-re "1\[ \t\]+#include .*7\[ \t\]+set_debug_traps\[(\]\[)\]+;\r\n$gdb_prompt $" { incr testcnt }
! 	-re ".*$gdb_prompt $" { fail "list 1-7" ; gdb_suppress_tests }
! 	timeout { fail "list 1-7 (timeout)" ; gdb_suppress_tests }
!     }
! 
!     pass "$testcnt successive \"list -\" commands to page backwards"
!     gdb_stop_suppressing_tests;
  }
  
  #
--- 240,284 ----
  
  proc test_repeat_list_command {} {
      global gdb_prompt
  
!     gdb_test "list \
!       list0.c:10" "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;" \
!       "list repeat list0.c:10"
! 
!     # I need to send an empty command, but gdb_test cannot do that.
!     # send_gdb "\n" sends an empty command line,
!     # and gdb_test "" sends nothing and then processes the output.
!     # -- chastain 2002-02-18
  
      send_gdb "\n"
!     gdb_test "" \
!       "15\[ \t\]+foo \[(\]+.*\[)\]+;.*24\[ \t\]+foo \[(\]+.*\[)\]+;" \
!       "list repeat 15-24"
  
      send_gdb "\n"
!     gdb_test "" \
! 	"25\[ \t\]+foo \[(\]+.*\[)\]+;.*34\[ \t\]+foo \[(\]+.*\[)\]+;" \
! 	"list repeat 25-34"
  
      send_gdb "\n"
!     gdb_test "" \
! 	"35\[ \t\]+foo \\(.*\\);.*42\[ \t\]+.*\}" \
! 	"list repeat 35-42"
  }
  
  proc test_list_backwards {} {
!     gdb_test "list list0.c:33" \
!       "28\[ \t\]+foo \\(.*\\);.*37\[ \t\]+\}" \
!       "list backwards list0.c:33"
!     gdb_test "list -" \
!       "18\[ \t\]+foo \[(\]+.*\[)\]+;.*27\[ \t\]+foo \[(\]+.*\[)\]+;" \
!       "list backwards 18-27"
!     gdb_test "list -"  \
!       "8\[ \t\]+breakpoint\[(\]\[)\];.*17\[ \t\]+foo \[(\]+.*\[)\]+;" \
!       "list backwards 8-17"
!     gdb_test "list -"  \
!       "1\[ \t\]+#include .*7\[ \t\]+set_debug_traps\[(\]\[)\]+;" \
!       "list backwards 1-7"
  }
  
  #
*************** proc test_list_range {} {
*** 389,396 ****
  proc test_list_filename_and_function {} {
      global gdb_prompt
  
-     set testcnt 0
- 
      # gcc appears to generate incorrect debugging information for code
      # in include files, which breaks this test.
      # SunPRO cc is the second case below, it's also correct.
--- 310,315 ----
*************** proc test_list_filename_and_function {} 
*** 398,407 ****
      send_gdb "list list0.c:main\n"
      gdb_expect {
  	-re "1\[ \t\]+#include .*10\[ \t\]+x = 0;\r\n$gdb_prompt $" {
! 	    incr testcnt
  	}
  	-re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
! 	    pass "list function in source file 1"
  	}
  	-re ".*$gdb_prompt $" { fail "list list0.c:main" }
  	timeout { fail "list list0.c:main (timeout)" }
--- 317,326 ----
      send_gdb "list list0.c:main\n"
      gdb_expect {
  	-re "1\[ \t\]+#include .*10\[ \t\]+x = 0;\r\n$gdb_prompt $" {
! 	    pass "list list0.c:main"
  	}
  	-re "5\[ \t\]+int x;.*14\[ \t\]+foo \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
! 	    pass "list list0.c:main (SunPRO cc)"
  	}
  	-re ".*$gdb_prompt $" { fail "list list0.c:main" }
  	timeout { fail "list list0.c:main (timeout)" }
*************** proc test_list_filename_and_function {} 
*** 416,425 ****
      send_gdb "list list0.c:unused\n"
      gdb_expect {
  	-re "40\[ \t\]+unused.*43\[ \t\]+\}\r\n$gdb_prompt $" {
! 	    incr testcnt
  	}
  	-re "37.*42\[ \t\]+\}\r\n$gdb_prompt $" {
! 	    incr testcnt
  	}
  	-re ".*$gdb_prompt $" { fail "list list0.c:unused" }
  	timeout { fail "list list0.c:unused (timeout)" }
--- 335,344 ----
      send_gdb "list list0.c:unused\n"
      gdb_expect {
  	-re "40\[ \t\]+unused.*43\[ \t\]+\}\r\n$gdb_prompt $" {
! 	    pass "list list0.c:unused"
  	}
  	-re "37.*42\[ \t\]+\}\r\n$gdb_prompt $" {
! 	    pass "list list0.c:unused"
  	}
  	-re ".*$gdb_prompt $" { fail "list list0.c:unused" }
  	timeout { fail "list list0.c:unused (timeout)" }
*************** proc test_list_filename_and_function {} 
*** 438,450 ****
      send_gdb "list list0.h:foo\n"
      gdb_expect {
  	-re "2\[ \t\]+including file.  This.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
! 	    incr testcnt
  	}
  	-re "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
! 	    incr testcnt
  	}
  	-re "3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
! 	    incr testcnt
  	}
  	-re "No source file named list0.h.\r\n$gdb_prompt $" {
  	    fail "list list0.h:foo"
--- 357,369 ----
      send_gdb "list list0.h:foo\n"
      gdb_expect {
  	-re "2\[ \t\]+including file.  This.*11\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
! 	    pass "list list0.h:foo"
  	}
  	-re "1\[ \t\]+/. An include file.*10\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
! 	    pass "list list0.h:foo"
  	}
  	-re "3\[ \t\]+.*12\[ \t\]+bar \[(\]+.*\[)\]+;\r\n$gdb_prompt $" {
! 	    pass "list list0.h:foo"
  	}
  	-re "No source file named list0.h.\r\n$gdb_prompt $" {
  	    fail "list list0.h:foo"
*************** proc test_list_filename_and_function {} 
*** 458,470 ****
      send_gdb "list list1.c:bar\n"
      gdb_expect {
  	-re "4\[ \t\]+void.*13\[ \t\]+\}\r\n$gdb_prompt $" {
! 	    incr testcnt
  	}
  	-re "4\[ \t\]+void.*12\[ \t\]*long_line ..;\r\n$gdb_prompt $" {
! 	    incr testcnt
  	}
  	-re "4\[ \t\]+void.*11\[ \t\]*\r\n$gdb_prompt $" {
! 	    incr testcnt
  	}
  	-re ".*$gdb_prompt $" { fail "list list1.c:bar" }
  	timeout { fail "list list1.c:bar (timeout)" }
--- 377,389 ----
      send_gdb "list list1.c:bar\n"
      gdb_expect {
  	-re "4\[ \t\]+void.*13\[ \t\]+\}\r\n$gdb_prompt $" {
! 	    pass "list list1.c:bar"
  	}
  	-re "4\[ \t\]+void.*12\[ \t\]*long_line ..;\r\n$gdb_prompt $" {
! 	    pass "list list1.c:bar"
  	}
  	-re "4\[ \t\]+void.*11\[ \t\]*\r\n$gdb_prompt $" {
! 	    pass "list list1.c:bar"
  	}
  	-re ".*$gdb_prompt $" { fail "list list1.c:bar" }
  	timeout { fail "list list1.c:bar (timeout)" }
*************** proc test_list_filename_and_function {} 
*** 479,495 ****
      send_gdb "list list1.c:unused\n"
      gdb_expect {
  	-re "12\[ \t\]+long_line \[(\]\[)\];.*13\[ \t\]+\}\r\n.*$gdb_prompt $" {
! 	    incr testcnt
  	}
  	-re "14.*19\[ \t\]+\}\r\n.*$gdb_prompt $" {
! 	    incr testcnt
  	}
  	-re ".*$gdb_prompt $" { fail "list list1.c:unused" }
  	timeout { fail "list list1.c:unused (timeout)" }
      }
      clear_xfail "rs6000-*-aix*"
- 
-     pass "list filename:function ($testcnt tests)"
  
      # Test some invalid specs
      # The following test takes the FIXME result on most systems using
--- 398,412 ----
      send_gdb "list list1.c:unused\n"
      gdb_expect {
  	-re "12\[ \t\]+long_line \[(\]\[)\];.*13\[ \t\]+\}\r\n.*$gdb_prompt $" {
! 	    pass "list1.c:unused"
  	}
  	-re "14.*19\[ \t\]+\}\r\n.*$gdb_prompt $" {
! 	    pass "list1.c:unused"
  	}
  	-re ".*$gdb_prompt $" { fail "list list1.c:unused" }
  	timeout { fail "list list1.c:unused (timeout)" }
      }
      clear_xfail "rs6000-*-aix*"
  
      # Test some invalid specs
      # The following test takes the FIXME result on most systems using


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]