diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-15 17:03:59 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-15 17:03:59 +0000 |
commit | ac01064f2f336b9903164e11450bb46d4c5c04ad (patch) | |
tree | 944056458bea3529042287fdec40a65f78802824 /src/integration-tests/gnunet_testing.py.in | |
parent | 9af43c04be4bb3df805b07e42e04e4a5e70453d8 (diff) | |
download | gnunet-ac01064f2f336b9903164e11450bb46d4c5c04ad.tar.gz gnunet-ac01064f2f336b9903164e11450bb46d4c5c04ad.zip |
improved tests
Diffstat (limited to 'src/integration-tests/gnunet_testing.py.in')
-rw-r--r-- | src/integration-tests/gnunet_testing.py.in | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/src/integration-tests/gnunet_testing.py.in b/src/integration-tests/gnunet_testing.py.in index be288ff44..3fb6221fd 100644 --- a/src/integration-tests/gnunet_testing.py.in +++ b/src/integration-tests/gnunet_testing.py.in | |||
@@ -27,9 +27,10 @@ import time | |||
27 | 27 | ||
28 | 28 | ||
29 | class Check: | 29 | class Check: |
30 | def __init__(self): | 30 | def __init__(self, test): |
31 | self.fulfilled = False | 31 | self.fulfilled = False |
32 | self.conditions = list() | 32 | self.conditions = list() |
33 | self.test = test | ||
33 | def add (self, condition): | 34 | def add (self, condition): |
34 | self.conditions.append(condition) | 35 | self.conditions.append(condition) |
35 | def run (self): | 36 | def run (self): |
@@ -42,7 +43,7 @@ class Check: | |||
42 | neg += 1 | 43 | neg += 1 |
43 | else: | 44 | else: |
44 | pos += 1 | 45 | pos += 1 |
45 | print (str(pos) +' out of '+ str (pos+neg) + ' conditions fulfilled') | 46 | self.test.p (str(pos) +' out of '+ str (pos+neg) + ' conditions fulfilled') |
46 | return fulfilled | 47 | return fulfilled |
47 | def run_blocking (self, timeout, pos_cont, neg_cont): | 48 | def run_blocking (self, timeout, pos_cont, neg_cont): |
48 | execs = 0; | 49 | execs = 0; |
@@ -52,17 +53,37 @@ class Check: | |||
52 | time.sleep(1) | 53 | time.sleep(1) |
53 | execs += 1 | 54 | execs += 1 |
54 | if (res == False): | 55 | if (res == False): |
55 | neg_cont () | 56 | neg_cont (self) |
56 | else: | 57 | else: |
57 | pos_cont () | 58 | pos_cont (self) |
59 | def eval(self, failed_only): | ||
60 | pos = 0 | ||
61 | neg = 0 | ||
62 | for c in self.conditions: | ||
63 | if (False == c.eval (failed_only)): | ||
64 | neg += 1 | ||
65 | else: | ||
66 | pos += 1 | ||
67 | print (str(pos) +' out of '+ str (pos+neg) + ' conditions fulfilled') | ||
68 | return self.fulfilled | ||
69 | |||
58 | 70 | ||
59 | 71 | ||
60 | class Condition: | 72 | class Condition: |
73 | def __init__(self): | ||
74 | self.fulfilled = False | ||
75 | self.type = 'generic' | ||
61 | def __init__(self, type): | 76 | def __init__(self, type): |
62 | self.fulfilled = False | 77 | self.fulfilled = False |
63 | self.type = type | 78 | self.type = type |
64 | def check(self): | 79 | def check(self): |
65 | return False; | 80 | return False; |
81 | def eval(self, failed_only): | ||
82 | if ((self.fulfilled == False) and (failed_only == True)): | ||
83 | print str(self.type) + 'condition for was ' + str(self.fulfilled) | ||
84 | elif (failed_only == False): | ||
85 | print str(self.type) + 'condition for was ' + str(self.fulfilled) | ||
86 | return self.fulfilled | ||
66 | 87 | ||
67 | class FileExistCondition (Condition): | 88 | class FileExistCondition (Condition): |
68 | def __init__(self, file): | 89 | def __init__(self, file): |
@@ -79,6 +100,12 @@ class FileExistCondition (Condition): | |||
79 | return False | 100 | return False |
80 | else: | 101 | else: |
81 | return True | 102 | return True |
103 | def eval(self, failed_only): | ||
104 | if ((self.fulfilled == False) and (failed_only == True)): | ||
105 | print str(self.type) + 'condition for file '+self.file+' was ' + str(self.fulfilled) | ||
106 | elif (failed_only == False): | ||
107 | print str(self.type) + 'condition for file '+self.file+' was ' + str(self.fulfilled) | ||
108 | return self.fulfilled | ||
82 | 109 | ||
83 | class StatisticsCondition (Condition): | 110 | class StatisticsCondition (Condition): |
84 | def __init__(self, peer, subsystem, name, value): | 111 | def __init__(self, peer, subsystem, name, value): |
@@ -98,6 +125,13 @@ class StatisticsCondition (Condition): | |||
98 | return False | 125 | return False |
99 | else: | 126 | else: |
100 | return True | 127 | return True |
128 | def eval(self, failed_only): | ||
129 | if ((self.fulfilled == False) and (failed_only == True)): | ||
130 | print str(self.type) + ' condition for value "'+str(self.value)+'" in subsystem "' + self.subsystem +'" : "' + self.name +'" was ' + str(self.fulfilled) | ||
131 | elif (failed_only == False): | ||
132 | print str(self.type) + ' condition for value "'+str(self.value)+'" in subsystem "' + self.subsystem +'" : "' + self.name +'" was ' + str(self.fulfilled) | ||
133 | return self.fulfilled | ||
134 | |||
101 | class Test: | 135 | class Test: |
102 | def __init__(self, testname, verbose): | 136 | def __init__(self, testname, verbose): |
103 | self.verbose = verbose; | 137 | self.verbose = verbose; |
@@ -120,7 +154,8 @@ class Test: | |||
120 | else: | 154 | else: |
121 | shutil.rmtree ("/tmp/" + testname, True) | 155 | shutil.rmtree ("/tmp/" + testname, True) |
122 | def p (self, msg): | 156 | def p (self, msg): |
123 | print msg | 157 | if (self.verbose == True): |
158 | print msg | ||
124 | 159 | ||
125 | class Peer: | 160 | class Peer: |
126 | def __init__(self, test, cfg_file): | 161 | def __init__(self, test, cfg_file): |
@@ -147,6 +182,8 @@ class Peer: | |||
147 | self.started = True | 182 | self.started = True |
148 | return True | 183 | return True |
149 | def stop (self): | 184 | def stop (self): |
185 | if (self.started == False): | ||
186 | return False | ||
150 | self.test.p ("Stopping peer using cfg " + self.cfg) | 187 | self.test.p ("Stopping peer using cfg " + self.cfg) |
151 | try: | 188 | try: |
152 | server = subprocess.Popen ([self.test.gnunetarm, '-eq', '-c', self.cfg]) | 189 | server = subprocess.Popen ([self.test.gnunetarm, '-eq', '-c', self.cfg]) |