# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1207811341 -28800
# Node ID 28d173f24fb60cbbe230b7a67de97cb26aaa95dc
# Parent 19ff9c851ed8cb76b74d158a4c439dfa5f4ccb50
[TEST] Add -d to duplicate error output to stderr
This gives us the capability to output the error messages to screen.
The default value is set to false, where error messages will only
be saved in the 'vsmtest.log' file.
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r 19ff9c851ed8 -r 28d173f24fb6 lib/CimTest/Globals.py
--- a/lib/CimTest/Globals.py Wed Apr 09 18:00:14 2008 +0530
+++ b/lib/CimTest/Globals.py Thu Apr 10 15:09:01 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="Print the output to stderr")
if not CIM_NS:
CIM_NS = "root/cimv2"
@@ -85,11 +87,14 @@ if not CIM_IP:
if not CIM_IP:
CIM_IP = "localhost"
-def log_param():
+def log_param(debug=False):
logger.setLevel(logging.DEBUG)
#create console handler and set level to debug
ch = logging.StreamHandler()
- ch.setLevel(int(CIM_LEVEL))
+ 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)
@@ -98,6 +103,7 @@ def log_param():
\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
logger.addHandler(fh)
@@ -119,6 +125,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 19ff9c851ed8 -r 28d173f24fb6 suites/libvirt-cim/main.py
--- a/suites/libvirt-cim/main.py Wed Apr 09 18:00:14 2008 +0530
+++ b/suites/libvirt-cim/main.py Thu Apr 10 15:09:01 2008 +0800
@@ -49,6 +49,9 @@ 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="Print the output to stderr")
+
TEST_SUITE = 'cimtest'
@@ -110,14 +113,19 @@ def main():
if options.clean:
remove_old_logs(options.group)
+ if options.debug:
+ debug_param = "-d"
+ else:
+ debug_param = ""
+
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, debug_param)
status, output = commands.getstatusoutput(cmd)
os_status = os.WEXITSTATUS(status)