gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r20870 - gnunet/src/integration-tests


From: gnunet
Subject: [GNUnet-SVN] r20870 - gnunet/src/integration-tests
Date: Tue, 3 Apr 2012 14:10:44 +0200

Author: wachs
Date: 2012-04-03 14:10:44 +0200 (Tue, 03 Apr 2012)
New Revision: 20870

Added:
   gnunet/src/integration-tests/test_integration_connection_value.py.in
Modified:
   gnunet/src/integration-tests/Makefile.am
   gnunet/src/integration-tests/gnunet_testing.py.in
Log:
- changes to the scripts


Modified: gnunet/src/integration-tests/Makefile.am
===================================================================
--- gnunet/src/integration-tests/Makefile.am    2012-04-03 12:06:34 UTC (rev 
20869)
+++ gnunet/src/integration-tests/Makefile.am    2012-04-03 12:10:44 UTC (rev 
20870)
@@ -24,7 +24,8 @@
  test_integration_bootstrap_and_connect_and_disconnect_nat.py \
  test_integration_restart.py \
  test_integration_clique.py \
- test_integration_clique_nat.py
+ test_integration_clique_nat.py \
+ test_integration_connection_value.py
 endif
 # test_integration_disconnect.py 
 
@@ -81,7 +82,11 @@
        $(do_subst) < $(srcdir)/test_integration_clique_nat.py.in > 
test_integration_clique_nat.py
        chmod +x test_integration_clique_nat.py 
 
+test_integration_connection_value.py: test_integration_connection_value.py.in 
Makefile
+       $(do_subst) < $(srcdir)/test_integration_connection_value.py.in > 
test_integration_connection_value.py
+       chmod +x test_integration_connection_value.py           
 
+
 EXTRA_DIST = \
    gnunet_testing.py.in \
    gnunet_pyexpect.py.in \

Modified: gnunet/src/integration-tests/gnunet_testing.py.in
===================================================================
--- gnunet/src/integration-tests/gnunet_testing.py.in   2012-04-03 12:06:34 UTC 
(rev 20869)
+++ gnunet/src/integration-tests/gnunet_testing.py.in   2012-04-03 12:10:44 UTC 
(rev 20870)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
address@hidden@
 #    This file is part of GNUnet.
 #    (C) 2010 Christian Grothoff (and other contributing authors)
 #
@@ -55,6 +55,16 @@
             neg_cont (self)
         else:
             pos_cont (self)
+        return res            
+    def run_once (self, pos_cont, neg_cont):
+        execs = 0;
+        res = False
+        res = self.run()
+        if ((res == False) and (neg_cont != None)):
+            neg_cont (self)
+        if ((res == True) and (pos_cont != None)):
+            pos_cont (self)            
+        return res
     def evaluate (self, failed_only):
         pos = 0
         neg = 0
@@ -139,6 +149,52 @@
         elif (failed_only == False): 
             print self.peer.id[:4] + " " +self.peer.cfg + " " +  
str(self.type) + ' condition in subsystem "' + self.subsystem.ljust(12) +'" : 
"' + self.name.ljust(30) +'" : (expected/real value) ' + str(self.value) + op + 
res + fail 
         return self.fulfilled    
+
+# Specify two statistic values and check if they are equal  
+class EqualStatisticsCondition (Condition):
+    def __init__(self, peer, subsystem, name, peer2, subsystem2, name2):
+        self.fulfilled = False
+        self.type = 'equalstatistics'
+        self.peer = peer;
+        self.subsystem = subsystem;
+        self.name = name;
+        self.result = -1;
+        self.peer2 = peer2;
+        self.subsystem2 = subsystem2;
+        self.name2 = name2;
+        self.result2 = -1;
+    def check(self):
+        if (self.fulfilled == False):
+            self.result = self.peer.get_statistics_value (self.subsystem, 
self.name);
+            self.result2 = self.peer2.get_statistics_value (self.subsystem2, 
self.name2);
+            if (str(self.result) == str(self.result2)):
+                self.fulfilled = True
+                return True
+            else:
+                return False
+        else:
+            return True
+    def evaluate (self, failed_only):
+        if (self.result == -1):
+            res = 'NaN'
+        else:
+            res = str(self.result)
+        if (self.result2 == -1):
+            res2 = 'NaN'
+        else:
+            res2 = str(self.result2)            
+        if (self.fulfilled == False):
+            fail = " FAIL!" 
+            op = " != "
+        else: 
+            fail = ""
+            op = " == "
+        if ((self.fulfilled == False) and (failed_only == True)):
+            print self.peer.id[:4] + " "  + self.subsystem.ljust(12) + " " + 
self.result +" " + self.peer2.id[:4] + " "  + self.subsystem2.ljust(12) + " " + 
self.result2 
+            #print self.peer.id[:4] + " " + str(self.type) + ' condition in 
subsystem "' + self.subsystem.ljust(12) +'" : "' + self.name.ljust(30) +'" : 
(expected/real value) ' + str(self.value) + op + res + fail
+        elif (failed_only == False): 
+            print self.peer.id[:4] + " "  + self.subsystem.ljust(12) + " " + 
self.result +" " + self.peer2.id[:4] + " "  + self.subsystem2.ljust(12) + " " + 
self.result2 
+        return self.fulfilled                    
         
 class Test:
     def __init__(self, testname, verbose):

Added: gnunet/src/integration-tests/test_integration_connection_value.py.in
===================================================================
--- gnunet/src/integration-tests/test_integration_connection_value.py.in        
                        (rev 0)
+++ gnunet/src/integration-tests/test_integration_connection_value.py.in        
2012-04-03 12:10:44 UTC (rev 20870)
@@ -0,0 +1,120 @@
+#!/usr/bin/python
+#    This file is part of GNUnet.
+#    (C) 2010 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
+#    by the Free Software Foundation; either version 2, or (at your
+#    option) any later version.
+#
+#    GNUnet is distributed in the hope that it will be useful, but
+#    WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#    General Public License for more details.
+#
+#    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.
+#
+# 
+#
+# This test starts 3 peers and expects bootstrap and a connected clique
+#
+# Conditions for successful exit:
+# Both peers have 1 connected peer in transport, core, topology, fs 
+
+import sys
+import os
+import subprocess
+import re
+import shutil
+import time
+import pexpect
+from gnunet_testing import Peer
+from gnunet_testing import Test
+from gnunet_testing import Check
+from gnunet_testing import Condition
+from gnunet_testing import * 
+ 
+
+#definitions
+
+testname = "test_integration_connection_value"
+verbose = True
+check_timeout = 30
+
+
+def cleanup ():
+       if os.name == "nt":
+           shutil.rmtree (os.path.join (os.getenv ("TEMP"), 
"gnunet-test-fs-py-ns"), True)
+           shutil.rmtree (os.path.join (os.getenv ("TEMP"), 
"c_no_nat_client"), True)
+       else:
+           shutil.rmtree ("/tmp/c_no_nat_client/", True)
+
+
+def success_cont (check):
+    global success 
+    success = True;
+
+def fail_cont (check):    
+    global success 
+    success= False;
+    check.evaluate(True)        
+
+
+def check_connect ():
+  check = Check (test)
+  check.add (EqualStatisticsCondition (client, 'transport', '# peers 
connected', client,  'core', '# neighbour entries allocated'))
+  
+#  while True ==  check.run_once (check_timeout, None, None):
+#      print "Yes"
+       
+  res = check.run_once (None, None)
+  print "RES " + str(res)
+
+# 
+# Test execution
+# 
+def run ():
+       global success
+       global test
+       global client
+
+       
+       success = False
+       
+       test = Test ('test_integration_connection_value', verbose)
+       
+       client = Peer(test, './confs/c_no_nat_client.conf');
+       client.start();
+       
+       if (client.started == True):
+           test.p ('Peers started, running check')
+           check_connect ()
+               
+       client.stop ()
+       
+       cleanup ()
+       
+       if (success == False):
+               print ('Test failed')
+               return False 
+       else:
+               return True
+
+    
+try:
+    run ()
+except (KeyboardInterrupt, SystemExit):    
+    print 'Test interrupted'
+    server.stop ()
+    client.stop ()
+    client2.stop ()
+    cleanup ()
+if (success == False):
+       sys.exit(1)   
+else:
+       sys.exit(0)    
+           
+


Property changes on: 
gnunet/src/integration-tests/test_integration_connection_value.py.in
___________________________________________________________________
Added: svn:executable
   + *




reply via email to

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