| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# run_qmtest.py

Go to the documentation of this file.

    00001 #!/usr/bin/env python
    00002 #
    00003 # Small wrapper script to simplify the execution of QMTest tests.
    00004 #
    00005 # @author: Marco Clemencic <marco.clemencic@cern.ch>
    00006 # @date: 22/10/2007
    00007 #
    00008 import os, sys
    00009
    00010 package = "Unknown"
    00011 qmtest_args = []
    00012 have_user_options = False
    00013 if len(sys.argv) > 1:
    00014     package = sys.argv[1]
    00015     if len(sys.argv) > 2:
    00016         qmtest_args = sys.argv[2:]
    00017         have_user_options = True
    00018
    00019 print "==========> Running tests for package %s"%package
    00020
    00021 qmtest_dir = os.path.normpath(os.path.expandvars(os.environ["QMTESTLOCALDIR"]))
    00022
    00023 # check if the user specified a different output file
    00024 output_pos = -1
    00025 for i in range(len(qmtest_args)):
    00026     if qmtest_args[i] in ['-o','--output']:
    00027         output_pos = i + 1
    00028         break
    00029 if output_pos != -1:
    00030     if output_pos < len(qmtest_args):
    00031         # make the path absolute
    00032         qmtest_args[output_pos] = os.path.realpath(qmtest_args[output_pos])
    00033 else:
    00034     # otherwise add the default
    00035     qmtest_results = os.path.normpath(os.path.expandvars(os.environ["QMTESTRESULTS"]))
    00036     qmtest_args = ["-o",qmtest_results] + qmtest_args
    00037     # create the destination directory if necessary
    00038     results_dest_dir = os.path.realpath(os.path.join(qmtest_dir, os.path.dirname(qmtest_results)))
    00039     if not os.path.exists(results_dest_dir):
    00040         print "==========> Creating '%s'" % results_dest_dir
    00041         os.makedirs(results_dest_dir, 0755)
    00042
    00043 cmd = "qmtest run %s"%(" ".join(qmtest_args))
    00044
    00045 print "==========> Entering '%s'"%qmtest_dir
    00046 os.chdir(qmtest_dir)
    00047
    00048 if not os.path.isdir("QMTest"):
    00049     # The QMTest database is not initialized
    00050     print "==========> Initializing QMTest database"
    00051     os.system("qmtest create-tdb")
    00052
    00053 # check if we have a test suite called as the package
    00054 if not have_user_options and os.path.exists("%s.qms"%package.lower()):
    00055     cmd += " %s"%package.lower()
    00056
    00057 print "==========> Running '%s'"%cmd
    00058 os.system(cmd)
    00059 # Note: the return code od qmtest is not propagated to aviod that
    00060 #       CMT stops if we have a non-PASS tests (e.g. UNTESTED).