diff options
-rw-r--r-- | src/usr/diag/attn/test/attntest.C | 18 | ||||
-rw-r--r-- | src/usr/diag/attn/test/attntestmem.H | 6 | ||||
-rw-r--r-- | src/usr/diag/attn/test/attntestproc.H | 8 |
3 files changed, 20 insertions, 12 deletions
diff --git a/src/usr/diag/attn/test/attntest.C b/src/usr/diag/attn/test/attntest.C index 1be9647c6..22fc032ba 100644 --- a/src/usr/diag/attn/test/attntest.C +++ b/src/usr/diag/attn/test/attntest.C @@ -43,10 +43,12 @@ namespace ATTN uint64_t randint(uint64_t i_min, uint64_t i_max) { static bool setup = false; - static uint64_t hapSeed = generate_random(); + static uint64_t seed = 0; if(!setup) { + uint64_t hapSeed = generate_random(); + if(!hapSeed) { ATTN_DBG("falling back to timebase seed for PRNG"); @@ -56,19 +58,20 @@ uint64_t randint(uint64_t i_min, uint64_t i_max) ATTN_DBG("hapseed: %d", hapSeed); } + seed = hapSeed ? hapSeed : getTB() + 1; + setup = true; } - static uint64_t seed = hapSeed ? hapSeed : getTB() + 1; - uint64_t lo, hi; seed = seed * seed; lo = (seed & 0x0000ffffffff0000ull) >> 16; hi = (seed & 0x000000000000ffffull) << 32; hi |= (seed & 0xffff000000000000ull); - seed = lo; + seed = (lo | hi) + 2; + static const uint64_t randMax = 0xfffffffffffffffe; uint64_t min = i_min, max = i_max; if(i_min > i_max) @@ -76,7 +79,12 @@ uint64_t randint(uint64_t i_min, uint64_t i_max) swap(min, max); } - return ((lo | hi) % (i_max +1 - i_min)) + i_min; + if(max > randMax) + { + max = randMax; + } + + return ((lo | hi) % (max +1 - min)) + min; } ATTENTION_VALUE_TYPE getRandomAttentionType() diff --git a/src/usr/diag/attn/test/attntestmem.H b/src/usr/diag/attn/test/attntestmem.H index 38046df89..9b472761b 100644 --- a/src/usr/diag/attn/test/attntestmem.H +++ b/src/usr/diag/attn/test/attntestmem.H @@ -91,7 +91,7 @@ class AttnMemTest: public CxxTest::TestSuite // put some random data in the mask register - uint64_t randomData = randint(0, 0xffffffff); + uint64_t randomData = randint(0, 0xffffffffffffffffull); uint64_t maskbits = 0; if(!IPOLL::getCheckbits(HOST, maskbits)) @@ -202,7 +202,7 @@ class AttnMemTest: public CxxTest::TestSuite // put some random data in the mask register - uint64_t randomData = randint(0, 0xffffffff); + uint64_t randomData = randint(0, 0xffffffffffffffffull); uint64_t maskbits = 0; if(!IPOLL::getCheckbits(HOST, maskbits)) @@ -239,7 +239,7 @@ class AttnMemTest: public CxxTest::TestSuite // verify that the attn was masked, and that // other bits weren't touched - if(!(data & ~maskbits)) + if(!(~data & maskbits)) { TS_FAIL("attention not unmasked"); break; diff --git a/src/usr/diag/attn/test/attntestproc.H b/src/usr/diag/attn/test/attntestproc.H index cb62fc0f9..a9f8001a1 100644 --- a/src/usr/diag/attn/test/attntestproc.H +++ b/src/usr/diag/attn/test/attntestproc.H @@ -87,7 +87,7 @@ class AttnProcTest: public CxxTest::TestSuite // put some random data in the mask register - uint64_t randomData = randint(0, 0xffffffff); + uint64_t randomData = randint(0, 0xffffffffffffffffull); uint64_t maskbits = 0; if(!IPOLL::getCheckbits(d.attnType, maskbits)) @@ -195,7 +195,7 @@ class AttnProcTest: public CxxTest::TestSuite // put some random data in the mask register - uint64_t randomData = randint(0, 0xffffffff); + uint64_t randomData = randint(0, 0xffffffffffffffffull); uint64_t maskbits = 0; if(!IPOLL::getCheckbits(d.attnType, maskbits)) @@ -229,10 +229,10 @@ class AttnProcTest: public CxxTest::TestSuite break; } - // verify that the attn was masked, and that + // verify that the attn was unmasked, and that // other bits weren't touched - if(!(data & ~maskbits)) + if(!(~data & maskbits)) { TS_FAIL("attention not unmasked"); break; |