aboutsummaryrefslogtreecommitdiff
path: root/src/integration-tests
diff options
context:
space:
mode:
authorng0 <ng0@infotropique.org>2017-11-20 10:56:45 +0000
committerng0 <ng0@n0.is>2018-03-03 16:46:09 +0000
commit4d8e3210dbedf2a17ccb239610010a2f297079e6 (patch)
tree754fe53a1240c94cfff86266bddce8b1769fbbc4 /src/integration-tests
parent3883a7f609b1107fc679b94b425781abc9eb1931 (diff)
downloadgnunet-4d8e3210dbedf2a17ccb239610010a2f297079e6.tar.gz
gnunet-4d8e3210dbedf2a17ccb239610010a2f297079e6.zip
2to3 ./src/integration-tests/gnunet_testing.py.in
Diffstat (limited to 'src/integration-tests')
-rw-r--r--src/integration-tests/gnunet_testing.py.in34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/integration-tests/gnunet_testing.py.in b/src/integration-tests/gnunet_testing.py.in
index 7cead069b..cc3e18b06 100644
--- a/src/integration-tests/gnunet_testing.py.in
+++ b/src/integration-tests/gnunet_testing.py.in
@@ -1,6 +1,6 @@
1#!@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, 2017 Christian Grothoff (and other contributing authors)
4# 4#
5# GNUnet is free software; you can redistribute it and/or modify 5# GNUnet is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published 6# it under the terms of the GNU General Public License as published
@@ -51,7 +51,7 @@ class Check:
51 time.sleep(1) 51 time.sleep(1)
52 execs += 1 52 execs += 1
53 if ((False == res) and (execs >= timeout)): 53 if ((False == res) and (execs >= timeout)):
54 print ('Check had timeout after ' +str(timeout)+ ' seconds') 54 print(('Check had timeout after ' +str(timeout)+ ' seconds'))
55 neg_cont (self) 55 neg_cont (self)
56 elif ((False == res) and (execs < timeout)): 56 elif ((False == res) and (execs < timeout)):
57 if (None != neg_cont): 57 if (None != neg_cont):
@@ -77,7 +77,7 @@ class Check:
77 neg += 1 77 neg += 1
78 else: 78 else:
79 pos += 1 79 pos += 1
80 print (str(pos) +' out of '+ str (pos+neg) + ' conditions fulfilled') 80 print((str(pos) +' out of '+ str (pos+neg) + ' conditions fulfilled'))
81 return self.fulfilled 81 return self.fulfilled
82 def reset (self): 82 def reset (self):
83 self.fulfilled = False 83 self.fulfilled = False
@@ -95,9 +95,9 @@ class Condition:
95 return False; 95 return False;
96 def evaluate (self, failed_only): 96 def evaluate (self, failed_only):
97 if ((self.fulfilled == False) and (failed_only == True)): 97 if ((self.fulfilled == False) and (failed_only == True)):
98 print str(self.type) + 'condition for was ' + str(self.fulfilled) 98 print(str(self.type) + 'condition for was ' + str(self.fulfilled))
99 elif (failed_only == False): 99 elif (failed_only == False):
100 print str(self.type) + 'condition for was ' + str(self.fulfilled) 100 print(str(self.type) + 'condition for was ' + str(self.fulfilled))
101 return self.fulfilled 101 return self.fulfilled
102 102
103class FileExistCondition (Condition): 103class FileExistCondition (Condition):
@@ -117,9 +117,9 @@ class FileExistCondition (Condition):
117 return True 117 return True
118 def evaluate (self, failed_only): 118 def evaluate (self, failed_only):
119 if ((self.fulfilled == False) and (failed_only == True)): 119 if ((self.fulfilled == False) and (failed_only == True)):
120 print str(self.type) + 'condition for file '+self.file+' was ' + str(self.fulfilled) 120 print(str(self.type) + 'condition for file '+self.file+' was ' + str(self.fulfilled))
121 elif (failed_only == False): 121 elif (failed_only == False):
122 print str(self.type) + 'condition for file '+self.file+' was ' + str(self.fulfilled) 122 print(str(self.type) + 'condition for file '+self.file+' was ' + str(self.fulfilled))
123 return self.fulfilled 123 return self.fulfilled
124 124
125class StatisticsCondition (Condition): 125class StatisticsCondition (Condition):
@@ -153,7 +153,7 @@ class StatisticsCondition (Condition):
153 fail = "" 153 fail = ""
154 op = " == " 154 op = " == "
155 if (((self.fulfilled == False) and (failed_only == True)) or (failed_only == False)): 155 if (((self.fulfilled == False) and (failed_only == True)) or (failed_only == False)):
156 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 156 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)
157 return self.fulfilled 157 return self.fulfilled
158 158
159# Specify two statistic values and check if they are equal 159# Specify two statistic values and check if they are equal
@@ -196,7 +196,7 @@ class EqualStatisticsCondition (Condition):
196 fail = "" 196 fail = ""
197 op = " == " 197 op = " == "
198 if (((self.fulfilled == False) and (failed_only == True)) or (failed_only == False)): 198 if (((self.fulfilled == False) and (failed_only == True)) or (failed_only == False)):
199 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) 199 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))
200 return self.fulfilled 200 return self.fulfilled
201 201
202class Test: 202class Test:
@@ -226,22 +226,22 @@ class Test:
226 self.peers.append(peer) 226 self.peers.append(peer)
227 def p (self, msg): 227 def p (self, msg):
228 if (self.verbose == True): 228 if (self.verbose == True):
229 print msg 229 print(msg)
230 230
231class Peer: 231class Peer:
232 def __init__(self, test, cfg_file): 232 def __init__(self, test, cfg_file):
233 if (False == os.path.isfile(cfg_file)): 233 if (False == os.path.isfile(cfg_file)):
234 print ("Peer cfg " + cfg_file + ": FILE NOT FOUND") 234 print(("Peer cfg " + cfg_file + ": FILE NOT FOUND"))
235 self.id = "<NaN>" 235 self.id = "<NaN>"
236 self.test = test 236 self.test = test
237 self.started = False 237 self.started = False
238 self.cfg = cfg_file 238 self.cfg = cfg_file
239 def __del__(self): 239 def __del__(self):
240 if (self.started == True): 240 if (self.started == True):
241 print 'ERROR! Peer using cfg ' + self.cfg + ' was not stopped' 241 print('ERROR! Peer using cfg ' + self.cfg + ' was not stopped')
242 ret = self.stop () 242 ret = self.stop ()
243 if (False == ret): 243 if (False == ret):
244 print 'ERROR! Peer using cfg ' + self.cfg + ' could not be stopped' 244 print('ERROR! Peer using cfg ' + self.cfg + ' could not be stopped')
245 self.started = False 245 self.started = False
246 return ret 246 return ret
247 else: 247 else:
@@ -252,7 +252,7 @@ class Peer:
252 server = subprocess.Popen ([self.test.gnunetarm, '-sq', '-c', self.cfg]) 252 server = subprocess.Popen ([self.test.gnunetarm, '-sq', '-c', self.cfg])
253 server.communicate () 253 server.communicate ()
254 except OSError: 254 except OSError:
255 print "Can not start peer" 255 print("Can not start peer")
256 self.started = False 256 self.started = False
257 return False 257 return False
258 self.started = True; 258 self.started = True;
@@ -262,7 +262,7 @@ class Peer:
262 server.spawn (None, [self.test.gnunetpeerinfo, '-c', self.cfg ,'-s'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 262 server.spawn (None, [self.test.gnunetpeerinfo, '-c', self.cfg ,'-s'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
263 test = server.read("stdout", 1024) 263 test = server.read("stdout", 1024)
264 except OSError: 264 except OSError:
265 print "Can not get peer identity" 265 print("Can not get peer identity")
266 test = (test.split('`')[1]) 266 test = (test.split('`')[1])
267 self.id = test.split('\'')[0] 267 self.id = test.split('\'')[0]
268 return True 268 return True
@@ -274,7 +274,7 @@ class Peer:
274 server = subprocess.Popen ([self.test.gnunetarm, '-eq', '-c', self.cfg]) 274 server = subprocess.Popen ([self.test.gnunetarm, '-eq', '-c', self.cfg])
275 server.communicate () 275 server.communicate ()
276 except OSError: 276 except OSError:
277 print "Can not stop peer" 277 print("Can not stop peer")
278 return False 278 return False
279 self.started = False 279 self.started = False
280 return True; 280 return True;
@@ -292,4 +292,4 @@ class Peer:
292 return tests 292 return tests
293 else: 293 else:
294 return -1 294 return -1
295 \ No newline at end of file 295