first step towards using testbox properly
[tests.git] / system / TestMain.py
index b06f14a..576e8bb 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # $Id$
 
-import os, sys
+import sys, os, os.path
 from optparse import OptionParser
 import traceback
 
@@ -23,22 +23,25 @@ class TestMain:
                      'bootcd', 'nodegroups', 
                      'kill_all_qemus', 'start_nodes', 
                      'standby_4', 'nodes_booted',
-                     'standby_6','nodes_ssh', 'check_slices',
-                     'check_tcp' ]
+                     'standby_6','nodes_ssh', 'check_slices','check_initscripts',
+                     'check_tcp',
+                     'kill_qemus', ]
     other_steps = [ 'fresh_install', 'stop', 
                     'clean_sites', 'clean_nodes', 'clean_slices', 'clean_keys',
-                    'kill_qemus', 'stop_nodes' ,  'db_dump' , 'db_restore',
+                    'list_all_qemus', 'kill_qemus', 'stop_nodes' ,  
+                    'db_dump' , 'db_restore',
                     'standby_1 through 20',
                     ]
     default_build_url = "http://svn.planet-lab.org/svn/build/trunk"
 
     def __init__ (self):
        self.path=os.path.dirname(sys.argv[0])
+        os.chdir(self.path)
 
     @staticmethod
     def show_env (options, message):
         utils.header (message)
-        utils.show_spec("main options",options)
+        utils.pprint("main options",options)
 
     @staticmethod
     def optparse_list (option, opt, value, parser):
@@ -106,12 +109,14 @@ steps refer to a method in TestPlc or to a step_* module
             self.options.steps = self.args
 
         # handle defaults and option persistence
-        for (recname,filename,default) in ( ('myplc_url','arg-myplc-url',"") , 
-                                            ('build_url','arg-build-url',TestMain.default_build_url) ,
-                                            ('ips','arg-ips',[]) , 
-                                            ('config','arg-config',TestMain.default_config) , ) :
-            print 'handling',recname
-            path="%s/%s"%(self.path,filename)
+        for (recname,filename,default) in (
+            ('build_url','arg-build-url',TestMain.default_build_url) ,
+            ('ips','arg-ips',[]) , 
+            ('config','arg-config',TestMain.default_config) , 
+            ('myplc_url','arg-myplc-url',"") , 
+            ) :
+#            print 'handling',recname
+            path=filename
             is_list = isinstance(default,list)
             if not getattr(self.options,recname):
                 try:
@@ -141,7 +146,7 @@ steps refer to a method in TestPlc or to a step_* module
                 for value in getattr(self.options,recname):
                     fsave.write(value + "\n")
             fsave.close()
-            utils.header('Saved %s into %s'%(recname,filename))
+#            utils.header('Saved %s into %s'%(recname,filename))
 
         # steps
         if not self.options.steps:
@@ -151,6 +156,8 @@ steps refer to a method in TestPlc or to a step_* module
 
         # store self.path in options.path for the various callbacks
         self.options.path = self.path
+        # this is useful when propagating on host boxes, to avoid conflicts
+        self.options.buildname = os.path.basename (os.path.abspath (self.path))
 
         if self.options.verbose:
             self.show_env(self.options,"Verbose")
@@ -167,11 +174,14 @@ steps refer to a method in TestPlc or to a step_* module
                 print 'Cannot load config %s -- ignored'%modulename
                 raise
         # show config
-        utils.show_spec("Test specifications",all_plc_specs)
+        utils.show_test_spec("Test specifications",all_plc_specs)
         # build a TestPlc object from the result
         for spec in all_plc_specs:
             spec['disabled'] = False
         all_plcs = [ (x, TestPlc(x)) for x in all_plc_specs]
+        # expose to the various objects
+        for (spec,obj) in all_plcs:
+            obj.options=self.options
 
         overall_result = True
         testplc_method_dict = __import__("TestPlc").__dict__['TestPlc'].__dict__