test_integration_bootstrap_and_connect_and_disconnect_nat.py \
test_integration_restart.py \
test_integration_clique.py \
- test_integration_clique_nat.py
+ test_integration_clique_nat.py \
+ test_integration_connection_value.py
endif
# test_integration_disconnect.py
$(do_subst) < $(srcdir)/test_integration_clique_nat.py.in > test_integration_clique_nat.py
chmod +x test_integration_clique_nat.py
+test_integration_connection_value.py: test_integration_connection_value.py.in Makefile
+ $(do_subst) < $(srcdir)/test_integration_connection_value.py.in > test_integration_connection_value.py
+ chmod +x test_integration_connection_value.py
+
EXTRA_DIST = \
gnunet_testing.py.in \
-#!/usr/bin/python
+#!@PYTHON@
# This file is part of GNUnet.
# (C) 2010 Christian Grothoff (and other contributing authors)
#
neg_cont (self)
else:
pos_cont (self)
+ return res
+ def run_once (self, pos_cont, neg_cont):
+ execs = 0;
+ res = False
+ res = self.run()
+ if ((res == False) and (neg_cont != None)):
+ neg_cont (self)
+ if ((res == True) and (pos_cont != None)):
+ pos_cont (self)
+ return res
def evaluate (self, failed_only):
pos = 0
neg = 0
elif (failed_only == False):
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
return self.fulfilled
+
+# Specify two statistic values and check if they are equal
+class EqualStatisticsCondition (Condition):
+ def __init__(self, peer, subsystem, name, peer2, subsystem2, name2):
+ self.fulfilled = False
+ self.type = 'equalstatistics'
+ self.peer = peer;
+ self.subsystem = subsystem;
+ self.name = name;
+ self.result = -1;
+ self.peer2 = peer2;
+ self.subsystem2 = subsystem2;
+ self.name2 = name2;
+ self.result2 = -1;
+ def check(self):
+ if (self.fulfilled == False):
+ self.result = self.peer.get_statistics_value (self.subsystem, self.name);
+ self.result2 = self.peer2.get_statistics_value (self.subsystem2, self.name2);
+ if (str(self.result) == str(self.result2)):
+ self.fulfilled = True
+ return True
+ else:
+ return False
+ else:
+ return True
+ def evaluate (self, failed_only):
+ if (self.result == -1):
+ res = 'NaN'
+ else:
+ res = str(self.result)
+ if (self.result2 == -1):
+ res2 = 'NaN'
+ else:
+ res2 = str(self.result2)
+ if (self.fulfilled == False):
+ fail = " FAIL!"
+ op = " != "
+ else:
+ fail = ""
+ op = " == "
+ if ((self.fulfilled == False) and (failed_only == True)):
+ print self.peer.id[:4] + " " + self.subsystem.ljust(12) + " " + self.result +" " + self.peer2.id[:4] + " " + self.subsystem2.ljust(12) + " " + self.result2
+ #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
+ elif (failed_only == False):
+ print self.peer.id[:4] + " " + self.subsystem.ljust(12) + " " + self.result +" " + self.peer2.id[:4] + " " + self.subsystem2.ljust(12) + " " + self.result2
+ return self.fulfilled
class Test:
def __init__(self, testname, verbose):
--- /dev/null
+#!/usr/bin/python
+# This file is part of GNUnet.
+# (C) 2010 Christian Grothoff (and other contributing authors)
+#
+# GNUnet is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published
+# by the Free Software Foundation; either version 2, or (at your
+# option) any later version.
+#
+# GNUnet is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNUnet; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+#
+#
+# This test starts 3 peers and expects bootstrap and a connected clique
+#
+# Conditions for successful exit:
+# Both peers have 1 connected peer in transport, core, topology, fs
+
+import sys
+import os
+import subprocess
+import re
+import shutil
+import time
+import pexpect
+from gnunet_testing import Peer
+from gnunet_testing import Test
+from gnunet_testing import Check
+from gnunet_testing import Condition
+from gnunet_testing import *
+
+
+#definitions
+
+testname = "test_integration_connection_value"
+verbose = True
+check_timeout = 30
+
+
+def cleanup ():
+ if os.name == "nt":
+ shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-ns"), True)
+ shutil.rmtree (os.path.join (os.getenv ("TEMP"), "c_no_nat_client"), True)
+ else:
+ shutil.rmtree ("/tmp/c_no_nat_client/", True)
+
+
+def success_cont (check):
+ global success
+ success = True;
+
+def fail_cont (check):
+ global success
+ success= False;
+ check.evaluate(True)
+
+
+def check_connect ():
+ check = Check (test)
+ check.add (EqualStatisticsCondition (client, 'transport', '# peers connected', client, 'core', '# neighbour entries allocated'))
+
+# while True == check.run_once (check_timeout, None, None):
+# print "Yes"
+
+ res = check.run_once (None, None)
+ print "RES " + str(res)
+
+#
+# Test execution
+#
+def run ():
+ global success
+ global test
+ global client
+
+
+ success = False
+
+ test = Test ('test_integration_connection_value', verbose)
+
+ client = Peer(test, './confs/c_no_nat_client.conf');
+ client.start();
+
+ if (client.started == True):
+ test.p ('Peers started, running check')
+ check_connect ()
+
+ client.stop ()
+
+ cleanup ()
+
+ if (success == False):
+ print ('Test failed')
+ return False
+ else:
+ return True
+
+
+try:
+ run ()
+except (KeyboardInterrupt, SystemExit):
+ print 'Test interrupted'
+ server.stop ()
+ client.stop ()
+ client2.stop ()
+ cleanup ()
+if (success == False):
+ sys.exit(1)
+else:
+ sys.exit(0)
+
+