diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-04-03 12:10:44 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-04-03 12:10:44 +0000 |
commit | bc04203f71e022e30d53a411f9c49a0a0a9890ef (patch) | |
tree | 389b4aa450c9bc23fb6ac29fb4b95dacee494a97 /src/integration-tests/gnunet_testing.py.in | |
parent | b7b7fc29f4ea1661ebdd35e7247a9e178648395d (diff) | |
download | gnunet-bc04203f71e022e30d53a411f9c49a0a0a9890ef.tar.gz gnunet-bc04203f71e022e30d53a411f9c49a0a0a9890ef.zip |
- changes to the scripts
Diffstat (limited to 'src/integration-tests/gnunet_testing.py.in')
-rw-r--r-- | src/integration-tests/gnunet_testing.py.in | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/src/integration-tests/gnunet_testing.py.in b/src/integration-tests/gnunet_testing.py.in index f8b8ff31d..4cfa051f2 100644 --- a/src/integration-tests/gnunet_testing.py.in +++ b/src/integration-tests/gnunet_testing.py.in | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/usr/bin/python | 1 | #!@PYTHON@ |
2 | # This file is part of GNUnet. | 2 | # This file is part of GNUnet. |
3 | # (C) 2010 Christian Grothoff (and other contributing authors) | 3 | # (C) 2010 Christian Grothoff (and other contributing authors) |
4 | # | 4 | # |
@@ -55,6 +55,16 @@ class Check: | |||
55 | neg_cont (self) | 55 | neg_cont (self) |
56 | else: | 56 | else: |
57 | pos_cont (self) | 57 | pos_cont (self) |
58 | return res | ||
59 | def run_once (self, pos_cont, neg_cont): | ||
60 | execs = 0; | ||
61 | res = False | ||
62 | res = self.run() | ||
63 | if ((res == False) and (neg_cont != None)): | ||
64 | neg_cont (self) | ||
65 | if ((res == True) and (pos_cont != None)): | ||
66 | pos_cont (self) | ||
67 | return res | ||
58 | def evaluate (self, failed_only): | 68 | def evaluate (self, failed_only): |
59 | pos = 0 | 69 | pos = 0 |
60 | neg = 0 | 70 | neg = 0 |
@@ -139,6 +149,52 @@ class StatisticsCondition (Condition): | |||
139 | elif (failed_only == False): | 149 | elif (failed_only == False): |
140 | print self.peer.id[:4] + " " +self.peer.cfg + " " + str(self.type) + ' condition in subsystem "' + self.subsystem.ljust(12) +'" : "' + self.name.ljust(30) +'" : (expected/real value) ' + str(self.value) + op + res + fail | 150 | print self.peer.id[:4] + " " +self.peer.cfg + " " + str(self.type) + ' condition in subsystem "' + self.subsystem.ljust(12) +'" : "' + self.name.ljust(30) +'" : (expected/real value) ' + str(self.value) + op + res + fail |
141 | return self.fulfilled | 151 | return self.fulfilled |
152 | |||
153 | # Specify two statistic values and check if they are equal | ||
154 | class EqualStatisticsCondition (Condition): | ||
155 | def __init__(self, peer, subsystem, name, peer2, subsystem2, name2): | ||
156 | self.fulfilled = False | ||
157 | self.type = 'equalstatistics' | ||
158 | self.peer = peer; | ||
159 | self.subsystem = subsystem; | ||
160 | self.name = name; | ||
161 | self.result = -1; | ||
162 | self.peer2 = peer2; | ||
163 | self.subsystem2 = subsystem2; | ||
164 | self.name2 = name2; | ||
165 | self.result2 = -1; | ||
166 | def check(self): | ||
167 | if (self.fulfilled == False): | ||
168 | self.result = self.peer.get_statistics_value (self.subsystem, self.name); | ||
169 | self.result2 = self.peer2.get_statistics_value (self.subsystem2, self.name2); | ||
170 | if (str(self.result) == str(self.result2)): | ||
171 | self.fulfilled = True | ||
172 | return True | ||
173 | else: | ||
174 | return False | ||
175 | else: | ||
176 | return True | ||
177 | def evaluate (self, failed_only): | ||
178 | if (self.result == -1): | ||
179 | res = 'NaN' | ||
180 | else: | ||
181 | res = str(self.result) | ||
182 | if (self.result2 == -1): | ||
183 | res2 = 'NaN' | ||
184 | else: | ||
185 | res2 = str(self.result2) | ||
186 | if (self.fulfilled == False): | ||
187 | fail = " FAIL!" | ||
188 | op = " != " | ||
189 | else: | ||
190 | fail = "" | ||
191 | op = " == " | ||
192 | if ((self.fulfilled == False) and (failed_only == True)): | ||
193 | print self.peer.id[:4] + " " + self.subsystem.ljust(12) + " " + self.result +" " + self.peer2.id[:4] + " " + self.subsystem2.ljust(12) + " " + self.result2 | ||
194 | #print self.peer.id[:4] + " " + str(self.type) + ' condition in subsystem "' + self.subsystem.ljust(12) +'" : "' + self.name.ljust(30) +'" : (expected/real value) ' + str(self.value) + op + res + fail | ||
195 | elif (failed_only == False): | ||
196 | print self.peer.id[:4] + " " + self.subsystem.ljust(12) + " " + self.result +" " + self.peer2.id[:4] + " " + self.subsystem2.ljust(12) + " " + self.result2 | ||
197 | return self.fulfilled | ||
142 | 198 | ||
143 | class Test: | 199 | class Test: |
144 | def __init__(self, testname, verbose): | 200 | def __init__(self, testname, verbose): |