From: Bart Van Assche Date: Sun, 4 May 2008 07:47:21 +0000 (+0000) Subject: Suppressed most output while the regression test is run. X-Git-Tag: svn/VALGRIND_3_4_0~635 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eeb4e09fceed9a06bda0d0d857edcdf68376581b;p=thirdparty%2Fvalgrind.git Suppressed most output while the regression test is run. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8002 --- diff --git a/exp-drd/tests/drd_bitmap_test.c b/exp-drd/tests/drd_bitmap_test.c index 4cda0ab049..57fc2cd141 100644 --- a/exp-drd/tests/drd_bitmap_test.c +++ b/exp-drd/tests/drd_bitmap_test.c @@ -2,6 +2,7 @@ #include #include #include +#include #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; } diff --git a/exp-drd/tests/drd_bitmap_test.stdout.exp b/exp-drd/tests/drd_bitmap_test.stdout.exp index 823b0e6204..2efe8bde3c 100644 --- a/exp-drd/tests/drd_bitmap_test.stdout.exp +++ b/exp-drd/tests/drd_bitmap_test.stdout.exp @@ -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. diff --git a/exp-drd/tests/drd_bitmap_test.vgtest b/exp-drd/tests/drd_bitmap_test.vgtest index 9df029cd5c..f4ccdf0203 100644 --- a/exp-drd/tests/drd_bitmap_test.vgtest +++ b/exp-drd/tests/drd_bitmap_test.vgtest @@ -1,2 +1,3 @@ prereq: ./supported_libpthread prog: drd_bitmap_test +args: -q