dbrtools/dbr/smoketest.py
branchDBRToolsDev
changeset 283 398d483e91bb
equal deleted inserted replaced
245:fd0a8d235c70 283:398d483e91bb
       
     1 # Copyright (c) 2009 Symbian Foundation Ltd
       
     2 # This component and the accompanying materials are made available
       
     3 # under the terms of the License "Eclipse Public License v1.0"
       
     4 # which accompanies this distribution, and is available
       
     5 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     6 #
       
     7 # Initial Contributors:
       
     8 # Symbian Foundation Ltd - initial contribution.
       
     9 #
       
    10 # Contributors:
       
    11 # mattd <mattd@symbian.org>
       
    12 #
       
    13 # Description:
       
    14 # DBR help - displays the DBR help
       
    15 
       
    16 import sys
       
    17 import os
       
    18 import re
       
    19 
       
    20 
       
    21 def main():
       
    22   args = sys.argv
       
    23   run(args)
       
    24 
       
    25 def run(args):
       
    26   if(len(args)):
       
    27     for module in args:
       
    28       dosmoketest(module)
       
    29   else:
       
    30     print sys.argv[0]
       
    31     modules = os.listdir(os.path.join(os.path.dirname(sys.argv[0]),'dbr'))
       
    32     for module in sorted(modules):
       
    33       modname = re.match('(.+)\.py$',module)
       
    34       if(modname):
       
    35         module = modname.group(1)
       
    36         dosmoketest(module)
       
    37     
       
    38 
       
    39 def dosmoketest(module):
       
    40   print "\nTesting %s:" % module
       
    41   try:
       
    42     tool = __import__(module)
       
    43     tool.smoketest()
       
    44   except ImportError:
       
    45     print "Error: Could not load %s" % module
       
    46   except AttributeError:
       
    47     print "Warning: No Smoketest found in %s" % module
       
    48   except SyntaxError:
       
    49     print "Error: Syntax error in %s" % module
       
    50   except NameError:
       
    51     print "Error: Name error in %s" % module
       
    52   
       
    53 
       
    54 def help():
       
    55   print "Usage:"
       
    56   print "\tdbr smoketest\t- runs the smoketests"
       
    57 
       
    58 def summary():
       
    59   return "Runs smoketests"