tests/qtest/npcm7xx_rng-test: count runs properly
authorHavard Skinnemoen <hskinnemoen@google.com>
Tue, 3 Nov 2020 01:14:55 +0000 (17:14 -0800)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 10 Nov 2020 11:03:48 +0000 (11:03 +0000)
The number of runs is equal to the number of 0-1 and 1-0 transitions,
plus one. Currently, it's counting the number of times these transitions
do _not_ happen, plus one.

Source:
https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-22r1a.pdf
section 2.3.4 point (3).

Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com>
Message-id: 20201103011457.2959989-2-hskinnemoen@google.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
tests/qtest/npcm7xx_rng-test.c

index e7cde85fbbcbc3d4abd8bf77e9639d3f12f5fbbe..c614968ffcda81152fa348d505174dd9fd881f30 100644 (file)
@@ -126,7 +126,7 @@ static double calc_runs_p(const unsigned long *buf, unsigned int nr_bits)
     pi = (double)nr_ones / nr_bits;
 
     for (k = 0; k < nr_bits - 1; k++) {
-        vn_obs += !(test_bit(k, buf) ^ test_bit(k + 1, buf));
+        vn_obs += (test_bit(k, buf) ^ test_bit(k + 1, buf));
     }
     vn_obs += 1;