aboutsummaryrefslogtreecommitdiff
path: root/src/integration-tests/gnunet_testing.py.in
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-12-15 15:20:50 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-12-15 15:20:50 +0000
commitecc60a21d15be5359d05e5c113183e981d1e1715 (patch)
tree4c897b5bd8d720a14c981bed36b37b4729e483f1 /src/integration-tests/gnunet_testing.py.in
parent4e7a56b5f9e1600979cf3f3ce12f90240704ce59 (diff)
downloadgnunet-ecc60a21d15be5359d05e5c113183e981d1e1715.tar.gz
gnunet-ecc60a21d15be5359d05e5c113183e981d1e1715.zip
added improved check management
Diffstat (limited to 'src/integration-tests/gnunet_testing.py.in')
-rw-r--r--src/integration-tests/gnunet_testing.py.in72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/integration-tests/gnunet_testing.py.in b/src/integration-tests/gnunet_testing.py.in
index 404d5db4e..dccaf43eb 100644
--- a/src/integration-tests/gnunet_testing.py.in
+++ b/src/integration-tests/gnunet_testing.py.in
@@ -25,6 +25,78 @@ import sys
25import shutil 25import shutil
26import time 26import time
27 27
28
29class Check:
30 def __init__(self):
31 self.fulfilled = False
32 self.conditions = list()
33 def add (self, condition):
34 self.conditions.append(condition)
35 def run (self):
36 fulfilled = True
37 pos = 0
38 neg = 0
39 for c in self.conditions:
40 if (False == c.check ()):
41 fulfilled = False
42 neg += 1
43 else:
44 pos += 1
45 print (str(pos) +' out of '+ str (pos+neg) + ' conditions fulfilled')
46 return fulfilled
47 def run_blocking (self, timeout, pos_cont, neg_cont):
48 execs = 0;
49 res = False
50 while ((False == res) and (execs < timeout)):
51 res = self.run()
52 time.sleep(1)
53 execs += 1
54 if (res == False):
55 neg_cont ()
56 else:
57 pos_cont ()
58
59
60class Condition:
61 def __init__(self, type):
62 self.fulfilled = False
63 self.type = type
64 def check(self):
65 return False;
66
67class FileExistCondition (Condition):
68 def __init__(self, file):
69 self.fulfilled = False
70 self.type = 'file'
71 self.file = file
72 def check(self):
73 if (self.fulfilled == False):
74 res = os.path.isfile(self.file)
75 if (res == True):
76 self.fulfilled = True
77 return True
78 else:
79 return False
80 else:
81 return True
82
83class StatisticsCondition (Condition):
84 def __init__(self, peer, subsystem, name, value):
85 self.fulfilled = False
86 self.type = 'statistics'
87 self.peer = peer;
88 self.subsystem = subsystem;
89 self.name = value;
90 def check(self):
91 if (self.fulfilled == False):
92 res = self.peer.check (subsystem, name, value);
93 if (res == True):
94 self.fulfilled = True
95 return True
96 else:
97 return False
98 else:
99 return True
28class Test: 100class Test:
29 def __init__(self, testname, verbose): 101 def __init__(self, testname, verbose):
30 self.verbose = verbose; 102 self.verbose = verbose;