[LTP] [Patch 5/10]CPU consolidation testcase updated to handle exceptions

Poornima Nayak
2009-06-30T14:58:13Z

[Patch 5/10]CPU consolidation testcase updated to handle exceptions

Signed-off-by: poornima nayak <mpnayak@linux.vnet.ibm.com>

diff -uprN ltp_orig/testcases/kernel/power_management/cpu_consolidation.py ltp_patched/testcases/kernel/power_management/cpu_consolidation.py
--- ltp_orig/testcases/kernel/power_management/cpu_consolidation.py 2009-06-30 15:04:19.000000000 +0530
+++ ltp_patched/testcases/kernel/power_management/cpu_consolidation.py 2009-06-30 15:21:42.000000000 +0530
@@ -12,42 +12,47 @@ from sched_mc import *

__author__ = "Poornima Nayak <mpnayak@linux.vnet.ibm.com>"

-# Run test based on the command line arguments
-if __name__ == "__main__":
+class Usage(Exception):
+ def __init__(self, msg):
+ self.msg = msg
+
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv
+
usage = "-w"
parser = OptionParser(usage)
parser.add_option("-c", "--mc_level", dest="mc_level",
- help="Sched mc power saving value 0/1/2")
+ default=0, help="Sched mc power saving value 0/1/2")
parser.add_option("-t", "--smt_level", dest="smt_level",
default=0, help="Sched smt power saving value 0/1/2")
+ parser.add_option("-w", "--workload", dest="work_ld",
+ default="ebizzy", help="Workload can be ebizzy/kernbench")
+ parser.add_option("-s", "--stress", dest="stress",
+ default="partial", help="Load on system is full/partial [i.e 50%]/thread")
(options, args) = parser.parse_args()
- test_thread_consld = 0
-

try:
- set_sched_mc_power(options.mc_level)
count_num_cpu()
+ count_num_sockets()
+ if is_multi_socket():
+ set_sched_mc_power(options.mc_level)
+ if is_hyper_threaded():
+ set_sched_smt_power(options.smt_level)
map_cpuid_pkgid()
print "INFO: Created table mapping cpu to package"
-
- if int(options.smt_level) == 1 or int(options.smt_level) == 2 :
- if is_hyper_threaded():
- set_sched_smt_power(options.smt_level)
- # Trigger ebizzy with 2 threads only to verify logical CPU
- # consolidation
- test_thread_consld = 1
- trigger_workld(options.mc_level, test_thread_consld)
- generate_report()
- validate_cpu_consolidation(options.mc_level, options.smt_level)
- test_thread_consld = 0
- else:
- print "INFO: No Hyper-threading support in this machine"
- sys.exit(0)
-
- trigger_workld(options.mc_level, test_thread_consld)
+ background="no"
+ duration=60
+ trigger_workld(options.work_ld, options.stress, duration, background)
generate_report()
- validate_cpu_consolidation(options.mc_level, options.smt_level)
- sys.exit(0)
+ status = validate_cpu_consolidation(options.mc_level, options.smt_level)
+ reset_schedmc()
+ if is_hyper_threaded():
+ reset_schedsmt()
+ return(status)
except Exception, details:
- print "INFO(: CPU consolidation failed", details
- sys.exit(1)
+ print "INFO: CPU consolidation failed", details
+ return(1)
+
+if __name__ == "__main__":
+ sys.exit(main())