diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-08 17:22:03 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-08 17:22:03 +0000 |
commit | 1ff3fa2d954f9d1e74585ee6652339bb8a1aff4a (patch) | |
tree | 0fd31d1fac430449574a201cb48e7b6814607ac8 /src/integration-tests/test_integration_bootstrap_and_connect.py.in | |
parent | 3ec5e14c7071bfb39ad7af8f98365d6e81cbe026 (diff) | |
download | gnunet-1ff3fa2d954f9d1e74585ee6652339bb8a1aff4a.tar.gz gnunet-1ff3fa2d954f9d1e74585ee6652339bb8a1aff4a.zip |
-more
Diffstat (limited to 'src/integration-tests/test_integration_bootstrap_and_connect.py.in')
-rwxr-xr-x | src/integration-tests/test_integration_bootstrap_and_connect.py.in | 153 |
1 files changed, 88 insertions, 65 deletions
diff --git a/src/integration-tests/test_integration_bootstrap_and_connect.py.in b/src/integration-tests/test_integration_bootstrap_and_connect.py.in index 44e8df3df..e88c2988a 100755 --- a/src/integration-tests/test_integration_bootstrap_and_connect.py.in +++ b/src/integration-tests/test_integration_bootstrap_and_connect.py.in | |||
@@ -23,6 +23,7 @@ import os | |||
23 | import subprocess | 23 | import subprocess |
24 | import re | 24 | import re |
25 | import shutil | 25 | import shutil |
26 | import time | ||
26 | 27 | ||
27 | # | 28 | # |
28 | # This test tests if a fresh peer bootstraps from a hostlist server and then | 29 | # This test tests if a fresh peer bootstraps from a hostlist server and then |
@@ -31,80 +32,102 @@ import shutil | |||
31 | 32 | ||
32 | #definitions | 33 | #definitions |
33 | 34 | ||
34 | def vpfrint (msg): | ||
35 | if verbose == True: | ||
36 | print msg | ||
37 | |||
38 | |||
39 | testname = "test_integration_bootstrap_and_connect" | 35 | testname = "test_integration_bootstrap_and_connect" |
40 | verbose = True | 36 | verbose = True |
37 | gnunetarm = "" | ||
38 | #fix this! | ||
39 | success = True | ||
40 | timeout = 2 | ||
41 | 41 | ||
42 | # setup | 42 | def vprintf (msg): |
43 | 43 | if verbose == True: | |
44 | srcdir = "../.." | 44 | print msg |
45 | gnunet_pyexpect_dir = os.path.join (srcdir, "contrib") | ||
46 | if gnunet_pyexpect_dir not in sys.path: | ||
47 | sys.path.append (gnunet_pyexpect_dir) | ||
48 | |||
49 | from gnunet_pyexpect import pexpect | ||
50 | |||
51 | if os.name == 'posix': | ||
52 | gnunetarm = 'gnunet-arm' | ||
53 | elif os.name == 'nt': | ||
54 | gnunetarm = 'gnunet-arm.exe' | ||
55 | |||
56 | if os.name == "nt": | ||
57 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), testname), True) | ||
58 | else: | ||
59 | shutil.rmtree ("/tmp/" + testname, True) | ||
60 | |||
61 | vpfrint ("Running " + testname) | ||
62 | 45 | ||
46 | def setup (): | ||
47 | srcdir = "../.." | ||
48 | gnunet_pyexpect_dir = os.path.join (srcdir, "contrib") | ||
49 | if gnunet_pyexpect_dir not in sys.path: | ||
50 | sys.path.append (gnunet_pyexpect_dir) | ||
51 | |||
52 | from gnunet_pyexpect import pexpect | ||
53 | |||
54 | global gnunetarm | ||
55 | if os.name == 'posix': | ||
56 | gnunetarm = 'gnunet-arm' | ||
57 | elif os.name == 'nt': | ||
58 | gnunetarm = 'gnunet-arm.exe' | ||
59 | |||
60 | if os.name == "nt": | ||
61 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), testname), True) | ||
62 | else: | ||
63 | shutil.rmtree ("/tmp/" + testname, True) | ||
64 | |||
65 | def start (): | ||
66 | vprintf ("Starting bootstrap server & client") | ||
67 | try: | ||
68 | server = subprocess.Popen ([gnunetarm, '-sq', '-c', './confs/c_bootstrap_server.conf']) | ||
69 | server.communicate () | ||
70 | except OSError: | ||
71 | print "Can not start bootstrap server, exiting..." | ||
72 | exit (1) | ||
73 | try: | ||
74 | client = subprocess.Popen ([gnunetarm, '-sq', '-c', 'confs/c_no_nat_client.conf']) | ||
75 | client.communicate () | ||
76 | except OSError: | ||
77 | print "Can not start bootstrap client, exiting..." | ||
78 | exit (1) | ||
79 | vprintf ("Bootstrap server & client started") | ||
80 | |||
81 | def stop (): | ||
82 | vprintf ("Shutting down bootstrap server") | ||
83 | try: | ||
84 | server = subprocess.Popen ([gnunetarm, '-eq', '-c', './confs/c_bootstrap_server.conf']) | ||
85 | server.communicate () | ||
86 | except OSError: | ||
87 | print "Can not stop bootstrap server, exiting..." | ||
88 | exit (1) | ||
89 | try: | ||
90 | client = subprocess.Popen ([gnunetarm, '-eq', '-c', 'confs/c_no_nat_client.conf']) | ||
91 | client.communicate () | ||
92 | except OSError: | ||
93 | print "Can not stop bootstrap client, exiting..." | ||
94 | exit (1) | ||
95 | vprintf ("Bootstrap server & client stopped") | ||
96 | |||
97 | |||
98 | def cleanup (): | ||
99 | if os.name == "nt": | ||
100 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-ns"), True) | ||
101 | else: | ||
102 | shutil.rmtree ("/tmp/gnunet-test-fs-py-ns", True) | ||
103 | |||
104 | def check (): | ||
105 | global success | ||
106 | global timeout | ||
107 | count = 1 | ||
108 | |||
109 | while ((success == False) and (count < timeout)): | ||
110 | time.sleep(1) | ||
111 | count += 1 | ||
63 | 112 | ||
113 | # | ||
114 | # Test execution | ||
115 | # | ||
64 | 116 | ||
65 | # start nodes | 117 | vprintf ("Running " + testname) |
118 | setup () | ||
119 | start () | ||
66 | 120 | ||
67 | vpfrint ("Starting bootstrap server & client") | 121 | check () |
68 | try: | ||
69 | server = subprocess.Popen ([gnunetarm, '-sq', '-c', './confs/c_bootstrap_server.conf']) | ||
70 | server.communicate () | ||
71 | except OSError: | ||
72 | print "Can not start bootstrap server, exiting..." | ||
73 | exit (1) | ||
74 | try: | ||
75 | client = subprocess.Popen ([gnunetarm, '-sq', '-c', 'confs/c_no_nat_client.conf']) | ||
76 | client.communicate () | ||
77 | except OSError: | ||
78 | print "Can not start bootstrap client, exiting..." | ||
79 | exit (1) | ||
80 | vpfrint ("Bootstrap server & client started") | ||
81 | 122 | ||
123 | stop () | ||
124 | cleanup () | ||
82 | 125 | ||
83 | import time | 126 | if (success == False): |
84 | time.sleep(5) | 127 | print ('Test failed') |
85 | 128 | exit (1) | |
86 | # shutdown | ||
87 | vpfrint ("Shutting down bootstrap server") | ||
88 | try: | ||
89 | server = subprocess.Popen ([gnunetarm, '-eq', '-c', './confs/c_bootstrap_server.conf']) | ||
90 | server.communicate () | ||
91 | except OSError: | ||
92 | print "Can not stop bootstrap server, exiting..." | ||
93 | exit (1) | ||
94 | try: | ||
95 | client = subprocess.Popen ([gnunetarm, '-eq', '-c', 'confs/c_no_nat_client.conf']) | ||
96 | client.communicate () | ||
97 | except OSError: | ||
98 | print "Can not stop bootstrap client, exiting..." | ||
99 | exit (1) | ||
100 | vpfrint ("Bootstrap server & client stopped") | ||
101 | |||
102 | # clean up | ||
103 | |||
104 | if os.name == "nt": | ||
105 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-ns"), True) | ||
106 | else: | 129 | else: |
107 | shutil.rmtree ("/tmp/gnunet-test-fs-py-ns", True) | 130 | print ('Test successful') |
131 | exit (0) | ||
108 | 132 | ||
109 | exit (0) | ||
110 | 133 | ||