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.in143
1 files changed, 0 insertions, 143 deletions
diff --git a/src/peerinfo-tool/test_gnunet_peerinfo.py.in b/src/peerinfo-tool/test_gnunet_peerinfo.py.in
deleted file mode 100755
index 709556f70..000000000
--- a/src/peerinfo-tool/test_gnunet_peerinfo.py.in
+++ /dev/null
@@ -1,143 +0,0 @@
1#!@PYTHONEXE@
2# This file is part of GNUnet.
3# (C) 2010, 2018 Christian Grothoff (and other contributing authors)
4#
5# GNUnet is free software: you can redistribute it and/or modify it
6# under the terms of the GNU Affero General Public License as published
7# by the Free Software Foundation, either version 3 of the License,
8# or (at your 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# Affero General Public License for more details.
14#
15# You should have received a copy of the GNU Affero General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18# SPDX-License-Identifier: AGPL3.0-or-later
19#
20# Testcase for gnunet-peerinfo
21import sys
22import os
23import subprocess
24import re
25import shutil
26import time
27
28srcdir = "../.."
29gnunet_pyexpect_dir = os.path.join(srcdir, "contrib/scripts")
30if gnunet_pyexpect_dir not in sys.path:
31 sys.path.append(gnunet_pyexpect_dir)
32
33from gnunet_pyexpect import pexpect
34
35#save LANG and set it to C
36mylang = os.environ.get('LANG')
37os.environ['LANG'] = 'C'
38
39if os.name == 'posix':
40 peerinfo = './gnunet-peerinfo'
41 gnunetarm = 'gnunet-arm'
42 gnunettesting = 'gnunet-testing'
43elif os.name == 'nt':
44 peerinfo = './gnunet-peerinfo.exe'
45 gnunetarm = 'gnunet-arm.exe'
46 gnunettesting = 'gnunet-testing.exe'
47
48pinfo = pexpect()
49
50if os.name == "nt":
51 shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-peerinfo"), True)
52else:
53 shutil.rmtree("/tmp/gnunet-test-peerinfo", True)
54
55# create hostkey via testing lib # FIXME: The /tmp/ location needs to be adjusted to the TMP variable!
56hkk = subprocess.Popen([
57 gnunettesting, '-n', '1', '-c', 'test_gnunet_peerinfo_data.conf', '-k',
58 '/tmp/gnunet-test-peerinfo/.hostkey'
59])
60hkk.communicate()
61
62arm = subprocess.Popen([
63 gnunetarm, '-sq', '-c', 'test_gnunet_peerinfo_data.conf'
64])
65arm.communicate()
66
67try:
68 pinfo.spawn(
69 None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-s'],
70 stdout=subprocess.PIPE,
71 stderr=subprocess.STDOUT
72 )
73 pinfo.expect("stdout", re.compile(r'I am peer `.*\'.\r?\n'))
74
75 pinfo.spawn(
76 None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-qs'],
77 stdout=subprocess.PIPE,
78 stderr=subprocess.STDOUT
79 )
80 pinfo.expect(
81 "stdout",
82 re.
83 compile(r'....................................................\r?\n')
84 )
85
86 pinfo.spawn(
87 None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', 'invalid'],
88 stdout=subprocess.PIPE,
89 stderr=subprocess.STDOUT
90 )
91 pinfo.expect(
92 "stdout", re.compile(r'Invalid command line argument `invalid\'\r?\n')
93 )
94
95 arm = subprocess.Popen([
96 gnunetarm, '-q', '-i', 'transport', '-c',
97 'test_gnunet_peerinfo_data.conf'
98 ])
99 arm.communicate()
100 time.sleep(1)
101
102 pinfo.spawn(
103 None, [peerinfo, '-i', '-c', 'test_gnunet_peerinfo_data.conf'],
104 stdout=subprocess.PIPE,
105 stderr=subprocess.STDOUT
106 )
107 pinfo.expect("stdout", re.compile("Peer `.*'\r?\n"))
108 m = pinfo.expect("stdout", re.compile("\s.*:24357\r?\n"))
109 while len(m.group(0)) > 0:
110 m = pinfo.expect("stdout", re.compile("(\s.*:24357\r?\n|\r?\n|)"))
111
112 pinfo.spawn(
113 None, [peerinfo, '-i', '-c', 'test_gnunet_peerinfo_data.conf', '-n'],
114 stdout=subprocess.PIPE,
115 stderr=subprocess.STDOUT
116 )
117 pinfo.expect("stdout", re.compile("Peer `.*'\r?\n"))
118 m = pinfo.expect("stdout", re.compile("\s.*:24357\r?\n"))
119 while len(m.group(0)) > 0:
120 m = pinfo.expect("stdout", re.compile("(\s.*:24357\r?\n|\r?\n|)"))
121
122 pinfo.spawn(
123 None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-qs'],
124 stdout=subprocess.PIPE,
125 stderr=subprocess.STDOUT
126 )
127 pid = pinfo.read("stdout")
128 pid.strip()
129
130finally:
131 arm = subprocess.Popen([
132 gnunetarm, '-eq', '-c', 'test_gnunet_peerinfo_data.conf'
133 ])
134 arm.communicate()
135 if os.name == "nt":
136 shutil.rmtree(
137 os.path.join(os.getenv("TEMP"), "gnunet-test-peerinfo"), True
138 )
139 else:
140 shutil.rmtree("/tmp/gnunet-test-peerinfo", True)
141 #Reset LANG
142 if type(mylang) == str:
143 os.environ['LANG'] = mylang