SHUTDOWN
[oweals/gnunet.git] / src / peerinfo-tool / test_gnunet_peerinfo.py.in
1 #!@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  ('Error in communication 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   pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf invalid')
42   pinfo.expect (re.compile ("Invalid command line argument `invalid\'\r"));
43   pinfo.expect (pexpect.EOF);
44
45
46   os.system ('gnunet-arm -q -i transport -c test_gnunet_peerinfo_data.conf')
47   os.system ('sleep 1')
48   pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf')
49   pinfo.expect (re.compile ("Peer `.*\'\r"));
50   pinfo.expect (re.compile (" *:24357\r"));
51   pinfo.expect (pexpect.EOF);
52
53   pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf -n')
54   pinfo.expect (re.compile ("Peer `.*\'\r"));
55   pinfo.expect (re.compile (" *:24357\r"));
56   pinfo.expect (pexpect.EOF);
57
58   pinfo = pexpect.spawn ('gnunet-peerinfo -c test_gnunet_peerinfo_data.conf -qs')
59   pid = pinfo.read (-1)
60   pid = pid.strip ()
61
62 finally:
63   os.system ('gnunet-arm -c test_gnunet_peerinfo_data.conf -eq')
64   os.system ('rm -rf /tmp/gnunet-test-peerinfo/')