diff options
author | ng0 <ng0@n0.is> | 2019-02-13 21:53:27 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-02-13 21:53:27 +0000 |
commit | 1104fccaef9483fb92303eb5ce854b971b1b8151 (patch) | |
tree | 497e325a0f8f8cd85319a2daf82bb94730416339 | |
parent | aaca8161989c5af3f46251cd3e8d5fb531a5cb01 (diff) | |
download | gnunet-1104fccaef9483fb92303eb5ce854b971b1b8151.tar.gz gnunet-1104fccaef9483fb92303eb5ce854b971b1b8151.zip |
attempt to fix 5560, not fixed yet. see log at https://gnunet.org/bugs/view.php?id=5560
Signed-off-by: ng0 <ng0@n0.is>
-rw-r--r-- | src/integration-tests/gnunet_testing.py.in | 101 |
1 files changed, 71 insertions, 30 deletions
diff --git a/src/integration-tests/gnunet_testing.py.in b/src/integration-tests/gnunet_testing.py.in index 0d02a792f..76ab3b0a0 100644 --- a/src/integration-tests/gnunet_testing.py.in +++ b/src/integration-tests/gnunet_testing.py.in | |||
@@ -11,13 +11,17 @@ | |||
11 | # WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | # Affero General Public License for more details. | 13 | # Affero General Public License for more details. |
14 | # | 14 | # |
15 | # You should have received a copy of the GNU Affero General Public License | 15 | # You should have received a copy of the GNU Affero General Public License |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | # | 17 | # |
18 | # SPDX-License-Identifier: AGPL3.0-or-later | 18 | # SPDX-License-Identifier: AGPL3.0-or-later |
19 | # | 19 | # |
20 | # Functions for integration testing | 20 | # Functions for integration testing |
21 | from __future__ import unicode_literals | ||
22 | from __future__ import print_function | ||
23 | from builtins import object | ||
24 | from builtins import str | ||
21 | import os | 25 | import os |
22 | import subprocess | 26 | import subprocess |
23 | import sys | 27 | import sys |
@@ -26,7 +30,7 @@ import time | |||
26 | from gnunet_pyexpect import pexpect | 30 | from gnunet_pyexpect import pexpect |
27 | 31 | ||
28 | 32 | ||
29 | class Check: | 33 | class Check(object): |
30 | def __init__(self, test): | 34 | def __init__(self, test): |
31 | self.fulfilled = False | 35 | self.fulfilled = False |
32 | self.conditions = list() | 36 | self.conditions = list() |
@@ -92,7 +96,7 @@ class Check: | |||
92 | c.fulfilled = False | 96 | c.fulfilled = False |
93 | 97 | ||
94 | 98 | ||
95 | class Condition: | 99 | class Condition(object): |
96 | def __init__(self): | 100 | def __init__(self): |
97 | self.fulfilled = False | 101 | self.fulfilled = False |
98 | self.type = 'generic' | 102 | self.type = 'generic' |
@@ -131,13 +135,21 @@ class FileExistCondition(Condition): | |||
131 | 135 | ||
132 | def evaluate(self, failed_only): | 136 | def evaluate(self, failed_only): |
133 | if ((self.fulfilled == False) and (failed_only == True)): | 137 | if ((self.fulfilled == False) and (failed_only == True)): |
134 | print(str(self.type) + 'condition for file '+self.file+' was ' + str(self.fulfilled)) | 138 | print(str(self.type) + |
139 | 'condition for file ' + | ||
140 | self.file + | ||
141 | ' was ' + | ||
142 | str(self.fulfilled)) | ||
135 | elif (failed_only == False): | 143 | elif (failed_only == False): |
136 | print(str(self.type) + 'condition for file '+self.file+' was ' + str(self.fulfilled)) | 144 | print(str(self.type) + |
145 | 'condition for file ' + | ||
146 | self.file + | ||
147 | ' was ' + | ||
148 | str(self.fulfilled)) | ||
137 | return self.fulfilled | 149 | return self.fulfilled |
138 | 150 | ||
139 | 151 | ||
140 | class StatisticsCondition (Condition): | 152 | class StatisticsCondition(Condition): |
141 | def __init__(self, peer, subsystem, name, value): | 153 | def __init__(self, peer, subsystem, name, value): |
142 | self.fulfilled = False | 154 | self.fulfilled = False |
143 | self.type = 'statistics' | 155 | self.type = 'statistics' |
@@ -160,22 +172,35 @@ class StatisticsCondition (Condition): | |||
160 | 172 | ||
161 | def evaluate(self, failed_only): | 173 | def evaluate(self, failed_only): |
162 | if (self.result == -1): | 174 | if (self.result == -1): |
163 | res = 'NaN' | 175 | res = b'NaN' |
164 | else: | 176 | else: |
165 | res = str(self.result) | 177 | res = str(self.result).encode('utf-8') |
166 | if (self.fulfilled == False): | 178 | if (self.fulfilled == False): |
167 | fail = " FAIL!" | 179 | fail = b" FAIL!" |
168 | op = " != " | 180 | op = b" != " |
169 | else: | 181 | else: |
170 | fail = "" | 182 | fail = b"" |
171 | op = " == " | 183 | op = b" == " |
172 | if (((self.fulfilled == False) and (failed_only == True)) or (failed_only == False)): | 184 | if (((self.fulfilled == False) and (failed_only == True)) or (failed_only == False)): |
173 | 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) | 185 | print(self.peer.id[:4] + |
186 | b" " + | ||
187 | self.peer.cfg.encode('utf-8') + | ||
188 | b" " + | ||
189 | str(self.type).encode('utf-8') + | ||
190 | b' condition in subsystem "' + | ||
191 | self.subsystem.encode('utf-8').ljust(12) + | ||
192 | b'" : "' + | ||
193 | self.name.encode('utf-8').ljust(30) + | ||
194 | b'" : (expected/real value) ' + | ||
195 | str(self.value).encode('utf-8') + | ||
196 | op + | ||
197 | res + | ||
198 | fail) | ||
174 | return self.fulfilled | 199 | return self.fulfilled |
175 | 200 | ||
176 | 201 | ||
177 | # Specify two statistic values and check if they are equal | 202 | # Specify two statistic values and check if they are equal |
178 | class EqualStatisticsCondition (Condition): | 203 | class EqualStatisticsCondition(Condition): |
179 | def __init__(self, peer, subsystem, name, peer2, subsystem2, name2): | 204 | def __init__(self, peer, subsystem, name, peer2, subsystem2, name2): |
180 | self.fulfilled = False | 205 | self.fulfilled = False |
181 | self.type = 'equalstatistics' | 206 | self.type = 'equalstatistics' |
@@ -202,25 +227,39 @@ class EqualStatisticsCondition (Condition): | |||
202 | 227 | ||
203 | def evaluate(self, failed_only): | 228 | def evaluate(self, failed_only): |
204 | if (self.result == -1): | 229 | if (self.result == -1): |
205 | res = 'NaN' | 230 | res = b'NaN' |
206 | else: | 231 | else: |
207 | res = str(self.result) | 232 | res = str(self.result).encode('utf-8') |
208 | if (self.result2 == -1): | 233 | if (self.result2 == -1): |
209 | res2 = 'NaN' | 234 | res2 = b'NaN' |
210 | else: | 235 | else: |
211 | res2 = str(self.result2) | 236 | res2 = str(self.result2).encode('utf-8') |
212 | if (self.fulfilled == False): | 237 | if (self.fulfilled == False): |
213 | fail = " FAIL!" | 238 | fail = b" FAIL!" |
214 | op = " != " | 239 | op = b" != " |
215 | else: | 240 | else: |
216 | fail = "" | 241 | fail = b"" |
217 | op = " == " | 242 | op = b" == " |
218 | if (((self.fulfilled == False) and (failed_only == True)) or (failed_only == False)): | 243 | if (((self.fulfilled == False) and (failed_only == True)) or (failed_only == False)): |
219 | print(self.peer.id[:4] + ' "' + self.subsystem.ljust(12) + '" "' + self.name.ljust(30) + '" == ' + str(self.result) + " " + self.peer2.id[:4] + ' "' + self.subsystem2.ljust(12) + '" ' + self.name2.ljust(30) + '" ' + str(self.result2)) | 244 | print(self.peer.id[:4] + |
245 | b' "' + | ||
246 | self.subsystem.encode('utf-8').ljust(12) + | ||
247 | b'" "' + | ||
248 | self.name.encode('utf-8').ljust(30) + | ||
249 | b'" == ' + | ||
250 | str(self.result).encode('utf-8') + | ||
251 | b" " + | ||
252 | self.peer2.id[:4] + | ||
253 | b' "' + | ||
254 | self.subsystem2.encode('utf-8').ljust(12) + | ||
255 | b'" ' + | ||
256 | self.name2.encode('utf-8').ljust(30) + | ||
257 | b'" ' + | ||
258 | str(self.result2).encode('utf-8')) | ||
220 | return self.fulfilled | 259 | return self.fulfilled |
221 | 260 | ||
222 | 261 | ||
223 | class Test: | 262 | class Test(object): |
224 | def __init__(self, testname, verbose): | 263 | def __init__(self, testname, verbose): |
225 | self.peers = list() | 264 | self.peers = list() |
226 | self.verbose = verbose | 265 | self.verbose = verbose |
@@ -252,7 +291,7 @@ class Test: | |||
252 | print(msg) | 291 | print(msg) |
253 | 292 | ||
254 | 293 | ||
255 | class Peer: | 294 | class Peer(object): |
256 | def __init__(self, test, cfg_file): | 295 | def __init__(self, test, cfg_file): |
257 | if (False == os.path.isfile(cfg_file)): | 296 | if (False == os.path.isfile(cfg_file)): |
258 | print(("Peer cfg " + cfg_file + ": FILE NOT FOUND")) | 297 | print(("Peer cfg " + cfg_file + ": FILE NOT FOUND")) |
@@ -266,7 +305,9 @@ class Peer: | |||
266 | print('ERROR! Peer using cfg ' + self.cfg + ' was not stopped') | 305 | print('ERROR! Peer using cfg ' + self.cfg + ' was not stopped') |
267 | ret = self.stop() | 306 | ret = self.stop() |
268 | if (False == ret): | 307 | if (False == ret): |
269 | print('ERROR! Peer using cfg ' + self.cfg + ' could not be stopped') | 308 | print('ERROR! Peer using cfg ' + |
309 | self.cfg + | ||
310 | ' could not be stopped') | ||
270 | self.started = False | 311 | self.started = False |
271 | return ret | 312 | return ret |
272 | else: | 313 | else: |
@@ -289,8 +330,8 @@ class Peer: | |||
289 | test = server.read("stdout", 1024) | 330 | test = server.read("stdout", 1024) |
290 | except OSError: | 331 | except OSError: |
291 | print("Can not get peer identity") | 332 | print("Can not get peer identity") |
292 | test = (test.split('`')[1]) | 333 | test = (test.split(b'`')[1]) |
293 | self.id = test.split('\'')[0] | 334 | self.id = test.split(b'\'')[0] |
294 | return True | 335 | return True |
295 | 336 | ||
296 | def stop(self): | 337 | def stop(self): |
@@ -311,9 +352,9 @@ class Peer: | |||
311 | server.spawn(None, [self.test.gnunetstatistics, '-c', self.cfg, '-q', '-n', name, '-s', subsystem], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 352 | server.spawn(None, [self.test.gnunetstatistics, '-c', self.cfg, '-q', '-n', name, '-s', subsystem], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
312 | # server.expect ("stdout", re.compile (r"")) | 353 | # server.expect ("stdout", re.compile (r"")) |
313 | test = server.read("stdout", 10240) | 354 | test = server.read("stdout", 10240) |
314 | tests = test.partition('\n') | 355 | tests = test.partition(b'\n') |
315 | # On W32 GNUnet outputs with \r\n, rather than \n | 356 | # On W32 GNUnet outputs with \r\n, rather than \n |
316 | if os.name == 'nt' and tests[1] == '\n' and tests[0][-1] == '\r': | 357 | if os.name == 'nt' and tests[1] == b'\n' and tests[0][-1] == b'\r': |
317 | tests = (tests[0][:-1], tests[1], tests[2]) | 358 | tests = (tests[0][:-1], tests[1], tests[2]) |
318 | tests = tests[0] | 359 | tests = tests[0] |
319 | if (tests.isdigit() == True): | 360 | if (tests.isdigit() == True): |