diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-15 15:20:50 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-15 15:20:50 +0000 |
commit | ecc60a21d15be5359d05e5c113183e981d1e1715 (patch) | |
tree | 4c897b5bd8d720a14c981bed36b37b4729e483f1 /src/integration-tests/gnunet_testing.py.in | |
parent | 4e7a56b5f9e1600979cf3f3ce12f90240704ce59 (diff) |
added improved check management
Diffstat (limited to 'src/integration-tests/gnunet_testing.py.in')
-rw-r--r-- | src/integration-tests/gnunet_testing.py.in | 72 |
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 import shutil import time + +class Check: + def __init__(self): + self.fulfilled = False + self.conditions = list() + def add (self, condition): + self.conditions.append(condition) + def run (self): + fulfilled = True + pos = 0 + neg = 0 + for c in self.conditions: + if (False == c.check ()): + fulfilled = False + neg += 1 + else: + pos += 1 + print (str(pos) +' out of '+ str (pos+neg) + ' conditions fulfilled') + return fulfilled + def run_blocking (self, timeout, pos_cont, neg_cont): + execs = 0; + res = False + while ((False == res) and (execs < timeout)): + res = self.run() + time.sleep(1) + execs += 1 + if (res == False): + neg_cont () + else: + pos_cont () + + +class Condition: + def __init__(self, type): + self.fulfilled = False + self.type = type + def check(self): + return False; + +class FileExistCondition (Condition): + def __init__(self, file): + self.fulfilled = False + self.type = 'file' + self.file = file + def check(self): + if (self.fulfilled == False): + res = os.path.isfile(self.file) + if (res == True): + self.fulfilled = True + return True + else: + return False + else: + return True + +class StatisticsCondition (Condition): + def __init__(self, peer, subsystem, name, value): + self.fulfilled = False + self.type = 'statistics' + self.peer = peer; + self.subsystem = subsystem; + self.name = value; + def check(self): + if (self.fulfilled == False): + res = self.peer.check (subsystem, name, value); + if (res == True): + self.fulfilled = True + return True + else: + return False + else: + return True class Test: def __init__(self, testname, verbose): self.verbose = verbose; |