]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Suppressed most output while the regression test is run.
authorBart Van Assche <bvanassche@acm.org>
Sun, 4 May 2008 07:47:21 +0000 (07:47 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sun, 4 May 2008 07:47:21 +0000 (07:47 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8002

exp-drd/tests/drd_bitmap_test.c
exp-drd/tests/drd_bitmap_test.stdout.exp
exp-drd/tests/drd_bitmap_test.vgtest

index 4cda0ab0492d84b77c0480d456799eacd3b84254..57fc2cd14128ebaac2e5f32b56045f144e588e86 100644 (file)
@@ -2,6 +2,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #include "coregrind/m_oset.c"
 #include "exp-drd/drd_bitmap.c"
 #include "exp-drd/pub_drd_bitmap.h"
@@ -24,69 +25,130 @@ Int VG_(memcmp)(const void* s1, const void* s2, SizeT n)
 { return memcmp(s1, s2, n); }
 UInt VG_(printf)(const HChar *format, ...)
 { UInt ret; va_list vargs; va_start(vargs, format); ret = vprintf(format, vargs); va_end(vargs); return ret; }
+UInt VG_(message)(VgMsgKind kind, const HChar* format, ...)
+{ UInt ret; va_list vargs; va_start(vargs, format); ret = vprintf(format, vargs); va_end(vargs); printf("\n"); return ret; }
 Bool drd_is_suppressed(const Addr a1, const Addr a2)
 { assert(0); }
 
 
-/* Unit test */
+/* Actual unit test */
+
+static int s_verbose = 1;
+
 static
 struct { Addr address; SizeT size; BmAccessTypeT access_type; }
-  s_args[] = {
-    {            0, 1, eLoad  },
-    {          666, 4, eLoad  },
-    {          667, 2, eStore },
-    {         1024, 1, eStore },
-    {     0xffffUL, 1, eStore },
-    { 0x0001ffffUL, 1, eLoad  },
-    { 0x00ffffffUL, 1, eLoad  },
-    { 0xffffffffUL, 1, eStore },
+  s_test1_args[] = {
+    {                           0, 1, eLoad  },
+    {                         666, 4, eLoad  },
+    {                         667, 2, eStore },
+    {                        1024, 1, eStore },
+    {                   0xffffULL, 1, eStore },
+    {               0x0001ffffULL, 1, eLoad  },
+    {               0x00ffffffULL, 1, eLoad  },
+    { 0xfffffffeULL - ADDR0_COUNT, 1, eStore },
+#if defined(VGP_amd64_linux) || defined(VGP_ppc64_linux)
+    { 0xffffffffULL - ADDR0_COUNT, 1, eStore },
+    {               0xffffffffULL, 1, eStore },
+    {              0x100000000ULL, 1, eStore },
+    {         -2ULL - ADDR0_COUNT, 1, eStore },
+#endif
   };
 
-void bm_test(void)
+void bm_test1(void)
 {
   struct bitmap* bm;
   struct bitmap* bm2;
   unsigned i, j;
 
-  VG_(printf)("Start of DRD BM unit test.\n");
-
   bm = bm_new();
 
-  for (i = 0; i < sizeof(s_args)/sizeof(s_args[0]); i++)
+  for (i = 0; i < sizeof(s_test1_args)/sizeof(s_test1_args[0]); i++)
   {
     bm_access_range(bm,
-                    s_args[i].address,
-                    s_args[i].address + s_args[i].size,
-                    s_args[i].access_type);
+                    s_test1_args[i].address,
+                    s_test1_args[i].address + s_test1_args[i].size,
+                    s_test1_args[i].access_type);
   }
 
-  VG_(printf)("Map contents -- should contain 10 addresses:\n");
-  bm_print(bm);
+  if (s_verbose)
+  {
+    VG_(printf)("Bitmap contents:\n");
+    bm_print(bm);
+  }
 
-  for (i = 0; i < sizeof(s_args)/sizeof(s_args[0]); i++)
+  for (i = 0; i < sizeof(s_test1_args)/sizeof(s_test1_args[0]); i++)
   {
-    for (j = 0; j < s_args[i].size; j++)
+    for (j = 0; j < s_test1_args[i].size; j++)
     {
-      tl_assert(bm_has_1(bm, s_args[i].address + j, s_args[i].access_type));
+      tl_assert(bm_has_1(bm,
+                         s_test1_args[i].address + j,
+                         s_test1_args[i].access_type));
     }
   }
 
-  VG_(printf)("Merge result:\n");
+  if (s_verbose)
+    VG_(printf)("Merge result:\n");
   bm2 = bm_new();
   bm_merge2(bm2, bm);
   bm_merge2(bm2, bm);
-  bm_print(bm);
+  if (s_verbose)
+    bm_print(bm2);
+  //assert(bm_equal(bm, bm2));
+  assert(bm_equal(bm2, bm));
 
-  VG_(printf)("Deleting bitmap bm\n");
+  if (s_verbose)
+    VG_(printf)("Deleting bitmap bm\n");
   bm_delete(bm);
-  VG_(printf)("Deleting bitmap bm2\n");
+  if (s_verbose)
+    VG_(printf)("Deleting bitmap bm2\n");
   bm_delete(bm2);
+}
 
-  VG_(printf)("End of DRD BM unit test.\n");
+/* Test whether bm_equal() works correctly. */
+void bm_test2()
+{
+  struct bitmap* bm1;
+  struct bitmap* bm2;
+
+  bm1 = bm_new();
+  bm2 = bm_new();
+  bm_access_load_1(bm1, 7);
+  bm_access_load_1(bm2, ADDR0_COUNT + 7);
+  assert(! bm_equal(bm1, bm2));
+  assert(! bm_equal(bm2, bm1));
+  bm_access_load_1(bm2, 7);
+  assert(! bm_equal(bm1, bm2));
+  assert(! bm_equal(bm2, bm1));
+  bm_access_store_1(bm1, ADDR0_COUNT + 7);
+  assert(! bm_equal(bm1, bm2));
+  assert(! bm_equal(bm2, bm1));
+  bm_delete(bm1);
+  bm_delete(bm2);
 }
 
 int main(int argc, char** argv)
 {
-  bm_test();
+  int optchar;
+
+  while ((optchar = getopt(argc, argv, "q")) != EOF)
+  {
+    switch (optchar)
+    {
+    case 'q':
+      s_verbose = 0;
+      break;
+    default:
+      fprintf(stderr, "Usage: %s [-q].\n", argv[0]);
+      break;
+    }
+  }
+
+  VG_(printf)("Start of DRD BM unit test.\n");
+
+  bm_test1();
+  bm_test2();
+
+  VG_(printf)("End of DRD BM unit test.\n");
+
   return 0;
 }
index 823b0e62044cbe2788e685d92b6622f2db349c0d..2efe8bde3cd7f84cf7debc13871597b9162a2092 100644 (file)
@@ -1,26 +1,2 @@
 Start of DRD BM unit test.
-Map contents -- should contain 10 addresses:
-0x00000000   R
-0x0000029a   R
-0x0000029b W R
-0x0000029c W R
-0x0000029d   R
-0x00000400 W  
-0x0000ffff W  
-0x0001ffff   R
-0x00ffffff   R
-0xffffffff W  
-Merge result:
-0x00000000   R
-0x0000029a   R
-0x0000029b W R
-0x0000029c W R
-0x0000029d   R
-0x00000400 W  
-0x0000ffff W  
-0x0001ffff   R
-0x00ffffff   R
-0xffffffff W  
-Deleting bitmap bm
-Deleting bitmap bm2
 End of DRD BM unit test.
index 9df029cd5caaa039fd2fb13d892fe15eae45d038..f4ccdf0203b2b1a13f858081260f124deaca50be 100644 (file)
@@ -1,2 +1,3 @@
 prereq: ./supported_libpthread
 prog: drd_bitmap_test
+args: -q