This is the mail archive of the gdb-patches@sourceware.org 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 2/3] Add testcases for display function


    add testcases to test display under different conditions
---
 gdb/testsuite/gdb.base/display.c       |  5 +++++
 gdb/testsuite/gdb.base/testdisplay.exp | 35 ++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
 create mode 100644 gdb/testsuite/gdb.base/testdisplay.exp

diff --git a/gdb/testsuite/gdb.base/display.c b/gdb/testsuite/gdb.base/display.c
index cd833e2..6db289c 100644
--- a/gdb/testsuite/gdb.base/display.c
+++ b/gdb/testsuite/gdb.base/display.c
@@ -4,6 +4,11 @@
 #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/testdisplay.exp b/gdb/testsuite/gdb.base/testdisplay.exp
new file mode 100644
index 0000000..984465e2
--- /dev/null
+++ b/gdb/testsuite/gdb.base/testdisplay.exp
@@ -0,0 +1,35 @@
+set srcfile display.c
+
+if { [prepare_for_testing testdisplay.exp "testdisplay" display.c {debug nowarnings}] } {
+	untest testdisplay.exp
+	return -1
+}
+
+set bp_location [gdb_get_line_number "set breakpoint 1 here"]
+send_gdb "break $bp_location\n"
+send_gdb "run\n"
+
+#Test disp(display)
+gdb_test "display f" "1: f = 3.1415"
+gdb_test "display/x f" "2: /x f = 0x3"
+gdb_test "display/d f" "3: /d f = 3"
+gdb_test "display/u f" "4: /u f = 3"
+gdb_test "display/o f" "5: /o f = 03"
+gdb_test "display/t f" "6: /t f = 11"
+gdb_test "display/a f" "7: /a f = 0x3"
+gdb_test "display/c f" "8: /c f = 3\ \'\\\\003\'"
+gdb_test "display/f f" "9: /f f = 3.1415"
+
+gdb_test "display int_array" \
+	"10: int_array = \\{0, 1\\}"
+gdb_test "display human" \
+	"11: human = {name = 0 '\\\\000', age = 0}"
+
+#Test disable/enable display
+gdb_test "disable display 999" \
+	"No display number 999\."
+gdb_test_no_output "disable display 9"
+gdb_test_no_output "enable display 9"
+
+gdb_exit
+return 0
-- 
1.8.3.1


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