diff options
Diffstat (limited to 'src/integration-tests/test_integration_connection_value.py.in')
-rwxr-xr-x | src/integration-tests/test_integration_connection_value.py.in | 120 |
1 files changed, 120 insertions, 0 deletions
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 | |||
27 | import sys | ||
28 | import os | ||
29 | import subprocess | ||
30 | import re | ||
31 | import shutil | ||
32 | import time | ||
33 | import pexpect | ||
34 | from gnunet_testing import Peer | ||
35 | from gnunet_testing import Test | ||
36 | from gnunet_testing import Check | ||
37 | from gnunet_testing import Condition | ||
38 | from gnunet_testing import * | ||
39 | |||
40 | |||
41 | #definitions | ||
42 | |||
43 | testname = "test_integration_connection_value" | ||
44 | verbose = True | ||
45 | check_timeout = 30 | ||
46 | |||
47 | |||
48 | def 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 | |||
56 | def success_cont (check): | ||
57 | global success | ||
58 | success = True; | ||
59 | |||
60 | def fail_cont (check): | ||
61 | global success | ||
62 | success= False; | ||
63 | check.evaluate(True) | ||
64 | |||
65 | |||
66 | def 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 | # | ||
79 | def 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 | |||
107 | try: | ||
108 | run () | ||
109 | except (KeyboardInterrupt, SystemExit): | ||
110 | print 'Test interrupted' | ||
111 | server.stop () | ||
112 | client.stop () | ||
113 | client2.stop () | ||
114 | cleanup () | ||
115 | if (success == False): | ||
116 | sys.exit(1) | ||
117 | else: | ||
118 | sys.exit(0) | ||
119 | |||
120 | |||