diff options
Diffstat (limited to 'src/peerinfo-tool')
-rw-r--r-- | src/peerinfo-tool/Makefile.am | 8 | ||||
-rw-r--r-- | src/peerinfo-tool/gnunet-peerinfo.c | 16 | ||||
-rwxr-xr-x | src/peerinfo-tool/test_gnunet_peerinfo.py | 56 | ||||
-rw-r--r-- | src/peerinfo-tool/test_gnunet_peerinfo_data.conf | 21 |
4 files changed, 99 insertions, 2 deletions
diff --git a/src/peerinfo-tool/Makefile.am b/src/peerinfo-tool/Makefile.am index c10440f92..25885a34c 100644 --- a/src/peerinfo-tool/Makefile.am +++ b/src/peerinfo-tool/Makefile.am | |||
@@ -20,5 +20,9 @@ gnunet_peerinfo_LDADD = \ | |||
20 | $(top_builddir)/src/util/libgnunetutil.la | 20 | $(top_builddir)/src/util/libgnunetutil.la |
21 | 21 | ||
22 | 22 | ||
23 | #check_SCRIPTS = \ | 23 | if HAVE_PYTHON_PEXPECT |
24 | # test_gnunet_peerinfo.sh | 24 | check_SCRIPTS = \ |
25 | test_gnunet_peerinfo.py | ||
26 | endif | ||
27 | |||
28 | TESTS = $(check_SCRIPTS) | ||
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 5efd7262c..ba6609596 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c | |||
@@ -170,6 +170,22 @@ print_peer_info (void *cls, | |||
170 | if (peer == NULL) | 170 | if (peer == NULL) |
171 | { | 171 | { |
172 | GNUNET_PEERINFO_disconnect (peerinfo); | 172 | GNUNET_PEERINFO_disconnect (peerinfo); |
173 | switch (trust) | ||
174 | { | ||
175 | case 0: | ||
176 | break; | ||
177 | case 1: | ||
178 | fprintf (stderr, | ||
179 | _("Timeout trying to interact with PEERINFO service\n")); | ||
180 | break; | ||
181 | case 2: | ||
182 | fprintf (stderr, | ||
183 | _("Error in communication with PEERINFO service\n")); | ||
184 | break; | ||
185 | default: | ||
186 | GNUNET_break (0); | ||
187 | break; | ||
188 | } | ||
173 | return; | 189 | return; |
174 | } | 190 | } |
175 | if (be_quiet) | 191 | if (be_quiet) |
diff --git a/src/peerinfo-tool/test_gnunet_peerinfo.py b/src/peerinfo-tool/test_gnunet_peerinfo.py new file mode 100755 index 000000000..3aa8497af --- /dev/null +++ b/src/peerinfo-tool/test_gnunet_peerinfo.py | |||
@@ -0,0 +1,56 @@ | |||
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 | # Testcase for gnunet-peerinfo | ||
21 | import pexpect | ||
22 | import os | ||
23 | import signal | ||
24 | import re | ||
25 | |||
26 | pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf') | ||
27 | pinfo.expect ('Timeout trying to interact with PEERINFO service\r') | ||
28 | pinfo.expect (pexpect.EOF); | ||
29 | os.system ('rm -rf /tmp/gnunet-test-peerinfo/') | ||
30 | os.system ('gnunet-arm -sq -c test_gnunet_peerinfo_data.conf') | ||
31 | |||
32 | try: | ||
33 | pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf -s') | ||
34 | pinfo.expect (re.compile ("I am peer `.*\'.\r")); | ||
35 | pinfo.expect (pexpect.EOF); | ||
36 | |||
37 | pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf -qs') | ||
38 | pinfo.expect (re.compile (".......................................................................................................\r")); | ||
39 | pinfo.expect (pexpect.EOF); | ||
40 | |||
41 | os.system ('gnunet-arm -q -i transport -c test_gnunet_peerinfo_data.conf') | ||
42 | |||
43 | pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf') | ||
44 | pinfo.expect (re.compile ("Peer `.*\' with trust *0\r")); | ||
45 | pinfo.expect (re.compile (" *localhost:24357\r")); | ||
46 | pinfo.expect (pexpect.EOF); | ||
47 | |||
48 | pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf -n') | ||
49 | pinfo.expect (re.compile ("Peer `.*\' with trust *0\r")); | ||
50 | pinfo.expect (re.compile (" *127.0.0.1:24357\r")); | ||
51 | pinfo.expect (pexpect.EOF); | ||
52 | |||
53 | |||
54 | finally: | ||
55 | os.system ('gnunet-arm -c test_gnunet_peerinfo_data.conf -eq') | ||
56 | os.system ('rm -rf /tmp/gnunet-test-peerinfo/') | ||
diff --git a/src/peerinfo-tool/test_gnunet_peerinfo_data.conf b/src/peerinfo-tool/test_gnunet_peerinfo_data.conf new file mode 100644 index 000000000..5641d5baf --- /dev/null +++ b/src/peerinfo-tool/test_gnunet_peerinfo_data.conf | |||
@@ -0,0 +1,21 @@ | |||
1 | [PATHS] | ||
2 | SERVICEHOME = /tmp/gnunet-test-peerinfo/ | ||
3 | |||
4 | [peerinfo] | ||
5 | PORT = 24354 | ||
6 | |||
7 | [resolver] | ||
8 | PORT = 24355 | ||
9 | |||
10 | [arm] | ||
11 | DEFAULTSERVICES = resolver peerinfo | ||
12 | |||
13 | [testing] | ||
14 | WEAKRANDOM = YES | ||
15 | |||
16 | [transport] | ||
17 | plugins = tcp | ||
18 | PORT = 24356 | ||
19 | |||
20 | [transport-tcp] | ||
21 | PORT = 24357 \ No newline at end of file | ||