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] Test case for dump/restore of large array


This adds a test case to dump.exp that dumps and restores a large array.
In particular it verifies that the dump and restore operations are
completed in reasonable time.

gdb/testsuite/ChangeLog:

	PR gdb/21220
	* gdb.base/dump.c (bigarray): New variable.
	(zero_all): Clear bigarray as well.
	(func, fill_bigarray, cmp_bigarray): New functions.
	(main): Call fill_bigarray.
	* gdb.base/dump.exp: Add test for dump/restore of a large array.
---
 gdb/testsuite/gdb.base/dump.c   | 37 +++++++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/dump.exp |  8 ++++++++
 2 files changed, 45 insertions(+)

diff --git a/gdb/testsuite/gdb.base/dump.c b/gdb/testsuite/gdb.base/dump.c
index bdcafbf..fdeefa8 100644
--- a/gdb/testsuite/gdb.base/dump.c
+++ b/gdb/testsuite/gdb.base/dump.c
@@ -3,6 +3,9 @@
 #define ARRSIZE 32
 int intarray[ARRSIZE], intarray2[ARRSIZE];
 
+#define BIGSIZE 16777216
+unsigned char bigarray[BIGSIZE];
+
 struct teststruct {
   int a;
   int b;
@@ -25,6 +28,38 @@ zero_all ()
   memset ((char *) &intarray2,  0, sizeof (intarray2));
   memset ((char *) &intstruct,  0, sizeof (intstruct));
   memset ((char *) &intstruct2, 0, sizeof (intstruct2));
+  memset ((char *) &bigarray,	0, sizeof (bigarray));
+}
+
+static unsigned char
+func (unsigned u)
+{
+  unsigned char a = u;
+  unsigned char b = (u >> 8);
+  unsigned char c = (u >> 16);
+  unsigned char d = (u >> 24);
+
+  return (a ^ b ^ c ^ d);
+}
+
+int
+fill_bigarray ()
+{
+  unsigned i;
+
+  for (i = 0; i < sizeof (bigarray); i++)
+    bigarray[i] = func (i);
+}
+
+int
+cmp_bigarray ()
+{
+  unsigned i;
+
+  for (i = 0; i < sizeof (bigarray); i++)
+    if (bigarray[i] != func (i))
+      return 0;
+  return 1;
 }
 
 int
@@ -43,6 +78,8 @@ main()
   intstruct.f = 12 * 6;
   intstruct.g = 12 * 7;
 
+  fill_bigarray ();
+
   checkpoint1 ();
   return 0;
 }
diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
index e67e1aa..170a09f 100644
--- a/gdb/testsuite/gdb.base/dump.exp
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -74,6 +74,7 @@ set all_files {
     intstr2.bin intstr2b.bin intstr2.ihex
     intstr2.srec intstr2.tekhex intstr2.verilog
     intarr3.srec
+    bigarr1.bin
 }
 
 # This loop sets variables dynamically -- each name listed in
@@ -263,6 +264,9 @@ make_dump_file \
     "dump srec mem [set intarr3.srec] &intarray \(char *\) &intarray + sizeof intarray" \
 	"dump array as mem, srec, expressions"
 
+make_dump_file "dump bin mem [set bigarr1.bin] &bigarray &bigarray\[sizeof bigarray\]" \
+	"dump big array as memory, default"
+
 proc test_restore_saved_value { restore_args msg oldval newval } {
     global gdb_prompt
     
@@ -348,6 +352,10 @@ test_restore_saved_value "[set intstr2.bin] binary $struct_start" \
 	"struct as memory, binary" \
 	$struct_val "intstruct"
 
+test_restore_saved_value "[set bigarr1.bin] binary &bigarray" \
+        "reload big array as memory, binary" \
+	1 "cmp_bigarray ()"
+
 # test restore with offset.
 
 set array2_start   [capture_value "/x &intarray2\[0\]"]
-- 
2.3.0


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