gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r22580 - gnunet/src/arm


From: gnunet
Subject: [GNUnet-SVN] r22580 - gnunet/src/arm
Date: Mon, 9 Jul 2012 21:39:27 +0200

Author: grothoff
Date: 2012-07-09 21:39:27 +0200 (Mon, 09 Jul 2012)
New Revision: 22580

Added:
   gnunet/src/arm/test_gnunet_arm.py.in
Removed:
   gnunet/src/arm/test_gnunet_arm.sh
Modified:
   gnunet/src/arm/Makefile.am
Log:
-LRN: switching to py for arm test as well

Modified: gnunet/src/arm/Makefile.am
===================================================================
--- gnunet/src/arm/Makefile.am  2012-07-09 19:07:42 UTC (rev 22579)
+++ gnunet/src/arm/Makefile.am  2012-07-09 19:39:27 UTC (rev 22580)
@@ -61,7 +61,7 @@
  test_gnunet_service_manager
 
 check_SCRIPTS = \
- test_gnunet_arm.sh
+ test_gnunet_arm.py
 
 if ENABLE_TEST_RUN
 TESTS = $(check_PROGRAMS)  $(check_SCRIPTS)
@@ -85,7 +85,17 @@
   $(top_builddir)/src/arm/libgnunetarm.la \
   $(top_builddir)/src/util/libgnunetutil.la  
 
+do_subst = $(SED) -e 's,address@hidden@],$(PYTHON),g'
+
+%.py: %.py.in Makefile
+       $(do_subst) < $(srcdir)/$< > $@
+       chmod +x $@
+
+test_gnunet_arm.py: test_gnunet_arm.py.in Makefile
+       $(do_subst) < $(srcdir)/test_gnunet_arm.py.in > test_gnunet_arm.py
+       chmod +x test_gnunet_arm.py
+
 EXTRA_DIST = \
   test_arm_api_data.conf \
-  do_start_process.c \
-  $(check_SCRIPTS) 
+  test_gnunet_arm.py.in \
+  do_start_process.c

Added: gnunet/src/arm/test_gnunet_arm.py.in
===================================================================
--- gnunet/src/arm/test_gnunet_arm.py.in                                (rev 0)
+++ gnunet/src/arm/test_gnunet_arm.py.in        2012-07-09 19:39:27 UTC (rev 
22580)
@@ -0,0 +1,106 @@
address@hidden@
+from __future__ import print_function
+import os
+import sys
+import shutil
+import re
+import subprocess
+import time
+
+if os.name == "nt":
+  tmp = os.getenv ("TEMP")
+else:
+  tmp = "/tmp"
+
+if os.name == 'nt':
+  st = 'gnunet-statistics.exe'
+  arm = 'gnunet-arm.exe'
+else:
+  st = 'gnunet-statistics'
+  arm = 'gnunet-arm'
+
+run_arm = [arm, '-c', 'test_arm_api_data.conf', '--no-stdout', '--no-stderr']
+debug = os.getenv ('DEBUG')
+if debug:
+  run_arm += [debug.split (' ')]
+
+def cleanup ():
+  shutil.rmtree (os.path.join (tmp, "test-gnunetd-arm"), True)
+
+def sub_run (args, want_stdo = True, want_stde = False, nofail = False):
+  if want_stdo:
+    stdo = subprocess.PIPE
+  else:
+    stdo = None
+  if want_stde:
+    stde = subprocess.PIPE
+  else:
+    stde = None
+  p = subprocess.Popen (args, stdout = stdo, stderr = stde)
+  stdo, stde = p.communicate ()
+  if not nofail:
+    if p.returncode != 0:
+      sys.exit (p.returncode)
+  return (p.returncode, stdo, stde)
+
+def fail (result):
+  print (result)
+  r_arm (['-e'], want_stdo = False)
+  sys.exit (1)
+
+
+def end_arm_failer (command, rc, stdo, stde, normal):
+  if normal:
+    if rc != 0:
+      fail ("FAIL: error running {}\nCommand output was:\n{}\n{}".format 
(command, stdo, stde))
+  else:
+    if rc == 0:
+      fail ("FAIL: expected error while running {}\nCommand output 
was:\n{}\n{}".format (command, stdo, stde))
+
+def print_only_failer (command, rc, stdo, stde, normal):
+  if normal:
+    if rc != 0:
+      print ("FAIL: error running {}\nCommand output was:\n{}\n{}".format 
(command, stdo, stde))
+      sys.exit (1)
+  else:
+    if rc == 0:
+      print ("FAIL: expected error while running {}\nCommand output 
was:\n{}\n{}".format (command, stdo, stde))
+      sys.exit (1)
+
+
+def r_something (to_run, extra_args, failer = None, normal = True, **kw):
+  rc, stdo, stde = sub_run (to_run + extra_args, nofail = True, want_stde = 
True, **kw)
+  if failer is not None:
+    failer (to_run + extra_args, rc, stdo, stde, normal)
+  return (rc, stdo, stde)
+
+def r_arm (extra_args, **kw):
+  return r_something (run_arm, extra_args, **kw)
+
+cleanup ()
+
+print ("TEST: Bad argument checking...", end='')
+r_arm (['-x'], normal = False, failer = print_only_failer)
+print ("PASS")
+
+print ("TEST: Start ARM...", end='')
+r_arm (['-s'], failer = print_only_failer)
+time.sleep (1)
+print ("PASS")
+
+print ("TEST: Start another service...", end='')
+r_arm (['-i', 'resolver'], failer = end_arm_failer)
+time.sleep (1)
+print ("PASS")
+
+print ("TEST: Stop a service...", end='')
+r_arm (['-k', 'resolver'], failer = end_arm_failer)
+time.sleep (1)
+print ("PASS")
+
+print ("TEST: Stop ARM...", end='')
+r_arm (['-e'], failer = print_only_failer)
+time.sleep (1)
+print ("PASS")
+
+cleanup ()

Deleted: gnunet/src/arm/test_gnunet_arm.sh
===================================================================
--- gnunet/src/arm/test_gnunet_arm.sh   2012-07-09 19:07:42 UTC (rev 22579)
+++ gnunet/src/arm/test_gnunet_arm.sh   2012-07-09 19:39:27 UTC (rev 22580)
@@ -1,65 +0,0 @@
-#!/bin/sh
-
-exe="./gnunet-arm -c test_arm_api_data.conf"
-out=`mktemp /tmp/test-gnunet-arm-logXXXXXXXX`
-#DEBUG="-L DEBUG"
-
-
-# 
----------------------------------------------------------------------------------
-echo -n "TEST: Bad argument checking... "
-
-if $exe -x 2> /dev/null; then
-  echo "FAIL: error running $exe"
-  exit 1
-fi
-echo "PASS"
-
-# 
----------------------------------------------------------------------------------
-echo -n "TEST: Start ARM..."
-
-if ! $exe $DEBUG -s > $out ; then
-  echo "FAIL: error running $exe"
-  echo "Command output was:"
-  cat $out
-  exit 1
-fi
-echo "PASS"
-sleep 1
-
-# 
----------------------------------------------------------------------------------
-echo -n "TEST: Start another service... "
-
-if ! $exe $DEBUG -i resolver > $out ; then
-  echo "FAIL: error running $exe"
-  echo "Command output was:"
-  cat $out
-  kill %%
-  exit 1
-fi
-sleep 1
-echo "PASS"
-
-# 
----------------------------------------------------------------------------------
-echo -n "TEST: Stop a service... "
-
-if ! $exe $DEBUG -k resolver > $out; then
-  echo "FAIL: error running $exe"
-  $exe -e
-  exit 1
-fi
-sleep 1
-echo "PASS"
-
-# 
----------------------------------------------------------------------------------
-echo -n "TEST: Stop ARM... "
-
-if ! $exe $DEBUG -e > $out; then
-  echo "FAIL: error running $exe"
-  exit 1
-fi
-sleep 1
-echo "PASS"
-
-rm -rf /tmp/test-gnunetd-arm/
-rm -f $out
-




reply via email to

[Prev in Thread] Current Thread [Next in Thread]