aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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 = \
24 test_integration_bootstrap_and_connect_and_disconnect_nat.py \ 24 test_integration_bootstrap_and_connect_and_disconnect_nat.py \
25 test_integration_restart.py \ 25 test_integration_restart.py \
26 test_integration_clique.py \ 26 test_integration_clique.py \
27 test_integration_clique_nat.py 27 test_integration_clique_nat.py \
28 test_integration_connection_value.py
28endif 29endif
29# test_integration_disconnect.py 30# test_integration_disconnect.py
30 31
@@ -81,6 +82,10 @@ test_integration_clique_nat.py: test_integration_clique_nat.py.in Makefile
81 $(do_subst) < $(srcdir)/test_integration_clique_nat.py.in > test_integration_clique_nat.py 82 $(do_subst) < $(srcdir)/test_integration_clique_nat.py.in > test_integration_clique_nat.py
82 chmod +x test_integration_clique_nat.py 83 chmod +x test_integration_clique_nat.py
83 84
85test_integration_connection_value.py: test_integration_connection_value.py.in Makefile
86 $(do_subst) < $(srcdir)/test_integration_connection_value.py.in > test_integration_connection_value.py
87 chmod +x test_integration_connection_value.py
88
84 89
85EXTRA_DIST = \ 90EXTRA_DIST = \
86 gnunet_testing.py.in \ 91 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 @@
1#!/usr/bin/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 Christian Grothoff (and other contributing authors)
4# 4#
@@ -55,6 +55,16 @@ class Check:
55 neg_cont (self) 55 neg_cont (self)
56 else: 56 else:
57 pos_cont (self) 57 pos_cont (self)
58 return res
59 def run_once (self, pos_cont, neg_cont):
60 execs = 0;
61 res = False
62 res = self.run()
63 if ((res == False) and (neg_cont != None)):
64 neg_cont (self)
65 if ((res == True) and (pos_cont != None)):
66 pos_cont (self)
67 return res
58 def evaluate (self, failed_only): 68 def evaluate (self, failed_only):
59 pos = 0 69 pos = 0
60 neg = 0 70 neg = 0
@@ -139,6 +149,52 @@ class StatisticsCondition (Condition):
139 elif (failed_only == False): 149 elif (failed_only == False):
140 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 150 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
141 return self.fulfilled 151 return self.fulfilled
152
153# Specify two statistic values and check if they are equal
154class EqualStatisticsCondition (Condition):
155 def __init__(self, peer, subsystem, name, peer2, subsystem2, name2):
156 self.fulfilled = False
157 self.type = 'equalstatistics'
158 self.peer = peer;
159 self.subsystem = subsystem;
160 self.name = name;
161 self.result = -1;
162 self.peer2 = peer2;
163 self.subsystem2 = subsystem2;
164 self.name2 = name2;
165 self.result2 = -1;
166 def check(self):
167 if (self.fulfilled == False):
168 self.result = self.peer.get_statistics_value (self.subsystem, self.name);
169 self.result2 = self.peer2.get_statistics_value (self.subsystem2, self.name2);
170 if (str(self.result) == str(self.result2)):
171 self.fulfilled = True
172 return True
173 else:
174 return False
175 else:
176 return True
177 def evaluate (self, failed_only):
178 if (self.result == -1):
179 res = 'NaN'
180 else:
181 res = str(self.result)
182 if (self.result2 == -1):
183 res2 = 'NaN'
184 else:
185 res2 = str(self.result2)
186 if (self.fulfilled == False):
187 fail = " FAIL!"
188 op = " != "
189 else:
190 fail = ""
191 op = " == "
192 if ((self.fulfilled == False) and (failed_only == True)):
193 print self.peer.id[:4] + " " + self.subsystem.ljust(12) + " " + self.result +" " + self.peer2.id[:4] + " " + self.subsystem2.ljust(12) + " " + self.result2
194 #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
195 elif (failed_only == False):
196 print self.peer.id[:4] + " " + self.subsystem.ljust(12) + " " + self.result +" " + self.peer2.id[:4] + " " + self.subsystem2.ljust(12) + " " + self.result2
197 return self.fulfilled
142 198
143class Test: 199class Test:
144 def __init__(self, testname, verbose): 200 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 @@
1#!/usr/bin/python
2# This file is part of GNUnet.
3# (C) 2010 Christian Grothoff (and other contributing authors)
4#
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
7# by the Free Software Foundation; either version 2, or (at your
8# option) any later version.
9#
10# GNUnet is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with GNUnet; see the file COPYING. If not, write to the
17# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18# Boston, MA 02111-1307, USA.
19#
20#
21#
22# This test starts 3 peers and expects bootstrap and a connected clique
23#
24# Conditions for successful exit:
25# Both peers have 1 connected peer in transport, core, topology, fs
26
27import sys
28import os
29import subprocess
30import re
31import shutil
32import time
33import pexpect
34from gnunet_testing import Peer
35from gnunet_testing import Test
36from gnunet_testing import Check
37from gnunet_testing import Condition
38from gnunet_testing import *
39
40
41#definitions
42
43testname = "test_integration_connection_value"
44verbose = True
45check_timeout = 30
46
47
48def cleanup ():
49 if os.name == "nt":
50 shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-ns"), True)
51 shutil.rmtree (os.path.join (os.getenv ("TEMP"), "c_no_nat_client"), True)
52 else:
53 shutil.rmtree ("/tmp/c_no_nat_client/", True)
54
55
56def success_cont (check):
57 global success
58 success = True;
59
60def fail_cont (check):
61 global success
62 success= False;
63 check.evaluate(True)
64
65
66def check_connect ():
67 check = Check (test)
68 check.add (EqualStatisticsCondition (client, 'transport', '# peers connected', client, 'core', '# neighbour entries allocated'))
69
70# while True == check.run_once (check_timeout, None, None):
71# print "Yes"
72
73 res = check.run_once (None, None)
74 print "RES " + str(res)
75
76#
77# Test execution
78#
79def run ():
80 global success
81 global test
82 global client
83
84
85 success = False
86
87 test = Test ('test_integration_connection_value', verbose)
88
89 client = Peer(test, './confs/c_no_nat_client.conf');
90 client.start();
91
92 if (client.started == True):
93 test.p ('Peers started, running check')
94 check_connect ()
95
96 client.stop ()
97
98 cleanup ()
99
100 if (success == False):
101 print ('Test failed')
102 return False
103 else:
104 return True
105
106
107try:
108 run ()
109except (KeyboardInterrupt, SystemExit):
110 print 'Test interrupted'
111 server.stop ()
112 client.stop ()
113 client2.stop ()
114 cleanup ()
115if (success == False):
116 sys.exit(1)
117else:
118 sys.exit(0)
119
120