示例#1
0
 def change_ip(self):
     ip = self.args.get('ip')
     result = change_avstreaming_ip(ip)
     if result:
         print ingreen(
             '##################### Set IP for AV_Streaming Server Successfully! ####################'
         )
示例#2
0
 def showUserGuidePrint(self):
     print ingreen("\n*****************************")
     print "You may need to create or edit your profile files, please refer to below detail profile info:\n"
     print "1 " + inred(
         "execution profile") + " -- located in test_repo/execution/"
     print "    1.1 name: refer to TMS Excution name and replace all spaces ' ' with underlines '_'.    e.g. tms_excution_name: Build 20110312-001, and the name in execution.xml should be Build_20110312-001"
     print "    1.2 OS: operating system under test. android or meego"
     print "    1.3 DUTTestsuite: ftp or http address for downloading Testsuite.    e.g. ftp://172.16.120.166/TestSuite/Android/mfld/0318/"
     print "    1.4 DUTWorkDirectory: an absolute path used for storing you test output files.    e.g. /cache/"
     print "    1.5 ClipsDirectory: an absolute path leading to your stored clips.    e.g. /cache/Clips/"
     print "    1.6 SystemBoot: from where your system boot.    e.g. SD or eMMC \n"
     print "2 " + inred(
         "device profile") + " -- located in test_repo/device/"
     print "    2.1 Platform: platform under test. MFLD or MRST"
     print "    2.2 OS: operating system under test. android or meego"
     print "    2.3 Connect: device connection method. adb or ssh"
     print "    2.4 serialNumber: use unix command \"adb devices\" to obtain you device serialNumber.    e.g. 0123456789ABCDEF or 172.16.125.197:5555\n"
     print "3. You need" + inred(
         " root"
     ) + " authority to completely implement all functions in setup.py.\n"
     print "4. Your Python version should be" + inred(" 2.6") + ".\n"
     print "5. If you encountered something wrong with Paramiko, try executing step 4 first.\n"
     print "6. You need busybox installed. If not, please install it with step 5 in the main menu."
     print ingreen("*****************************\n")
     userNext = raw_input("Please Enter to continue: ")
示例#3
0
 def execuitonEndPrint(self, execution_name, end_time, pass_count_total, fail_count_total, TBD_count_total, result_xml):
     print "\nExecution Name: %s"%execution_name
     print "End Time: %s" %end_time
     print "Pass Count: " + ingreen(pass_count_total)
     print "Fail Count: " + inred(fail_count_total)
     print "TBD Count: " + ingreen(TBD_count_total)
     print "Log Path: %s" %result_xml
     print "_____________________________\n"
示例#4
0
 def suiteEndPrint(self, suitename, end_time, pass_count, fail_count, TBD_count, rtlog):
     print "Suite Name: %s"%suitename
     print "End Time: %s" %end_time
     print 'Pass Count: ' + ingreen(pass_count)
     print 'Fail Count: ' + inred(fail_count)
     print 'TBD Count: ' + ingreen(TBD_count)
     print "Log Path: %s" %rtlog
     print "###############################\n"
示例#5
0
 def execuitonEndPrint(self, execution_name, end_time, pass_count_total,
                       fail_count_total, TBD_count_total, result_xml):
     print "\nExecution Name: %s" % execution_name
     print "End Time: %s" % end_time
     print "Pass Count: " + ingreen(pass_count_total)
     print "Fail Count: " + inred(fail_count_total)
     print "TBD Count: " + ingreen(TBD_count_total)
     print "Log Path: %s" % result_xml
     print "_____________________________\n"
示例#6
0
 def suiteEndPrint(self, suitename, end_time, pass_count, fail_count,
                   TBD_count, rtlog):
     print "Suite Name: %s" % suitename
     print "End Time: %s" % end_time
     print 'Pass Count: ' + ingreen(pass_count)
     print 'Fail Count: ' + inred(fail_count)
     print 'TBD Count: ' + ingreen(TBD_count)
     print "Log Path: %s" % rtlog
     print "###############################\n"
示例#7
0
 def _connect_wifi(self):
     result = connect_wifi(self.devcfg)
     if result:
         print ingreen(
             '##################### Connect Wifi Successfully #############################'
         )
     else:
         print inred(
             '##################### Fail to Connect Wifi #############################'
         )
示例#8
0
 def _push_busybox(self):
     result = push_busybox(self.devcfg)
     if result:
         print ingreen(
             '##################### Push Busybox to Device Successfully #####################'
         )
     else:
         print inred(
             '##################### Fail to Push Busybox to Device #####################'
         )
示例#9
0
 def install_android_sdk(self):
     result = install_android_sdk(self.devcfg)
     if result:
         print ingreen(
             '##################### Install Android SDK Successfully #######################'
         )
     else:
         print inred(
             '##################### Fail to Install Android SDK ##########################'
         )
示例#10
0
 def install_paramiko(self):
     result = install_paramiko()
     if result:
         print ingreen(
             '##################### Install Paramiko Successfully.#####################'
         )
     else:
         print inred(
             '##################### Fail to Install Paramiko, Check If You Run This by Root #####################'
         )
示例#11
0
def download(ingredient, buildname):
    if ingredient == '':
        ingredient = raw_input("Enter Ingredient name:");
        ingredient = ingredient.replace(" ","%20");
        
    if buildname == '':
        buildname = raw_input("Enter Test Execution name:");
        buildname = buildname.replace(" ","%20");
        
    #create buildname in ./conf/
    buildname_file = open('conf/buildname','w')
    buildname_file.write(buildname)
    buildname_file.close()
    
    #delete origin test_repo
    os.system("cd .. ; rm -rf test_repo")
    
    #download test_repo.tar.gz
    url = "http://tms.bj.intel.com/tms/execution/tool/download.php"
    command = "curl --noproxy tms.bj.intel.com -o ../test_repo.tar.gz '%s'" %(url)
    status, output = commands.getstatusoutput(command)
    if not status == 0:
        print inred("###########################--Download test_repo.tar.gz Error--###########################")
    else:
        status, output = commands.getstatusoutput("cd .. ; tar zxvf test_repo.tar.gz")
        if not status == 0:
            print inred("Error: fail to download test_repo from TMS.")
        else:
            os.system("cd .. ; rm -rf test_repo.tar.gz")
            
            #download config.tar.gz
            url = "http://tms.bj.intel.com/tms/execution/tool/video_profile.php?plat=Medfield&os=Android&ing=%s&ex=%s"%(ingredient, buildname)
            command = "curl --noproxy tms.bj.intel.com -o %sconfig.tar.gz '%s'" %(conf.TEST_REPO, url)
            status, output = commands.getstatusoutput(command)
            if not status == 0:
                print inred("###########################--Download Case Profile Error--###########################")
            else:
                status, output = commands.getstatusoutput("cd " + conf.TEST_REPO + " ; tar zxvf config.tar.gz")
                if not status == 0:
                    print inred("Error: fail to download execution from TMS, maybe the ingredient name or execution name is invalid. Or your host need to install curl.")
                else:
                    os.system("cd " + conf.TEST_REPO + " ; rm -rf config.tar.gz")
                    os.system("mv " + conf.TEST_REPO + "config/" + buildname + ".xml " + conf.TEST_REPO)
                    os.system("mv " + conf.TEST_REPO + "config/case_profile " + conf.TEST_REPO)
                    os.system("cd " + conf.TEST_REPO + " ; mv config suite_profile")
                    print ingreen("###########################Download Successful--###########################") 
                    # set device number
                    try:
                        main()
                    except Exception, e:
                        print e
示例#12
0
 def chmod_suite(self):
     fail_chmod_list = []
     for file_num in self.download_item_pass_list:
         if file_num[-2:] in ['so', 'ko'] or file_num.strip().endswith('apk'):
             pass
         else:
             result = self.acc.execute('chmod 4777 /system/bin/%s'%(file_num) )
             if result == ('', ''):
                 pass
             else:
                 fail_chmod_list.appand(file_num)
     if fail_chmod_list:
         print inred('##################### Fail to change mode' + ', '.join(fail_chmod_list) + ' ####################')
     if len(self.download_item_pass_list) != 0:
        print ingreen('##################### Push  ' + ', '.join([item for item in self.download_item_pass_list if item not in fail_chmod_list]) + ' into Device Successfully ##############')
示例#13
0
 def showCIGuidePrint(self):
     print ingreen("\n*****************************")
     print "You may need to create or edit your profile files, please refer to below detail profile info:\n"
     print "1 " + inred("execution profile") + " -- located in test_repo/execution/"
     print "    1.1 name: refer to TMS Excution name and replace all spaces ' ' with underlines '_'.    e.g. tms_excution_name: Build 20110312-001, and the name in execution.xml should be Build_20110312-001\n"
     print "2 " + inred("device profile") + " -- located in test_repo/device/"
     print "    2.1 Platform: platform under test. MFLD or MRST"
     print "    2.2 OS: operating system under test. android or meego"
     print "    2.3 Connect: device connection method. adb or ssh"
     print "    2.4 serialNumber: use unix command \"adb devices\" to obtain you device serialNumber.    e.g. 0123456789ABCDEF or 172.16.125.197:5555\n"
     print "3. You need" + inred(" root") + " authority to completely implement all functions in setup.py.\n"
     print "4. Your Python version should be" + inred(" 2.6") + ".\n"
     print "5. If you encountered something wrong with Paramiko, try executing step 4 first."
     print ingreen("*****************************\n")
     userNext = raw_input ("Please Enter to continue: ")
示例#14
0
 def caseEndPrint(self, casename, end_time, case_result, xmllog):
     print "\nCase Name: %s" % casename
     print "End Time: %s" % end_time
     if not cmp(case_result, 'pass'):
         print 'Result: ' + ingreen(case_result)
     else:
         print 'Result: ' + inred(case_result)
     print "Log Path: %s" % xmllog
     print "******************************"
示例#15
0
 def caseEndPrint(self, casename, end_time, case_result, xmllog):
     print "\nCase Name: %s" %casename
     print "End Time: %s" %end_time
     if not cmp(case_result, 'pass'):
         print 'Result: ' + ingreen(case_result)
     else:
         print 'Result: ' + inred(case_result)
     print "Log Path: %s" %xmllog
     print "******************************"
     
示例#16
0
 def showCIGuidePrint(self):
     print ingreen("\n*****************************")
     print "You may need to create or edit your profile files, please refer to below detail profile info:\n"
     print "1 " + inred(
         "execution profile") + " -- located in test_repo/execution/"
     print "    1.1 name: refer to TMS Excution name and replace all spaces ' ' with underlines '_'.    e.g. tms_excution_name: Build 20110312-001, and the name in execution.xml should be Build_20110312-001\n"
     print "2 " + inred(
         "device profile") + " -- located in test_repo/device/"
     print "    2.1 Platform: platform under test. MFLD or MRST"
     print "    2.2 OS: operating system under test. android or meego"
     print "    2.3 Connect: device connection method. adb or ssh"
     print "    2.4 serialNumber: use unix command \"adb devices\" to obtain you device serialNumber.    e.g. 0123456789ABCDEF or 172.16.125.197:5555\n"
     print "3. You need" + inred(
         " root"
     ) + " authority to completely implement all functions in setup.py.\n"
     print "4. Your Python version should be" + inred(" 2.6") + ".\n"
     print "5. If you encountered something wrong with Paramiko, try executing step 4 first."
     print ingreen("*****************************\n")
     userNext = raw_input("Please Enter to continue: ")
示例#17
0
 def chmod_suite(self):
     fail_chmod_list = []
     for file_num in self.download_item_pass_list:
         if file_num[-2:] in ['so', 'ko'
                              ] or file_num.strip().endswith('apk'):
             pass
         else:
             result = self.acc.execute('chmod 4777 /system/bin/%s' %
                                       (file_num))
             if result == ('', ''):
                 pass
             else:
                 fail_chmod_list.appand(file_num)
     if fail_chmod_list:
         print inred('##################### Fail to change mode' +
                     ', '.join(fail_chmod_list) + ' ####################')
     if len(self.download_item_pass_list) != 0:
         print ingreen('##################### Push  ' + ', '.join([
             item for item in self.download_item_pass_list
             if item not in fail_chmod_list
         ]) + ' into Device Successfully ##############')
示例#18
0
 def showUserGuidePrint(self):
     print ingreen("\n*****************************")
     print "You may need to create or edit your profile files, please refer to below detail profile info:\n"
     print "1 " + inred("execution profile") + " -- located in test_repo/execution/"
     print "    1.1 name: refer to TMS Excution name and replace all spaces ' ' with underlines '_'.    e.g. tms_excution_name: Build 20110312-001, and the name in execution.xml should be Build_20110312-001"
     print "    1.2 OS: operating system under test. android or meego"
     print "    1.3 DUTTestsuite: ftp or http address for downloading Testsuite.    e.g. ftp://172.16.120.166/TestSuite/Android/mfld/0318/"
     print "    1.4 DUTWorkDirectory: an absolute path used for storing you test output files.    e.g. /cache/"
     print "    1.5 ClipsDirectory: an absolute path leading to your stored clips.    e.g. /cache/Clips/"
     print "    1.6 SystemBoot: from where your system boot.    e.g. SD or eMMC \n"
     print "2 " + inred("device profile") + " -- located in test_repo/device/"
     print "    2.1 Platform: platform under test. MFLD or MRST"
     print "    2.2 OS: operating system under test. android or meego"
     print "    2.3 Connect: device connection method. adb or ssh"
     print "    2.4 serialNumber: use unix command \"adb devices\" to obtain you device serialNumber.    e.g. 0123456789ABCDEF or 172.16.125.197:5555\n"
     print "3. You need" + inred(" root") + " authority to completely implement all functions in setup.py.\n"
     print "4. Your Python version should be" + inred(" 2.6") + ".\n"
     print "5. If you encountered something wrong with Paramiko, try executing step 4 first.\n"
     print "6. You need busybox installed. If not, please install it with step 5 in the main menu."
     print ingreen("*****************************\n")
     userNext = raw_input ("Please Enter to continue: ")
示例#19
0
def main():
    device_list = get_device_list()
    if len(device_list) == 0:
        print 'No Device Connected to Host'
        sys.exit(0)
    elif len(device_list) == 1:
        print ingreen('Only One Device ' + device_list[0] +
                      ' Connected to Host')
        chDev(device_list[0])
        print ingreen("Default Set " + device_list[0] + " in Device Profile.")
        sys.exit(0)
    else:
        print_device(device_list)
        user_input = ''
        while user_input == '':
            user_input = raw_input('Please select the device number:')
            try:
                if int(user_input) < 0 or int(user_input) > (len(device_list) +
                                                             1):
                    raise ValueError
                elif int(user_input) == len(device_list) + 1:
                    main()
                chDev(device_list[int(user_input) - 1])
                print ingreen('Set ' + device_list[int(user_input) - 1] +
                              ' in Device Profile Successfully')
                sys.exit(0)
            except ValueError, e:
                print 'invalid user input'
                user_input = ''
示例#20
0
def main():
    device_list = get_device_list()
    if len(device_list) == 0:
        print 'No Device Connected to Host'
        sys.exit(0)
    elif len(device_list) == 1:
        print ingreen('Only One Device ' + device_list[0] + ' Connected to Host')
        chDev(device_list[0])
        print ingreen("Default Set " + device_list[0] + " in Device Profile.")
        sys.exit(0)
    else:
        print_device(device_list)
        user_input = ''
        while user_input == '':
            user_input = raw_input('Please select the device number:')
            try:
                if int(user_input) < 0 or int(user_input) > (len(device_list) + 1):
                    raise ValueError
                elif int(user_input) == len(device_list) + 1:
                    main()
                chDev(device_list[int(user_input) -1])
                print ingreen('Set ' + device_list[int(user_input) -1] + ' in Device Profile Successfully')
                sys.exit(0)
            except ValueError, e:
                print 'invalid user input'
                user_input = ''
示例#21
0
            #download clip if it does not exist in self.Clip_Path + 'YUV/'
            stdout, stderr = self.cli.execute("ls " + inp)
            flag = stdout.find("No such file or directory")
            if flag < 0:
                pass
            else:
                print '\nDownloading %s ......' % self.dict['InputFile']
                status, output = commands.getstatusoutput(
                    "wget --no-proxy " + config.VIDEO_CLIP_DOWNLOAD_PATH +
                    self.dict['InputFile'])
                if status != 0:
                    raise TestException(
                        "Error: failed download " + self.dict['InputFile'] +
                        ", maybe the clip storing address is invalid!\n")
                else:
                    print ingreen(self.dict['InputFile'] +
                                  " downloaded successfully.\n")
                    print("Push " + self.dict['InputFile'] +
                          " into device ......")
                    self.cli.upload(
                        self.dict['InputFile'],
                        self.Clip_Path + '/' + self.dict.get('Format') + '/')
                    os.system("rm -rf " + self.dict['InputFile'])

            if self.stepType == 10:
                return "noResult"

        if self.stepType == 0 or self.stepType == 20:
            #execute cmd
            print "Execute Output: \n"
            self.cli.execute_test(cmd, self.step_id)
            try:
示例#22
0
 def _open_fps(self):
     self.acc.execute('setprop debug.dump.log 1')
     print ingreen('##################### Open FPS in Logcat Successfully##################### ')
示例#23
0
文件: omx.py 项目: sunshine027/pytest
    def encode(self):

        print "Command for va_log detection:"

        #enable va_log
        stdout, stderr = self.cli.execute(
            "echo \\\"LIBVA_TRACE=/data/1\\\" > /etc/libva.conf")

        #delete original
        stdout, stderr = self.cli.execute("rm -rf /data/1.*")

        print ""

        for item in self.dict:
            if self.dict[item] == None:
                raise TestException("Error: No text in element '" + item +
                                    "', please check the case profile.")

        try:
            if not cmp(self.dict['Format'], 'H264'):
                encodeFormat = 7
            elif not cmp(self.dict['Format'], 'MPEG4'):
                encodeFormat = 4
            elif not cmp(self.dict['Format'], 'H263'):
                encodeFormat = 3
            else:
                raise TestException(
                    "Error: Invalid text in Format element in case configuration file."
                )
        except KeyError:
            raise TestException(
                "Error: no Format element found in Parameter element.")

        try:
            input = self.Clip_Path + "YUV/" + self.dict['InputFile']
        except KeyError:
            raise TestException(
                "Error: no InputFile element found in Parameter element ")
        try:
            output = get_result_path() + self.dict['OutputFile']
        except KeyError:
            raise TestException(
                "Error: no OutputFile element found in Parameter element ")

        try:
            resolution = self.dict['Resolution']
        except KeyError:
            raise TestException(
                "Error: no Resolution element found in Parameter element ")
        try:
            width = resolution.split('x')[0]
            height = resolution.split('x')[1]
        except IndexError:
            raise TestException(
                "Error: the text in Resolution element must be in the format of NUMBERxNUMBER "
            )

        try:
            speed = self.dict['Speed']
            if speed == 'Off':
                speed = '0'
        except KeyError:
            raise TestException(
                "Error: no Speed element found in Parameter element ")

        try:
            bitRate = self.dict['BitRate']
            if bitRate == 'Off':
                bitRate = '0'
        except KeyError:
            raise TestException(
                "Error: no BitRate element found in Parameter element ")

        try:
            framerate = self.dict['Framerate']
            if framerate == 'Off':
                framerate = '15'
        except KeyError:
            raise TestException(
                "Error: no Framerate element found in Parameter element ")

        try:
            level = self.dict['Level'].replace('L', '')
            if encodeFormat == 7:
                if level == 'Off':
                    level = '0'
                elif level == '1':
                    level = '1'
                elif level == '1b':
                    level = '2'
                elif level == '1.1':
                    level = '4'
                elif level == '1.2':
                    level = '8'
                elif level == '1.3':
                    level = '10'
                elif level == '2.0':
                    level = '20'
                elif level == '2.1':
                    level = '40'
                elif level == '2.2':
                    level = '80'
                elif level == '3.0':
                    level = '100'
                elif level == '3.1':
                    level = '200'
                elif level == '3.2':
                    level = '400'
                elif level == '4.0':
                    level = '800'
                elif level == '4.1':
                    level = '1000'
                elif level == '4.2':
                    level = '2000'
                elif level == '5.0':
                    level = '4000'
                elif level == '5.1':
                    level = '8000'
            elif encodeFormat == 3:
                if level == 'Off':
                    level = '0'
                elif level == '10':
                    level = '1'
                elif level == '20':
                    level = '2'
                elif level == '30':
                    level = '4'
                elif level == '40':
                    level = '8'
                elif level == '50':
                    level = '10'
                elif level == '60':
                    level = '20'
                elif level == '70':
                    level = '40'
            elif encodeFormat == 4:
                if level == 'Off':
                    level = '0'
                elif level == '1':
                    level = '1'
                elif level == '2':
                    level = '2'
                elif level == '3':
                    level = '4'
                elif level == '4':
                    level = '8'
                elif level == '5':
                    level = '7FFFFFFF'
        except KeyError:
            raise TestException(
                "Error: no Level element found in Parameter element ")

        try:
            nalsize = self.dict['NalSize']
            if nalsize == 'Off':
                nalsize = '0'
        except KeyError:
            raise TestException(
                "Error: no NalSize element found in Parameter element ")

        try:
            CIFrames = self.dict['CIFrames']
            if CIFrames == 'Off':
                CIFrames = '0'
        except KeyError:
            raise TestException(
                "Error: no CIFrames element found in Parameter element ")

        try:
            profile = self.dict['Profile']
            if encodeFormat == 7:
                if profile == 'Off':
                    profile = '0'
                elif profile == 'BP':
                    profile = '1'
                elif profile == 'MP':
                    profile = '2'
                elif profile == 'EP':
                    profile = '4'
                elif profile == 'HP':
                    profile = '8'
            elif encodeFormat == 3:
                if profile == 'Off':
                    profile = '0'
                elif profile == 'BP':
                    profile = '1'
            elif encodeFormat == 4:
                if profile == 'Off':
                    profile = '0'
                elif profile == 'SP':
                    profile = '1'
                elif profile == 'MP':
                    profile = '8'
        except KeyError:
            raise TestException(
                "Error: no Profile element found in Parameter element ")

        try:
            rcMode = self.dict['RcMode']
            if rcMode == 'VBR':
                rcMode = '1'
            elif rcMode == 'CBR':
                rcMode = '2'
            else:
                rcMode = '0'
        except KeyError:
            raise TestException(
                "Error: no RcMode element found in Parameter element ")
        try:
            VUIEnable = self.dict['VUIEnable']
            if VUIEnable == 'Off':
                VUIEnable = '0'
        except KeyError:
            raise TestException(
                "Error: no VUIEnable element found in Parameter element ")

        try:
            testtype = self.dict['TestType']
        except KeyError:
            raise TestException(
                "Error: no TestType element found in Parameter element ")

        try:
            referenceframe = self.dict['Referenceframe']
            if referenceframe == 'Off':
                referenceframe = '0'
        except KeyError:
            raise TestException(
                "Error: no Referenceframe element found in Parameter element ")

        try:
            testtimes = self.dict['TestTimes']
        except KeyError:
            raise TestException(
                "Error: no TestTimes element found in Parameter element ")

        if encodeFormat == 7:
            cmd = "VideoEncTest" + ' ' + input + ' ' + output + ' ' + width + ' ' + height + ' ' + speed + ' ' + bitRate + ' ' + framerate + ' ' + str(
                encodeFormat
            ) + ' ' + level + ' ' + nalsize + ' ' + CIFrames + ' ' + profile + ' ' + rcMode + ' ' + VUIEnable + ' ' + testtype + ' ' + referenceframe + ' ' + testtimes
        else:
            cmd = "VideoEncTest" + ' ' + input + ' ' + output + ' ' + width + ' ' + height + ' ' + speed + ' ' + bitRate + ' ' + framerate + ' ' + str(
                encodeFormat
            ) + ' ' + rcMode + ' ' + CIFrames + ' ' + profile + ' ' + level + ' 0 0 ' + testtype + ' ' + referenceframe + ' ' + testtimes

        print "Command:"
        print cmd
        print ""
        self.rt_dict.setdefault('cmd', cmd)

        if self.stepType == 0 or self.stepType == 10:
            #download clip if it does not exist in self.Clip_Path + 'YUV/'
            stdout, stderr = self.cli.execute("ls " + input)
            flag = stdout.find("No such file or directory")
            if flag < 0:
                pass
            else:
                print '\nDownloading %s ......' % self.dict['InputFile']
                status, output = commands.getstatusoutput(
                    "wget --no-proxy " + conf.VIDEO_CLIP_DOWNLOAD_PATH +
                    self.dict['InputFile'])
                if status != 0:
                    print inred(
                        "Error: failed download " + self.dict['InputFile'] +
                        ", maybe the clip storing address is invalid!\n")
                else:
                    print ingreen(self.dict['InputFile'] +
                                  " downloaded successfully.\n")
                    print("Push " + self.dict['InputFile'] +
                          " into device ......")
                    self.cli.upload(self.dict['InputFile'],
                                    self.Clip_Path + 'YUV/')
                    os.system("rm -rf " + self.dict['InputFile'])

            if self.stepType == 10:
                return "noResult"

        if self.stepType == 0 or self.stepType == 20:
            #execute in remote device
            print "Execute Output: \n"
            self.cli.execute_test(cmd, self.step_id)
            try:
                outfile = open('log' + str(self.step_id), 'r')
            except IOError, e:
                print inred("Error: cannot generat log.")
                os.system("touch log" + str(self.step_id))
            stdout = outfile.read()
            outfile.close()

            #obtain FPS
            str1 = stdout.find("Average frames per second") + 28
            str2 = stdout[str1:str1 + 50].find('\n')
            fps = stdout[str1:str1 + str2].replace('\n', '').replace(
                ' ', '').replace('\r', '')
            self.rt_dict.setdefault('FPS', fps)

            #obtain attrib[1].value
            stdout_text, stderr = self.cli.execute("head /data/1.* -n 20")
            flag = stdout_text.find("attrib_list[1].value") + 23
            if flag == 22:
                print inred("No attrib_list[1].value found in va_log.")
                attrib_value = "Off"
            else:
                attrib_value = stdout_text[flag:flag + 10]
            self.rt_dict.setdefault('AttribValue', attrib_value)
示例#24
0
文件: omx.py 项目: sunshine027/pytest
 def encode(self):
     
     print "Command for va_log detection:"
             
     #enable va_log
     stdout,stderr = self.cli.execute("echo \\\"LIBVA_TRACE=/data/1\\\" > /etc/libva.conf")
     
     #delete original 
     stdout,stderr = self.cli.execute("rm -rf /data/1.*")
     
     print ""
     
     for item in self.dict:
         if self.dict[item] == None:
             raise TestException("Error: No text in element '" + item + "', please check the case profile.")
     
     try:
         if not cmp(self.dict['Format'], 'H264'):
             encodeFormat = 7
         elif not cmp(self.dict['Format'], 'MPEG4'):
             encodeFormat = 4
         elif not cmp(self.dict['Format'], 'H263'):
             encodeFormat = 3
         else:
             raise TestException("Error: Invalid text in Format element in case configuration file.")
     except KeyError:
         raise TestException("Error: no Format element found in Parameter element.")
     
     try:
         input = self.Clip_Path + "YUV/" + self.dict['InputFile']
     except KeyError:
         raise TestException("Error: no InputFile element found in Parameter element ")
     try:
         output = get_result_path() + self.dict['OutputFile']
     except KeyError:
         raise TestException("Error: no OutputFile element found in Parameter element ")
     
     try:
         resolution = self.dict['Resolution']
     except KeyError:
         raise TestException("Error: no Resolution element found in Parameter element ")
     try:
         width = resolution.split('x')[0]
         height = resolution.split('x')[1]
     except IndexError:
         raise TestException("Error: the text in Resolution element must be in the format of NUMBERxNUMBER ")
      
     try:
         speed = self.dict['Speed']
         if speed == 'Off':
             speed = '0'
     except KeyError:
         raise TestException("Error: no Speed element found in Parameter element ") 
     
     try:
         bitRate = self.dict['BitRate']
         if bitRate == 'Off':
             bitRate = '0'
     except KeyError:
         raise TestException("Error: no BitRate element found in Parameter element ")
     
     try:
         framerate = self.dict['Framerate']
         if framerate == 'Off':
             framerate = '15'
     except KeyError:
         raise TestException("Error: no Framerate element found in Parameter element ")
     
     try:
         level = self.dict['Level'].replace('L', '')
         if encodeFormat == 7:
             if level == 'Off':
                 level = '0'
             elif level == '1':
                 level = '1'
             elif level == '1b':
                 level = '2' 
             elif level == '1.1':
                 level = '4' 
             elif level == '1.2':
                 level = '8'  
             elif level == '1.3':
                 level = '10'
             elif level == '2.0':
                 level = '20'
             elif level == '2.1':
                 level = '40'
             elif level == '2.2':
                 level = '80'
             elif level == '3.0':
                 level = '100'
             elif level == '3.1':
                 level = '200'
             elif level == '3.2':
                 level = '400'
             elif level == '4.0':
                 level = '800'
             elif level == '4.1':
                 level = '1000'
             elif level == '4.2':
                 level = '2000'
             elif level == '5.0':
                 level = '4000'
             elif level == '5.1':
                 level = '8000'
         elif encodeFormat == 3:
             if level == 'Off':
                 level = '0'
             elif level == '10':
                 level = '1'
             elif level == '20':
                 level = '2'
             elif level == '30':
                 level = '4'
             elif level == '40':
                 level = '8'
             elif level == '50':
                 level = '10'
             elif level == '60':
                 level = '20'
             elif level == '70':
                 level = '40'
         elif encodeFormat == 4:
             if level == 'Off':
                 level = '0'
             elif level == '1':
                 level = '1'
             elif level == '2':
                 level = '2'
             elif level == '3':
                 level = '4'
             elif level == '4':
                 level = '8'
             elif level == '5':
                 level = '7FFFFFFF'
     except KeyError:
         raise TestException("Error: no Level element found in Parameter element ")
     
     try:
         nalsize = self.dict['NalSize']
         if nalsize == 'Off':
             nalsize = '0'
     except KeyError:
         raise TestException("Error: no NalSize element found in Parameter element ")
     
     try:
         CIFrames = self.dict['CIFrames']
         if CIFrames == 'Off':
             CIFrames = '0'
     except KeyError:
         raise TestException("Error: no CIFrames element found in Parameter element ")
     
     try:
         profile = self.dict['Profile']
         if encodeFormat == 7:
             if profile == 'Off':
                 profile = '0'
             elif profile == 'BP':
                 profile = '1'
             elif profile == 'MP':
                 profile = '2' 
             elif profile == 'EP':
                 profile = '4' 
             elif profile == 'HP':
                 profile = '8'  
         elif encodeFormat == 3:
             if profile == 'Off':
                 profile = '0'
             elif profile == 'BP':
                 profile = '1'
         elif encodeFormat == 4:
             if profile == 'Off':
                 profile = '0'
             elif profile == 'SP':
                 profile = '1'
             elif profile == 'MP':
                 profile = '8'
     except KeyError:
         raise TestException("Error: no Profile element found in Parameter element ")
     
     try:
         rcMode = self.dict['RcMode']
         if rcMode == 'VBR':
             rcMode = '1'
         elif rcMode == 'CBR':
             rcMode = '2'
         else:
             rcMode = '0'
     except KeyError:
         raise TestException("Error: no RcMode element found in Parameter element ")
     try:
         VUIEnable = self.dict['VUIEnable']
         if VUIEnable == 'Off':
             VUIEnable = '0'
     except KeyError:
         raise TestException("Error: no VUIEnable element found in Parameter element ")
     
     try:
         testtype = self.dict['TestType']
     except KeyError:
         raise TestException("Error: no TestType element found in Parameter element ")
     
     try:
         referenceframe = self.dict['Referenceframe']
         if referenceframe == 'Off':
             referenceframe = '0'
     except KeyError:
         raise TestException("Error: no Referenceframe element found in Parameter element ")
     
     try:
         testtimes = self.dict['TestTimes']
     except KeyError:
         raise TestException("Error: no TestTimes element found in Parameter element ")
     
     if encodeFormat == 7:
         cmd = "VideoEncTest" + ' ' + input + ' ' + output + ' ' + width + ' ' + height + ' ' + speed + ' ' + bitRate + ' ' + framerate + ' ' + str(encodeFormat) + ' ' + level + ' ' + nalsize + ' ' + CIFrames + ' ' + profile + ' ' + rcMode + ' ' + VUIEnable + ' ' + testtype + ' ' + referenceframe + ' ' + testtimes 
     else:
         cmd = "VideoEncTest" + ' ' + input + ' ' + output + ' ' + width + ' ' + height + ' ' + speed + ' ' + bitRate + ' ' + framerate + ' ' + str(encodeFormat) + ' ' + rcMode + ' ' + CIFrames + ' ' + profile + ' ' + level + ' 0 0 ' + testtype + ' ' + referenceframe + ' ' + testtimes
    
     print "Command:"
     print cmd
     print ""
     self.rt_dict.setdefault('cmd', cmd)
     
     if self.stepType == 0 or self.stepType == 10:        
         #download clip if it does not exist in self.Clip_Path + 'YUV/'
         stdout, stderr = self.cli.execute("ls " + input)
         flag = stdout.find("No such file or directory")
         if flag < 0:
             pass
         else:
             print '\nDownloading %s ......' %self.dict['InputFile']
             status, output = commands.getstatusoutput("wget --no-proxy " + conf.VIDEO_CLIP_DOWNLOAD_PATH + self.dict['InputFile'])
             if status != 0:
                 print inred("Error: failed download " + self.dict['InputFile'] + ", maybe the clip storing address is invalid!\n")
             else:
                 print ingreen(self.dict['InputFile'] + " downloaded successfully.\n")
                 print ("Push " + self.dict['InputFile'] + " into device ......")
                 self.cli.upload(self.dict['InputFile'], self.Clip_Path + 'YUV/')
                 os.system("rm -rf " + self.dict['InputFile'])
             
         if self.stepType == 10:
             return "noResult"
     
     if self.stepType == 0 or self.stepType == 20:
         #execute in remote device
         print "Execute Output: \n"
         self.cli.execute_test(cmd, self.step_id)
         try:
             outfile = open('log' + str(self.step_id), 'r') 
         except IOError, e:
             print inred("Error: cannot generat log.")
             os.system("touch log" + str(self.step_id))
         stdout = outfile.read()
         outfile.close()
         
         #obtain FPS
         str1 = stdout.find("Average frames per second") + 28
         str2 = stdout[str1: str1+50].find('\n')
         fps = stdout[str1:str1+str2].replace('\n', '').replace(' ', '').replace('\r', '')
         self.rt_dict.setdefault('FPS', fps)
         
         #obtain attrib[1].value
         stdout_text,stderr = self.cli.execute("head /data/1.* -n 20")
         flag = stdout_text.find("attrib_list[1].value") + 23
         if flag == 22 :
             print inred("No attrib_list[1].value found in va_log.")
             attrib_value = "Off"
         else:
             attrib_value = stdout_text[flag : flag+10]                
         self.rt_dict.setdefault('AttribValue', attrib_value)
示例#25
0
                       
def deleteCaseInSuiteResume(casename):
    try:
        parsed_xml = ET.parse(suiteResumePath)
    except Exception,e:
        raise TestException("IOError: Cannot find: " + suiteResumePath)
    root = parsed_xml.getroot()
    all_cases = root.find('list')
    if len(all_cases) == 0:
        print inred("Error: no case in this suite file: " + suiteResumePath)
        userinput = ''
        while userinput != 'y' and userinput !='n':
            userinput = raw_input(inblue('Do you want to delete this suite resume file? y/n '))
        if userinput == 'y':
            deleteResume('suite')
            print ingreen("File deleted.")
        else:
            print inred("This suite file is invalid, we strongly recommend you delete it!")
        sys.exit(-1)
    for case in all_cases:
        if case.text == casename:
            all_cases.remove(case)
            break
    try:
        parsed_xml.write(suiteResumePath)
    except Exception,e:
        raise TestException("IOError: Cannot find directory: " + suiteResumePath)
            
def deleteResume(type, file_path=''):
    if type == 'suite':
        try:
示例#26
0
    if status != 0:
        print inred("Error: upload clips failed.")
        return ''
    '''

    resultClipDir = conf.RESULTCLIP_PATH_WITHOUTBUILDNAME

    if buildname == '':
        status, output = commands.getstatusoutput("ls -l " + resultClipDir +
                                                  " | grep ^d")
        dirList = output.split('\n')
        resultDirList = []
        for eachDir in dirList:
            resultDirList.append(eachDir.split(' ')[-1])
        for executionName in resultDirList:
            status, output = commands.getstatusoutput(
                "resource/uploadClip.sh " + resultClipDir + executionName)
            if status != 0:
                print inred("Error: upload clips failed.")
                return ''
        print ingreen(
            "################### Upload finished ###################")
    else:
        status, output = commands.getstatusoutput("resource/uploadClip.sh " +
                                                  resultClipDir + buildname)
        if status != 0:
            print inred("Error: upload clips failed.")
            return ''
        print ingreen(
            "################### Upload finished ###################")
示例#27
0
def deleteCaseInSuiteResume(casename):
    try:
        parsed_xml = ET.parse(suiteResumePath)
    except Exception, e:
        raise TestException("IOError: Cannot find: " + suiteResumePath)
    root = parsed_xml.getroot()
    all_cases = root.find('list')
    if len(all_cases) == 0:
        print inred("Error: no case in this suite file: " + suiteResumePath)
        userinput = ''
        while userinput != 'y' and userinput != 'n':
            userinput = raw_input(
                inblue('Do you want to delete this suite resume file? y/n '))
        if userinput == 'y':
            deleteResume('suite')
            print ingreen("File deleted.")
        else:
            print inred(
                "This suite file is invalid, we strongly recommend you delete it!"
            )
        sys.exit(-1)
    for case in all_cases:
        if case.text == casename:
            all_cases.remove(case)
            break
    try:
        parsed_xml.write(suiteResumePath)
    except Exception, e:
        raise TestException("IOError: Cannot find directory: " +
                            suiteResumePath)
示例#28
0
            raise TestException("No path.py generated. please run setup.py again.")
        build_name = path.build_name
    print "Build name: " + build_name
    
    #obtain ip of tms.bj.intel.com
    status, output = commands.getstatusoutput("nslookup tms.bj.intel.com")
    ip = output.split('\n')[-2].replace(' ', '').replace("Address:", '')

    #generate tar.gz file
    status, output = commands.getstatusoutput("cd %s ; tar cvzf %s.tar.gz %s/"%(conf.RESULT_PATH, build_name, build_name))
    if status != 0:
        raise TestException("Error: zip result file failed.")
    
    ingredientId = "174"
    if ingredient == "Camera_Img":
        ingredientId = "176"
    cmd = "cd %s ; curl --noproxy %s -F upload=@%s.tar.gz http://%s/tms/execution/tool/upload.php?id=%s"%(conf.RESULT_PATH, ip, build_name, ip, ingredientId)
    p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
    if p.wait() !=0:
        raise TestException("Error: upload result to http://tms.bj.intel.com/tms/execution/tool/upload.php failed.") 
    else:
        cmd = "curl --noproxy %s 'http://%s/tms/execution/tool/video_input.php?plat=Medfield&os=Android&ing=%s&ex=%s'" %(ip, ip, ingredient, build_name)
        p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
        if p.wait() !=0:
            raise TestException("Error: upload result to http://tms.bj.intel.com/tms/execution/tool/upload.php failed.") 
                   
    status, output = commands.getstatusoutput("rm -rf %s%s.tar.gz"%(conf.RESULT_PATH, build_name))  
    print ingreen("###########################--UPLOAD FINISHED--###########################")  

    
示例#29
0
 def _connect_wifi(self):
     result = connect_wifi(self.devcfg)
     if result:
         print ingreen('##################### Connect Wifi Successfully #############################')
     else:
         print inred('##################### Fail to Connect Wifi #############################')
示例#30
0
文件: va.py 项目: sunshine027/pytest
        self.rt_dict.setdefault('cmd', cmd)

        print cmd
        if self.stepType == 0 or self.stepType == 10:        
            #download clip if it does not exist in self.Clip_Path + 'YUV/'
            stdout, stderr = self.cli.execute("ls " + inp)
            flag = stdout.find("No such file or directory")
            if flag < 0:
                pass
            else:
                print '\nDownloading %s ......' %self.dict['InputFile']
                status, output = commands.getstatusoutput("wget --no-proxy " + config.VIDEO_CLIP_DOWNLOAD_PATH + self.dict['InputFile'])
                if status != 0:
                    raise TestException("Error: failed download " + self.dict['InputFile'] + ", maybe the clip storing address is invalid!\n")
                else:
                    print ingreen(self.dict['InputFile'] + " downloaded successfully.\n")
                    print ("Push " + self.dict['InputFile'] + " into device ......")
                    self.cli.upload(self.dict['InputFile'], self.Clip_Path + '/' + self.dict.get('Format') +'/')
                    os.system("rm -rf " + self.dict['InputFile'])

            if self.stepType == 10:
                return "noResult"
        
        if self.stepType == 0 or self.stepType == 20:
            #execute cmd
            print "Execute Output: \n"
            self.cli.execute_test(cmd, self.step_id)
            try:
                outfile = open('log' + str(self.step_id), 'r') 
            except IOError, e:
                print inred("Error: cannot generat log.")
示例#31
0
 def change_ip(self):
     ip = self.args.get('ip')
     result = change_avstreaming_ip(ip)
     if result:
         print ingreen('##################### Set IP for AV_Streaming Server Successfully! ####################')
示例#32
0
 def _push_busybox(self):
     result = push_busybox(self.devcfg)
     if result:
         print ingreen('##################### Push Busybox to Device Successfully #####################')
     else:
         print inred('##################### Fail to Push Busybox to Device #####################')
示例#33
0
 def install_android_sdk(self):
     result = install_android_sdk(self.devcfg)
     if result:
         print ingreen('##################### Install Android SDK Successfully #######################')
     else:
         print inred('##################### Fail to Install Android SDK ##########################')
示例#34
0
 def _open_fps(self):
     self.acc.execute('setprop debug.dump.log 1')
     print ingreen(
         '##################### Open FPS in Logcat Successfully##################### '
     )
示例#35
0
 def install_paramiko(self):
     result = install_paramiko()
     if result:
         print ingreen('##################### Install Paramiko Successfully.#####################')
     else:
         print inred('##################### Fail to Install Paramiko, Check If You Run This by Root #####################')
示例#36
0
def download(ingredient, buildname):
    if ingredient == '':
        ingredient = raw_input("Enter Ingredient name:")
        ingredient = ingredient.replace(" ", "%20")

    if buildname == '':
        buildname = raw_input("Enter Test Execution name:")
        buildname = buildname.replace(" ", "%20")

    #create buildname in ./conf/
    buildname_file = open('conf/buildname', 'w')
    buildname_file.write(buildname)
    buildname_file.close()

    #delete origin test_repo
    os.system("cd .. ; rm -rf test_repo")

    #download test_repo.tar.gz
    url = "http://tms.bj.intel.com/tms/execution/tool/download.php"
    command = "curl --noproxy tms.bj.intel.com -o ../test_repo.tar.gz '%s'" % (
        url)
    status, output = commands.getstatusoutput(command)
    if not status == 0:
        print inred(
            "###########################--Download test_repo.tar.gz Error--###########################"
        )
    else:
        status, output = commands.getstatusoutput(
            "cd .. ; tar zxvf test_repo.tar.gz")
        if not status == 0:
            print inred("Error: fail to download test_repo from TMS.")
        else:
            os.system("cd .. ; rm -rf test_repo.tar.gz")

            #download config.tar.gz
            url = "http://tms.bj.intel.com/tms/execution/tool/video_profile.php?plat=Medfield&os=Android&ing=%s&ex=%s" % (
                ingredient, buildname)
            command = "curl --noproxy tms.bj.intel.com -o %sconfig.tar.gz '%s'" % (
                conf.TEST_REPO, url)
            status, output = commands.getstatusoutput(command)
            if not status == 0:
                print inred(
                    "###########################--Download Case Profile Error--###########################"
                )
            else:
                status, output = commands.getstatusoutput(
                    "cd " + conf.TEST_REPO + " ; tar zxvf config.tar.gz")
                if not status == 0:
                    print inred(
                        "Error: fail to download execution from TMS, maybe the ingredient name or execution name is invalid. Or your host need to install curl."
                    )
                else:
                    os.system("cd " + conf.TEST_REPO +
                              " ; rm -rf config.tar.gz")
                    os.system("mv " + conf.TEST_REPO + "config/" + buildname +
                              ".xml " + conf.TEST_REPO)
                    os.system("mv " + conf.TEST_REPO + "config/case_profile " +
                              conf.TEST_REPO)
                    os.system("cd " + conf.TEST_REPO +
                              " ; mv config suite_profile")
                    print ingreen(
                        "###########################Download Successful--###########################"
                    )
                    # set device number
                    try:
                        main()
                    except Exception, e:
                        print e
示例#37
0
 
 print inpurple("Uploading result clips to media server......")
 
 '''
 status, output = commands.getstatusoutput("resource/uploadClipPrepare.sh")
 if status != 0:
     print inred("Error: upload clips failed.")
     return ''
 '''
 
 resultClipDir = conf.RESULTCLIP_PATH_WITHOUTBUILDNAME
 
 if buildname == '':
     status, output = commands.getstatusoutput("ls -l " + resultClipDir + " | grep ^d")
     dirList = output.split('\n')
     resultDirList = []
     for eachDir in dirList:
         resultDirList.append(eachDir.split(' ')[-1])            
     for executionName in resultDirList:
         status, output = commands.getstatusoutput("resource/uploadClip.sh " + resultClipDir + executionName)
         if status != 0:
             print inred("Error: upload clips failed.")
             return ''
     print ingreen("################### Upload finished ###################")
 else:
     status, output = commands.getstatusoutput("resource/uploadClip.sh " + resultClipDir + buildname)
     if status != 0:
         print inred("Error: upload clips failed.")
         return ''
     print ingreen("################### Upload finished ###################")