Esempio n. 1
0
 def Debug(self, info):
         print debug_flag_start
         print info
         print debug_flag_end
         command.WriteFile(debug_flag_start)
         command.WriteFile(info)
         command.WriteFile(debug_flag_end)
Esempio n. 2
0
 def ParseSvnlog(self, log):
     import re
     pattern = "revision=\"(\d+)\""
     for match in re.findall(pattern,log):
         print "REVISION IS:%s\n"%match
     xmldoc = minidom.parseString(log)
     author = xmldoc.getElementsByTagName('author')[0].firstChild.data
     date   = xmldoc.getElementsByTagName('date')[0].firstChild.data
     comment= xmldoc.getElementsByTagName('msg')[0].firstChild.data
     nodelist=xmldoc.getElementsByTagName('path')
     filelist=[]
     for node in nodelist:
         filelist.append(node.firstChild.data)
     lists = ";".join(filelist)
     command.WriteFile('svn last author: '+author)
     command.WriteFile("svn last date: " + date)
     command.WriteFile("svn last lists: " + lists)
     command.WriteFile("svn last comment: " + comment)
Esempio n. 3
0
 def copyfile(self, fName, dirName):
     filename = os.path.basename(fName)
     if os.path.isfile(os.path.join(dirName, filename)) == False:
         try:
             command.WriteFile("copying " + fName + " to " + dirName)
             shutil.copy(fName, dirName)
             if fName.endswith("gcda"):
                 os.remove(fName)
         except Exception, e:
             print 'Meet exception while copy file '
             print e
Esempio n. 4
0
 def ExecYum(self,cmd,operation):
     if cmd != '':
         self.Debug('Yum running')
         yumcmds = cmd.split(';')
         for yum_cmd in yumcmds:
             a = yum_cmd.split(',')
             package=(a[0],)
             if len(a) == 2:
                 branch = a[1]
             else:
                  branch = 'test'
             status,output = command.yum(package,'',operation,branch)
             command.WriteFile(output)
             if(status!=0):
                 raise Exception,output
Esempio n. 5
0
    def OutputHtmlDataForScons(self):
        self.Debug('Start to capture coverage data by lcov.....')
        if self.ignoreDirs != []:
            self.RemoveIgnoreDirs()

        lcov_cmd = self.Lcov + " -c -d ./build/ -b . -o " + " app.info"
        command.DoCmd1(lcov_cmd)

        self.lcov_info = os.path.abspath("app.info")

        import replacedir
        replacedir.visit_dir(self.BasePath)
        replacedir.deal_file("app.info")
        if os.path.exists("tmp.info"):
            subprocess.call("mv tmp.info app.info", shell=True)
        print 'replace dir processing end'

        os.system("find -name \"*.gcno\" |xargs rm -rf")
        os.system("find -name \"*.gcda\" |xargs rm -rf")
        #Get Current time and store html output to the directory named with current time
        self.Debug(
            'Store html output to the directory named with current time')
        now = datetime.datetime.now().strftime("%m-%d-%Y-%X")
        directory = '/tmp/' + now
        info_path = os.path.join(self.makefilepath, "app.info")
        genhtml_cmd = self.Genhtml + ' ' + info_path + ' -o ' + directory
        cp_info = "cp -r " + info_path + " " + directory
        command.WriteFile('genhtml_cmd is:\t' + genhtml_cmd)
        command.DoCmd(genhtml_cmd, '')
        command.DoCmd(cp_info, '')
        print "\nInfomations for code coverage in the: " + directory + "\n"

        self.OutPutLineInfoForGcov(self.LogFile)
        self.OutPutBranchInfoForGcov(self.LogFile)

        self.ToHtdocs(directory)
        self.DisplayURL(now)
Esempio n. 6
0
class MvnTest(TestParent):
    def __init__(self, config, options):
        TestParent.__init__(self, config, options)

    '''
    copy html files from subdirs to makefilepath/target/site/cobertura
    '''

    def copy_html(self, frompath, topath):
        subdirs = []
        for root, dirs, files in os.walk(frompath):
            for dir in dirs:
                subdir = os.path.join(root, dir)
                if subdir.endswith(pathofmvncov) and subdir != topath:
                    subdirs += [subdir]
        for subdir in subdirs:
            copycommand = "find " + subdir + "  -maxdepth 1 -name '*.html' ! -name 'frame*.html' ! -name 'index.html' ! -name 'help.html' -print | xargs -i cp  {} " + topath
            command.DoCmd1(copycommand)

    '''
       Merge all the cobertura.ser to buildpath/target/cobertura/cobertura.ser" 
    '''

    def MergeCobertura(self):
        self.Debug('Merge all the cobertura.ser....')
        if os.path.exists(self.makefilepath) == False:
            print "Invalid makefilepath: " + self.makefilepath
            return False
        os.chdir(self.makefilepath)
        coberturapath = os.path.join(self.makefilepath, "target/cobertura")
        if not os.path.exists(coberturapath):
            try:
                os.makedirs(coberturapath)
            except Exception, e:
                print "Meet a exception when crating " + coberturapath
                print e
                return false
        mergeto = os.path.join(self.makefilepath,
                               "target/cobertura/cobertura.ser")
        mergeFrom = " "
        sers = []
        for root, dirs, files in os.walk(self.makefilepath):
            for name in files:
                if name == "cobertura.ser":
                    ser = os.path.join(root, name)
                    if ser != mergeto:
                        mergeFrom += " " + os.path.join(root, name)
        if mergeFrom == " ":  #No any .ser to merge
            return False
        merge = self.MvnMerge + " --datafile " + mergeto + mergeFrom
        command.WriteFile(merge)
        command.DoCmd1(merge)

        self.Debug('Generate the html...... ')
        datafile = mergeto
        destination = os.path.join(self.makefilepath, pathofmvncov)
        if not os.path.exists(destination):
            try:
                os.makedirs(destination)
            except Exception, e:
                print "Meet an exception when creating " + destination
                print e
                return false
Esempio n. 7
0
    def OutputHtmlData(self):
        self.Debug('Start to capture coverage data by lcov.....')
        if self.ignoreDirs != []:
            self.RemoveIgnoreDirs()
        i = 0
        for root, dirs, files in os.walk(self.makefilepath, False):
            for dirname in dirs:
                dirname = os.path.join(root, dirname)
                command.WriteFile("lcovpath: " + dirname)
                if os.path.isdir(dirname) and self.HasGcda(dirname) == True:
                    os.chdir(dirname)
                    outputpath = os.path.join(self.makefilepath,
                                              str(i) + ".info")
                    lcov_cmd = self.Lcov + " -c -d . -b . -o " + outputpath + " >> " + self.LogFile
                    i = i + 1
                    command.DoCmd1(lcov_cmd)
        dirlist = os.listdir(self.makefilepath)
        hasgcda = False
        for myfile in dirlist:
            if os.path.isfile(os.path.join(
                    self.makefilepath, myfile)) and myfile.endswith(".gcda"):
                hasgcda = True
                break
        if hasgcda:
            os.chdir(self.makefilepath)
            outputpath = os.path.join(self.makefilepath, str(i) + ".info")
            lcov_cmd = self.Lcov + " -c -d . -b . -o " + outputpath + ">>" + self.LogFile
            command.DoCmd1(lcov_cmd)

        infolist = os.listdir(self.makefilepath)
        lcov = self.Lcov

        for myfile in infolist:
            if myfile.endswith(".info"):
                if dealinfo.check_file(os.path.join(self.makefilepath,
                                                    myfile)):
                    lcov = lcov + " -a " + myfile

        os.chdir(self.makefilepath)
        if (self.extract == 1):
            lcov = lcov + " -o app1.info"
            command.DoCmd(lcov, '')

            lcov = self.Lcov + " -e app1.info *" + self.makefilepath + "* -o app.info"
            command.DoCmd(lcov, '')
        else:
            lcov = lcov + " -o app.info"
            command.DoCmd(lcov, '')

        replacedir.visit_dir(self.BasePath)
        replacedir.deal_file("app.info")
        if os.path.exists("tmp.info"):
            subprocess.call("mv tmp.info app.info", shell=True)
        print 'replace dir processing end'

        self.lcov_info = os.path.abspath("app.info")

        if (self.keep == 1):
            dealinfo.modify_info("app.info", self.BasePath)

        os.system("find -name \"*.gcno\" |xargs rm -rf")
        os.system("find -name \"*.gcda\" |xargs rm -rf")
        #Get Current time and store html output to the directory named with current time
        self.Debug(
            'Store html output to the directory named with current time')
        now = datetime.datetime.now().strftime("%m-%d-%Y-%X")
        directory = '/tmp/' + now
        info_path = os.path.join(self.makefilepath, "app.info")
        genhtml_cmd = self.Genhtml + ' ' + info_path + ' -o ' + directory
        cp_info = "cp -r " + info_path + " " + directory
        command.WriteFile('genhtml_cmd is:\t' + genhtml_cmd)
        command.DoCmd(genhtml_cmd, '')
        command.DoCmd(cp_info, '')
        print "\nInfomations for code coverage in the: " + directory + "\n"

        self.OutPutLineInfoForGcov(self.LogFile)
        self.OutPutBranchInfoForGcov(self.LogFile)

        self.ToHtdocs(directory)
        self.DisplayURL(now)