|
From: <sv...@va...> - 2008-05-01 13:50:15
|
Author: bart
Date: 2008-05-01 14:50:20 +0100 (Thu, 01 May 2008)
New Revision: 7973
Log:
Moved bitmap test from drd_bitmap.c to tests/drd_bitmap_test.c
Added:
trunk/exp-drd/tests/drd_bitmap_test.c
trunk/exp-drd/tests/drd_bitmap_test.stderr.exp
trunk/exp-drd/tests/drd_bitmap_test.stdout.exp
Modified:
trunk/exp-drd/drd_bitmap.c
trunk/exp-drd/tests/Makefile.am
Modified: trunk/exp-drd/drd_bitmap.c
===================================================================
--- trunk/exp-drd/drd_bitmap.c 2008-05-01 13:06:04 UTC (rev 7972)
+++ trunk/exp-drd/drd_bitmap.c 2008-05-01 13:50:20 UTC (rev 7973)
@@ -1002,63 +1002,3 @@
bm2l->bm1.bm0_w[k] |= bm2r->bm1.bm0_w[k];
}
}
-
-#if 0
-
-/* Unit test */
-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 },
- };
-
-void bm_test(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++)
- {
- bm_access_range(bm,
- s_args[i].address,
- s_args[i].address + s_args[i].size,
- s_args[i].access_type);
- }
-
- VG_(printf)("Map contents -- should contain 10 addresses:\n");
- bm_print(bm);
-
- for (i = 0; i < sizeof(s_args)/sizeof(s_args[0]); i++)
- {
- for (j = 0; j < s_args[i].size; j++)
- {
- tl_assert(bm_has_1(bm, s_args[i].address + j, s_args[i].access_type));
- }
- }
-
- VG_(printf)("Merge result:\n");
- bm2 = bm_new();
- bm_merge2(bm2, bm);
- bm_merge2(bm2, bm);
- bm_print(bm);
-
- VG_(printf)("Deleting bitmap bm\n");
- bm_delete(bm);
- VG_(printf)("Deleting bitmap bm2\n");
- bm_delete(bm2);
-
- VG_(printf)("End of DRD BM unit test.\n");
-}
-#endif
Modified: trunk/exp-drd/tests/Makefile.am
===================================================================
--- trunk/exp-drd/tests/Makefile.am 2008-05-01 13:06:04 UTC (rev 7972)
+++ trunk/exp-drd/tests/Makefile.am 2008-05-01 13:50:20 UTC (rev 7973)
@@ -17,6 +17,7 @@
EXTRA_DIST = \
$(noinst_SCRIPTS) \
+ drd_bitmap_test.stderr.exp \
fp_race.stderr.exp \
fp_race.vgtest \
fp_race2.stderr.exp \
@@ -143,11 +144,13 @@
tc24_nonzero_sem.vgtest \
trylock.c trylock.stderr.exp
-AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g $(AM_FLAG_M3264_PRI)
+AM_CFLAGS = $(WERROR) -Wall -Wextra -Wshadow -Wno-unused-parameter \
+ -g $(AM_FLAG_M3264_PRI)
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_builddir)/include
AM_CXXFLAGS = $(AM_CFLAGS)
check_PROGRAMS_COMMON = \
+ drd_bitmap_test \
fp_race \
hg01_all_ok \
hg02_deadlock \
@@ -204,6 +207,12 @@
# tc14_laog_dinphils -- hangs.
+drd_bitmap_test_SOURCES = drd_bitmap_test.c
+drd_bitmap_test_CFLAGS = \
+ $(AM_FLAG_M3264_PRI) -DVGA_$(VG_ARCH)=1 -DVGO_$(VG_OS)=1 \
+ -DVGP_$(VG_ARCH)_$(VG_OS)=1
+drd_bitmap_test_LDADD =
+
fp_race_SOURCES = fp_race.c
fp_race_LDADD = -lpthread
Added: trunk/exp-drd/tests/drd_bitmap_test.c
===================================================================
--- trunk/exp-drd/tests/drd_bitmap_test.c (rev 0)
+++ trunk/exp-drd/tests/drd_bitmap_test.c 2008-05-01 13:50:20 UTC (rev 7973)
@@ -0,0 +1,91 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include "coregrind/m_oset.c"
+#include "exp-drd/drd_bitmap.c"
+#include "exp-drd/pub_drd_bitmap.h"
+
+
+/* Replacements for core functionality. */
+
+void* VG_(malloc)(SizeT nbytes)
+{ return malloc(nbytes); }
+void VG_(free)(void* p)
+{ return free(p); }
+void VG_(assert_fail)(Bool isCore, const Char* expr, const Char* file,
+ Int line, const Char* fn, const HChar* format, ...)
+{ __assert_fail(expr, file, line, fn); abort(); }
+void* VG_(memset)(void *s, Int c, SizeT sz)
+{ return memset(s, c, sz); }
+void* VG_(memcpy)(void *d, const void *s, SizeT sz)
+{ return memcpy(d, s, sz); }
+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; }
+Bool drd_is_suppressed(const Addr a1, const Addr a2)
+{ assert(0); }
+
+
+/* Unit test */
+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 },
+ };
+
+void bm_test(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++)
+ {
+ bm_access_range(bm,
+ s_args[i].address,
+ s_args[i].address + s_args[i].size,
+ s_args[i].access_type);
+ }
+
+ VG_(printf)("Map contents -- should contain 10 addresses:\n");
+ bm_print(bm);
+
+ for (i = 0; i < sizeof(s_args)/sizeof(s_args[0]); i++)
+ {
+ for (j = 0; j < s_args[i].size; j++)
+ {
+ tl_assert(bm_has_1(bm, s_args[i].address + j, s_args[i].access_type));
+ }
+ }
+
+ VG_(printf)("Merge result:\n");
+ bm2 = bm_new();
+ bm_merge2(bm2, bm);
+ bm_merge2(bm2, bm);
+ bm_print(bm);
+
+ VG_(printf)("Deleting bitmap bm\n");
+ bm_delete(bm);
+ VG_(printf)("Deleting bitmap bm2\n");
+ bm_delete(bm2);
+
+ VG_(printf)("End of DRD BM unit test.\n");
+}
+
+int main(int argc, char** argv)
+{
+ bm_test();
+ return 0;
+}
Added: trunk/exp-drd/tests/drd_bitmap_test.stderr.exp
===================================================================
--- trunk/exp-drd/tests/drd_bitmap_test.stderr.exp (rev 0)
+++ trunk/exp-drd/tests/drd_bitmap_test.stderr.exp 2008-05-01 13:50:20 UTC (rev 7973)
@@ -0,0 +1,3 @@
+
+
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Added: trunk/exp-drd/tests/drd_bitmap_test.stdout.exp
===================================================================
--- trunk/exp-drd/tests/drd_bitmap_test.stdout.exp (rev 0)
+++ trunk/exp-drd/tests/drd_bitmap_test.stdout.exp 2008-05-01 13:50:20 UTC (rev 7973)
@@ -0,0 +1,26 @@
+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.
|