update velocity always at the end of iteration
[oweals/gnunet.git] / src / peerinfo-tool / test_gnunet_peerinfo.py.in
index ee8bc4af600d0b0ab6ff64a8d64ab75c4e23fbb2..3207c2c2fe40847df0d507ee30f2004aa40e12f1 100755 (executable)
@@ -4,7 +4,7 @@
 #
 #    GNUnet is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published
-#    by the Free Software Foundation; either version 2, or (at your
+#    by the Free Software Foundation; either version 3, or (at your
 #    option) any later version.
 #
 #    GNUnet is distributed in the hope that it will be useful, but
@@ -14,8 +14,8 @@
 #
 #    You should have received a copy of the GNU General Public License
 #    along with GNUnet; see the file COPYING.  If not, write to the
-#    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-#    Boston, MA 02111-1307, USA.
+#    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+#    Boston, MA 02110-1301, USA.
 #
 # Testcase for gnunet-peerinfo
 import sys
@@ -33,23 +33,26 @@ if gnunet_pyexpect_dir not in sys.path:
 from gnunet_pyexpect import pexpect
 
 if os.name == 'posix':
-  peerinfo = 'gnunet-peerinfo'
+  peerinfo = './gnunet-peerinfo'
   gnunetarm = 'gnunet-arm'
+  gnunettesting = 'gnunet-testing'
 elif os.name == 'nt':
-  peerinfo = 'gnunet-peerinfo.exe'
+  peerinfo = './gnunet-peerinfo.exe'
   gnunetarm = 'gnunet-arm.exe'
-
-
+  gnunettesting = 'gnunet-testing.exe'
 
 pinfo = pexpect ()
-pinfo.spawn (None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-L', 'ERROR'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-pinfo.expect ("stdout", re.compile (r'Error in communication with PEERINFO service\r?\n'))
-pinfo.expect ("stdout", "EOF")
+
 
 if os.name == "nt":
   shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-peerinfo"), True)
 else:
   shutil.rmtree ("/tmp/gnunet-test-peerinfo", True)
+
+# create hostkey via testing lib
+hkk = subprocess.Popen ([gnunettesting, '-n', '1', '-c', 'test_gnunet_peerinfo_data.conf', '-k', '/tmp/gnunet-test-peerinfo/.hostkey'])
+hkk.communicate ()
+
 arm = subprocess.Popen ([gnunetarm, '-sq', '-c', 'test_gnunet_peerinfo_data.conf'])
 arm.communicate ()
 
@@ -58,7 +61,7 @@ try:
   pinfo.expect ("stdout", re.compile (r'I am peer `.*\'.\r?\n'))
 
   pinfo.spawn (None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-qs'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-  pinfo.expect ("stdout", re.compile (r'.......................................................................................................\r?\n'))
+  pinfo.expect ("stdout", re.compile (r'....................................................\r?\n'))
 
   pinfo.spawn (None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', 'invalid'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
   pinfo.expect ("stdout", re.compile (r'Invalid command line argument `invalid\'\r?\n'))
@@ -67,13 +70,13 @@ try:
   arm.communicate ()
   time.sleep (1)
 
-  pinfo.spawn (None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+  pinfo.spawn (None, [peerinfo, '-i', '-c', 'test_gnunet_peerinfo_data.conf'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
   pinfo.expect ("stdout", re.compile ("Peer `.*'\r?\n"))
   m = pinfo.expect ("stdout", re.compile ("\s.*:24357\r?\n"))
   while len (m.group (0)) > 0:
     m = pinfo.expect ("stdout", re.compile ("(\s.*:24357\r?\n|\r?\n|)"))
 
-  pinfo.spawn (None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-n'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+  pinfo.spawn (None, [peerinfo, '-i', '-c', 'test_gnunet_peerinfo_data.conf', '-n'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
   pinfo.expect ("stdout", re.compile ("Peer `.*'\r?\n"))
   m = pinfo.expect ("stdout", re.compile ("\s.*:24357\r?\n"))
   while len (m.group (0)) > 0:
@@ -82,7 +85,7 @@ try:
   pinfo.spawn (None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-qs'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
   pid = pinfo.read ("stdout")
   pid.strip ()
-  
+
 finally:
   arm = subprocess.Popen ([gnunetarm, '-eq', '-c', 'test_gnunet_peerinfo_data.conf'])
   arm.communicate ()
@@ -90,4 +93,3 @@ finally:
     shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-peerinfo"), True)
   else:
     shutil.rmtree ("/tmp/gnunet-test-peerinfo", True)
-