gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (8d7ab1640 -> 78eeba903)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (8d7ab1640 -> 78eeba903)
Date: Wed, 23 May 2018 10:11:42 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a change to branch master
in repository gnunet.

    from 8d7ab1640 starting with another CADET testcase (unfinished)
     new e955fc492 revocation: test_local_revocation: Adjust to flake8
     new 1cc13d48e integration-tests disconnect_nat flake8
     new 78eeba903 Merge branch 'master' of gnunet.org:gnunet

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../test_integration_disconnect_nat.py.in          | 324 +++++++++++----------
 src/revocation/test_local_revocation.py.in         | 139 +++++----
 2 files changed, 232 insertions(+), 231 deletions(-)

diff --git a/src/integration-tests/test_integration_disconnect_nat.py.in 
b/src/integration-tests/test_integration_disconnect_nat.py.in
index 611255a09..12c268bd6 100755
--- a/src/integration-tests/test_integration_disconnect_nat.py.in
+++ b/src/integration-tests/test_integration_disconnect_nat.py.in
@@ -17,7 +17,7 @@
 #    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 #    Boston, MA 02110-1301, USA.
 #
-# 
+#
 import sys
 import signal
 import os
@@ -29,8 +29,8 @@ from gnunet_testing import Peer
 from gnunet_testing import Test
 from gnunet_testing import Check
 from gnunet_testing import Condition
-from gnunet_testing import * 
- 
+from gnunet_testing import *
+
 
 #
 # This test tests if a fresh peer bootstraps from a hostlist server and then
@@ -40,173 +40,175 @@ from gnunet_testing import *
 # Conditions for successful exit:
 # Client peer has 0 connected peer in transport, core, topology, dht, fs
 
-#definitions
+# definitions
 
 testname = "test_integration_disconnect"
 verbose = True
 check_timeout = 180
 
 if os.name == "nt":
-  tmp = os.getenv ("TEMP")
-  signals = [signal.SIGTERM, signal.SIGINT]
+    tmp = os.getenv("TEMP")
+    signals = [signal.SIGTERM, signal.SIGINT]
 else:
-  tmp = "/tmp"
-  signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]
-
-def cleanup_onerror (function, path, excinfo):
-  import stat
-  if not os.path.exists (path):
-    pass
-  elif not os.access(path, os.W_OK):
-    # Is the error an access error ?
-    os.chmod (path, stat.S_IWUSR)
-    function (path)
-  else:
-    raise
-
-def cleanup ():
-  shutil.rmtree (os.path.join (tmp, "c_bootstrap_server"), False, 
cleanup_onerror)
-  shutil.rmtree (os.path.join (tmp, "c_nat_client"), False, cleanup_onerror)
-
-
-def success_disconnect_cont (check):
-       print('Peers disconnected successfully')
-       global success 
-       success = True;
-
-
-def fail_disconnect_cont (check):    
-       global success 
-       success = False;
-       print('Peers failed to disconnect')
-       check.evaluate(True)   
-  
-def check_disconnect ():
-  global server
-  global nat_client  
-  test.p ('Shutting down nat client')
-  nat_client.stop ()
-  check = Check (test)
-  check.add (StatisticsCondition (server, 'transport', '# peers connected',0))
-  check.add (StatisticsCondition (server, 'core', '# peers connected',0))
-  check.add (StatisticsCondition (server, 'topology', '# peers connected',0))
-  check.add (StatisticsCondition (server, 'dht', '# peers connected',0))
-  check.add (StatisticsCondition (server, 'fs', '# peers connected',0))
-  check.run_blocking (check_timeout, success_disconnect_cont, 
fail_disconnect_cont)
-
-
-def success_connect_cont (check):
-       print('Peers connected successfully')
-       check_disconnect ()
-
-
-def fail_connect_cont (check):    
-  global success 
-  success= False
-  print('Peers failed to connected!')
-  check.evaluate(True)
-
-
-def check_connect ():
-  global server
-  global nat_client  
-  check = Check (test)
-  check.add (StatisticsCondition (nat_client, 'transport', '# peers 
connected',1))
-  check.add (StatisticsCondition (nat_client, 'core', '# peers connected',1))
-  check.add (StatisticsCondition (nat_client, 'topology', '# peers 
connected',1))
-  check.add (StatisticsCondition (nat_client, 'dht', '# peers connected',1))
-  check.add (StatisticsCondition (nat_client, 'fs', '# peers connected',1))
-  
-  check.add (StatisticsCondition (server, 'transport', '# peers connected',1))
-  check.add (StatisticsCondition (server, 'core', '# peers connected',1))
-  check.add (StatisticsCondition (server, 'topology', '# peers connected',1))
-  check.add (StatisticsCondition (server, 'dht', '# peers connected',1))
-  check.add (StatisticsCondition (server, 'fs', '# peers connected',1))  
-  
-  check.run_blocking (check_timeout, success_connect_cont, fail_connect_cont)
-
-# 
+    tmp = "/tmp"
+    signals = [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]
+
+
+def cleanup_onerror(function, path, excinfo):
+    import stat
+    if not os.path.exists(path):
+        pass
+    elif not os.access(path, os.W_OK):
+        # Is the error an access error ?
+        os.chmod(path, stat.S_IWUSR)
+        function(path)
+    else:
+        raise
+
+
+def cleanup():
+    shutil.rmtree(os.path.join(tmp, "c_bootstrap_server"), False, 
cleanup_onerror)
+    shutil.rmtree(os.path.join(tmp, "c_nat_client"), False, cleanup_onerror)
+
+
+def success_disconnect_cont(check):
+    print('Peers disconnected successfully')
+    global success
+    success = True
+
+
+def fail_disconnect_cont(check):
+    global success
+    success = False;
+    print('Peers failed to disconnect')
+    check.evaluate(True)
+
+
+def check_disconnect():
+    global server
+    global nat_client
+    test.p('Shutting down nat client')
+    nat_client.stop()
+    check = Check(test)
+    check.add(StatisticsCondition(server, 'transport', '# peers connected', 0))
+    check.add(StatisticsCondition(server, 'core', '# peers connected', 0))
+    check.add(StatisticsCondition(server, 'topology', '# peers connected', 0))
+    check.add(StatisticsCondition(server, 'dht', '# peers connected', 0))
+    check.add(StatisticsCondition(server, 'fs', '# peers connected', 0))
+    check.run_blocking(check_timeout, success_disconnect_cont, 
fail_disconnect_cont)
+
+
+def success_connect_cont(check):
+    print('Peers connected successfully')
+    check_disconnect()
+
+
+def fail_connect_cont(check):
+    global success
+    success = False
+    print('Peers failed to connected!')
+    check.evaluate(True)
+
+
+def check_connect():
+    global server
+    global nat_client
+    check = Check(test)
+    check.add(StatisticsCondition(nat_client, 'transport', '# peers 
connected', 1))
+    check.add(StatisticsCondition(nat_client, 'core', '# peers connected', 1))
+    check.add(StatisticsCondition(nat_client, 'topology', '# peers connected', 
1))
+    check.add(StatisticsCondition(nat_client, 'dht', '# peers connected', 1))
+    check.add(StatisticsCondition(nat_client, 'fs', '# peers connected', 1))
+
+    check.add(StatisticsCondition(server, 'transport', '# peers connected', 1))
+    check.add(StatisticsCondition(server, 'core', '# peers connected', 1))
+    check.add(StatisticsCondition(server, 'topology', '# peers connected', 1))
+    check.add(StatisticsCondition(server, 'dht', '# peers connected', 1))
+    check.add(StatisticsCondition(server, 'fs', '# peers connected', 1))
+
+    check.run_blocking(check_timeout, success_connect_cont, fail_connect_cont)
+
+
+#
 # Test execution
-# 
-
-def SigHandler(signum = None, frame = None):
-       global success  
-       global server
-       global nat_client  
-       
-       print('Test was aborted!')
-       if (None != server):
-               server.stop ()
-       if (None != nat_client):                
-               nat_client.stop ()
-       cleanup ()
-       sys.exit(success)
-
-def run ():
-       global success
-       global test
-       global server
-       global nat_client    
-       
-       server = None
-       nat_client = None
-       success = False  
-       
-       for sig in signals:
-               signal.signal(sig, SigHandler)
-
-       test = Test ('test_integration_bootstrap_and_connect.py', verbose)
-       cleanup ()
-       
-       server = Peer(test, './confs/c_bootstrap_server.conf');
-       nat_client = Peer(test, './confs/c_nat_client.conf');
-       
-       if (True != server.start()):
-               print('Failed to start server')
-               if (None != server):
-                       server.stop ()
-               cleanup ()
-               sys.exit(success)
-               
-       # Give the server time to start
-       time.sleep(5)
-               
-       if (True != nat_client.start()):
-               print('Failed to start nat_client')
-               if (None != server):
-                       server.stop ()
-               if (None != nat_client):                
-                       nat_client.stop ()
-               cleanup ()
-               sys.exit(success)
-       
-       if ((nat_client.started == True) and (server.started == True)):
-               test.p ('Peers started, running check')
-               time.sleep(5)
-               check_connect ()
-       server.stop ()
-       nat_client.stop ()
-       
-       cleanup ()
-       
-       if (success == False):
-               print ('Test failed')
-               return False 
-       else:
-               return True
+#
+
+def SigHandler(signum=None, frame=None):
+    global success
+    global server
+    global nat_client
+
+    print('Test was aborted!')
+    if (None != server):
+        server.stop()
+    if (None != nat_client):
+        nat_client.stop()
+    cleanup()
+    sys.exit(success)
+
+
+def run():
+    global success
+    global test
+    global server
+    global nat_client
+
+    server = None
+    nat_client = None
+    success = False
+
+    for sig in signals:
+        signal.signal(sig, SigHandler)
+
+    test = Test('test_integration_bootstrap_and_connect.py', verbose)
+    cleanup()
+
+    server = Peer(test, './confs/c_bootstrap_server.conf')
+    nat_client = Peer(test, './confs/c_nat_client.conf')
+
+    if (True != server.start()):
+        print('Failed to start server')
+        if (None != server):
+            server.stop()
+        cleanup()
+        sys.exit(success)
+
+    # Give the server time to start
+    time.sleep(5)
+
+    if (True != nat_client.start()):
+        print('Failed to start nat_client')
+        if (None != server):
+            server.stop()
+        if (None != nat_client):
+            nat_client.stop()
+        cleanup()
+        sys.exit(success)
+
+    if ((nat_client.started == True) and (server.started == True)):
+        test.p('Peers started, running check')
+        time.sleep(5)
+        check_connect()
+    server.stop()
+    nat_client.stop()
+
+    cleanup()
+
+    if (success == False):
+        print('Test failed')
+        return False
+    else:
+        return True
+
 
 try:
-       run ()
-except (KeyboardInterrupt, SystemExit):    
-       print('Test interrupted')
-       server.stop ()
-       nat_client.stop ()
-       cleanup ()
+    run()
+except(KeyboardInterrupt, SystemExit):
+    print('Test interrupted')
+    server.stop()
+    nat_client.stop()
+    cleanup()
 if (success == False):
-       sys.exit(1)   
+    sys.exit(1)
 else:
-       sys.exit(0)    
-     
-       
-     
-       
+    sys.exit(0)
diff --git a/src/revocation/test_local_revocation.py.in 
b/src/revocation/test_local_revocation.py.in
index 28257715f..067091b58 100644
--- a/src/revocation/test_local_revocation.py.in
+++ b/src/revocation/test_local_revocation.py.in
@@ -1,6 +1,6 @@
 address@hidden@
 #    This file is part of GNUnet.
-#    (C) 2010 Christian Grothoff (and other contributing authors)
+#    (C) 2010, 2018 Christian Grothoff (and other contributing authors)
 #
 #    GNUnet is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published
@@ -26,90 +26,89 @@ import re
 import shutil
 
 if os.name == 'posix':
-  config = 'gnunet-config'
-  gnunetarm = 'gnunet-arm'
-  ident = 'gnunet-identity'
-  revoc = './gnunet-revocation'
+    config = 'gnunet-config'
+    gnunetarm = 'gnunet-arm'
+    ident = 'gnunet-identity'
+    revoc = './gnunet-revocation'
 elif os.name == 'nt':
-  config = 'gnunet-config.exe'
-  gnunetarm = 'gnunet-arm.exe'
-  ident = 'gnunet-identity.exe'
-  revoc = './gnunet-revocation.exe'
+    config = 'gnunet-config.exe'
+    gnunetarm = 'gnunet-arm.exe'
+    ident = 'gnunet-identity.exe'
+    revoc = './gnunet-revocation.exe'
 
 TEST_CONFIGURATION = "test_revocation.conf"
 TEST_REVOCATION_EGO = "revoc_test"
 
-
-get_clean = subprocess.Popen ([config, '-c', TEST_CONFIGURATION, '-s', 
'PATHS', '-o', 'GNUNET_HOME', '-f'], stdout=subprocess.PIPE)
-cleandir, x = get_clean.communicate ()
+get_clean = subprocess.Popen([config, '-c', TEST_CONFIGURATION, '-s', 'PATHS', 
'-o', 'GNUNET_HOME', '-f'], stdout=subprocess.PIPE)
+cleandir, x = get_clean.communicate()
 cleandir = cleandir.decode("utf-8")
-cleandir = cleandir.rstrip ('\n').rstrip ('\r')
+cleandir = cleandir.rstrip('\n').rstrip('\r')
 
-if os.path.isdir (cleandir):
-  shutil.rmtree (cleandir, True)
+if os.path.isdir(cleandir):
+    shutil.rmtree(cleandir, True)
 
 res = 0
-arm = subprocess.Popen ([gnunetarm, '-s', '-c', TEST_CONFIGURATION])
-arm.communicate ()
+arm = subprocess.Popen([gnunetarm, '-s', '-c', TEST_CONFIGURATION])
+arm.communicate()
 
 try:
-  print ("Creating an ego " + TEST_REVOCATION_EGO)
-  sys.stdout.flush ()
-  sys.stderr.flush ()
-  idc = subprocess.Popen ([ident, '-C', TEST_REVOCATION_EGO, '-c', 
TEST_CONFIGURATION])
-  idc.communicate ()
-  if idc.returncode != 0:
-    raise Exception ("gnunet-identity failed to create an ego `" + 
TEST_REVOCATION_EGO + "'")
+    print("Creating an ego " + TEST_REVOCATION_EGO)
+    sys.stdout.flush()
+    sys.stderr.flush()
+    idc = subprocess.Popen([ident, '-C', TEST_REVOCATION_EGO, '-c', 
TEST_CONFIGURATION])
+    idc.communicate()
+    if idc.returncode != 0:
+        raise Exception("gnunet-identity failed to create an ego `" + 
TEST_REVOCATION_EGO + "'")
 
-  sys.stdout.flush ()
-  sys.stderr.flush ()
-  idd = subprocess.Popen ([ident, '-d'], stdout=subprocess.PIPE)
-  rev_key, x = idd.communicate ()
-  rev_key = rev_key.decode("utf-8")
-  if len (rev_key.split ()) < 3:
-    raise Exception ("can't get revocation key out of `" + rev_key + "'")
-  rev_key = rev_key.split ()[2]
+    sys.stdout.flush()
+    sys.stderr.flush()
+    idd = subprocess.Popen([ident, '-d'], stdout=subprocess.PIPE)
+    rev_key, x = idd.communicate()
+    rev_key = rev_key.decode("utf-8")
+    if len(rev_key.split()) < 3:
+        raise Exception("can't get revocation key out of `" + rev_key + "'")
+    rev_key = rev_key.split()[2]
 
-  print ("Testing key " + rev_key)
-  sys.stdout.flush ()
-  sys.stderr.flush ()
-  tst = subprocess.Popen ([revoc, '-t', rev_key, '-c', TEST_CONFIGURATION], 
stdout=subprocess.PIPE)
-  output_not_revoked, x = tst.communicate ()
-  output_not_revoked = output_not_revoked.decode("utf-8")
-  if tst.returncode != 0:
-    raise Exception ("gnunet-revocation failed to test a key - " + str 
(tst.returncode) + ": " + output_not_revoked)
-  if 'valid' not in output_not_revoked:
-    res = 1
-    print ("Key was not valid")
-  else:
-    print ("Key was valid")
+    print("Testing key " + rev_key)
+    sys.stdout.flush()
+    sys.stderr.flush()
+    tst = subprocess.Popen([revoc, '-t', rev_key, '-c', TEST_CONFIGURATION], 
stdout=subprocess.PIPE)
+    output_not_revoked, x = tst.communicate()
+    output_not_revoked = output_not_revoked.decode("utf-8")
+    if tst.returncode != 0:
+        raise Exception("gnunet-revocation failed to test a key - " + 
str(tst.returncode) + ": " + output_not_revoked)
+    if 'valid' not in output_not_revoked:
+        res = 1
+        print("Key was not valid")
+    else:
+        print("Key was valid")
 
-  print ("Revoking key " + rev_key)
-  sys.stdout.flush ()
-  sys.stderr.flush ()
-  rev = subprocess.Popen ([revoc, '-R', TEST_REVOCATION_EGO, '-p', '-c', 
TEST_CONFIGURATION])
-  rev.communicate ()
-  if rev.returncode != 0:
-    raise Exception ("gnunet-revocation failed to revoke a key")
+    print("Revoking key " + rev_key)
+    sys.stdout.flush()
+    sys.stderr.flush()
+    rev = subprocess.Popen([revoc, '-R', TEST_REVOCATION_EGO, '-p', '-c', 
TEST_CONFIGURATION])
+    rev.communicate()
+    if rev.returncode != 0:
+        raise Exception("gnunet-revocation failed to revoke a key")
 
-  print ("Testing revoked key " + rev_key)
-  sys.stdout.flush ()
-  sys.stderr.flush ()
-  tst = subprocess.Popen ([revoc, '-t', rev_key, '-c', TEST_CONFIGURATION], 
stdout=subprocess.PIPE)
-  output_revoked, x = tst.communicate ()
-  output_revoked = output_revoked.decode("utf-8")
-  if tst.returncode != 0:
-    raise Exception ("gnunet-revocation failed to test a revoked key")
-  if 'revoked' not in output_revoked:
-    res = 1
-    print ("Key was not revoked")
-  else:
-    print ("Key was revoked")
+    print("Testing revoked key " + rev_key)
+    sys.stdout.flush()
+    sys.stderr.flush()
+    tst = subprocess.Popen([revoc, '-t', rev_key, '-c', TEST_CONFIGURATION], 
stdout=subprocess.PIPE)
+    output_revoked, x = tst.communicate()
+    output_revoked = output_revoked.decode("utf-8")
+    if tst.returncode != 0:
+        raise Exception("gnunet-revocation failed to test a revoked key")
+    if 'revoked' not in output_revoked:
+        res = 1
+        print("Key was not revoked")
+    else:
+        print("Key was revoked")
 
 finally:
-  arm = subprocess.Popen ([gnunetarm, '-e', '-c', TEST_CONFIGURATION])
-  arm.communicate ()
-  if os.path.isdir (cleandir):
-    shutil.rmtree (cleandir, True)
+    arm = subprocess.Popen([gnunetarm, '-e', '-c', TEST_CONFIGURATION])
+    arm.communicate()
+    if os.path.isdir(cleandir):
+        shutil.rmtree(cleandir, True)
 
-sys.exit (res)
+sys.exit(res)

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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