From 366140a6d53155134020a4b128c73df1d4752f2a Mon Sep 17 00:00:00 2001
From: Alberto Bertogli <albertito@blitiri.com.ar>
Date: Mon, 13 Jul 2009 14:23:51 -0300
Subject: [PATCH 33/74] tests/stress: Make the failure probabilities a bit random

This change makes the probabilities of the points of failure random within
a range, so the result combination of failures in a long run will vary
more, increasing code coverage.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
---
 tests/stress/jiostress |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/tests/stress/jiostress b/tests/stress/jiostress
index e492670..a6f816b 100755
--- a/tests/stress/jiostress
+++ b/tests/stress/jiostress
@@ -37,6 +37,9 @@ def randfrange(maxend, maxsize):
 	size = random.randint(0, (maxend - 1) - start) % maxsize
 	return start, start + size
 
+def randfloat(min, max):
+	return min + random.random() % (max - min)
+
 class ConsistencyError (Exception):
 	pass
 
@@ -162,11 +165,19 @@ class Stresser:
 		return r
 
 	def fiu_enable(self):
-		if self.use_fi:
-			fiu.enable_random('jio/*', probability = 0.001)
-			fiu.enable_random('linux/*', probability = 0.01)
-			fiu.enable_random('posix/*', probability = 0.01)
-			fiu.enable_random('libc/mm/*', probability = 0.003)
+		if not self.use_fi:
+			return
+
+		# To improve code coverage, we randomize the probability each
+		# time we enable failure points
+		fiu.enable_random('jio/*',
+				probability = randfloat(0.0005, 0.005))
+		fiu.enable_random('linux/*',
+				probability = randfloat(0.005, 0.03))
+		fiu.enable_random('posix/*',
+			probability = randfloat(0.005, 0.03))
+		fiu.enable_random('libc/mm/*',
+			probability = randfloat(0.003, 0.007))
 
 	def fiu_disable(self):
 		if self.use_fi:
-- 
1.6.2.2.646.gb214


