# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1208226308 -28800
# Node ID a22ea10d1e46adfcd2e878328c1746b5c618230b
# Parent 137e5079c73fcbfc70e6654cee0b3c3eb3c6acd2
[TEST] #2 Add -d to duplicate error output to stderr
This gives us the capability to output the error messages to screen.
.#2:
- Added a temp work around to avoid duplicated logging to file.
- Update some indent (8 spaces -> 4 spaces, line cut, commenting)
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r 137e5079c73f -r a22ea10d1e46 lib/CimTest/Globals.py
--- a/lib/CimTest/Globals.py Fri Apr 11 16:58:23 2008 +0530
+++ b/lib/CimTest/Globals.py Tue Apr 15 10:25:08 2008 +0800
@@ -68,6 +68,8 @@ parser.add_option("-v", "--virt", dest="
parser.add_option("-v", "--virt", dest="virt",
type="choice",
choices=platform_sup, default="Xen",
help="Virt type, select from: 'Xen' & 'KVM'
& 'XenFV', default: Xen")
+parser.add_option("-d", "--debug-output",
action="store_true", dest="debug",
+ help="Duplicate the output to stderr")
if not CIM_NS:
CIM_NS = "root/cimv2"
@@ -85,29 +87,42 @@ if not CIM_IP:
if not CIM_IP:
CIM_IP = "localhost"
-def log_param():
+def log_param(debug=None):
+ #FIXME debug=None is a temporary work around to avoid duplicate
+ # logging in vsmtest.log because we have log_param in both the
+ # do_main decorator and the test case's main function.
+ # We can safely delete the if branch here after all test cases
+ # have removed the log_param invoke.
+ if debug == None:
+ return
+ else:
logger.setLevel(logging.DEBUG)
-#create console handler and set level to debug
+ #create console handler and set level to debug
ch = logging.StreamHandler()
- ch.setLevel(int(CIM_LEVEL))
-#create file handler and set level to debug
+ if debug:
+ ch.setLevel(logging.ERROR)
+ else:
+ ch.setLevel(int(CIM_LEVEL))
+ #create file handler and set level to debug
fh = logging.FileHandler("vsmtest.log")
fh.setLevel(logging.DEBUG)
-#create formatter
- formatter = logging.Formatter("%(asctime)s:%(name)s:%(levelname)s \
-\t- %(message)s", datefmt="%a, %d %b %Y %H:%M:%S")
-#add formatter to handlers
+ #create formatter
+ formatter = logging.Formatter(\
+ "%(asctime)s:%(name)s:%(levelname)s \t- %(message)s",
+ datefmt="%a, %d %b %Y %H:%M:%S")
+ #add formatter to handlers
fh.setFormatter(formatter)
+ formatter = logging.Formatter("%(levelname)s \t- %(message)s")
ch.setFormatter(formatter)
-#add handlers to logger
+ #add handlers to logger
logger.addHandler(fh)
logger.addHandler(ch)
-#Print header
+ #Print header
logger.info("====%s Log====", CIM_TC)
def log_bug(bug_num):
- logger.info("Known Bug:%s" % bug_num)
- print "Bug:<%s>" % bug_num
+ logger.info("Known Bug:%s" % bug_num)
+ print "Bug:<%s>" % bug_num
def do_main(types=['Xen'], p=parser):
def do_type(f):
@@ -119,6 +134,7 @@ def do_main(types=['Xen'], p=parser):
else:
def do_try():
try:
+ log_param(options.debug)
from VirtLib.utils import setup_ssh_key
from XenKvmLib.test_doms import destroy_and_undefine_all
setup_ssh_key()
diff -r 137e5079c73f -r a22ea10d1e46 suites/libvirt-cim/main.py
--- a/suites/libvirt-cim/main.py Fri Apr 11 16:58:23 2008 +0530
+++ b/suites/libvirt-cim/main.py Tue Apr 15 10:25:08 2008 +0800
@@ -49,6 +49,8 @@ parser.add_option("-v", "--virt", dest="
parser.add_option("-v", "--virt", dest="virt",
type="choice",
choices=platform_sup, default="Xen",
help="Virt type, select from 'Xen' & 'KVM'
& 'XenFV'(default: Xen). ")
+parser.add_option("-d", "--debug-output",
action="store_true", dest="debug",
+ help="Duplicate the output to stderr")
TEST_SUITE = 'cimtest'
@@ -110,14 +112,19 @@ def main():
if options.clean:
remove_old_logs(options.group)
+ if options.debug:
+ dbg = "-d"
+ else:
+ dbg = ""
+
print "Testing " + options.virt + " hypervisor"
for test in test_list:
t_path = os.path.join(TEST_SUITE, test['group'])
os.environ['CIM_TC'] = test['test']
- cmd = "cd %s && python %s -i %s -v %s" % \
- (t_path, test['test'], options.ip, options.virt)
+ cmd = "cd %s && python %s -i %s -v %s %s" % \
+ (t_path, test['test'], options.ip, options.virt, dbg)
status, output = commands.getstatusoutput(cmd)
os_status = os.WEXITSTATUS(status)