1#---------------------------------------------------------------------------- 2# Project: Horizon 3# File: run-core_0_2.py 4# 5# Copyright (C)2009-2011 Nintendo Co., Ltd. All rights reserved. 6# 7# These coded instructions, statements, and computer programs contain 8# proprietary information of Nintendo of America Inc. and/or Nintendo 9# Company Ltd., and are protected by Federal copyright law. They may 10# not be disclosed to third parties or copied or duplicated in any form, 11# in whole or in part, without the prior written consent of Nintendo. 12# 13# $Rev: 38282 $ 14#---------------------------------------------------------------------------- 15# -*- coding: cp932 -*- 16import sys 17import os 18import os.path 19import popen2 20import re 21import optparse 22 23Core0DebuggerName = "PARTNER-CTR/J_0" 24Core2DebuggerName = "PARTNER-CTR/J_2" 25 26Core0StopPattern = "(^((CU_TEST_EXIT)|(KernelPanic))|(Exception =+$))" 27Core2StopPattern = "Complete" 28 29ROOT = os.getenv("HORIZON_ROOT").replace("\\","/") 30 31Timeout = 30 32 33WF = os.path.normpath(os.path.join(ROOT,"tools/CommandLineTools/wf.exe")) 34 35# partner_partner.rb 36PP = os.path.normpath(os.path.join(ROOT,"tools/CommandLineTools/partner_partner.rb")) 37 38def debuggers_available(): 39 wfout, wfin = popen2.popen4("%s PARTNER" % WF) 40 response = wfout.read() 41 wfout.close() 42 wfin.close() 43 return Core0DebuggerName in response and Core2DebuggerName in response 44 45def run_partner(macro, debuggername, timeout, stoppattern): 46 print "runpertner", 'ruby %s --input %s --window-title %s --timeout %d --stop-pattern "%s"' % (PP, macro, debuggername, timeout, stoppattern) 47 ppout, ppin = popen2.popen4('ruby %s --input %s --window-title %s --timeout %d --stop-pattern "%s"' % (PP, macro, debuggername, timeout, stoppattern)) 48 response = ppout.read() 49 ppout.close() 50 ppin.close() 51 print response 52 return response 53 54if __name__ == "__main__": 55 opt = optparse.OptionParser() 56 opt.add_option("--mcr_core0", dest="mcr_core0", metavar="PARTNERMACRO") 57 opt.add_option("--mcr_core2", dest="mcr_core2", metavar="PARTNERMACRO") 58 opt.add_option("--output", dest="output", metavar="OUTPUTFILE") 59 opt.add_option("--stoppattern", dest="stoppattern", metavar="PATTERN") 60 opt.add_option("--stoppattern_core2", dest="stoppattern_core2", metavar="PATTERN") 61 62 options, args = opt.parse_args() 63 64 if (options.mcr_core0 is None or 65 options.mcr_core2 is None): 66 opt.error("set mcr_core0,mcr_core2 args") 67 68 if options.stoppattern != None: 69 Core0StopPattern = options.stoppattern 70 71 if options.stoppattern_core2 != None: 72 Core2StopPattern = options.stoppattern_core2 73 74 if debuggers_available(): 75 run_partner(options.mcr_core2.replace("\\","\\\\"), 76 Core2DebuggerName, 77 Timeout, 78 Core2StopPattern) 79 res = run_partner(options.mcr_core0.replace("\\","\\\\"), 80 Core0DebuggerName, 81 Timeout, 82 Core0StopPattern) 83 if options.output != None: 84 f = file(options.output,"w") 85 f.write(res) 86 f.close() 87 88 else: 89 print "�f�o�b�K���ł��܂���ł����B" 90 sys.exit(-1) 91 92