summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-03 12:10:44 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-03 12:10:44 +0000
commitbc04203f71e022e30d53a411f9c49a0a0a9890ef (patch)
tree389b4aa450c9bc23fb6ac29fb4b95dacee494a97 /src
parentb7b7fc29f4ea1661ebdd35e7247a9e178648395d (diff)
- changes to the scripts
Diffstat (limited to 'src')
-rw-r--r--src/integration-tests/Makefile.am7
-rw-r--r--src/integration-tests/gnunet_testing.py.in58
-rwxr-xr-xsrc/integration-tests/test_integration_connection_value.py.in120
3 files changed, 183 insertions, 2 deletions
diff --git a/src/integration-tests/Makefile.am b/src/integration-tests/Makefile.am
index d948b3d4d..5bf86efb9 100644
--- a/src/integration-tests/Makefile.am
+++ b/src/integration-tests/Makefile.am
@@ -24,7 +24,8 @@ check_SCRIPTS = \
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
@@ -81,6 +82,10 @@ test_integration_clique_nat.py: test_integration_clique_nat.py.in Makefile
$(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 \
diff --git a/src/integration-tests/gnunet_testing.py.in b/src/integration-tests/gnunet_testing.py.in
index f8b8ff31d..4cfa051f2 100644
--- a/src/integration-tests/gnunet_testing.py.in
+++ b/src/integration-tests/gnunet_testing.py.in
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!@PYTHON@
# This file is part of GNUnet.
# (C) 2010 Christian Grothoff (and other contributing authors)
#
@@ -55,6 +55,16 @@ class Check:
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
@@ -139,6 +149,52 @@ class StatisticsCondition (Condition):
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):
diff --git a/src/integration-tests/test_integration_connection_value.py.in b/src/integration-tests/test_integration_connection_value.py.in
new file mode 100755
index 000000000..47e4dee88
--- /dev/null
+++ b/src/integration-tests/test_integration_connection_value.py.in
@@ -0,0 +1,120 @@
+#!/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)
+
+