aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo-tool/test_gnunet_peerinfo.py.in
diff options
context:
space:
mode:
Diffstat (limited to 'src/peerinfo-tool/test_gnunet_peerinfo.py.in')
-rwxr-xr-xsrc/peerinfo-tool/test_gnunet_peerinfo.py.in108
1 files changed, 53 insertions, 55 deletions
diff --git a/src/peerinfo-tool/test_gnunet_peerinfo.py.in b/src/peerinfo-tool/test_gnunet_peerinfo.py.in
index 3207c2c2f..f54da3564 100755
--- a/src/peerinfo-tool/test_gnunet_peerinfo.py.in
+++ b/src/peerinfo-tool/test_gnunet_peerinfo.py.in
@@ -1,21 +1,19 @@
1#!@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, 2018 Christian Grothoff (and other contributing authors)
4# 4#
5# GNUnet is free software; you can redistribute it and/or modify 5# GNUnet is free software: you can redistribute it and/or modify it
6# it under the terms of the GNU General Public License as published 6# under the terms of the GNU Affero General Public License as published
7# by the Free Software Foundation; either version 3, or (at your 7# by the Free Software Foundation, either version 3 of the License,
8# option) any later version. 8# or (at your option) any later version.
9# 9#
10# GNUnet is distributed in the hope that it will be useful, but 10# GNUnet is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of 11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details. 13# Affero General Public License for more details.
14# 14#
15# You should have received a copy of the GNU General Public License 15# You should have received a copy of the GNU Affero General Public License
16# along with GNUnet; see the file COPYING. If not, write to the 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18# Boston, MA 02110-1301, USA.
19# 17#
20# Testcase for gnunet-peerinfo 18# Testcase for gnunet-peerinfo
21import sys 19import sys
@@ -26,70 +24,70 @@ import shutil
26import time 24import time
27 25
28srcdir = "../.." 26srcdir = "../.."
29gnunet_pyexpect_dir = os.path.join (srcdir, "contrib") 27gnunet_pyexpect_dir = os.path.join(srcdir, "contrib/scripts")
30if gnunet_pyexpect_dir not in sys.path: 28if gnunet_pyexpect_dir not in sys.path:
31 sys.path.append (gnunet_pyexpect_dir) 29 sys.path.append(gnunet_pyexpect_dir)
32 30
33from gnunet_pyexpect import pexpect 31from gnunet_pyexpect import pexpect
34 32
35if os.name == 'posix': 33if os.name == 'posix':
36 peerinfo = './gnunet-peerinfo' 34 peerinfo = './gnunet-peerinfo'
37 gnunetarm = 'gnunet-arm' 35 gnunetarm = 'gnunet-arm'
38 gnunettesting = 'gnunet-testing' 36 gnunettesting = 'gnunet-testing'
39elif os.name == 'nt': 37elif os.name == 'nt':
40 peerinfo = './gnunet-peerinfo.exe' 38 peerinfo = './gnunet-peerinfo.exe'
41 gnunetarm = 'gnunet-arm.exe' 39 gnunetarm = 'gnunet-arm.exe'
42 gnunettesting = 'gnunet-testing.exe' 40 gnunettesting = 'gnunet-testing.exe'
43 41
44pinfo = pexpect () 42pinfo = pexpect()
45 43
46 44
47if os.name == "nt": 45if os.name == "nt":
48 shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-peerinfo"), True) 46 shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-peerinfo"), True)
49else: 47else:
50 shutil.rmtree ("/tmp/gnunet-test-peerinfo", True) 48 shutil.rmtree("/tmp/gnunet-test-peerinfo", True)
51 49
52# create hostkey via testing lib 50# create hostkey via testing lib # FIXME: The /tmp/ location needs to be adjusted to the TMP variable!
53hkk = subprocess.Popen ([gnunettesting, '-n', '1', '-c', 'test_gnunet_peerinfo_data.conf', '-k', '/tmp/gnunet-test-peerinfo/.hostkey']) 51hkk = subprocess.Popen([gnunettesting, '-n', '1', '-c', 'test_gnunet_peerinfo_data.conf', '-k', '/tmp/gnunet-test-peerinfo/.hostkey'])
54hkk.communicate () 52hkk.communicate()
55 53
56arm = subprocess.Popen ([gnunetarm, '-sq', '-c', 'test_gnunet_peerinfo_data.conf']) 54arm = subprocess.Popen([gnunetarm, '-sq', '-c', 'test_gnunet_peerinfo_data.conf'])
57arm.communicate () 55arm.communicate()
58 56
59try: 57try:
60 pinfo.spawn (None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-s'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 58 pinfo.spawn(None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-s'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
61 pinfo.expect ("stdout", re.compile (r'I am peer `.*\'.\r?\n')) 59 pinfo.expect("stdout", re.compile(r'I am peer `.*\'.\r?\n'))
62 60
63 pinfo.spawn (None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-qs'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 61 pinfo.spawn(None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-qs'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
64 pinfo.expect ("stdout", re.compile (r'....................................................\r?\n')) 62 pinfo.expect("stdout", re.compile(r'....................................................\r?\n'))
65 63
66 pinfo.spawn (None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', 'invalid'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 64 pinfo.spawn(None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', 'invalid'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
67 pinfo.expect ("stdout", re.compile (r'Invalid command line argument `invalid\'\r?\n')) 65 pinfo.expect("stdout", re.compile(r'Invalid command line argument `invalid\'\r?\n'))
68 66
69 arm = subprocess.Popen ([gnunetarm, '-q', '-i', 'transport', '-c', 'test_gnunet_peerinfo_data.conf']) 67 arm = subprocess.Popen([gnunetarm, '-q', '-i', 'transport', '-c', 'test_gnunet_peerinfo_data.conf'])
70 arm.communicate () 68 arm.communicate()
71 time.sleep (1) 69 time.sleep(1)
72 70
73 pinfo.spawn (None, [peerinfo, '-i', '-c', 'test_gnunet_peerinfo_data.conf'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 71 pinfo.spawn(None, [peerinfo, '-i', '-c', 'test_gnunet_peerinfo_data.conf'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
74 pinfo.expect ("stdout", re.compile ("Peer `.*'\r?\n")) 72 pinfo.expect("stdout", re.compile("Peer `.*'\r?\n"))
75 m = pinfo.expect ("stdout", re.compile ("\s.*:24357\r?\n")) 73 m = pinfo.expect("stdout", re.compile("\s.*:24357\r?\n"))
76 while len (m.group (0)) > 0: 74 while len(m.group(0)) > 0:
77 m = pinfo.expect ("stdout", re.compile ("(\s.*:24357\r?\n|\r?\n|)")) 75 m = pinfo.expect("stdout", re.compile("(\s.*:24357\r?\n|\r?\n|)"))
78 76
79 pinfo.spawn (None, [peerinfo, '-i', '-c', 'test_gnunet_peerinfo_data.conf', '-n'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 77 pinfo.spawn(None, [peerinfo, '-i', '-c', 'test_gnunet_peerinfo_data.conf', '-n'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
80 pinfo.expect ("stdout", re.compile ("Peer `.*'\r?\n")) 78 pinfo.expect("stdout", re.compile("Peer `.*'\r?\n"))
81 m = pinfo.expect ("stdout", re.compile ("\s.*:24357\r?\n")) 79 m = pinfo.expect("stdout", re.compile("\s.*:24357\r?\n"))
82 while len (m.group (0)) > 0: 80 while len(m.group(0)) > 0:
83 m = pinfo.expect ("stdout", re.compile ("(\s.*:24357\r?\n|\r?\n|)")) 81 m = pinfo.expect("stdout", re.compile("(\s.*:24357\r?\n|\r?\n|)"))
84 82
85 pinfo.spawn (None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-qs'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 83 pinfo.spawn(None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-qs'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
86 pid = pinfo.read ("stdout") 84 pid = pinfo.read("stdout")
87 pid.strip () 85 pid.strip()
88 86
89finally: 87finally:
90 arm = subprocess.Popen ([gnunetarm, '-eq', '-c', 'test_gnunet_peerinfo_data.conf']) 88 arm = subprocess.Popen([gnunetarm, '-eq', '-c', 'test_gnunet_peerinfo_data.conf'])
91 arm.communicate () 89 arm.communicate()
92 if os.name == "nt": 90 if os.name == "nt":
93 shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-peerinfo"), True) 91 shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-peerinfo"), True)
94 else: 92 else:
95 shutil.rmtree ("/tmp/gnunet-test-peerinfo", True) 93 shutil.rmtree("/tmp/gnunet-test-peerinfo", True)