public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Add some testcases
@ 2015-11-09  8:20 Fei Jie
  2015-11-09  8:20 ` [PATCH v2 2/4] Add testcases to display.exp Fei Jie
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Fei Jie @ 2015-11-09  8:20 UTC (permalink / raw)
  To: gdb-patches

I fixed my previous patches.These patches add testcases to files in gdb.base,
including default.exp, display.exp, list.exp, dfp-test.exp and break.exp so 
they can test these commands under more conditions.

Fei Jie (4):
  Add testcases to default.exp
  Add testcases to display.exp
  Add testcases to list.exp and dfp-test.exp
  Add testcases to break.exp

 gdb/testsuite/gdb.base/break.exp    |  9 +++++++
 gdb/testsuite/gdb.base/default.exp  | 10 ++++++++
 gdb/testsuite/gdb.base/dfp-test.exp |  1 +
 gdb/testsuite/gdb.base/display.c    |  6 +++++
 gdb/testsuite/gdb.base/display.exp  | 17 ++++++++++---
 gdb/testsuite/gdb.base/list.exp     | 49 +++++++++++++++++++++++++++++++++++++
 6 files changed, 89 insertions(+), 3 deletions(-)

-- 
1.8.3.1

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

* [PATCH v2 4/4] Add testcases to break.exp
  2015-11-09  8:20 [PATCH v2 0/4] Add some testcases Fei Jie
                   ` (2 preceding siblings ...)
  2015-11-09  8:20 ` [PATCH v2 1/4] Add testcases to default.exp Fei Jie
@ 2015-11-09  8:20 ` Fei Jie
  2015-11-09  9:36   ` Andrew Burgess
  3 siblings, 1 reply; 7+ messages in thread
From: Fei Jie @ 2015-11-09  8:20 UTC (permalink / raw)
  To: gdb-patches

    add testcases to break.exp as follows:
    *break with non-existed condition
    *break with out-ou-ranged address
    *break at offset -1

gdb/testsuite/ChangeLog:

    * gdb.base/break.exp: Add new testcases.
---
 gdb/testsuite/gdb.base/break.exp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index f879bc8..5178773 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -334,6 +334,11 @@ gdb_test "enable" "" ""
 gdb_test "disable 10" "No breakpoint number 10." \
     "disable non-existent breakpoint 10"
 
+gdb_test "break main if donot_exist == 0" \
+    "No symbol \"donot_exist\" in current context\\."
+gdb_test "break \*0xfffffffffffffffff" \
+    "Numeric constant too large\\."
+
 gdb_test_no_output "set \$baz = 1.234"
 gdb_test "disable \$baz" \
     "Convenience variable must have integer value.*" \
@@ -399,6 +404,10 @@ set bp_location10 [gdb_get_line_number "set breakpoint 10 here"]
 gdb_test "break +1" \
     "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \
     "breakpoint offset +1"
+# Test break at offset -1.
+gdb_test "break -1" \
+    "Note: breakpoint 6 also set at.*Breakpoint.*at.* file .*$srcfile, line.*" \
+    "breakpoint offset -1"
 
 # Check to see if breakpoint is hit when stepped onto
 
-- 
1.8.3.1

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

* [PATCH v2 2/4] Add testcases to display.exp
  2015-11-09  8:20 [PATCH v2 0/4] Add some testcases Fei Jie
@ 2015-11-09  8:20 ` Fei Jie
  2015-11-09  8:20 ` [PATCH v2 3/4] Add testcases to list.exp and dfp-test.exp Fei Jie
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Fei Jie @ 2015-11-09  8:20 UTC (permalink / raw)
  To: gdb-patches

    add testcases to display different types of data and variables
    *display/d/u/o/t/a/c
    *display array and structure

gdb/testsuite/ChangeLog:

    * gdb.base/display.c: Add variable types.
    * gdb.base/display.exp: Add testcases to test display.
---
 gdb/testsuite/gdb.base/display.c   |  6 ++++++
 gdb/testsuite/gdb.base/display.exp | 17 ++++++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.base/display.c b/gdb/testsuite/gdb.base/display.c
index cd833e2..2ade4d7 100644
--- a/gdb/testsuite/gdb.base/display.c
+++ b/gdb/testsuite/gdb.base/display.c
@@ -4,6 +4,12 @@
 #define LOOP 10
 
 int sum = 0;
+int int_array[2] = {0, 1};
+struct
+  {
+	char name;
+	int age;
+  } human;
 
 /* Call to force a variable onto the stack so we can see its address.  */
 void force_mem (int *arg) { }
diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp
index 6e21d9e..8cbf875 100644
--- a/gdb/testsuite/gdb.base/display.exp
+++ b/gdb/testsuite/gdb.base/display.exp
@@ -80,13 +80,24 @@ gdb_test "disp/x j" ".*2: /x j = 0x0.*" "display j"
 gdb_test "disp/i &k" ".*3: x/i &k(\r\n|  )   $hex:.*" "display &k"
 gdb_test "disp/f f" ".*4: /f f = 3.1415*" "display/f f"
 gdb_test "disp/s &sum" ".*5: x/s &sum  $hex.*sum.:.*" "display/s &sum"
+gdb_test "disp/d f" "6: /d f = 3" "display/d f"
+gdb_test "disp/u f" "7: /u f = 3" "display/u f"
+gdb_test "disp/o f" "8: /o f = 03" "display/o f"
+gdb_test "disp/t f" "9: /t f = 11" "display/t f"
+gdb_test "disp/a f" "10: /a f = 0x3" "display/a f"
+gdb_test "disp/c f" "11: /c f = 3\ \'\\\\003\'" "display/c f"
+
+gdb_test "disp int_array" \
+    "12: int_array = \\{0, 1\\}" "display array"
+gdb_test "disp human" \
+    "13: human = {name = 0 '\\\\000', age = 0}" "display struct"
 
 # Hit the displays
 #
-gdb_test "cont" ".*\[Ww\]atchpoint 3: sum.*\[1-9\]*: x/s &sum.*\[1-9\]*: /f f = 3.1415\r\n\[1-9\]*: x/i &k.*\r\n\[1-9\]*: /x j = 0x0\r\n\[1-9\]*: i = 0.*" "first disp"
-gdb_test "cont" ".*\[Ww\]atchpoint 3: sum.*\[1-9\]*: x/s &sum.*\[1-9\]*: /f f = 4.1415\r\n\[1-9\]*: x/i &k.*\r\n\[1-9\]*: /x j = 0x0.*\[1-9\]*: i = 0.*" "second disp"
+gdb_test "cont" ".*\[Ww\]atchpoint 3: sum.*\[1-9\]*: human.*\[1-9\]*: int_array.*\[1-9\]*: /c f = 3 \'\\\\003\'\r\n\[0-9\]*: /a f = 0x3\r\n\[1-9\]*: /t f = 11\r\n\[1-9\]*: /o f = 03\r\n\[1-9\]*: /u f = 3\r\n\[1-9\]*: /d f = 3\r\n\[1-9\]*: x/s &sum.*\[1-9\]*: /f f = 3.1415\r\n\[1-9\]*: x/i &k.*\r\n\[1-9\]*: /x j = 0x0\r\n\[1-9\]*: i = 0.*" "first disp"
+gdb_test "cont" ".*\[Ww\]atchpoint 3: sum.*\[1-9\]*: human.*\[1-9\]*: int_array.*\[1-9\]*: /c f = 4 \'\\\\004\'\r\n\[0-9\]*: /a f = 0x4\r\n\[1-9\]*: /t f = 100\r\n\[1-9\]*: /o f = 04\r\n\[1-9\]*: /u f = 4\r\n\[1-9\]*: /d f = 4\r\n\[1-9\]*: x/s &sum.*\[1-9\]*: /f f = 4.1415\r\n\[1-9\]*: x/i &k.*\r\n\[1-9\]*: /x j = 0x0\r\n\[1-9\]*: i = 0.*" "second disp"
 
-gdb_test "enab  disp 6" ".*No display number 6..*" "catch err"
+gdb_test "enab  disp 14" ".*No display number 14..*" "catch err"
 gdb_test_no_output "disab disp 1" "disab disp 1"
 gdb_test_no_output "disab disp 2" "disab disp 2"
 gdb_test_no_output "enab disp 1"  "re-enab"
-- 
1.8.3.1

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

* [PATCH v2 3/4] Add testcases to list.exp and dfp-test.exp
  2015-11-09  8:20 [PATCH v2 0/4] Add some testcases Fei Jie
  2015-11-09  8:20 ` [PATCH v2 2/4] Add testcases to display.exp Fei Jie
@ 2015-11-09  8:20 ` Fei Jie
  2015-11-09  8:20 ` [PATCH v2 1/4] Add testcases to default.exp Fei Jie
  2015-11-09  8:20 ` [PATCH v2 4/4] Add testcases to break.exp Fei Jie
  3 siblings, 0 replies; 7+ messages in thread
From: Fei Jie @ 2015-11-09  8:20 UTC (permalink / raw)
  To: gdb-patches

    add testcases which test list with more paraments to list.exp, and
    backtrace with parament '-1' to dfp-test.exp

gdb/testsuite/ChangeLog:

    *gdb.base/list.exp: Add new testcases.
    *gdb.base/dfp-test.exp: Likewise.
---
 gdb/testsuite/gdb.base/dfp-test.exp |  1 +
 gdb/testsuite/gdb.base/list.exp     | 49 +++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/gdb/testsuite/gdb.base/dfp-test.exp b/gdb/testsuite/gdb.base/dfp-test.exp
index e648a6b..4caa50e 100644
--- a/gdb/testsuite/gdb.base/dfp-test.exp
+++ b/gdb/testsuite/gdb.base/dfp-test.exp
@@ -220,6 +220,7 @@ gdb_test "backtrace" ".*arg0_64 \\(arg0=0.1, arg1=1.0, arg2=2.0, arg3=3.0, arg4=
 gdb_breakpoint arg0_128
 gdb_continue_to_breakpoint "entry to arg0_128"
 gdb_test "backtrace" ".*arg0_128 \\(arg0=0.1, arg1=1.0, arg2=2.0, arg3=3.0, arg4=4.0, arg5=5.0\\).*" "backtrace at arg0_128"
+gdb_test "backtrace -1" ".*0x\[0-9\]\{1,16\}.*at\ .*${srcfile}.*"
 
 # Test calling inferior function with DFP arguments or return value.
 
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 2aea9a3..c61f88f 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -624,4 +624,53 @@ test_list "list -" 10 2 "7-8" "5-6"
 # the current line.
 test_list "list -" 10 1 "7" "6"
 
+# Get main address.
+set main_addr ""
+gdb_test_multiple "print/x &main" "getting main's address" {
+    -re "$decimal = \($hex\)\r\n$gdb_prompt $" {
+        set main_addr $expect_out(1,string)
+    }
+}
+# Test set listsize to -1.
+set_listsize -1
+
+set_listsize 10
+# Test list with line number.
+gdb_test "list 12" \
+    "7\\s+x = 0.*16\\s+foo \\(x\\+\\+\\);"
+
+# Test list with +.
+gdb_test "list +" \
+    "17\\s+foo \\(x\\+\\+\\).*26\\s+foo \\(x\\+\\+\\);"
+
+# Test list with '+' number.
+gdb_test "list +1" \
+    "23\\s+foo \\(x\\+\\+\\).*32\\s+foo \\(x\\+\\+\\);"
+
+# Test list with starting line number and ','.
+gdb_test "list 20," \
+    "20\\s+foo \\(x\\+\\+\\).*29\\s+foo \\(x\\+\\+\\);"
+
+# Test list with ',' and ending line number.
+gdb_test "list ,25" \
+    "16\\s+foo \\(x\\+\\+\\).*25\\s+foo \\(x\\+\\+\\);"
+
+# Test list with address.
+gdb_test "list *${main_addr}" \
+    "${main_addr} is in main.*${srcfile}.*"
+
+# Test list with '-' last line number.
+gdb_test "list -${last_line}" \
+    "1\\s+#include \"list0.h\".*10\\s+foo \\(x\\+\\+\\);"
+
+# Test list with ',NUM' (NUM is out of range but NUM-listsize is not).
+set little_past_end [expr ${last_line} + 5 ]
+gdb_test "list ,${little_past_end}" \
+    ".*43\\s+\\} \\/\\* last line \\*\\/"
+
+# Test list with ',NUM' (both NUM and NUM-listsize are out of range).
+set much_past_end [expr ${last_line} + 10 ]
+gdb_test "list ,${much_past_end}" \
+    "Line number 44 out of range.*"
+
 remote_exec build "rm -f list0.h"
-- 
1.8.3.1

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

* [PATCH v2 1/4] Add testcases to default.exp
  2015-11-09  8:20 [PATCH v2 0/4] Add some testcases Fei Jie
  2015-11-09  8:20 ` [PATCH v2 2/4] Add testcases to display.exp Fei Jie
  2015-11-09  8:20 ` [PATCH v2 3/4] Add testcases to list.exp and dfp-test.exp Fei Jie
@ 2015-11-09  8:20 ` Fei Jie
  2015-11-09  8:20 ` [PATCH v2 4/4] Add testcases to break.exp Fei Jie
  3 siblings, 0 replies; 7+ messages in thread
From: Fei Jie @ 2015-11-09  8:20 UTC (permalink / raw)
  To: gdb-patches

    add testcases about info:
    *info extensions
    *info handle
    *info scope
    *info win
    add testcases about set width:
    *set width -1

gdb/testsuite/ChangeLog:

    * gdb.base/default.exp: Add new testcases.
---
 gdb/testsuite/gdb.base/default.exp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp
index 4395c98..279dbb9 100644
--- a/gdb/testsuite/gdb.base/default.exp
+++ b/gdb/testsuite/gdb.base/default.exp
@@ -280,6 +280,8 @@ gdb_test "info copying"
 #
 #test info display
 gdb_test "info display" "There are no auto-display expressions now." "info display"
+#test info extensions
+gdb_test "info extensions" "Filename extensions and the languages they represent.*" "info extensions"
 #test info frame "f" abbreviation
 gdb_test "info f" "No stack.*|No selected frame.*" "info frame \"f\" abbreviation"
 #test info frame
@@ -290,6 +292,8 @@ gdb_test_no_output "info files" "info files"
 gdb_test "info float" "The program has no registers now." "info float"
 #test info functions
 gdb_test "info functions" "All defined functions:" "info functions"
+#test info handle
+gdb_test "info handle" "Signal\\s+Stop\\s+Print\\s+Pass to program\\s+Description.*" "info handle"
 #test info locals
 gdb_test "info locals" "No frame selected." "info locals"
 #test info program
@@ -298,6 +302,8 @@ gdb_test "info program" "The program being debugged is not being run." "info pro
 gdb_test "info registers" "The program has no registers now." "info registers"
 #test info stack "s" abbreviation
 gdb_test "info s" "No stack." "info stack \"s\" abbreviation"
+#test info scope
+gdb_test "info scope" "requires an argument \\(function, line or \\*addr\\) to define a scope" "info scope"
 #test info stack
 gdb_test "info stack" "No stack." "info stack"
 #test info set
@@ -353,6 +359,8 @@ gdb_test "info vector" "The program has no registers now." "info vector"
 gdb_test "info warranty" "15. *Disclaimer of Warranty.*" "info warranty"
 #test info watchpoints
 gdb_test "info watchpoints" "No watchpoints." "info watchpoints"
+#test info win
+gdb_test_no_output "info win" "info win"
 #test inspect
 gdb_test "inspect" "The history is empty." "inspect"
 #test jump
@@ -549,6 +557,8 @@ gdb_test "set variable" "Argument required .expression to compute.*" "set variab
 gdb_test_no_output "set verbose" "set verbose"
 #test set width
 gdb_test "set width" "Argument required .integer to set it to.*" "set width"
+#test set width -1
+gdb_test "set width -1" "integer -1 out of range"
 #test set write
 # This is only supported on targets which use exec.o.
 gdb_test_no_output "set write" "set write"
-- 
1.8.3.1

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

* Re: [PATCH v2 4/4] Add testcases to break.exp
  2015-11-09  8:20 ` [PATCH v2 4/4] Add testcases to break.exp Fei Jie
@ 2015-11-09  9:36   ` Andrew Burgess
  2015-11-10  1:15     ` fj
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Burgess @ 2015-11-09  9:36 UTC (permalink / raw)
  To: Fei Jie; +Cc: gdb-patches

* Fei Jie <feij.fnst@cn.fujitsu.com> [2015-11-09 16:20:15 +0800]:

>     add testcases to break.exp as follows:
>     *break with non-existed condition
>     *break with out-ou-ranged address
>     *break at offset -1
> 
> gdb/testsuite/ChangeLog:
> 
>     * gdb.base/break.exp: Add new testcases.
> ---
>  gdb/testsuite/gdb.base/break.exp | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
> index f879bc8..5178773 100644
> --- a/gdb/testsuite/gdb.base/break.exp
> +++ b/gdb/testsuite/gdb.base/break.exp
> @@ -334,6 +334,11 @@ gdb_test "enable" "" ""
>  gdb_test "disable 10" "No breakpoint number 10." \
>      "disable non-existent breakpoint 10"
>  
> +gdb_test "break main if donot_exist == 0" \
> +    "No symbol \"donot_exist\" in current context\\."
> +gdb_test "break \*0xfffffffffffffffff" \
> +    "Numeric constant too large\\."
> +
>  gdb_test_no_output "set \$baz = 1.234"
>  gdb_test "disable \$baz" \
>      "Convenience variable must have integer value.*" \
> @@ -399,6 +404,10 @@ set bp_location10 [gdb_get_line_number "set breakpoint 10 here"]
>  gdb_test "break +1" \
>      "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \
>      "breakpoint offset +1"
> +# Test break at offset -1.
> +gdb_test "break -1" \
> +    "Note: breakpoint 6 also set at.*Breakpoint.*at.* file .*$srcfile, line.*" \
> +    "breakpoint offset -1"

You can't rely on the previous breakpoint being number 6.  Some of the
different target types place breakpoints during start up and so the
breakpoint number will be different.  This is why non of the other
tests hard code the breakpoint numbers in the expected output.

You should either just regexp out the breakpoint number, or, capture
the breakpoint number earlier and use that in the expected output,
usually just using a regexp is sufficient.

Thanks,
Andrew

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

* Re: [PATCH v2 4/4] Add testcases to break.exp
  2015-11-09  9:36   ` Andrew Burgess
@ 2015-11-10  1:15     ` fj
  0 siblings, 0 replies; 7+ messages in thread
From: fj @ 2015-11-10  1:15 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches



On 11/09/2015 05:36 PM, Andrew Burgess wrote:
> * Fei Jie <feij.fnst@cn.fujitsu.com> [2015-11-09 16:20:15 +0800]:
>
>>      add testcases to break.exp as follows:
>>      *break with non-existed condition
>>      *break with out-ou-ranged address
>>      *break at offset -1
>>
>> gdb/testsuite/ChangeLog:
>>
>>      * gdb.base/break.exp: Add new testcases.
>> ---
>>   gdb/testsuite/gdb.base/break.exp | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
>> index f879bc8..5178773 100644
>> --- a/gdb/testsuite/gdb.base/break.exp
>> +++ b/gdb/testsuite/gdb.base/break.exp
>> @@ -334,6 +334,11 @@ gdb_test "enable" "" ""
>>   gdb_test "disable 10" "No breakpoint number 10." \
>>       "disable non-existent breakpoint 10"
>>
>> +gdb_test "break main if donot_exist == 0" \
>> +    "No symbol \"donot_exist\" in current context\\."
>> +gdb_test "break \*0xfffffffffffffffff" \
>> +    "Numeric constant too large\\."
>> +
>>   gdb_test_no_output "set \$baz = 1.234"
>>   gdb_test "disable \$baz" \
>>       "Convenience variable must have integer value.*" \
>> @@ -399,6 +404,10 @@ set bp_location10 [gdb_get_line_number "set breakpoint 10 here"]
>>   gdb_test "break +1" \
>>       "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \
>>       "breakpoint offset +1"
>> +# Test break at offset -1.
>> +gdb_test "break -1" \
>> +    "Note: breakpoint 6 also set at.*Breakpoint.*at.* file .*$srcfile, line.*" \
>> +    "breakpoint offset -1"
>
> You can't rely on the previous breakpoint being number 6.  Some of the
> different target types place breakpoints during start up and so the
> breakpoint number will be different.  This is why non of the other
> tests hard code the breakpoint numbers in the expected output.
>

Thanks for pointing out that. I didn't notice that situation. I'll 
regexp out the breakpoint number and continue to modify my patches.

> You should either just regexp out the breakpoint number, or, capture
> the breakpoint number earlier and use that in the expected output,
> usually just using a regexp is sufficient.
>
> Thanks,
> Andrew
>

-- 
Thanks
Fei Jie

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

end of thread, other threads:[~2015-11-10  1:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-09  8:20 [PATCH v2 0/4] Add some testcases Fei Jie
2015-11-09  8:20 ` [PATCH v2 2/4] Add testcases to display.exp Fei Jie
2015-11-09  8:20 ` [PATCH v2 3/4] Add testcases to list.exp and dfp-test.exp Fei Jie
2015-11-09  8:20 ` [PATCH v2 1/4] Add testcases to default.exp Fei Jie
2015-11-09  8:20 ` [PATCH v2 4/4] Add testcases to break.exp Fei Jie
2015-11-09  9:36   ` Andrew Burgess
2015-11-10  1:15     ` fj

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).