def writeCommand(aCmd, aMatchData, aParams, aHeaderTemplate, aSourceTemplate, aHeaderPath, aSourcePath): # separate by , matchParams = re.split(r'[^a-zA-Z_0-9\*]+', aMatchData); # Make template values c = {'COMMAND': aCmd, # plain command name 'CLASSNAME': 'C' + aCmd + 'Command', #CaCmd 'FILENAME': aCmd.lower() + 'command', # acmd 'HEADERGUARD': aCmd.upper() + 'COMMAND', # ACMD 'PARAMETERS': makeParameters(aParams), # aParam1, aParam2 'MEMBERS': makeMembers(aParams), # iParam1; iParam2 'NEWL_DEFINITIONS': makeNewLDefinitions(aParams, aCmd + 'Command'), # NewL($PARAMETERS) 'NEWL_IMPLEMENTATIONS': makeNewLImplementations(aParams, aCmd + 'Command'), 'CONSTRUCTOR_DEFINITIONS': makeConstructorDefinitions(aParams, aCmd + 'Command'), 'CONSTRUCTOR_IMPLEMENTATIONS': makeConstructorImplementations(aParams, aCmd, matchParams), # Don't add 'Command', aCmd is used to build K...Opcode 'DESTRUCTOR_IMPLEMENTATION': makeDestructorImplementation(aParams), 'WRITE_FRAME': makeWriteFrame(aParams), 'COMMANDFRAME': makeCommandFrame(aParams), 'MEMBER_ASSIGNMENT': makeMemberAssignment(aParams), 'ACCESSOR_DEFINITIONS': makeAccessorDefinitions(aParams), 'ACCESSOR_IMPLEMENTATIONS': makeAccessorImplementations(aParams, 'C' + aCmd + 'Command'), 'EVENT_MATCH_DEFINITIONS': makeEventMatchDefinitions(matchParams), 'EVENT_MATCH_IMPLEMENTATIONS': makeEventMatchImplementations(matchParams, aCmd), 'EVENT_MATCH_INCLUDES': makeEventMatchIncludes(matchParams), 'PRAGMA_HW_VOICE_SETTING_ADVICE': makePragmaHwVoiceSettingAdvice(aCmd), 'GENERATE_TIME_STAMP': strftime("%a, %d %b %Y %H:%M:%S") + ' (time stamp)'} # (time stamp) is needed for preventing unneccesary submissions. # Fill in template #file(aHeaderPath + '\\' + c['FILENAME'] + '.h', 'w+').write(aHeaderTemplate.substitute(c)) #file(aSourcePath + '\\' + c['FILENAME'] + '.cpp', 'w+').write(aSourceTemplate.substitute(c)) doTimeStampCompareAndWrite(aHeaderPath + '\\' + c['FILENAME'] + '.h', aHeaderTemplate.substitute(c)) doTimeStampCompareAndWrite(aSourcePath + '\\' + c['FILENAME'] + '.cpp', aSourceTemplate.substitute(c))
def writeCompleteEventTestStep(aEvent, aParams, aHeaderTemplate, aSourceTemplate, aPath): eve = { 'FILENAME': aEvent.lower() + 'completeeventstep', 'CLASSNAME': 'C' + aEvent + 'CompleteEventStep', 'HEADERGUARD': aEvent.upper() + 'COMPLETEEVENTSTEP', 'EVENTNAME': 'T' + aEvent + 'CompleteEvent', 'EVENTFILENAME': aEvent.lower() + 'completeevent', 'EVENTCODE': 'ECommandCompleteEvent', 'EVENTPARAMS': makeEventParams(aParams), 'CHECK_EVENT_ACCESSORS': makeEventMinAccessors(aParams, 'event'), 'TESTSTEPNAME': aEvent + 'CompleteEventStep', 'EVENTINITPARAMS': makeCompleteEventInitMinParams('ECommandCompleteEvent', 'K' + aEvent + 'Opcode', aParams), 'GENERATE_TIME_STAMP': strftime("%a, %d %b %Y %H:%M:%S") + ' (time stamp)' } #file(aPath + '\\' + eve['FILENAME'] + '.h', 'w+').write(aHeaderTemplate.substitute(eve)) #file(aPath + '\\' + eve['FILENAME'] + '.cpp', 'w+').write(aSourceTemplate.substitute(eve)) doTimeStampCompareAndWrite(aPath + '\\' + eve['FILENAME'] + '.h', aHeaderTemplate.substitute(eve)) doTimeStampCompareAndWrite(aPath + '\\' + eve['FILENAME'] + '.cpp', aSourceTemplate.substitute(eve))
def writeTestServer(aName, aHeaderTemplate, aSourceTemplate, aScriptTemplate, aTestSteps, aPath): cfg = ConfigParser.ConfigParser() cfg.readfp(file(aTestSteps)) steps = makeTestSteps(cfg, cfg.sections()) src = {'CREATE_TEST_STEP_IMPL': makeCreateTestStepImpl(steps), 'TEST_STEP_HEADERS': makeTestStepHeaders(steps), 'SERVERNAME': aName, 'CLASSNAME': 'C' + aName, 'FILENAME': aName.lower(), 'HEADERGUARD': aName.upper(), 'GENERATE_TIME_STAMP': strftime("%a, %d %b %Y %H:%M:%S") + ' (time stamp)'} hdr = {'CLASSNAME': 'C' + aName, 'FILENAME': aName.lower(), 'HEADERGUARD': aName.upper(), 'GENERATE_TIME_STAMP': strftime("%a, %d %b %Y %H:%M:%S") + ' (time stamp)'} #file(aPath + '\\' + hdr['FILENAME'] + '.h', 'w+').write(aHeaderTemplate.substitute(hdr)) #file(aPath + '\\' + src['FILENAME'] + '.cpp', 'w+').write(aSourceTemplate.substitute(src)) doTimeStampCompareAndWrite(aPath + '\\' + hdr['FILENAME'] + '.h', aHeaderTemplate.substitute(hdr)) doTimeStampCompareAndWrite(aPath + '\\' + src['FILENAME'] + '.cpp', aSourceTemplate.substitute(src)) writeTestScripts(aName, aScriptTemplate, steps, aPath)
def writeMMPFile(aIni, aTemplate, aDst): t = {'FILENAME': aDst.lower(), 'SOURCES': makeSources(aIni), 'GENERATE_TIME_STAMP': strftime("%a, %d %b %Y %H:%M:%S") + ' (time stamp)'} #file(aDst.lower(), 'w+').write(aTemplate.substitute(t)) doTimeStampCompareAndWrite(aDst.lower(), aTemplate.substitute(t))
def writeEvent(aEvent, aParams, aHeaderTemplate, aSourceTemplate, aHeaderPath, aSourcePath): c = { "EVENT": aEvent, "CLASSNAME": "T" + aEvent + "Event", "FILENAME": aEvent.lower() + "event", "HEADERGUARD": aEvent.upper() + "EVENT", "EVENTCODE": "E" + aEvent + "Event", "ACCESSOR_DEFINITION": makeAccessorDef(aParams), "ACCESSOR_IMPLEMENTATION": makeAccessorImpl(aEvent + "Event", aParams), "GENERATE_TIME_STAMP": strftime("%a, %d %b %Y %H:%M:%S") + " (time stamp)", } if hasStatus(aParams): c["PARAMETERS"] = "THCIErrorCode aErrorCode, const TDesC8& aEventData" c["CONSTRUCTOR_PARAMETERS"] = "aErrorCode, aEventData" else: c["PARAMETERS"] = "const TDesC8& aEventData" c["CONSTRUCTOR_PARAMETERS"] = "EOK, aEventData" c["FAKERPARAMETERS"] = makeFakingParameters(aParams, False) c["FAKER_PARAMETER_TOTAL_LENGTH"] = makeParameterTotalLengthValue(aParams, False) c["FAKERSETERRORCODEBYPARAM"] = makeEventSetErrorCode(aParams, True, eventPreHeaderBytes()) c["EVENTSETERRORCODEBYEXTRACT"] = makeEventSetErrorCode(aParams, False, eventPreHeaderBytes()) c["FAKERWRITE_IMPLEMENTATION"] = makeFakingWriteImplementation(aParams, False) # file(aHeaderPath + '\\' + c['FILENAME'] + '.h', 'w+').write(aHeaderTemplate.substitute(c)) # file(aSourcePath + '\\' + c['FILENAME'] + '.cpp', 'w+').write(aSourceTemplate.substitute(c)) doTimeStampCompareAndWrite(aHeaderPath + "\\" + c["FILENAME"] + ".h", aHeaderTemplate.substitute(c)) doTimeStampCompareAndWrite(aSourcePath + "\\" + c["FILENAME"] + ".cpp", aSourceTemplate.substitute(c))
def writeTestScripts(aName, aScriptTemplate, aTestSteps, aPath): script = {'FILENAME': aName.lower(), 'TESTSERVERNAME': aName, 'TESTS': makeTests(aName, aTestSteps), 'GENERATE_TIME_STAMP': strftime("%a, %d %b %Y %H:%M:%S") + ' (time stamp)'} #file(aPath + '\\' + script['FILENAME'] + '.script', 'w+').write(aScriptTemplate.substitute(script)) doTimeStampCompareAndWrite(aPath + '\\' + script['FILENAME'] + '.script', aScriptTemplate.substitute(script))
def writeMMPFile(aIni, aTemplate, aDst): t = { 'FILENAME': aDst.lower(), 'SOURCES': makeSources(aIni), 'GENERATE_TIME_STAMP': strftime("%a, %d %b %Y %H:%M:%S") + ' (time stamp)' } #file(aDst.lower(), 'w+').write(aTemplate.substitute(t)) doTimeStampCompareAndWrite(aDst.lower(), aTemplate.substitute(t))
def writeCommandTestStep(aCmd, aMatchData, aParams, aHeaderTemplate, aSourceTemplate, aPath): matchParams = re.split(r'[^a-zA-Z_0-9\*]+', aMatchData) cmd = { 'FILENAME': aCmd.lower() + 'commandstep', 'CLASSNAME': 'C' + aCmd + 'CommandStep', 'HEADERGUARD': aCmd.upper() + 'COMMANDSTEP', 'CMDNAME': 'C' + aCmd + 'Command', 'CMDFILENAME': aCmd.lower() + 'command', 'MAXPARAMETERS': makeMaxParameters(aParams), 'CMDOPCODE': 'K' + aCmd + 'Opcode', 'CHECK_MAX_ACCESSORS': makeCommandMaxAccessors(aParams, 'cmd'), 'FRAMEDATA': makeMaxData(aParams), 'MINPARAMETERS': makeMinParameters(aParams), 'CHECK_MIN_ACCESSORS': makeCommandMinAccessors(aParams, 'cmd'), 'TESTSTEPNAME': aCmd + 'CommandStep', 'CMDINITMAXPARAMS': makeCommandInitMaxParams(aParams), 'CMDINITMINPARAMS': makeCommandInitMinParams(aParams), 'MATCH_COMPLETE_EVENT': makeMatchCompleteEevnt('K' + aCmd + 'Opcode'), 'MATCH_STATUS_EVENT': makeMatchStatusEevnt('K' + aCmd + 'Opcode'), 'MATCH_PROPRIETARY_EVENT': makeMatchProprietaryEevnts('K' + aCmd + 'Opcode', matchParams), 'MATCH_EMPTY_EVENT': makeMatchEmptyEevnt('K' + aCmd + 'Opcode'), 'GENERATE_TIME_STAMP': strftime("%a, %d %b %Y %H:%M:%S") + ' (time stamp)' } #file(aPath + '\\' + cmd['FILENAME'] + '.h', 'w+').write(aHeaderTemplate.substitute(cmd)) #file(aPath + '\\' + cmd['FILENAME'] + '.cpp', 'w+').write(aSourceTemplate.substitute(cmd)) doTimeStampCompareAndWrite(aPath + '\\' + cmd['FILENAME'] + '.h', aHeaderTemplate.substitute(cmd)) doTimeStampCompareAndWrite(aPath + '\\' + cmd['FILENAME'] + '.cpp', aSourceTemplate.substitute(cmd))
def writeCompleteEvent(aCmd, aParams, aHeaderTemplate, aSourceTemplate, aHeaderPath, aSourcePath): c = { 'COMMAND': aCmd, 'CLASSNAME': 'T' + aCmd + 'CompleteEvent', 'FILENAME': aCmd.lower() + 'completeevent', 'HEADERGUARD': aCmd.upper() + 'COMPLETEEVENT', 'OPCODE': 'K' + aCmd + 'Opcode', 'PARAMETERS': 'THCIErrorCode aErrorCode, const TDesC8& aEventData', 'CONSTRUCTOR_PARAMETERS': 'aErrorCode, aEventData', 'ACCESSOR_DEFINITION': makeAccessorDef(aParams), 'ACCESSOR_IMPLEMENTATION': makeAccessorImpl(aCmd + 'CompleteEvent', aParams), 'GENERATE_TIME_STAMP': strftime("%a, %d %b %Y %H:%M:%S") + ' (time stamp)' } c['FAKERPARAMETERS'] = makeFakingParameters(aParams, True) c['FAKER_PARAMETER_TOTAL_LENGTH'] = makeParameterTotalLengthValue( aParams, True) c['FAKERSETERRORCODEBYPARAM'] = makeEventSetErrorCode( aParams, True, completeEventPreHeaderBytes()) c['EVENTSETERRORCODEBYEXTRACT'] = makeEventSetErrorCode( aParams, False, completeEventPreHeaderBytes()) c['FAKERWRITE_IMPLEMENTATION'] = makeFakingWriteImplementation( aParams, True) #file(aHeaderPath + '\\' + c['FILENAME'] + '.h', 'w+').write(aHeaderTemplate.substitute(c)) #file(aSourcePath + '\\' + c['FILENAME'] + '.cpp', 'w+').write(aSourceTemplate.substitute(c)) doTimeStampCompareAndWrite(aHeaderPath + '\\' + c['FILENAME'] + '.h', aHeaderTemplate.substitute(c)) doTimeStampCompareAndWrite(aSourcePath + '\\' + c['FILENAME'] + '.cpp', aSourceTemplate.substitute(c))
def writeCompleteEvent(aCmd, aParams, aHeaderTemplate, aSourceTemplate, aHeaderPath, aSourcePath): c = {'COMMAND' : aCmd, 'CLASSNAME' : 'T' + aCmd + 'CompleteEvent', 'FILENAME' : aCmd.lower() + 'completeevent', 'HEADERGUARD' : aCmd.upper() + 'COMPLETEEVENT', 'OPCODE' : 'K' + aCmd + 'Opcode', 'PARAMETERS' : 'THCIErrorCode aErrorCode, const TDesC8& aEventData', 'CONSTRUCTOR_PARAMETERS' : 'aErrorCode, aEventData', 'ACCESSOR_DEFINITION' : makeAccessorDef(aParams), 'ACCESSOR_IMPLEMENTATION' : makeAccessorImpl(aCmd + 'CompleteEvent', aParams), 'GENERATE_TIME_STAMP': strftime("%a, %d %b %Y %H:%M:%S") + ' (time stamp)'} c['FAKERPARAMETERS'] = makeFakingParameters(aParams, True) c['FAKER_PARAMETER_TOTAL_LENGTH'] = makeParameterTotalLengthValue(aParams, True) c['FAKERSETERRORCODEBYPARAM'] = makeEventSetErrorCode(aParams, True, completeEventPreHeaderBytes()) c['EVENTSETERRORCODEBYEXTRACT'] = makeEventSetErrorCode(aParams, False, completeEventPreHeaderBytes()) c['FAKERWRITE_IMPLEMENTATION'] = makeFakingWriteImplementation(aParams, True) #file(aHeaderPath + '\\' + c['FILENAME'] + '.h', 'w+').write(aHeaderTemplate.substitute(c)) #file(aSourcePath + '\\' + c['FILENAME'] + '.cpp', 'w+').write(aSourceTemplate.substitute(c)) doTimeStampCompareAndWrite(aHeaderPath + '\\' + c['FILENAME'] + '.h', aHeaderTemplate.substitute(c)) doTimeStampCompareAndWrite(aSourcePath + '\\' + c['FILENAME'] + '.cpp', aSourceTemplate.substitute(c))
def writeCommand(aCmd, aMatchData, aParams, aHeaderTemplate, aSourceTemplate, aHeaderPath, aSourcePath): # separate by , matchParams = re.split(r'[^a-zA-Z_0-9\*]+', aMatchData) # Make template values c = { 'COMMAND': aCmd, # plain command name 'CLASSNAME': 'C' + aCmd + 'Command', #CaCmd 'FILENAME': aCmd.lower() + 'command', # acmd 'HEADERGUARD': aCmd.upper() + 'COMMAND', # ACMD 'PARAMETERS': makeParameters(aParams), # aParam1, aParam2 'MEMBERS': makeMembers(aParams), # iParam1; iParam2 'NEWL_DEFINITIONS': makeNewLDefinitions(aParams, aCmd + 'Command'), # NewL($PARAMETERS) 'NEWL_IMPLEMENTATIONS': makeNewLImplementations(aParams, aCmd + 'Command'), 'CONSTRUCTOR_DEFINITIONS': makeConstructorDefinitions(aParams, aCmd + 'Command'), 'CONSTRUCTOR_IMPLEMENTATIONS': makeConstructorImplementations( aParams, aCmd, matchParams ), # Don't add 'Command', aCmd is used to build K...Opcode 'DESTRUCTOR_IMPLEMENTATION': makeDestructorImplementation(aParams), 'WRITE_FRAME': makeWriteFrame(aParams), 'COMMANDFRAME': makeCommandFrame(aParams), 'MEMBER_ASSIGNMENT': makeMemberAssignment(aParams), 'ACCESSOR_DEFINITIONS': makeAccessorDefinitions(aParams), 'ACCESSOR_IMPLEMENTATIONS': makeAccessorImplementations(aParams, 'C' + aCmd + 'Command'), 'EVENT_MATCH_DEFINITIONS': makeEventMatchDefinitions(matchParams), 'EVENT_MATCH_IMPLEMENTATIONS': makeEventMatchImplementations(matchParams, aCmd), 'EVENT_MATCH_INCLUDES': makeEventMatchIncludes(matchParams), 'PRAGMA_HW_VOICE_SETTING_ADVICE': makePragmaHwVoiceSettingAdvice(aCmd), 'GENERATE_TIME_STAMP': strftime("%a, %d %b %Y %H:%M:%S") + ' (time stamp)' } # (time stamp) is needed for preventing unneccesary submissions. # Fill in template #file(aHeaderPath + '\\' + c['FILENAME'] + '.h', 'w+').write(aHeaderTemplate.substitute(c)) #file(aSourcePath + '\\' + c['FILENAME'] + '.cpp', 'w+').write(aSourceTemplate.substitute(c)) doTimeStampCompareAndWrite(aHeaderPath + '\\' + c['FILENAME'] + '.h', aHeaderTemplate.substitute(c)) doTimeStampCompareAndWrite(aSourcePath + '\\' + c['FILENAME'] + '.cpp', aSourceTemplate.substitute(c))