1# -*- coding: cp932 -*- 2import sys 3import os 4import os.path 5import popen2 6import re 7import optparse 8 9Core0DebuggerName = "PARTNER-CTR/J_0" 10Core2DebuggerName = "PARTNER-CTR/J_2" 11 12Core0StopPattern = "(^((CU_TEST_EXIT)|(KernelPanic))|(Exception =+$))" 13Core2StopPattern = "Complete" 14 15ROOT = os.getenv("HORIZON_ROOT").replace("\\","/") 16 17Timeout = 30 18 19WF = os.path.normpath(os.path.join(ROOT,"tools/CommandLineTools/wf.exe")) 20 21# partner_partner.rb 22PP = os.path.normpath(os.path.join(ROOT,"tools/CommandLineTools/partner_partner.rb")) 23 24def debuggers_available(): 25 wfout, wfin = popen2.popen4("%s PARTNER" % WF) 26 response = wfout.read() 27 wfout.close() 28 wfin.close() 29 return Core0DebuggerName in response and Core2DebuggerName in response 30 31def run_partner(macro, debuggername, timeout, stoppattern): 32 print "runpertner", 'ruby %s --input %s --window-title %s --timeout %d --stop-pattern "%s"' % (PP, macro, debuggername, timeout, stoppattern) 33 ppout, ppin = popen2.popen4('ruby %s --input %s --window-title %s --timeout %d --stop-pattern "%s"' % (PP, macro, debuggername, timeout, stoppattern)) 34 response = ppout.read() 35 ppout.close() 36 ppin.close() 37 print response 38 return response 39 40if __name__ == "__main__": 41 opt = optparse.OptionParser() 42 opt.add_option("--mcr_core0", dest="mcr_core0", metavar="PARTNERMACRO") 43 opt.add_option("--mcr_core2", dest="mcr_core2", metavar="PARTNERMACRO") 44 opt.add_option("--output", dest="output", metavar="OUTPUTFILE") 45 opt.add_option("--stoppattern", dest="stoppattern", metavar="PATTERN") 46 opt.add_option("--stoppattern_core2", dest="stoppattern_core2", metavar="PATTERN") 47 48 options, args = opt.parse_args() 49 50 if (options.mcr_core0 is None or 51 options.mcr_core2 is None): 52 opt.error("set mcr_core0,mcr_core2 args") 53 54 if options.stoppattern != None: 55 Core0StopPattern = options.stoppattern 56 57 if options.stoppattern_core2 != None: 58 Core2StopPattern = options.stoppattern_core2 59 60 if debuggers_available(): 61 run_partner(options.mcr_core2.replace("\\","\\\\"), 62 Core2DebuggerName, 63 Timeout, 64 Core2StopPattern) 65 res = run_partner(options.mcr_core0.replace("\\","\\\\"), 66 Core0DebuggerName, 67 Timeout, 68 Core0StopPattern) 69 if options.output != None: 70 f = file(options.output,"w") 71 f.write(res) 72 f.close() 73 74 else: 75 print "�f�o�b�K���ł��܂���ł����B" 76 sys.exit(-1) 77 78