#---------------------------------------------------------------------------- # Project: Horizon # File: run-core_0_2.py # # Copyright (C)2009-2011 Nintendo Co., Ltd. All rights reserved. # # These coded instructions, statements, and computer programs contain # proprietary information of Nintendo of America Inc. and/or Nintendo # Company Ltd., and are protected by Federal copyright law. They may # not be disclosed to third parties or copied or duplicated in any form, # in whole or in part, without the prior written consent of Nintendo. # # $Rev: 38282 $ #---------------------------------------------------------------------------- # -*- coding: cp932 -*- import sys import os import os.path import popen2 import re import optparse Core0DebuggerName = "PARTNER-CTR/J_0" Core2DebuggerName = "PARTNER-CTR/J_2" Core0StopPattern = "(^((CU_TEST_EXIT)|(KernelPanic))|(Exception =+$))" Core2StopPattern = "Complete" ROOT = os.getenv("HORIZON_ROOT").replace("\\","/") Timeout = 30 WF = os.path.normpath(os.path.join(ROOT,"tools/CommandLineTools/wf.exe")) # partner_partner.rb PP = os.path.normpath(os.path.join(ROOT,"tools/CommandLineTools/partner_partner.rb")) def debuggers_available(): wfout, wfin = popen2.popen4("%s PARTNER" % WF) response = wfout.read() wfout.close() wfin.close() return Core0DebuggerName in response and Core2DebuggerName in response def run_partner(macro, debuggername, timeout, stoppattern): print "runpertner", 'ruby %s --input %s --window-title %s --timeout %d --stop-pattern "%s"' % (PP, macro, debuggername, timeout, stoppattern) ppout, ppin = popen2.popen4('ruby %s --input %s --window-title %s --timeout %d --stop-pattern "%s"' % (PP, macro, debuggername, timeout, stoppattern)) response = ppout.read() ppout.close() ppin.close() print response return response if __name__ == "__main__": opt = optparse.OptionParser() opt.add_option("--mcr_core0", dest="mcr_core0", metavar="PARTNERMACRO") opt.add_option("--mcr_core2", dest="mcr_core2", metavar="PARTNERMACRO") opt.add_option("--output", dest="output", metavar="OUTPUTFILE") opt.add_option("--stoppattern", dest="stoppattern", metavar="PATTERN") opt.add_option("--stoppattern_core2", dest="stoppattern_core2", metavar="PATTERN") options, args = opt.parse_args() if (options.mcr_core0 is None or options.mcr_core2 is None): opt.error("set mcr_core0,mcr_core2 args") if options.stoppattern != None: Core0StopPattern = options.stoppattern if options.stoppattern_core2 != None: Core2StopPattern = options.stoppattern_core2 if debuggers_available(): run_partner(options.mcr_core2.replace("\\","\\\\"), Core2DebuggerName, Timeout, Core2StopPattern) res = run_partner(options.mcr_core0.replace("\\","\\\\"), Core0DebuggerName, Timeout, Core0StopPattern) if options.output != None: f = file(options.output,"w") f.write(res) f.close() else: print "デバッガを発見できませんでした。" sys.exit(-1)