Example #1
0
    def writeLstsModel(self,
                       outputDir,
                       create_taskswitcher,
                       apps_only_ts,
                       generateSleep,
                       defaultSleep=True):

        output = outputDir
        if outputDir != "" and not outputDir.endswith(os.sep):
            output = output + os.sep

        lstsmodelname = output.split(os.sep)[-2]

        os.mkdir(output)
        os.mkdir(output + "rm" + os.sep)

        model_names = []

        products = self.__kendoXMLParser.getProducts()
        system_model = products[0]

        if create_taskswitcher:
            print "Creating TaskSwitcher...",
            converter = lstsmodel.LstsModelCreator(products[0], products)
            model = converter.convertToTaskSwitcher(
                apps_only_ts, lstsmodelname + "-GateModel")

            model_names.append("TaskSwitcher-" + lstsmodelname)
            self.__writeLsts(model, "TaskSwitcher-" + lstsmodelname, output)

            gate_model = converter.createGateModel(products[0])
            model_names.append(lstsmodelname + "-GateModel")
            print "done"
            print "Writing TaskSwitcher...",
            self.__writeLsts(gate_model, lstsmodelname + "-GateModel", output)
            print "done"
            #model_names.append(product.getName().replace(" ", "%20"))
            system_model = products.pop(0)

        for product in products:
            #TODO: if name not given use e.g. "product+id"
            #self.__writeLsts(product, output)
            print "Converting " + product.getName() + "...",
            converter = lstsmodel.LstsModelCreator(product, products)
            model = converter.convertProduct(create_taskswitcher,
                                             generateSleep, defaultSleep)
            print "done"

            modelName = lstsmodel.getModelName(product)
            print "Writing " + modelName + "...",
            self.__writeLsts(model, modelName, output)
            model_names.append(modelName)
            print "done"

        #Create variable models for flags
        print "Writing flag models...",
        self.__createFlagModels(output)

        for flag in self.__kendoXMLParser.getFlags():
            model_names.append("flagmodel_" + flag.getName())
        print "done"

        #Create empty -files for models ( no LaunchApps )
        #if not create_taskswitcher:
        #    for name in model_names:
        #        file = open(output + name + ".info", "w")
        #        file.close()

        #Create info files that contain the app_model name (Usually app-model name corresponds the launchApp name)
        for state in system_model.getStates():
            if state.getType() == "APP_MODEL":
                appname = state.getName()
                matcher = re.search("[aA]ppname:\\s*\"(\\w+)\"",
                                    state.getDescription())
                if matcher:
                    appName = matcher.group(1)

                file = open(
                    output + lstsmodel.getModelName(state.getLinkedProduct()) +
                    ".info", "w")
                file.write("APPLICATION: " + appname + "\n")
                for sub in state.getLinkedProduct().getSubModels():
                    file = open(output + lstsmodel.getModelName(sub) + ".info",
                                "w")
                    file.write("APPLICATION: " + appname + "\n")
                file.close()

        print "Generating Makefile...",
        self.__generateMakefile(output, model_names, lstsmodelname,
                                create_taskswitcher)
        print "done"
        print "Creating testdata...",
        self.__createDataTables(output)
        print "done"
        print "Creating coverage requirements based on the use cases...",
        self.__createCoverageRequirements(output, lstsmodelname)
        print "done"
Example #2
0
    def writeLstsModel(self, outputDir, create_taskswitcher, apps_only_ts, generateSleep, defaultSleep = True):
        
        output = outputDir
        if outputDir != "" and not outputDir.endswith(os.sep):
            output = output + os.sep
        
        lstsmodelname = output.split(os.sep)[-2]
        
        os.mkdir(output)
        os.mkdir(output + "rm" + os.sep)            
        
        model_names = []
        
        products = self.__kendoXMLParser.getProducts()
        system_model = products[0]
        
        if create_taskswitcher:
            print "Creating TaskSwitcher...",
            converter = lstsmodel.LstsModelCreator(products[0],products)
            model = converter.convertToTaskSwitcher(apps_only_ts, lstsmodelname +"-GateModel")
            
            model_names.append("TaskSwitcher-" + lstsmodelname)
            self.__writeLsts(model,"TaskSwitcher-" + lstsmodelname, output)
            
            gate_model = converter.createGateModel(products[0])
            model_names.append(lstsmodelname +"-GateModel")
            print "done"
            print "Writing TaskSwitcher...",
            self.__writeLsts(gate_model, lstsmodelname +"-GateModel", output) 
            print "done"
            #model_names.append(product.getName().replace(" ", "%20"))
            system_model = products.pop(0)
            
        for product in products:
            #TODO: if name not given use e.g. "product+id"
            #self.__writeLsts(product, output)
            print "Converting "+product.getName()+"...",
            converter = lstsmodel.LstsModelCreator(product, products)
            model = converter.convertProduct(create_taskswitcher, generateSleep, defaultSleep)
            print "done"
            
            modelName = lstsmodel.getModelName(product)
            print "Writing "+modelName+"...",
            self.__writeLsts(model, modelName, output)
            model_names.append(modelName)
            print "done"
        
        #Create variable models for flags
        print "Writing flag models...",
        self.__createFlagModels(output)
        

        for flag in self.__kendoXMLParser.getFlags():
            model_names.append("flagmodel_"+flag.getName())
        print "done"
        
        #Create empty -files for models ( no LaunchApps )
        #if not create_taskswitcher:
        #    for name in model_names:
        #        file = open(output + name + ".info", "w")
        #        file.close()
          
      
        #Create info files that contain the app_model name (Usually app-model name corresponds the launchApp name)             
        for state in system_model.getStates():
            if state.getType() == "APP_MODEL":
                appname = state.getName()
                matcher = re.search("[aA]ppname:\\s*\"(\\w+)\"",state.getDescription())
                if matcher:
                    appName = matcher.group(1)
            
                file = open(output + lstsmodel.getModelName(state.getLinkedProduct()) + ".info", "w")
                file.write("APPLICATION: " + appname + "\n")
                for sub in state.getLinkedProduct().getSubModels():
                    file = open(output + lstsmodel.getModelName(sub) + ".info", "w")
                    file.write("APPLICATION: " + appname + "\n")
                file.close()
        
        print "Generating Makefile...",
        self.__generateMakefile(output, model_names, lstsmodelname, create_taskswitcher)  
        print "done"  
        print "Creating testdata...",
        self.__createDataTables(output)
        print "done" 
        print "Creating coverage requirements based on the use cases...",
        self.__createCoverageRequirements(output, lstsmodelname)
        print "done"  
Example #3
0
    def __createCoverageRequirements(self, directory, project_name):

        covRegNames = []
        covRegs = []

        ucModel = self.__kendoXMLParser.getUseCaseModel()

        file = open(directory + "usecase_coverage_requirements.txt", "w")

        if not ucModel:
            return

        for uc in ucModel.getUseCases():

            if uc.getDescription() != None and uc.getDescription() != "":
                description = ", description: " + uc.getDescription()
            else:
                description = ""

            file.write("Use case: " + uc.getName() + description + "\n\n")
            for path in uc.getPaths():
                actions = []

                for t in path.getTransitions():
                    modelName = t[0]
                    transitionId = t[1]

                    product = None
                    transitionName = None

                    for p in self.__kendoXMLParser.getProducts():
                        if p.getName() == modelName:
                            product = p
                            break

                    if product:
                        for tt in product.getTransitions():
                            if tt.getId() == transitionId:
                                transitionName = tt.getEvent_id()
                                break

                        if transitionName:

                            actions.append(
                                lstsmodel.getModelName(product) + ":end_aw" +
                                transitionName)

                file.write("Path: " + path.getName() + ", " +
                           path.getDescription() + "\n")
                covRegNames.append(uc.getName() + " : " + path.getName())

                covreg = ""
                for a in actions:

                    if a == actions[0]:
                        covreg += "action " + a
                    else:
                        covreg += " THEN action " + a

                covRegs.append(covreg)
                file.write(covreg + "\n\n")

            file.write("\n\n")

        file.close()

        self.__createTestExecutionScript(covRegNames, covRegs, project_name,
                                         directory)
Example #4
0
    def __createCoverageRequirements(self, directory, project_name):
    
    
        covRegNames = []
        covRegs = []
        
        ucModel = self.__kendoXMLParser.getUseCaseModel()

        file = open(directory + "usecase_coverage_requirements.txt", "w")

        if not ucModel:
            return
            
        for uc in ucModel.getUseCases():
          
            if uc.getDescription() != None and uc.getDescription() != "":
                description = ", description: " + uc.getDescription()
            else:
                description = ""
            
        
            file.write("Use case: " + uc.getName() + description + "\n\n")
            for path in uc.getPaths():
                actions = []
                
                
                for t in path.getTransitions():
                    modelName = t[0]
                    transitionId = t[1]
                    
                    product = None
                    transitionName = None
                    
                    for p in self.__kendoXMLParser.getProducts():
                        if p.getName() == modelName:
                            product = p
                            break
                    
                    if product:
                        for tt in product.getTransitions():
                            if tt.getId() == transitionId:
                                transitionName = tt.getEvent_id()
                                break
                        
                        if transitionName:
                        
                            actions.append(lstsmodel.getModelName(product) +":end_aw"+ transitionName)
                
                file.write("Path: " + path.getName() + ", " + path.getDescription() +"\n")
                covRegNames.append(uc.getName() + " : " + path.getName())
                
                covreg = ""
                for a in actions:
                    
                    if a == actions[0]:
                        covreg += "action " + a
                    else:
                        covreg += " THEN action " + a
    
                covRegs.append(covreg)
                file.write(covreg + "\n\n")
                    
            file.write("\n\n")    
            
        file.close()
        
        self.__createTestExecutionScript(covRegNames, covRegs, project_name, directory)