[PATCH 3/3] Add testcases for list function

Fei Jie feij.fnst@cn.fujitsu.com
Wed Nov 4 07:10:00 GMT 2015


    add testcases to list.exp, test list under more conditions
---
 gdb/testsuite/gdb.base/list.exp | 48 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 2aea9a3..cf06cd5 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -624,4 +624,52 @@ 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)
+    }
+}
+send_gdb "set listsize 10\n"
+#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 '+' line 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.*list0\.c.*"
+
+#Test list with '-' max line number
+gdb_test "list -43" \
+    "1\\s+#include \"list0.h\".*10\\s+foo \\(x\\+\\+\\);"
+
+#Test list with starting line num and out-of-ranged ending line
+gdb_test " list 1,48" \
+    "1\\s+#include \"list0.h\".*43\\s+\\} \\/\\* last line \\*\\/"
+
+#Test list with ',' and out-of-ranged ending line
+gdb_test "list ,44" \
+    ".*43\\s+\\} \\/\\* last line \\*\\/"
+
+#Test list with ',' and out-of-ranged ending line(which is 10 more than max line number)
+gdb_test "list ,53" \
+    "Line number 44 out of range.*"
+
 remote_exec build "rm -f list0.h"
-- 
1.8.3.1



More information about the Gdb-patches mailing list